:root {
  /* Ink (text) scale */
  --ink-900: #0b1220;
  --ink-700: #38414f;
  --ink-500: #667085;
  --ink-300: #a3aab8;

  /* Surfaces */
  --surface: #ffffff;
  --page: #f4f6f9;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;

  /* Brand navy scale */
  --navy-950: #0b2540;
  --navy-800: #123655;
  --navy-700: #1a4a71;
  --navy-600: #23628f;
  --navy-100: #e3ecf5;
  --navy-50: #eef4fa;

  /* Legacy aliases kept for a couple of inline `var(--blue-900)` references in the PHP templates */
  --blue-900: var(--navy-700);
  --blue-700: var(--navy-600);
  --blue-100: var(--navy-100);

  /* Vibrant brand gradient (header) + active-pill blue */
  --brand-grad-1: #4361ee;
  --brand-grad-2: #6c4fe0;
  --pill-active: #3e63f5;

  /* Metric icon colors — one hue per data type, used consistently for icons, values, accents */
  --ic-blue: #3b82f6;   --ic-blue-bg: #eaf1fe;   /* OPD / people / general */
  --ic-green: #10b981;  --ic-green-bg: #e7f8f0;  /* Surgery */
  --ic-red: #ef4444;    --ic-red-bg: #fdebeb;    /* Cath */
  --ic-purple: #8b5cf6; --ic-purple-bg: #f1ecfe;
  --ic-orange: #f59e0b; --ic-orange-bg: #fef3e0; /* States / foreign */

  /* Semantic accents */
  --green-700: #1a7f37;
  --green-100: #e1f5e8;
  --green-border: #b9e6c6;
  --red-700: #b42318;
  --red-100: #fbe9e7;
  --red-border: #f3c1bc;
  --amber-700: #93650a;
  --amber-100: #fdf1d6;
  --amber-border: #f2d99b;
  --orange-100: #fbe8d8;

  /* Legacy alias */
  --muted: var(--ink-500);
  --text: var(--ink-900);
  --bg: var(--page);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.05), 0 1px 1px rgba(11, 18, 32, 0.04);
  --shadow-md: 0 4px 10px rgba(11, 18, 32, 0.06), 0 1px 2px rgba(11, 18, 32, 0.05);
  --shadow-lg: 0 10px 30px rgba(11, 18, 32, 0.10), 0 2px 6px rgba(11, 18, 32, 0.06);
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  background: var(--page);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
::selection { background: var(--navy-100); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { height: 9px; width: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

a { color: var(--navy-600); text-decoration: none; transition: color 120ms var(--ease); }
a:hover { color: var(--navy-950); text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--navy-600);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------ app shell */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  width: 232px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 0 20px;
  z-index: 50;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 18px 12px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--ink-700);
  font-weight: 600;
  font-size: 0.88rem;
  border-left: 3px solid transparent;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.sidebar-nav a svg { color: var(--ink-500); flex: none; }
.sidebar-nav a:hover { background: var(--navy-50); color: var(--pill-active); text-decoration: none; }
.sidebar-nav a:hover svg { color: var(--pill-active); }
.sidebar-nav a.active { background: var(--navy-50); color: var(--pill-active); border-left-color: var(--pill-active); }
.sidebar-nav a.active svg { color: var(--pill-active); }
.sidebar-divider { height: 1px; background: var(--border); margin: 12px 16px; }

@media (max-width: 900px) {
  .sidebar { display: none; }
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  background: linear-gradient(120deg, var(--brand-grad-1) 0%, var(--brand-grad-2) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.topbar-inner {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid rgba(255, 255, 255, 0.45);
}
.brand-mark svg { width: 21px; height: 21px; display: block; color: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { white-space: nowrap; }
.brand-sub { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: rgba(255, 255, 255, 0.75); }

.who {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 2px;
}

/* ---------------------------------------------------------------- layout */
.container { max-width: 1280px; margin: 0 auto; padding: 32px 24px 72px; width: 100%; }

.footer {
  text-align: center;
  color: var(--ink-500);
  font-size: 0.82rem;
  padding: 28px 20px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; color: var(--ink-900); }
h2 { font-size: 1.08rem; font-weight: 700; margin: 32px 0 12px; color: var(--ink-900); letter-spacing: -0.005em; }
.subtitle { color: var(--ink-500); margin: 0 0 22px; font-size: 0.96rem; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------- alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.9rem;
  border: 1px solid transparent;
  border-left-width: 4px;
  line-height: 1.5;
}
.alert-error { background: var(--red-100); color: var(--red-700); border-color: var(--red-border); border-left-color: var(--red-700); }
.alert-success { background: var(--green-100); color: var(--green-700); border-color: var(--green-border); border-left-color: var(--green-700); }
.alert-info { background: var(--navy-50); color: var(--navy-800); border-color: var(--navy-100); border-left-color: var(--navy-600); }
.alert a { font-weight: 600; }

/* --------------------------------------------------------------- forms */
label { font-weight: 600; font-size: 0.86rem; display: block; margin-bottom: 5px; color: var(--ink-700); }
select, input[type=text], input[type=password], input[type=number], input[type=file] {
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  background: var(--surface);
  color: var(--ink-900);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
  font-family: inherit;
}
select:hover, input:hover { border-color: var(--ink-300); }
select:focus, input:focus {
  outline: none;
  border-color: var(--navy-600);
  box-shadow: 0 0 0 3px var(--navy-100);
}
input[type=number] { width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
input:disabled, select:disabled { background: var(--page); color: var(--ink-500); cursor: not-allowed; }

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--pill-active);
  color: #fff;
  border: 1px solid #2f4fd9;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(11, 18, 32, 0.15);
  transition: background 120ms var(--ease), transform 120ms var(--ease), box-shadow 120ms var(--ease);
  font-family: inherit;
}
.btn:hover { background: #2f4fd9; box-shadow: 0 2px 6px rgba(11, 18, 32, 0.25); }
.btn:active { transform: translateY(1px); }
.btn-secondary {
  background: var(--surface);
  color: var(--pill-active);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--navy-50); border-color: var(--pill-active); color: #2f4fd9; box-shadow: var(--shadow-sm); }
.btn-success { background: var(--ic-green); border-color: #0d9668; }
.btn-success:hover { background: #0d9668; }

/* ----------------------------------------------------------- filter bar */
.filter-bar {
  display: flex;
  gap: 16px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------- tables */
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.89rem;
  background: var(--surface);
}
th, td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: center;
}
th {
  background: var(--navy-800);
  color: #fff;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}
td.state-name, th.state-name { text-align: left; }
tbody tr:nth-child(even) td { background: #fafbfc; }
tbody tr:hover td { background: var(--navy-50); }
tr.group-header td {
  background: var(--navy-100) !important;
  font-weight: 700;
  text-align: left;
  color: var(--navy-800);
}
tr.total-row td { background: var(--orange-100) !important; font-weight: 700; }
tr.grand-row td { background: var(--navy-950) !important; color: #fff; font-weight: 700; }
tr.grand-row:hover td { background: var(--navy-950) !important; }

.badge-ok, .badge-missing, .badge-draft, .badge-baseline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.badge-ok { background: var(--green-100); color: var(--green-700); }
.badge-draft { background: var(--ic-blue-bg); color: var(--ic-blue); }
.badge-baseline { background: var(--ic-purple-bg); color: var(--ic-purple); }
.badge-missing { background: var(--amber-100); color: var(--amber-700); }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.table-scroll table { border: none; }
.table-scroll table th:first-child { border-top-left-radius: var(--radius-md); }
.note { font-size: 0.83rem; color: var(--ink-500); margin-top: 7px; }

/* --------------------------------------------------------------- login */
body:has(.login-wrap) { background: radial-gradient(circle at 50% 0%, var(--navy-100), var(--page) 55%); }
.login-wrap {
  max-width: 400px;
  margin: 8vh auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 36px 32px;
  box-shadow: var(--shadow-lg);
}
.login-wrap .login-mark { display: flex; justify-content: center; margin-bottom: 18px; }
.login-wrap .login-mark .brand-mark {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--brand-grad-1), var(--brand-grad-2));
  border: none;
  box-shadow: var(--shadow-md);
}
.login-wrap .login-mark svg { width: 30px; height: 30px; color: #fff; }
.login-wrap h1 { text-align: center; margin-bottom: 6px; font-size: 1.2rem; }
.login-wrap .login-subtitle { text-align: center; color: var(--ink-500); font-size: 0.86rem; margin-bottom: 24px; }
.login-wrap .field { margin-bottom: 16px; }
.login-wrap input { width: 100%; }
.login-wrap .btn { width: 100%; text-align: center; margin-top: 6px; padding: 10px 18px; }

/* ------------------------------------------------------------ stat tiles */
.stat-grid { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 3px solid var(--ic-blue);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  flex: 1 1 190px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stat-tile.stat-green { border-bottom-color: var(--ic-green); }
.stat-tile.stat-red { border-bottom-color: var(--ic-red); }
.stat-tile.stat-purple { border-bottom-color: var(--ic-purple); }
.stat-tile.stat-orange { border-bottom-color: var(--ic-orange); }
.stat-tile-top { display: flex; align-items: center; gap: 14px; }
.sparkline { display: block; width: 100%; height: 34px; }

.icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex: none;
  color: #fff;
  background: var(--ic-blue);
}
.icon-badge svg { width: 22px; height: 22px; }
.icon-badge.blue { background: var(--ic-blue); }
.icon-badge.green { background: var(--ic-green); }
.icon-badge.red { background: var(--ic-red); }
.icon-badge.purple { background: var(--ic-purple); }
.icon-badge.orange { background: var(--ic-orange); }

.stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-700);
  margin-bottom: 3px;
}
.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.stat-sub { font-size: 0.74rem; color: var(--ink-500); margin-top: 1px; }

/* icon inline with text, e.g. table column headers, buttons */
.icon { width: 15px; height: 15px; display: inline-block; vertical-align: -2px; flex: none; }
.th-icon { display: inline-flex; align-items: center; gap: 5px; }
.th-icon.ic-blue svg { color: #7fb0fb; }
.th-icon.ic-green svg { color: #6fe0bb; }
.th-icon.ic-red svg { color: #ff9d9d; }

/* value color-coding, consistent across every table in the app */
.val-opd { color: var(--ic-blue); font-weight: 600; }
.val-surgery { color: var(--ic-green); font-weight: 600; }
.val-cath { color: var(--ic-red); font-weight: 600; }
.val-dash { color: var(--ink-300); font-weight: 400; }

/* segmented tab toggle (e.g. Indian Centres / Foreign Countries) */
.seg-tabs {
  display: inline-flex;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.seg-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-500);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.seg-tab:hover { color: var(--ink-900); }
.seg-tab.active { background: var(--pill-active); color: #fff; box-shadow: var(--shadow-sm); }

/* search box */
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--ink-300); pointer-events: none; }
.search-box input { padding-left: 36px; border-radius: 999px; min-width: 220px; }

.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable .icon { opacity: 0.65; margin-left: 4px; }
th.sortable:hover .icon { opacity: 1; }

/* ---------------------------------------------------------------- map */
.map-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}
.map-legend-bar {
  width: 220px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(to right, #cde2fb, #0d366b);
}
.map-legend-label { font-size: 0.84rem; color: var(--ink-500); font-weight: 700; font-variant-numeric: tabular-nums; }

.map-zones { display: flex; flex-wrap: wrap; gap: 16px; }
.map-zone {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  flex: 1 1 260px;
  box-shadow: var(--shadow-sm);
}
.map-zone-title {
  font-weight: 700;
  color: var(--navy-700);
  margin-bottom: 12px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.map-zone-tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.map-tile {
  position: relative;
  min-width: 96px;
  flex: 1 1 96px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  text-align: center;
  transition: transform 120ms var(--ease), box-shadow 120ms var(--ease);
}
.map-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); z-index: 2; }
.map-tile-name { font-size: 0.72rem; font-weight: 600; line-height: 1.25; }
.map-tile-value { font-size: 0.97rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }
.map-tile[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 108%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy-950);
  color: #ffffff;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 10;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

/* -------------------------------------------------------- split panels */
.split-panels { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.split-panel { flex: 1 1 400px; }
.split-panel h2 { margin-top: 0; }
tr.extra-row { display: none; }
.view-all-btn { display: block; width: 100%; text-align: center; margin-top: 12px; }

/* ---------------------------------------------------------- help callout */
.help-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--ic-purple-bg);
  border: 1px solid #e0d4fb;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  flex: 0 1 320px;
}
.help-card svg { color: var(--ic-purple); flex: none; margin-top: 1px; }
.help-card strong { display: block; color: var(--ink-900); font-size: 0.9rem; margin-bottom: 2px; }
.help-card span { font-size: 0.82rem; color: var(--ink-500); }
.page-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head-row .heading-block { flex: 1 1 320px; }

/* -------------------------------------------------------------- misc */
.field { margin-bottom: 14px; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
