/* ==========================================================================
   StarDeals Panel
   Palette: deep navy ledger + UPI cyan. The accent comes from the domain's own
   world (UPI / Paytm cyan on navy), not from a generic dashboard template.
   Type: Space Grotesk (display) / IBM Plex Sans (body) / IBM Plex Mono (data).
   Monospace on every amount, order ID and UTR is functional — those columns
   have to align to be scannable.
   ========================================================================== */

:root {
  --ink:        #0B1120;
  --surface:    #111A2E;
  --surface-2:  #17223C;
  --surface-3:  #1D2A48;
  --line:       #243050;
  --line-soft:  #1A2440;
  --paper:      #E9EEF9;
  --mute:       #808FB5;
  --mute-dim:   #5A6787;

  --cyan:       #00C2FF;
  --cyan-deep:  #0B4E68;
  --green:      #2FD47C;
  --green-deep: #10402A;
  --amber:      #FFB020;
  --amber-deep: #46320A;
  --red:        #FF5F5F;
  --red-deep:   #47191C;
  --violet:     #9B8CFF;
  --violet-deep:#2C2652;

  --rail-w: 232px;
  --radius: 8px;
  --radius-sm: 5px;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------------------------------------------------------------- layout */
.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail-w);
  flex: 0 0 var(--rail-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 0 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { padding: 0 20px 22px; display: flex; align-items: center; gap: 11px; }

/* The brand mark is a 3x3 QR finder pattern - the shop's own artifact. */
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
}
.brand-mark i { background: var(--cyan-deep); border-radius: 1px; }
.brand-mark i:nth-child(1),
.brand-mark i:nth-child(3),
.brand-mark i:nth-child(5),
.brand-mark i:nth-child(7),
.brand-mark i:nth-child(9) { background: var(--cyan); }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
}
.brand-sub {
  font-size: 10.5px;
  color: var(--mute-dim);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

.nav { display: flex; flex-direction: column; gap: 1px; padding: 0 10px; flex: 1; }

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--mute-dim);
  padding: 16px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  color: var(--mute);
  font-size: 13.8px;
  font-weight: 500;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: var(--paper); text-decoration: none; }
.nav-item.is-active {
  background: var(--surface-2);
  color: var(--paper);
  border-left-color: var(--cyan);
}
.nav-count {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-3);
  color: var(--mute);
  padding: 1px 6px;
  border-radius: 20px;
}
.nav-item.is-active .nav-count { background: var(--cyan-deep); color: var(--cyan); }
.nav-count.is-hot { background: var(--amber-deep); color: var(--amber); }

.rail-foot { padding: 14px 20px 0; border-top: 1px solid var(--line-soft); margin-top: 10px; }
.rail-user { font-size: 12.5px; color: var(--mute); }
.rail-user strong { color: var(--paper); font-weight: 600; }
.rail-role {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--cyan); display: block; margin-top: 1px;
}
.rail-foot a { font-size: 12.5px; color: var(--mute-dim); display: inline-block; margin-top: 8px; }
.rail-foot a:hover { color: var(--red); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 16px 26px;
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
.topbar h1 {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 600; letter-spacing: -0.3px;
  margin: 0;
}
.topbar .sub { color: var(--mute); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.content { padding: 22px 26px 60px; max-width: 1400px; }

/* ---------------------------------------------------------------- flash */
.flash {
  padding: 10px 14px; border-radius: var(--radius);
  margin-bottom: 18px; font-size: 13.5px;
  border: 1px solid; display: flex; gap: 9px; align-items: flex-start;
}
.flash-ok { background: var(--green-deep); border-color: #1E6B45; color: #9BEFC3; }
.flash-err { background: var(--red-deep); border-color: #6E2A2E; color: #FFB4B4; }

/* ------------------------------------------------------- signature strip */
/* One square per recent order, oldest left. Reads as a QR fragment, and a run
   of amber or red is visible instantly without reading a single number. */
.strip-card { margin-bottom: 20px; }
.strip {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 2px 0 12px;
}
.strip-cell {
  width: 15px; height: 15px;
  border-radius: 2px;
  background: var(--surface-3);
  border: none; padding: 0;
  cursor: help;
  transition: transform 0.09s ease;
}
.strip-cell:hover { transform: scale(1.32); }
.s-delivered { background: var(--green); }
.s-awaiting { background: var(--cyan); }
.s-pending { background: var(--amber); }
.s-cancelled { background: var(--red); }
.s-expired { background: #34405F; }

.strip-key { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--mute); }
.strip-key span { display: flex; align-items: center; gap: 5px; }
.strip-key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 16px; }

.card-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: -2px 0 14px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.1px;
  color: var(--mute);
  margin: 0;
}
.card-head .spacer { margin-left: auto; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-wide { grid-template-columns: 1.6fr 1fr; }

/* ---------------------------------------------------------------- metrics */
.metric { display: flex; flex-direction: column; gap: 3px; }
.metric-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--mute-dim); font-weight: 600;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 25px; font-weight: 500;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
}
.metric-note { font-size: 12px; color: var(--mute); }
.metric-value.is-good { color: var(--green); }
.metric-value.is-warn { color: var(--amber); }
.metric-value.is-bad { color: var(--red); }

/* ---------------------------------------------------------------- bars */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 96px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 5px; min-width: 0; }
.bar {
  background: var(--cyan-deep);
  border-top: 2px solid var(--cyan);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}
