/* ============================================================
   POSB GROWTH MONITORING TOOL - MAIN STYLESHEET
   Professional, responsive, India Post themed
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --red:        #c0392b;
  --dark-red:   #922b21;
  --deep-red:   #7b241c;
  --light-red:  #fdecea;
  --orange:     #e67e22;
  --green:      #1e8449;
  --light-green:#eafaf1;
  --blue:       #1a5276;
  --light-blue: #d6eaf8;
  --gold:       #d4ac0d;
  --light-gold: #fef9e7;
  --white:      #ffffff;
  --bg:         #f5f7fa;
  --card-bg:    #ffffff;
  --border:     #e0e0e0;
  --text:       #2c3e50;
  --muted:      #7f8c8d;
  --shadow-sm:  0 2px 8px rgba(0,0,0,.07);
  --shadow-md:  0 4px 20px rgba(0,0,0,.1);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.15);
  --radius:     10px;
  --radius-lg:  16px;
  --transition: all .25s ease;
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header / Navbar ─────────────────────────────────────── */
.navbar {
  background: linear-gradient(135deg, var(--red) 0%, var(--deep-red) 100%);
  color: var(--white);
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 3px 12px rgba(0,0,0,.25);
  position: sticky;
  top: 0;
  z-index: 200;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.navbar-brand .emblem {
  width: 42px;
  height: 42px;
  background: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  flex-shrink: 0;
}
.navbar-brand h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .2px;
  line-height: 1.3;
}
.navbar-brand p {
  font-size: .72rem;
  opacity: .85;
  letter-spacing: .3px;
}
.navbar-actions { display: flex; gap: 8px; }
.navbar-actions a {
  color: #fff;
  text-decoration: none;
  font-size: .8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, .15);
  padding: 7px 14px;
  border-radius: 6px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 5px;
}
.navbar-actions a:hover {
  background: #7b241c;
  transform: translateY(-1px);
}

/* ── Page Title Banner ──────────────────────────────────────── */
.page-title {
  background: linear-gradient(135deg, #2f3e94 0%, #3F51B5 60%, #333e7e 100%);
  color: var(--white);
  text-align: center;
   padding: 8px 10px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: .3px;
  box-shadow: 0 3px 10px rgba(0,0,0,.2);
  position: sticky;
  top: 64px;
  z-index: 190;
}
@media(max-width:600px) {
  .page-title { font-size: .95rem; padding: 14px 16px; }
}

/* ── Main Layout ─────────────────────────────────────────── */
.main-wrapper { max-width: 1400px; margin: 0 auto; padding: 20px 16px 40px; }

/* ── Filter Bar ──────────────────────────────────────────── */
.filter-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  border: 1px solid rgba(192,57,43,.12);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 140px;
}
.filter-group label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.filter-group select {
  padding: 9px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: .88rem;
  color: var(--text);
  background: #fafafa;
  transition: var(--transition);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%23777' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 20px;
  padding-right: 32px;
}
.filter-group select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192,57,43,.12);
  background-color: var(--white);
}
.filter-group select:disabled {
  opacity: .45;
  cursor: not-allowed;
  background-color: #f0f0f0;
}
.filter-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  align-items: flex-end;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--red);
  color: var(--white);
  box-shadow: 0 3px 10px rgba(192,57,43,.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--dark-red);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(192,57,43,.35);
}
.btn-export {
  background: #1a5276;
  color: var(--white);
  box-shadow: 0 3px 10px rgba(26,82,118,.25);
}
.btn-export:hover:not(:disabled) {
  background: #154360;
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(26,82,118,.35);
}
.btn-reset {
  background: #368f39;
  color: #fff;
}
.btn-reset:hover { background: #e0e0e0; transform: translateY(-1px); }

/* ── Loading ─────────────────────────────────────────────── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.75);
  z-index: 999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.loading-overlay.active { display: flex; }
.spinner {
  width: 48px; height: 48px;
  border: 5px solid #f0d0ce;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--red); font-weight: 600; font-size: .95rem; }

/* ── Result Info ─────────────────────────────────────────── */
.result-info {
  font-size: .875rem;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-badge {
  background: var(--light-red);
  border: 1px solid #f0c4bf;
  color: var(--red);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 700;
}

/* ── Report Container ────────────────────────────────────── */
.report-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Table ───────────────────────────────────────────────── */
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
  min-width: 860px;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* Header rows */
.report-table thead tr:first-child th {
  padding: 12px 14px;
  text-align: center;
  font-weight: 700;
  font-size: .88rem;
  letter-spacing: .2px;
}
.report-table thead tr:nth-child(2) th {
  padding: 9px 12px;
  font-size: .8rem;
  font-weight: 700;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,.2);
  background: #8ec7cf;
}

/* Header groups */
.th-label {
  background: #f5ede9;
  color: var(--red);
  border-right: 2px solid #e0c0bc;
  vertical-align: middle;
}
.th-prev {
  background: #cfbce6;
  color: #1a3a52;
}
.th-curr {
  background: #c8dfc5;
  color: #1a3a1a;
}
.th-growth {
  background: #f5e6bc;
  color: #5a3e00;
}
.th-sub {
  font-size: .78rem !important;
  font-weight: 600 !important;
}

/* Body cells */
.report-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
  text-align: center;
  color:#000000;
}
.report-table tbody td.td-label {
  text-align: left;
  font-weight: 500;
  color: var(--text);
}
.report-table tbody tr:hover td {
  background: #fff8f7;
}
.report-table tbody tr:nth-child(even) td {
  background: #fafafa;
}
.report-table tbody tr:nth-child(even):hover td {
  background: #fff0ee;
}

