/* Star Mobile Shop — counter-first admin UI.
   Brand: navy #002163 + star blue #0970FD (from the Star Mobile logo).
   Navy sidebar, cool paper background, money in green / money out red.
   Every number uses tabular figures so columns of rupees line up. */
:root {
  --paper: #F3F6FB;
  --surface: #FFFFFF;
  --ink: #0F1B33;
  --ink-soft: #56637A;
  --line: #DCE3EE;
  --pine: #002163;   /* brand navy */
  --pine-2: #0B3285;
  --blue: #0970FD;   /* brand star blue */
  --blue-2: #005BDB;
  --blue-soft: #E7F0FF;
  --green: #1F8A70;
  --red: #B3261E;
  --amber: #9A6400;
  --radius: 6px;
  --bs-body-font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-border-color: var(--line);
  --bs-primary: #0970FD;
  --bs-primary-rgb: 9, 112, 253;
  --bs-link-color: #005BDB;
  --bs-link-color-rgb: 0, 91, 219;
  --bs-link-hover-color: #002163;
  --bs-link-hover-color-rgb: 0, 33, 99;
}

body { font-size: .9375rem; font-feature-settings: "tnum" 1; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.in  { color: var(--green); }
.out { color: var(--red); }
.muted { color: var(--ink-soft); }
h1, .h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2, .h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .75rem; }