.bar-col:hover .bar { background: #12657F; }
.bar-tick {
  font-family: var(--font-mono);
  font-size: 9.5px; color: var(--mute-dim);
  text-align: center; white-space: nowrap; overflow: hidden;
}

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -18px -18px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
  text-align: left;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--mute-dim); font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table thead th:first-child,
.table tbody td:first-child { padding-left: 18px; }
.table thead th:last-child,
.table tbody td:last-child { padding-right: 18px; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right; white-space: nowrap;
}
.table .mono { font-family: var(--font-mono); font-size: 12px; }
.table .tight { white-space: nowrap; }
.table-actions { display: flex; gap: 5px; justify-content: flex-end; }

.ref { font-family: var(--font-mono); font-size: 12px; color: var(--mute); }
.ref-strong { font-family: var(--font-mono); font-size: 12.5px; color: var(--paper); }

/* ---------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.7px;
  padding: 3px 8px; border-radius: 20px;
  white-space: nowrap;
  background: var(--surface-3); color: var(--mute);
}
.pill-delivered { background: var(--green-deep); color: #7BE8AE; }
.pill-awaiting { background: var(--cyan-deep); color: #7FDCF5; }
.pill-pending { background: var(--amber-deep); color: #FFCF7A; }
.pill-cancelled { background: var(--red-deep); color: #FFA8A8; }
.pill-expired { background: #232D45; color: var(--mute); }
.pill-ok { background: var(--green-deep); color: #7BE8AE; }
.pill-manual { background: var(--violet-deep); color: #C4BAFF; }
.pill-off { background: #232D45; color: var(--mute-dim); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: currentColor; }

/* ---------------------------------------------------------------- switch */
/* On/off control for products, plans and payment methods. It is a real
   checkbox so it is keyboard reachable and announces its state; panel.js
   submits the surrounding form on change. */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }

.switch input {
  position: absolute; opacity: 0;
  width: 40px; height: 22px; margin: 0; cursor: pointer;
}

.switch-track {
  position: relative;
  width: 40px; height: 22px; flex: 0 0 40px;
  background: #2B3757;
  border-radius: 22px;
  transition: background 0.16s ease;
}
.switch-track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #8496BE;
  border-radius: 50%;
  transition: transform 0.16s ease, background 0.16s ease;
}

.switch input:checked + .switch-track { background: var(--cyan-deep); }
.switch input:checked + .switch-track::after {
  transform: translateX(18px);
  background: var(--cyan);
}
.switch:hover .switch-track { background: #333F63; }
.switch:hover input:checked + .switch-track { background: #0D5C7A; }

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--cyan); outline-offset: 2px;
}

.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }

/* The label text comes from the checkbox state via CSS, not from script. That
   way cancelling a confirmation (which calls form.reset()) restores the label
   automatically - setting it from JS left the switch reading the wrong state. */
.switch-text {
  font-size: 12px; color: var(--mute);
  min-width: 62px;
  font-variant-numeric: tabular-nums;
}
.switch-text::after { content: attr(data-off); }
.switch input:checked ~ .switch-text { color: var(--paper); }
.switch input:checked ~ .switch-text::after { content: attr(data-on); }

/* Without JS the switch cannot submit, so a plain button is shown instead. */
.switch-fallback { margin-left: 6px; }
.has-js .switch-fallback { display: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-body);
  font-size: 13px; font-weight: 500;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--paper);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn-primary {
  background: var(--cyan); border-color: var(--cyan); color: #04222E; font-weight: 600;
}
.btn-primary:hover { background: #35D0FF; border-color: #35D0FF; }
.btn-danger { color: #FFA8A8; border-color: #5A2226; background: transparent; }
.btn-danger:hover { background: var(--red-deep); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--mute); padding: 5px 8px; }
.btn-quiet:hover { background: var(--surface-2); color: var(--paper); }
.btn-sm { font-size: 12px; padding: 4px 9px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------------------------------------------------------- forms */
.form { max-width: 660px; }
.field { margin-bottom: 17px; }
.field label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  margin-bottom: 5px; color: var(--paper);
}
.field .hint { font-size: 12px; color: var(--mute); margin: 4px 0 0; font-weight: 400; }
.field label .hint { font-weight: 400; color: var(--mute); }
.req { color: var(--cyan); font-weight: 400; }

.input, .select, .textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 11px;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--cyan); outline: none;
  box-shadow: 0 0 0 3px rgba(0, 194, 255, 0.13);
}
.input-mono { font-family: var(--font-mono); font-size: 13px; }
.textarea { min-height: 76px; resize: vertical; }
.select { appearance: none; background-image: none; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.check { display: flex; align-items: flex-start; gap: 9px; }
.check input { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--cyan); }
.check label { margin: 0; }

