/* Prabal Motors Private Limited - IBT Control & Reconciliation
   Developed by Krishna Kumar MK
   Accessible design: WCAG 2.1 AA contrast, visible focus, reduced motion, high-contrast & large-text modes */
:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #eef2f7; --border: #d3dae3; --text: #1a2330; --muted: #4f5b6b;
  --primary: #12355b; --primary-ink: #ffffff; --primary-soft: #e3ecf6; --accent: #b06400; --link: #0b4f9c;
  --ok: #17663a; --ok-bg: #e3f4ea; --warn: #8a5300; --warn-bg: #fff3dc; --bad: #a3221b; --bad-bg: #fde8e6;
  --info: #0b4f9c; --info-bg: #e5effc; --neutral-bg: #eceff3;
  --focus: #f0a020; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 2px 8px rgba(16,24,40,.06);
  --fs: 15px; --nav-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #171e27; --surface-2: #1e2732; --border: #2f3a48; --text: #e8edf3; --muted: #a9b4c2;
    --primary: #8fb8e8; --primary-ink: #0b1622; --primary-soft: #1d2b3c; --accent: #f0a020; --link: #8fc1ff;
    --ok: #6fd39b; --ok-bg: #12301f; --warn: #ffc56b; --warn-bg: #33270f; --bad: #ff8d84; --bad-bg: #3a1714;
    --info: #8fc1ff; --info-bg: #142a44; --neutral-bg: #222b36; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #171e27; --surface-2: #1e2732; --border: #2f3a48; --text: #e8edf3; --muted: #a9b4c2;
  --primary: #8fb8e8; --primary-ink: #0b1622; --primary-soft: #1d2b3c; --accent: #f0a020; --link: #8fc1ff;
  --ok: #6fd39b; --ok-bg: #12301f; --warn: #ffc56b; --warn-bg: #33270f; --bad: #ff8d84; --bad-bg: #3a1714;
  --info: #8fc1ff; --info-bg: #142a44; --neutral-bg: #222b36; color-scheme: dark;
}
:root.hc { --border: currentColor; --muted: var(--text); --shadow: none; }
:root.hc .badge, :root.hc .btn, :root.hc .card, :root.hc input, :root.hc select, :root.hc textarea { border-width: 2px !important; border-color: var(--text) !important; }
:root.lt { --fs: 18px; }

* { box-sizing: border-box; }
html { font-size: var(--fs); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", Arial, sans-serif; line-height: 1.5; }
a { color: var(--link); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--primary); color: var(--primary-ink); padding: 10px 14px; border-radius: 6px; z-index: 1000; font-weight: 600; }
.skip-link:focus { top: 8px; }
.noscript { padding: 2rem; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; grid-template-rows: auto 1fr auto; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: #12355b; color: #ffffff; border-bottom: 3px solid #f0a020; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; color: inherit; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.14); display: grid; place-items: center; font-size: 13px; letter-spacing: .5px; }
.brand small { display: block; font-weight: 500; opacity: .85; font-size: .78rem; }
.topbar .spacer { flex: 1; }
.topbar .tb-btn { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: .88rem; min-height: 36px; }
.topbar .tb-btn:hover { background: rgba(255,255,255,.12); }
.tb-btn .count { background: #f0a020; color: #111; border-radius: 10px; padding: 0 6px; margin-left: 4px; font-size: .78rem; }
.userchip { font-size: .85rem; text-align: right; line-height: 1.2; }
.userchip span { display: block; opacity: .85; font-size: .75rem; }
.nav { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 8px; overflow-y: auto; }
.nav h2 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .93rem; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
main { padding: 20px 24px 40px; min-width: 0; }
.footer { grid-column: 1 / -1; padding: 12px 24px; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--border); background: var(--surface); display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; }
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .nav { display: none; position: fixed; inset: 56px 0 0 0; z-index: 50; }
  .nav.open { display: block; }
  .menu-toggle { display: inline-block; }
  .userchip { display: none; }
  main { padding: 16px; }
}