/* ---------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; background: var(--pine); color: #DCE6FA;
  --bs-offcanvas-width: 260px; --bs-offcanvas-bg: var(--pine); --bs-offcanvas-color: #DCE6FA;
}
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
}
.brandmark { padding: 1.25rem 1.25rem 1rem; display: flex; gap: .6rem; align-items: center; justify-content: center; position: relative; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: .5rem; }
.brandmark a { display: block; line-height: 0; }
.brandmark img { width: 132px; height: auto; }
.brandmark .btn-close { position: absolute; right: 1rem; top: 1rem; }
.nav-side { padding: .25rem .6rem 1rem; }
.nav-side a {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: var(--radius);
  color: #C3D2EE; text-decoration: none; font-size: .925rem;
}
.nav-side a:hover { background: var(--pine-2); color: #fff; }
.nav-side a.active { background: var(--blue); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(9,112,253,.35); }
.nav-side .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #7F96C4; padding: 1rem .7rem .35rem; }
.nav-side svg { width: 18px; height: 18px; flex-shrink: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: .6rem 1rem; display: flex; gap: .75rem; align-items: center; position: sticky; top: 0; z-index: 20;
}
.topbar .search { flex: 1; max-width: 560px; position: relative; }
.topbar .search input { padding-left: 2.3rem; background: var(--paper); border-color: transparent; height: 42px; }
.topbar .search input:focus { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(9,112,253,.15); }
.topbar .search svg { position: absolute; left: .75rem; top: 12px; width: 18px; height: 18px; color: var(--ink-soft); }
.content { padding: 1.25rem; max-width: 1400px; width: 100%; }
@media (min-width: 768px) { .content { padding: 1.75rem 2rem; } }

.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }

/* ---------- panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-body { padding: 1rem 1.15rem; }
.panel > .table-responsive > .table, .panel > .table { margin: 0; }

/* Position strip: one band, split by rules, instead of a row of identical cards */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.strip > div { padding: 1rem 1.15rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.strip .label { font-size: .82rem; color: var(--ink-soft); }
.strip .value { font-size: 1.55rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin-top: .15rem; }
.strip .sub { font-size: .8rem; color: var(--ink-soft); margin-top: .1rem; }
.strip .lead-cash { background: var(--pine); color: #fff; border-color: var(--pine); }
.strip .lead-cash .label, .strip .lead-cash .sub { color: #A9BEE6; }
.strip .lead-cash { background-image: linear-gradient(135deg, var(--pine) 0%, #0B3285 100%); }

/* Profit statement table */
.statement td { padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.statement tr.total td { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 600; padding-top: .65rem; }
.statement td:first-child { color: var(--ink-soft); }

/* ---------- tables */
.table { --bs-table-bg: transparent; font-size: .9rem; }
.table thead th { font-weight: 500; color: var(--ink-soft); font-size: .82rem; border-bottom-color: var(--line); white-space: nowrap; background: #F7F9FD; }
.table td { vertical-align: middle; }
.table a.row-link { color: inherit; text-decoration: none; font-weight: 500; }
.table a.row-link:hover { color: var(--blue); }
.sort-link { color: inherit; text-decoration: none; }
.sort-link.on { color: var(--ink); font-weight: 600; }

.imei { letter-spacing: .04em; font-variant-numeric: tabular-nums; }

/* ---------- status pills */
.pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 500; border: 1px solid transparent; white-space: nowrap; }
.pill-in_stock  { background: #E5F3EE; color: #146650; }
.pill-reserved  { background: #FFF4D6; color: #7A5200; }
.pill-sold      { background: #E9ECEF; color: #39474A; }
.pill-returned  { background: var(--blue-soft); color: #0B3285; }
.pill-damaged   { background: #FBE9E7; color: #8F1F17; }
.pill-exchanged { background: #F0E9FA; color: #5B3591; }
.pill-warn      { background: #FFF4D6; color: #7A5200; }
.pill-err       { background: #FBE9E7; color: #8F1F17; }

/* ---------- forms */
.form-label { font-size: .85rem; font-weight: 500; margin-bottom: .3rem; }
.form-control, .form-select { border-color: #C9D3E4; }
.form-control:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(9,112,253,.15); }
.form-check-input:checked { background-color: var(--blue); border-color: var(--blue); }
.btn-primary { --bs-btn-bg: var(--blue); --bs-btn-border-color: var(--blue); --bs-btn-hover-bg: var(--blue-2); --bs-btn-hover-border-color: var(--blue-2); --bs-btn-active-bg: #004CB8; --bs-btn-active-border-color: #004CB8; --bs-btn-disabled-bg: var(--blue); --bs-btn-disabled-border-color: var(--blue); }
.btn-outline-primary { --bs-btn-color: var(--blue); --bs-btn-border-color: var(--blue); --bs-btn-hover-bg: var(--blue); --bs-btn-hover-border-color: var(--blue); --bs-btn-active-bg: var(--blue-2); }
.page-link { --bs-pagination-color: var(--blue-2); --bs-pagination-active-bg: var(--blue); --bs-pagination-active-border-color: var(--blue); }
.btn-dark { --bs-btn-bg: var(--pine); --bs-btn-border-color: var(--pine); --bs-btn-hover-bg: #0B3285; --bs-btn-hover-border-color: #0B3285; }
.fieldset-title { font-weight: 600; font-size: .95rem; margin: 0 0 .85rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- unit page timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid var(--line); margin-left: .35rem; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-soft); }
.timeline li.ev-sold::before { border-color: var(--green); background: var(--green); }
.timeline li.ev-purchased::before, .timeline li.ev-imported::before { border-color: var(--pine); }
.timeline li.ev-deleted::before { border-color: var(--red); }
.timeline .when { font-size: .8rem; color: var(--ink-soft); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; }
dl.facts dt { font-weight: 400; color: var(--ink-soft); font-size: .88rem; }
dl.facts dd { margin: 0; }

/* ---------- toasts */
.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080; display: grid; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast-msg { background: var(--ink); color: #fff; padding: .75rem 1rem; border-radius: var(--radius); display: flex; gap: .75rem; align-items: start; box-shadow: 0 8px 24px rgba(0,33,99,.25); }
.toast-msg.error { background: var(--red); }
.toast-msg button { background: none; border: 0; color: inherit; opacity: .7; margin-left: auto; font-size: 1.1rem; line-height: 1; }

/* ---------- import preview */
.import-table input.form-control, .import-table select { min-width: 90px; padding: .25rem .4rem; font-size: .85rem; }
.import-table tr.has-error { background: #FDF3F2; }
.import-table tr.skipped { opacity: .45; }

/* ---------- login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .login-wrap { grid-template-columns: 1.1fr 1fr; } }
.login-side { background: radial-gradient(120% 90% at 85% 10%, #0B3285 0%, var(--pine) 55%); color: #fff; padding: 3rem; display: none; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-side .side-logo { width: 220px; height: auto; }
.login-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 28px solid rgba(9,112,253,.18); pointer-events: none; }
@media (min-width: 900px) { .login-side { display: flex; } }
.login-side .big { font-size: 2.6rem; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; max-width: 12ch; }
.login-side .imei-art { font-size: 1.05rem; color: #7FA8F5; letter-spacing: .12em; margin-bottom: 1.25rem; font-variant-numeric: tabular-nums; }
.login-form { display: grid; place-items: center; padding: 2rem; }
.login-form form { width: 100%; max-width: 360px; }
.login-form .form-logo { width: 150px; height: auto; display: block; margin: 0 auto 1.5rem; }
@media (min-width: 900px) { .login-form .form-logo { display: none; } }
.login-side .big .accent { color: var(--blue); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .sidebar, .topbar, .no-print { display: none !important; } .content { padding: 0; } }

/* Bootstrap makes .offcanvas-lg transparent on desktop; keep the navy brand sidebar. */
.sidebar.offcanvas-lg { background-color: var(--pine) !important; }

/* ---------- customer ID capture (quick sale) */
.id-capture { border: 0; padding: 0; margin: 0; min-width: 0; }
.id-capture legend { float: none; width: auto; font-size: .85rem; font-weight: 500; }
.id-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: .6rem; }
.id-tile { border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem; background: #FAFBFE; display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.id-tile.has-photo { border-color: #9EC2FF; background: #F5F9FF; }
.id-tile.has-error { border-color: var(--red); background: #FDF3F2; }
.id-tile-head { font-size: .8rem; font-weight: 600; color: var(--ink); }
.id-frame { position: relative; aspect-ratio: 1.586; border-radius: 4px; background: #EEF2F9; border: 1px dashed #C9D3E4; display: grid; place-items: center; overflow: hidden; }
.id-tile[data-photo=customer_photo] .id-frame { aspect-ratio: 1.586; }
.id-tile.has-photo .id-frame { border-style: solid; background: #fff; }
.id-empty { color: #9AA8C2; }
.id-empty svg { width: 34px; height: 34px; }
.id-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.id-busy { position: absolute; inset: 0; display: flex; gap: .4rem; align-items: center; justify-content: center; background: rgba(255,255,255,.88); font-size: .8rem; color: var(--ink-soft); }
.id-remove { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(15,27,51,.75); color: #fff; font-size: 1.1rem; line-height: 1; display: grid; place-items: center; }
.id-remove:hover { background: var(--red); }
.id-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
/* Side by side when the tile is wide enough, otherwise one per row; never overflowing the tile. */
.id-actions .btn { flex: 1 1 96px; min-width: 0; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; padding: .35rem .3rem; font-size: .8rem; min-height: 36px; }
.id-actions svg { width: 15px; height: 15px; flex-shrink: 0; }
.id-msg { color: var(--red); line-height: 1.3; }
.id-msg:empty { display: none; }
[hidden] { display: none !important; }

/* saved ID photos on the phone page */
.id-docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.id-doc { display: block; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.id-doc img { display: block; width: 100%; height: 110px; object-fit: cover; background: #EEF2F9; }
.id-doc span { display: block; padding: .35rem .5rem; font-size: .8rem; }
.id-doc:hover { border-color: var(--blue); }

/* webcam window */
.cam-stage { position: relative; background: #0B1220; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; max-height: 62vh; margin: 0 auto; display: grid; place-items: center; }
.cam-video, .cam-still { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-video.mirror { transform: scaleX(-1); }
.cam-guide { position: absolute; left: 12%; right: 12%; top: 50%; transform: translateY(-50%); aspect-ratio: 1.586; border: 3px dashed rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); pointer-events: none; }
.cam-wait { position: absolute; inset: 0; display: flex; flex-direction: column; gap: .75rem; align-items: center; justify-content: center; color: #C3D2EE; }
@media (max-width: 575.98px) { .cam-stage { aspect-ratio: 3 / 4; } }