.radio-set { display: flex; flex-direction: column; gap: 8px; }
.radio-card {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  cursor: pointer;
}
.radio-card:hover { border-color: var(--mute-dim); }
.radio-card input { margin-top: 3px; accent-color: var(--cyan); }
.radio-card:has(input:checked) { border-color: var(--cyan); background: rgba(0, 194, 255, 0.06); }
.radio-card .rc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.radio-card .rc-title { font-size: 13.5px; font-weight: 600; color: var(--paper); }
.radio-card .rc-detail { font-size: 12px; font-weight: 400; color: var(--mute); line-height: 1.45; }

.form-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding-top: 12px; border-top: 1px solid var(--line-soft); margin-top: 22px;
}
.form-actions .small { flex: 1 1 180px; min-width: 0; }
.form-actions .spacer { margin-left: auto; }

/* ---------------------------------------------------------------- filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input, .filters .select { width: auto; min-width: 150px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--line); color: var(--mute);
  background: var(--surface);
}
.chip:hover { color: var(--paper); border-color: var(--mute-dim); text-decoration: none; }
.chip.is-on { background: var(--cyan-deep); border-color: var(--cyan); color: var(--cyan); }
.chip-n { font-family: var(--font-mono); font-size: 11px; opacity: 0.75; margin-left: 3px; }

/* ---------------------------------------------------------------- pager */
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 20px; }
.pager-info { font-size: 12.5px; color: var(--mute); font-family: var(--font-mono); }

/* ---------------------------------------------------------------- empty */
.empty { text-align: center; padding: 46px 20px; }
.empty-mark {
  width: 40px; height: 40px; margin: 0 auto 14px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 3px;
  opacity: 0.4;
}
.empty-mark i { background: var(--surface-3); border-radius: 1px; }
.empty h3 {
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
  margin: 0 0 5px;
}
.empty p { color: var(--mute); font-size: 13.5px; margin: 0 auto 16px; max-width: 380px; }

/* ---------------------------------------------------------------- detail */
.detail-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; font-size: 13.5px; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; }
.kv dd.mono { font-family: var(--font-mono); font-size: 12.5px; word-break: break-all; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 15px 20px;
  border-left: 1px solid var(--line); margin-left: 4px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -4.5px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--line);
}
.timeline li.is-done::before { background: var(--green); border-color: var(--green); }
.timeline li.is-now::before { background: var(--amber); border-color: var(--amber); }
.timeline-title { font-size: 13.5px; font-weight: 500; }
.timeline-time { font-family: var(--font-mono); font-size: 11.5px; color: var(--mute-dim); }

.callout {
  border-left: 2px solid var(--cyan);
  background: var(--surface-2);
  padding: 11px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
}
.callout-warn { border-left-color: var(--amber); }
.callout-warn strong { color: var(--amber); }
.callout-danger { border-left-color: var(--red); }
.callout-danger strong { color: var(--red); }
.callout p { margin: 0; }
.callout p + p { margin-top: 7px; }

/* ---------------------------------------------------------------- login */
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card { width: 100%; max-width: 372px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-head {
  font-family: var(--font-display); font-size: 21px; font-weight: 600;
  margin: 0 0 5px; letter-spacing: -0.3px;
}
.login-sub { color: var(--mute); font-size: 13.5px; margin: 0 0 22px; }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--mute-dim); text-align: center; }

/* ---------------------------------------------------------------- error */
.error-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.error-code {
  font-family: var(--font-mono); font-size: 54px; font-weight: 300;
  color: var(--surface-3); line-height: 1; margin-bottom: 10px;
}
.error-head { font-family: var(--font-display); font-size: 21px; font-weight: 600; margin: 0 0 8px; }
.error-detail { color: var(--mute); margin: 0 0 22px; }

/* ---------------------------------------------------------------- utility */
.stack { display: flex; flex-direction: column; gap: 3px; }
.row { display: flex; align-items: center; gap: 8px; }
.muted { color: var(--mute); }
.dim { color: var(--mute-dim); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.inline-form { display: inline; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-wide, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .rail {
    width: 100%; flex: none; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 14px 0 8px;
  }
  .nav { flex-direction: row; overflow-x: auto; padding: 0 12px 4px; gap: 4px; }
  .nav-label { display: none; }
  .nav-item { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
  .nav-item.is-active { border-left-color: transparent; border-bottom-color: var(--cyan); }
  .rail-foot { display: flex; align-items: center; gap: 14px; }
  .rail-foot a { margin-top: 0; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .field-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .strip-cell:hover { transform: none; }
}
