:root {
  --bg: #f5f7f6; --surface: #ffffff; --surface-2: #eef2f0; --text: #14201b; --muted: #5d6b65; --border: #dbe3df;
  --brand: #0b6b45; --brand-2: #0f8a5a; --brand-ink: #ffffff; --danger: #b42318; --danger-bg: #fdecea;
  --warn: #9a6200; --warn-bg: #fff4dc; --ok: #0b6b45; --ok-bg: #e3f4ec; --info: #1d4ed8; --info-bg: #e7eefe;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 2px 8px rgba(16, 24, 20, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1412; --surface: #151d1a; --surface-2: #1c2622; --text: #e6eeea; --muted: #94a39c; --border: #2a3631;
    --brand: #2bb57a; --brand-2: #34c98a; --brand-ink: #06140e; --danger: #f97066; --danger-bg: #3a1714;
    --warn: #f5b546; --warn-bg: #352a12; --ok: #4ad295; --ok-bg: #12301f; --info: #7aa2ff; --info-bg: #16213d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1412; --surface: #151d1a; --surface-2: #1c2622; --text: #e6eeea; --muted: #94a39c; --border: #2a3631;
  --brand: #2bb57a; --brand-2: #34c98a; --brand-ink: #06140e; --danger: #f97066; --danger-bg: #3a1714;
  --warn: #f5b546; --warn-bg: #352a12; --ok: #4ad295; --ok-bg: #12301f; --info: #7aa2ff; --info-bg: #16213d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.urdu { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif; direction: rtl; line-height: 2.1; font-size: 16px; }

.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--muted); font-size: 11.5px; }
.nav a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--ok-bg); color: var(--brand); font-weight: 600; }
.sidebar .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; }
main { padding: 24px 28px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi.danger .value { color: var(--danger); }
.kpi.ok .value { color: var(--ok); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-danger { background: var(--danger-bg); color: var(--danger); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-muted { background: var(--surface-2); color: var(--muted); }

button, .btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--danger); }
button.small { padding: 3px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

form.stack { display: grid; gap: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
label.check input { width: auto; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 120px; font-family: ui-monospace, monospace; font-size: 12.5px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px; }
.auth .brand { padding: 0 0 18px; }
.error { color: var(--danger); min-height: 20px; font-size: 13px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border-radius: 12px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; padding: 22px; position: relative; border: 1px solid var(--border); }
.modal-close { position: absolute; right: 10px; top: 8px; border: 0; font-size: 22px; background: none; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; z-index: 30; max-width: calc(100% - 32px); }

.transcript { display: grid; gap: 8px; margin: 12px 0; }
.bubble { padding: 10px 14px; border-radius: 12px; max-width: 90%; }
.bubble.agent { background: var(--ok-bg); justify-self: start; }
.bubble.shopkeeper { background: var(--surface-2); justify-self: end; }
.bubble .meta { font-size: 11px; color: var(--muted); direction: ltr; text-align: left; font-family: system-ui, sans-serif; line-height: 1.4; }
.keypad { display: flex; gap: 6px; flex-wrap: wrap; }
.keypad button { width: 42px; }
.list { display: grid; gap: 8px; }
.list-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.section { margin-top: 18px; }
code.key { display: block; padding: 10px; background: var(--surface-2); border-radius: 8px; word-break: break-all; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); align-items: center; }
  .brand { padding: 0 10px 0 0; }
  .brand small, .sidebar .foot { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { white-space: nowrap; }
  main { padding: 16px; }
}