/* Net A/cs bold */
.td-net { font-weight: 700; color: var(--text); }

/* Growth cell */
.td-growth { font-weight: 700; }
.td-growth.positive { color: var(--green); }
.td-growth.negative { color: var(--red); }
.td-growth.neutral  { color: var(--muted); }

/* Total row */
.row-total td {
  background: #fef9e7 !important;
  color: var(--red) !important;
  font-weight: 700 !important;
  font-size: 1rem !important;
  border-top: 2px solid #f0d070;
}
.row-total td.td-growth.positive { color: var(--green) !important; }
.row-total td.td-growth.negative { color: var(--red) !important; }

/* Separator between sections */
.col-sep { border-right: 2px solid #dde; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: .88rem; }

/* ── Alert ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-error { background: var(--light-red); color: var(--red); border-left: 3px solid var(--red); }
.alert-info  { background: #eff8ff; color: #1a5276; border-left: 3px solid #2980b9; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .navbar-brand h1 { font-size: .92rem; }
  .navbar-brand p  { display: none; }
  .filter-group { min-width: 120px; }
}

@media (max-width: 640px) {
  .navbar { padding: 0 14px; height: 56px; }
  .page-title { font-size: .88rem; top: 56px; }
  .filter-row { gap: 8px; }
  .filter-group { min-width: 100%; }
  .filter-actions { width: 100%; }
  .btn { flex: 1; justify-content: center; }
  .report-table { font-size: .8rem; min-width: 700px; }
  .report-table thead tr:first-child th { padding: 9px 8px; font-size: .82rem; }
  .report-table tbody td { padding: 8px 8px; }
}

@media (max-width: 400px) {
  .navbar-brand .emblem { display: none; }
  .navbar-actions a span { display: none; }
}


/* ── Filter Status Row ───────────────────────────────────── */
.filter-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #f0c8c4;
  font-size: .82rem;
}
.filter-status-label {
  color: var(--muted);
  font-weight: 600;
}
.filter-status-badge {
  background: var(--red);
  color: #fff;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .3px;
}
.filter-hint {
  color: var(--muted);
  font-size: .78rem;
  font-style: italic;
}
/* ── View badge in result info ───────────────────────────── */
.view-badge {
  background: #eaf4ff;
  border: 1px solid #bee3f8;
  color: #1a5276;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
/* ── Print ───────────────────────────────────────────────── */
@media print {
  .navbar, .filter-card, .filter-actions, .navbar-actions { display: none !important; }
  .page-title { position: static; }
  .report-table { box-shadow: none; border: 1px solid #ccc; }
  .td-growth.positive { color: #1e8449 !important; }
  .td-growth.negative { color: #c0392b !important; }
}

/* ── Sl.No column ────────────────────────────────────────── */
.th-slno {
  background: #f5ede9;
  color: var(--red);
  font-weight: 700;
  text-align: center;
  width: 44px;
  min-width: 40px;
  border-right: 1px solid #e0c0bc;
}
.td-slno {
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
  font-weight: 500;
  border-right: 1px solid #f0e8e8;
  background: #fdf8f8;
}
.row-total .td-slno { background: #fef9e7 !important; }

/* ── Sortable column headers ────────────────────────────── */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background .15s, color .15s;
  white-space: nowrap;
  color:#b22222;
   font-weight: 800;
}
th.sortable:hover {
  filter: brightness(0.92);
}
th.sortable:hover .sort-icon {
  opacity: 1;
}
/* Growth header is rowspan=2 and also sortable */
.th-growth.sortable,
.th-growth[data-sortcol] {
  cursor: pointer;
  user-select: none;
}
.th-growth[data-sortcol]:hover { filter: brightness(0.92); }

/* Sort icons */
.sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: .7rem;
  opacity: .35;
  transition: opacity .15s, color .15s;
  vertical-align: middle;
}
.sort-icon.active {
  opacity: 1;
  color: #fff;
}
/* Highlight the actively sorted column cells */
.report-table th[data-sortcol].sort-asc,
.report-table th[data-sortcol].sort-desc {
  box-shadow: inset 0 -3px 0 rgba(255,255,255,.5);
}

/* ── Print: hide Sl.No sort icons ───────────────────────── */
@media print {
  .sort-icon { display: none; }
  .th-slno, .td-slno { display: table-cell; }
}