/* ---------- Components ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.page-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; display: block; box-shadow: var(--shadow); }
a.kpi:hover { border-color: var(--primary); }
.kpi .lbl { font-size: .8rem; color: var(--muted); }
.kpi .val { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .78rem; color: var(--muted); }
.kpi.bad .val { color: var(--bad); } .kpi.warn .val { color: var(--warn); } .kpi.ok .val { color: var(--ok); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ok { color: var(--ok); border-color: var(--ok); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: .84rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.linklike { background: none; border: 0; color: var(--link); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
.req::after { content: " *"; color: var(--bad); }
input, select, textarea { width: 100%; font: inherit; font-size: .95rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 40px; }
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); vertical-align: middle; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); border-width: 2px; }
.field { margin-bottom: 12px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.err { font-size: .82rem; color: var(--bad); margin-top: 3px; font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filters .field { margin: 0; min-width: 140px; flex: 0 1 180px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
caption { text-align: left; padding: 10px 12px; font-weight: 600; caption-side: top; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: .76rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.b-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.b-bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.b-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.b-neutral { background: var(--neutral-bg); color: var(--muted); border-color: var(--border); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--accent); }

.stepper { display: flex; flex-wrap: wrap; gap: 0; list-style: none; padding: 0; margin: 0 0 14px; }
.stepper li { flex: 1 1 110px; padding: 8px 10px; border-top: 4px solid var(--border); font-size: .8rem; color: var(--muted); }
.stepper li.done { border-color: var(--ok); color: var(--text); }
.stepper li.current { border-color: var(--accent); color: var(--text); font-weight: 700; }
.stepper li.blocked { border-color: var(--bad); color: var(--bad); font-weight: 700; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .9rem; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--border); position: relative; font-size: .87rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline time { color: var(--muted); font-size: .78rem; display: block; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 70px; gap: 8px; align-items: center; font-size: .85rem; }
.bar { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 7px; width: 0; }
.bar.warn > span { background: var(--accent); } .bar.bad > span { background: var(--bad); }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: .7rem; color: var(--muted); min-width: 0; }
.chart .col span.b { width: 70%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; height: 0; }
.chart .col span.l { margin-top: 4px; white-space: nowrap; }

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: .9rem; border: 1px solid; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 2000; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem; }
.toast.bad { background: var(--bad); color: #fff; }

dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; max-width: min(640px, calc(100vw - 24px)); width: 100%; background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10,18,28,.55); }
dialog .dlg-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
dialog .dlg-body { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }
dialog .dlg-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.notif-list { list-style: none; padding: 0; margin: 0; }
.notif-list li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.notif-list li.unread { font-weight: 600; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: linear-gradient(160deg, #0d2742, #12355b 60%, #1c4a78); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { font-size: 1.9rem; margin-top: 18px; }
.auth-side ul { padding-left: 18px; opacity: .92; }
.auth-side .flow { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0; }
.auth-side .flow span { border: 1px solid rgba(255,255,255,.4); border-radius: 999px; padding: 3px 10px; font-size: .78rem; letter-spacing: .04em; }
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 32px 20px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card { padding: 26px; }
.auth-foot { margin-top: 18px; font-size: .78rem; color: var(--muted); text-align: center; }
.banner-legal { font-size: .78rem; color: var(--muted); border-left: 3px solid var(--accent); padding-left: 10px; margin-top: 14px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 70px; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.policy { list-style: none; padding: 0; margin: 6px 0 0; font-size: .82rem; }
.policy li::before { content: "✗ "; color: var(--bad); font-weight: 700; }
.policy li.ok::before { content: "✓ "; color: var(--ok); }
.qr { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .86rem; overflow-wrap: anywhere; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { padding: 28px 20px; } .auth-side ul, .auth-side .flow { display: none; } }

.a11y-bar { display: flex; gap: 6px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
@media print { .nav, .topbar, .footer .a11y-bar, .btn, .filters { display: none !important; } .shell { display: block; } .card { box-shadow: none; } }
.w100 { width: 100%; }
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi .val { font-size: 1.25rem; }
  .filters .field { flex: 1 1 100%; min-width: 0; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; }
  .brand small { display: none; }
  .bar-row { grid-template-columns: 80px 1fr 36px; }
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dd { margin-bottom: 6px; }
  .page-head { align-items: flex-start; }
  .footer { padding: 12px 16px; }
}

.table-wrap td:first-child a { white-space: nowrap; }

/* Company logo */
.logo-top { height: 44px; width: auto; display: block; border-radius: 6px; }
.logo-auth { width: 320px; max-width: 100%; height: auto; display: block; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.auth-owner { margin: 12px 0 0; font-size: .9rem; opacity: .9; }
@media (max-width: 900px) { .logo-auth { width: 240px; } }
@media (max-width: 640px) { .logo-top { height: 30px; } }
@media print { .logo-top { display: block !important; } }
