:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel-2: #18202a;
  --line: #243040;
  --line-soft: #1c2532;
  --text: #e6ebf1;
  --muted: #8b98a9;
  --faint: #5d6a7b;
  --accent: #f2a33a;
  --accent-ink: #1a1206;
  --ok: #3fbf7f;
  --soon: #f2a33a;
  --bad: #ef5d5d;
  --info: #5aa9e6;
  --airtel: #e5484d;
  --jio: #3e7bfa;
  --vi: #c6a0f6;
  --radius: 10px;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
[hidden] { display: none !important; }

/* ---------- brand / top bar ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand > div { display: flex; flex-direction: column; line-height: 1.1; }
.brand-org { font-size: 10.5px; letter-spacing: .18em; color: var(--accent); font-weight: 600; }
.brand-app { font-weight: 600; font-size: 15px; }
.brand-lg .brand-app { font-size: 20px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: rgba(11,15,20,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.tabs a:hover { color: var(--text); background: var(--panel); }
.tabs a.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar-right { display: flex; gap: 6px; align-items: center; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap;
  text-decoration: none; list-style: none;
}
.btn::-webkit-details-marker { display: none; }
.btn:hover { border-color: #33435a; background: #1d2733; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #ffb24d; border-color: #ffb24d; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--panel); border-color: var(--line-soft); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }

input, select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg);
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 4px; font-weight: 500; }

/* ---------- menu ---------- */
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.45); }
.menu-pop a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.menu-pop a:hover { background: var(--panel); }

/* ---------- layout ---------- */
.view { max-width: 1320px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

.panel { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-head .count { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.panel-body { padding: 14px 16px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: var(--line); }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-note { color: var(--faint); font-size: 12px; }
.kpi.bad .kpi-value { color: var(--bad); }
.kpi.soon .kpi-value { color: var(--soon); }

.provider-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 4px 0 10px; }
.provider-bar span { display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; min-width: 0; grid-template-columns: minmax(0, 1fr); }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid #4a3a1c; background: #1d170c; border-radius: var(--radius); margin-bottom: 16px; color: #f3d9a8; }
.banner strong { color: #ffd38a; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line-soft); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { color: var(--muted); font-size: 12.5px; }
.empty { padding: 22px 16px; color: var(--muted); text-align: center; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: #1f4d37; background: #0f2219; }
.badge.soon { color: var(--soon); border-color: #5b4119; background: #22190b; }
.badge.bad { color: var(--bad); border-color: #5a2626; background: #231011; }
.badge.info { color: var(--info); border-color: #1f3d57; background: #0e1b26; }
.prov { display: inline-flex; align-items: center; font-weight: 500; }
.prov::before { content: ''; width: 8px; height: 8px; border-radius: 2px; margin-right: 7px; background: var(--faint); }
.prov-Airtel::before { background: var(--airtel); }
.prov-Jio::before { background: var(--jio); }
.prov-VI::before { background: var(--vi); }

/* ---------- toolbar & table ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; min-width: 130px; }
.toolbar .spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin: 0; cursor: pointer; }
.check input { width: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 500; border-top: 0; white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .arrow { color: var(--accent); }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: #151c25; }
td.actions { text-align: right; white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; }
.table-foot { padding: 10px 16px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line-soft); }

/* ---------- drawer ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--panel); border-left: 1px solid var(--line); z-index: 31; transform: translateX(100%); transition: transform .18s ease; overflow-y: auto; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-section { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.drawer-section h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; word-break: break-word; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 7px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.timeline li:first-child { border-top: 0; }
.timeline time { color: var(--faint); font-size: 12px; display: block; }

/* ---------- modal ---------- */
.modal { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal::backdrop { background: rgba(0,0,0,.6); }
.modal form { margin: 0; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 16px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; max-height: 65vh; overflow-y: auto; }
.modal-body .full { grid-column: 1 / -1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.form-error { color: var(--bad); margin: 0; font-size: 13px; }
.hint { color: var(--faint); font-size: 12px; margin-top: 3px; }
.pick-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: 8px; }
.pick-list label { display: flex; gap: 10px; align-items: center; padding: 8px 10px; margin: 0; border-top: 1px solid var(--line-soft); color: var(--text); font-size: 13.5px; cursor: pointer; }
.pick-list label:first-child { border-top: 0; }
.pick-list label:hover { background: var(--panel-2); }
.pick-list input { width: auto; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.error { border-color: var(--bad); color: #ffb3b3; }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1000px 500px at 80% -10%, rgba(242,163,58,.08), transparent 60%), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line-soft); border-radius: 16px; padding: 28px; }
.login-sub { color: var(--muted); margin: 10px 0 22px; }
.login-card form { display: grid; gap: 10px; }
.login-card .btn { margin-top: 6px; padding: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .list li { flex-wrap: wrap; row-gap: 6px; }
  .list li .grow { flex-basis: 100%; }
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .view { padding: 16px; }
}
@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar input[type=search] { max-width: none; flex-basis: 100%; }
  .toolbar select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .toolbar .spacer { display: none; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: 10px 16px; border-top: 1px solid var(--line-soft); }
  table.cards td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  table.cards td.actions { justify-content: flex-end; padding-top: 6px; }
  table.cards td.actions::before { content: none; }
  .modal-body { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
}

/* ---------- scanner ---------- */
.no-scroll { overflow: hidden; }
.btn-scan::before { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-radius: 3px; box-sizing: border-box;
  background: linear-gradient(currentColor, currentColor) center/8px 2px no-repeat; }
.scanner { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; color: var(--text); }
.scan-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(0,0,0,.6); position: relative; z-index: 2; }
.scan-title { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.scan-title span { color: var(--muted); font-size: 12.5px; }
.scan-top .btn-ghost { color: var(--text); }
.scan-top [data-torch].on { background: var(--accent); color: var(--accent-ink); }
.scan-stage { position: relative; flex: 1; overflow: hidden; }
.scan-stage video, .scan-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-still { object-fit: contain; background: #000; }
.scan-guide { position: absolute; left: 7%; right: 7%; top: 38%; height: 22%; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); }
.scan-guide span { position: absolute; inset: 0; border: 2px solid var(--accent); border-radius: 12px; }
.scan-guide span::after { content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: rgba(242,163,58,.7); animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { transform: translateY(-34px); } to { transform: translateY(34px); } }
@media (prefers-reduced-motion: reduce) { .scan-guide span::after { animation: none; } }
.scan-still:not([hidden]) ~ .scan-guide { display: none; }
.scan-msg { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(10,14,19,.85); border: 1px solid var(--line); padding: 7px 14px; border-radius: 999px; font-size: 13px; max-width: calc(100% - 32px); text-align: center; }
.scan-bar { display: flex; gap: 8px; justify-content: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #0b0f14; border-top: 1px solid var(--line-soft); }
.scan-bar .btn { flex: 1; max-width: 220px; }
.scan-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 82%; overflow-y: auto; background: var(--panel); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); z-index: 3; box-shadow: 0 -20px 50px rgba(0,0,0,.6); }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
.sheet-h { margin: 0 0 6px; font-size: 17px; }
.match-head { display: flex; align-items: center; gap: 10px; }
.match-mobile { font-size: 26px; font-weight: 500; margin: 6px 0 4px; letter-spacing: .02em; }
.match-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.match-kv { margin-bottom: 12px; grid-template-columns: 110px 1fr; }
.plan-pill { display: inline-block; padding: 4px 10px; border-radius: 6px; font-weight: 700; font-size: 13px; letter-spacing: .08em; }
.plan-prepaid { background: #2a1d07; color: #ffc46b; border: 1px solid #6b4a12; }
.plan-postpaid { background: #0c2033; color: #8fc8ff; border: 1px solid #22476b; }
.plan-unknown { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.sheet-actions { display: grid; gap: 8px; margin-top: 12px; }
.sheet-actions > .btn { width: 100%; padding: 11px; }
.sheet-actions .btn-row { justify-content: space-between; }
.scan-sheet .check { margin: 4px 0; }
.scan-sheet [data-picker] { margin-top: 14px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line-soft); display: block; }
.photo-grid figcaption { font-size: 11.5px; color: var(--faint); display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
@media (max-width: 860px) { .topbar-right { margin-left: auto; } }
@media (max-width: 720px) { .topbar-right .menu { display: none; } }
