/* ============================================================
   WIN TECH - Taxi Meter Management
   ============================================================ */

:root {
  --navy-900: #0d1626;
  --navy-800: #131f35;
  --navy-700: #1c2b47;
  --navy-600: #27395a;

  --amber-500: #f0b429;
  --amber-600: #de911d;
  --amber-100: #fff8e6;

  --blue-600: #2563eb;
  --blue-50: #eff6ff;
  --green-600: #15803d;
  --green-50: #ecfdf3;
  --red-600: #dc2626;
  --red-50: #fef2f2;
  --orange-600: #c2410c;
  --orange-50: #fff7ed;
  --purple-600: #7c3aed;
  --purple-50: #f5f3ff;

  --ink: #16202f;
  --ink-2: #475467;
  --ink-3: #667085;
  --line: #e4e7ec;
  --line-2: #f0f2f5;
  --bg: #f5f7fb;
  --card: #ffffff;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Segoe UI", Roboto, "Noto Sans Tamil", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------ layout ---------------------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--navy-900);
  color: #c8d2e0;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--amber-500), var(--amber-600));
  display: grid; place-items: center;
  font-size: 19px;
  flex: 0 0 36px;
}
.brand-text { line-height: 1.15; min-width: 0; }
.brand-text strong { display: block; color: #fff; font-size: 15px; letter-spacing: .3px; }
.brand-text span { font-size: 11px; color: #8c9ab1; }

.nav { padding: 10px 10px 20px; overflow-y: auto; flex: 1; }
.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #64748b;
  padding: 14px 10px 6px;
  font-weight: 700;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: #c2cddc;
  font-weight: 500;
  margin-bottom: 2px;
  text-decoration: none;
  transition: background .12s, color .12s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--amber-500); color: var(--navy-900); font-weight: 600; }
.nav a .ico { width: 18px; text-align: center; font-size: 14px; }
.nav a .badge-count {
  margin-left: auto;
  background: var(--red-600);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9px;
}
.nav a.active .badge-count { background: var(--navy-900); color: #fff; }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: 12px;
  color: #8c9ab1;
}
.sidebar-foot .who { color: #fff; font-weight: 600; font-size: 13px; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }

.content { padding: 20px 22px 60px; }

/* ----------------------------- buttons ---------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-accent { background: var(--amber-500); border-color: var(--amber-500); color: var(--navy-900); }
.btn-accent:hover { background: var(--amber-600); }
.btn-danger { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 6px 9px; font-size: 13px; }
.btn-link { border: none; background: none; color: var(--blue-600); padding: 4px 6px; }
.btn-link:hover { background: var(--blue-50); text-decoration: underline; }

/* ------------------------------ cards ----------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: #fcfdfe;
}
.card-head h2 { font-size: 14.5px; margin: 0; font-weight: 650; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

/* ------------------------------ stats ----------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 13px;
  align-items: flex-start;
}
.stat .s-ico {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 19px;
  flex: 0 0 40px;
}
.stat .s-label { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .s-value { font-size: 22px; font-weight: 700; line-height: 1.25; margin-top: 3px; }
.stat .s-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--navy-600); }

.i-blue { background: var(--blue-50); color: var(--blue-600); }
.i-green { background: var(--green-50); color: var(--green-600); }
.i-amber { background: var(--amber-100); color: var(--amber-600); }
.i-red { background: var(--red-50); color: var(--red-600); }
.i-orange { background: var(--orange-50); color: var(--orange-600); }
.i-purple { background: var(--purple-50); color: var(--purple-600); }

/* ------------------------------ tables ---------------------------- */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
  color: var(--ink-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
/*
 * A number column's heading has to sit over its numbers.
 *
 * `.num` alone loses to `table.data th`, which is more specific, so every
 * numeric heading in the app was left-aligned while the figures under it were
 * right-aligned. This puts the heading back over the column it names.
 */
table.data th.num { text-align: right; }

table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
table.data tbody tr:hover { background: #fbfcfe; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tfoot td {
  padding: 10px 14px;
  font-weight: 700;
  background: #f8fafc;
  border-top: 2px solid var(--line);
}
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: "Consolas", "Courier New", monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.strong { font-weight: 650; }

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty .big { font-size: 34px; display: block; margin-bottom: 8px; opacity: .5; }

/* ------------------------------ badges ---------------------------- */

.badge {
  display: inline-block;
  padding: 2.5px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
  border: 1px solid transparent;
}
.b-grey   { background: #f2f4f7; color: #475467; border-color: #e4e7ec; }
.b-blue   { background: var(--blue-50); color: var(--blue-600); border-color: #bfdbfe; }
.b-green  { background: var(--green-50); color: var(--green-600); border-color: #bbf7d0; }
.b-amber  { background: var(--amber-100); color: #a26100; border-color: #fde68a; }
.b-red    { background: var(--red-50); color: var(--red-600); border-color: #fecaca; }
.b-orange { background: var(--orange-50); color: var(--orange-600); border-color: #fed7aa; }
.b-purple { background: var(--purple-50); color: var(--purple-600); border-color: #ddd6fe; }

/* ------------------------------ forms ----------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field label .req { color: var(--red-600); }
.field .hint { font-size: 11.5px; color: var(--ink-3); }

/* A labelled divider inside a form grid — groups the boxes that follow it. */
.field.sub-head { gap: 2px; border-top: 1px solid var(--line); padding-top: 13px; margin-top: 3px; }
.field.sub-head label { font-weight: 700; color: var(--ink); }

input[type="text"], input[type="number"], input[type="date"], input[type="password"],
input[type="email"], input[type="search"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-600);
  box-shadow: 0 0 0 3px rgba(39, 57, 90, .1);
}
input:disabled, select:disabled, textarea:disabled { background: #f6f7f9; color: var(--ink-3); }
textarea { resize: vertical; min-height: 68px; }

.checkline { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.checkline input { width: 16px; height: 16px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar .grow { flex: 1; min-width: 190px; }
.toolbar input, .toolbar select { min-width: 130px; }

/* ----------------------------- tabs ------------------------------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  border: none;
  background: none;
  padding: 9px 15px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--navy-800); border-bottom-color: var(--amber-500); }

/* ----------------------------- modal ------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 22, 38, .5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  animation: pop .14s ease-out;
}
.modal.wide { max-width: 1000px; }
.modal.narrow { max-width: 430px; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

.modal-head {
  display: flex;
  align-items: center;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-head .close {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-3);
  padding: 0 4px;
}
.modal-head .close:hover { color: var(--ink); }
.modal-body { padding: 18px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 0 0 12px 12px;
}

/* ----------------------------- toast ------------------------------ */

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 200;
}
.toast {
  background: var(--navy-900);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  max-width: 380px;
  animation: slide .16s ease-out;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } }

/* --------------------------- pagination --------------------------- */

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
  flex-wrap: wrap;
}
.pager .spacer { flex: 1; }

/* ---------------------------- invoice ui -------------------------- */

.line-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.line-table th {
  background: #f8fafc;
  padding: 8px 8px;
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.line-table td { padding: 5px 6px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.line-table input, .line-table select { padding: 6px 7px; font-size: 13px; }
.line-table .rm {
  border: none; background: none; color: var(--red-600);
  cursor: pointer; font-size: 16px; padding: 4px 6px; line-height: 1;
}
.line-table .rm:hover { background: var(--red-50); border-radius: 4px; }

.totals-box {
  margin-left: auto;
  width: 320px;
  max-width: 100%;
  font-size: 13.5px;
}
.totals-box .row { display: flex; justify-content: space-between; padding: 6px 0; }
.totals-box .row.grand {
  border-top: 2px solid var(--line);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 17px;
  font-weight: 700;
}

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; }

/* ----------------------------- charts ----------------------------- */

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding: 8px 4px 0; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; min-width: 0; }
.bar-chart .bar {
  width: 100%;
  max-width: 46px;
  background: linear-gradient(180deg, var(--amber-500), var(--amber-600));
  border-radius: 5px 5px 0 0;
  min-height: 3px;
  transition: opacity .12s;
}
.bar-chart .bar:hover { opacity: .8; }
.bar-chart .bar-label { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.bar-chart .bar-value { font-size: 10.5px; font-weight: 650; color: var(--ink-2); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: start; }

/* ------------------------------ stepper ---------------------------- */

.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.stepper .step {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px 9px 11px;
  border: 1px solid var(--line);
  border-radius: 40px;
  background: #fff;
  box-shadow: var(--shadow);
}
.stepper .step .n {
  width: 25px; height: 25px;
  flex: 0 0 25px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--line-2);
  color: var(--ink-3);
  font-weight: 700;
  font-size: 12.5px;
}
.stepper .step .t { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.stepper .step.done .n { background: var(--green-600); color: #fff; }
.stepper .step.done .t { color: var(--ink-2); }
.stepper .step.current { border-color: var(--amber-500); }
.stepper .step.current .n { background: var(--amber-500); color: var(--navy-900); }
.stepper .step.current .t { color: var(--ink); }
.stepper .arrow { color: var(--ink-3); font-size: 15px; }

.chosen-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--green-50);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.chosen-bar .who { font-weight: 650; }
.chosen-bar .meta { font-size: 12.5px; color: var(--ink-2); }

/* --------------------------- action tiles -------------------------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
}
.tile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 15px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .12s, box-shadow .12s, transform .1s;
}
.tile:hover {
  text-decoration: none;
  border-color: var(--amber-500);
  box-shadow: 0 4px 14px rgba(16, 24, 40, .1);
  transform: translateY(-1px);
}
.tile .t-ico {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 18px;
}
.tile .t-name { font-weight: 650; font-size: 13.5px; line-height: 1.25; }
.tile .t-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.tile .t-num {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 700;
  margin-right: 2px;
}

.section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
  margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* --------------------------- code output --------------------------- */

.code-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: #fcfdfe;
  margin-bottom: 11px;
}
.code-card .c-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
  font-weight: 700;
}
.code-card .c-value {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--navy-900);
  margin: 5px 0 4px;
  word-break: break-all;
}
.code-card .c-note { font-size: 12.5px; color: var(--ink-2); }
.code-card .c-copy { float: right; }

.warn-box {
  background: var(--amber-100);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 12.5px;
  color: #7a4a00;
  margin-bottom: 14px;
}
.warn-box b { color: #5c3800; }

/* The same banner for something that is on and working, rather than a caution. */
.ok-box {
  background: var(--green-50);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 12.5px;
  color: #14532d;
  margin-bottom: 14px;
}
.ok-box b { color: #052e16; }

/* A password still set to the factory one. Red, above the page, and it does
   not go away on its own - it goes away when the password is changed. */
.weak-bar {
  background: var(--red-50); border-bottom: 2px solid var(--red-600); color: #7f1d1d;
  padding: 10px 20px; font-size: 13px; line-height: 1.5;
}
.weak-bar b { color: var(--red-600); }
.weak-bar button {
  margin-left: 10px; border: 1px solid var(--red-600); background: #fff; color: var(--red-600);
  border-radius: 6px; padding: 4px 12px; font: inherit; font-weight: 600; cursor: pointer;
}
.weak-bar button:hover { background: var(--red-600); color: #fff; }

/* ----------------------------- login ------------------------------ */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700) 60%, #24344f);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  width: 100%;
  max-width: 390px;
  padding: 30px 28px;
}
.login-card .logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--amber-500), var(--amber-600));
  display: grid; place-items: center;
  font-size: 28px;
  margin: 0 auto 14px;
}
.login-card h1 { text-align: center; font-size: 20px; margin: 0 0 2px; }
.login-card .sub { text-align: center; color: var(--ink-3); font-size: 13px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; padding: 10px; font-size: 14.5px; }
.login-err {
  background: var(--red-50);
  border: 1px solid #fecaca;
  color: var(--red-600);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.login-hint { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 16px; }

/* --------------------------- responsive --------------------------- */

@media (max-width: 980px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after {
    content: '';
    position: fixed; inset: 0;
    background: rgba(13, 22, 38, .45);
    z-index: 35;
  }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px 14px 60px; }
  .topbar { padding: 0 14px; }
  .field.span-2 { grid-column: span 1; }
}

/* ----------------------------- print ------------------------------ */

@media print {
  .sidebar, .topbar, .toolbar, .pager, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: none; }
  body { background: #fff; }
}

/* ------------------- print layout designer ------------------------ */

.design-split { display: grid; grid-template-columns: minmax(340px, 460px) 1fr; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .design-split { grid-template-columns: 1fr; } }
.design-form { display: flex; flex-direction: column; gap: 14px; }
.design-preview { position: sticky; top: 14px; }
.design-preview .card-body { max-height: calc(100vh - 190px); }
.design-preview .sheet { transform-origin: top left; }

.switch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 14px; margin: 4px 0 10px; }
.switch-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; cursor: pointer; padding: 3px 0; }
.switch-row input { margin-top: 2px; flex: 0 0 auto; }
.switch-row .hint { color: var(--ink-3); font-size: 11.5px; }

.sub-label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); margin: 12px 0 6px;
}
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 20px;
  border: 1px solid var(--line); background: #fff; font-size: 12.5px; cursor: pointer; user-select: none;
}
.chip input { display: none; }
.chip.on { background: var(--blue-50); border-color: #bfdbfe; color: var(--blue-600); font-weight: 600; }

/* ------------------------------ logo ------------------------------ */

.logo-preview {
  width: 96px; height: 96px; flex: 0 0 96px;
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--line-2); overflow: hidden; padding: 5px;
}
.logo-preview.small { width: 72px; height: 72px; flex-basis: 72px; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.logo-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 6px; }
@media (max-width: 620px) { .logo-row { flex-direction: column; } }

/* --------------------- login: password + help --------------------- */

.pwd-wrap { position: relative; display: flex; }
.pwd-wrap input { flex: 1; padding-right: 42px; }
.pwd-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; font-size: 16px;
  padding: 6px 8px; border-radius: var(--radius-sm); line-height: 1;
}
.pwd-eye:hover { background: var(--line-2); }

.login-help {
  position: fixed; inset: 0; z-index: 60; overflow: auto;
  background: rgba(9, 15, 26, .6); padding: 24px;
  display: flex; align-items: flex-start; justify-content: center;
}
.login-help[hidden] { display: none; }
.login-help > * { max-width: 560px; }
.login-help h2, .login-help p, .login-help ol, .login-help button {
  background: #fff; width: min(560px, 100%); margin: 0 auto; padding: 0 22px;
}
.login-help h2 { padding-top: 20px; border-radius: var(--radius) var(--radius) 0 0; font-size: 17px; }
.login-help p, .login-help ol { font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.login-help ol { padding-left: 44px; padding-right: 22px; }
.login-help li { margin-bottom: 10px; }
.login-help code {
  background: var(--line-2); padding: 2px 6px; border-radius: 4px;
  font-size: 12.5px; font-family: ui-monospace, Consolas, monospace;
}
.login-help .small { font-size: 12.5px; }
.login-help button {
  padding: 9px 22px; margin-bottom: 0; border-radius: 0 0 var(--radius) var(--radius);
  padding-bottom: 20px; border: none; text-align: right;
}

/* ------------------ print designer: drag placement ---------------- */

.place-bar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 9px 14px; border-bottom: 1px solid var(--line); background: #fcfdfe;
}
.place-bar[hidden] { display: none; }
.place-bar .sep { width: 1px; height: 20px; background: var(--line); }
.place-bar .spacer { flex: 1; }
.place-bar .btn.active { background: var(--amber-500); border-color: var(--amber-500); color: var(--navy-900); }
.place-readout { font-size: 12px; color: var(--ink-2); white-space: nowrap; }

.place-body { padding: 0 !important; }
.place-frame { position: relative; padding: 18px; }
.place-frame.free { padding: 24px 18px 18px 26px; }

/* rulers */
.ruler { display: none; position: absolute; background: #fff; border: 1px solid var(--line); z-index: 2; }
.place-frame.free .ruler { display: block; }
.ruler-top { top: 0; left: 26px; right: 0; height: 18px; }
.ruler-left { top: 24px; left: 0; bottom: 0; width: 18px; }
.ruler-corner { display: none; position: absolute; top: 0; left: 0; width: 18px; height: 18px; background: #fff; border: 1px solid var(--line); z-index: 3; }
.place-frame.free .ruler-corner { display: block; }
.ruler .tick { position: absolute; background: var(--ink-3); }
.ruler-top .tick { top: 0; width: 1px; }
.ruler-left .tick { left: 0; height: 1px; }
.ruler .tick-num { position: absolute; font-size: 8px; color: var(--ink-3); line-height: 1; }
.ruler-top .tick-num { bottom: 1px; }
.ruler-left .tick-num { left: 1px; writing-mode: vertical-rl; }

/* the blocks themselves */
.place-frame.free .sheet .blk { outline: 1px dashed rgba(37, 99, 235, .35); cursor: move; }
.place-frame.free .sheet .blk:hover { outline-color: var(--blue-600); background: rgba(37, 99, 235, .04); }
.place-frame.free .sheet .blk.on { outline: 2px solid var(--blue-600); background: rgba(37, 99, 235, .06); }
.blk-resize, .blk-tag { display: none; }
.place-frame.free .blk-resize {
  display: block; position: absolute; right: -4px; top: 0; bottom: 0; width: 8px;
  cursor: ew-resize; background: linear-gradient(90deg, transparent, rgba(37, 99, 235, .25));
}
.place-frame.free .blk.on .blk-tag {
  display: block; position: absolute; left: 0; top: -15px;
  font-size: 9.5px; font-weight: 700; color: #fff; background: var(--blue-600);
  padding: 1px 6px; border-radius: 3px; white-space: nowrap; pointer-events: none;
}
.place-frame.free .measuring, .place-frame.free.measuring .sheet { cursor: crosshair; }
#previewHost.measuring .blk { pointer-events: none; }

/* guides + tape measure */
.place-guide { display: none; position: absolute; z-index: 5; pointer-events: none; background: #ec4899; }
.place-guide.vert { top: 0; bottom: 0; width: 1px; }
.place-guide.horz { left: 0; right: 0; height: 1px; }
.place-tape {
  display: none; position: absolute; height: 2px; background: #ec4899;
  transform-origin: left center; z-index: 6; pointer-events: none;
}
.place-tape-label {
  display: none; position: absolute; z-index: 7; pointer-events: none;
  background: #ec4899; color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px; transform: translate(-50%, -140%); white-space: nowrap;
}

.text-box-row { border-bottom: 1px solid var(--line-2); padding-bottom: 8px; margin-bottom: 10px; }
.text-box-row:last-of-type { border-bottom: none; }

/* ------------------------ dashboard search ------------------------ */

.dash-search { position: relative; margin-bottom: 18px; }
.dash-search input {
  width: 100%; padding: 13px 16px; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; box-shadow: var(--shadow); font-family: inherit;
}
.dash-search input:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(39,57,90,.10); }

.dash-results {
  position: absolute; z-index: 25; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 62vh; overflow: auto; padding: 6px;
}
.dash-results[hidden] { display: none; }
.dash-group + .dash-group { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 6px; }
.dash-group-head {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); padding: 6px 10px 4px;
}
.dash-hit a {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  padding: 7px 10px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none;
}
.dash-hit a:hover { background: var(--blue-50); text-decoration: none; }
.dash-hit .muted { font-size: 12.5px; color: var(--ink-3); }

/* --------------------- old books / new books ---------------------- */

.era-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.era-tab {
  flex: 1 1 170px; text-align: left; cursor: pointer; font-family: inherit;
  padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 650;
  box-shadow: var(--shadow); transition: border-color .12s, background .12s;
}
.era-tab span { display: block; font-size: 11.5px; font-weight: 400; color: var(--ink-3); margin-top: 2px; }
.era-tab:hover { border-color: var(--navy-600); }
.era-tab.on { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.era-tab.on span { color: #a9b6c9; }

/* ------------------- colour per part of the app ------------------- */

/*
 * The same colours the documents print in, so a screen and the paper it makes
 * agree. A stripe under the title and a tint on the title itself are enough to
 * tell them apart without shouting.
 */
body { --section: var(--navy-800); }
body[data-section="invoice"]        { --section: #131f35; }
body[data-section="receipt"]        { --section: #15803d; }
body[data-section="sensor"]         { --section: #7c3aed; }
body[data-section="job"]            { --section: #c2410c; }
body[data-section="accounts"]       { --section: #a16207; }
body[data-section="customer"]       { --section: #0e7490; }
body[data-section="meter"]          { --section: #4338ca; }
body[data-section="code"]           { --section: #0f766e; }
body[data-section="dealer"]         { --section: #be185d; }
body[data-section="margin"]         { --section: #b45309; }
body[data-section="due"]            { --section: #9f1239; }

/* Each device job gets its own, so a Fare Change is never mistaken for a
   Receipt across the room - the greens were too close to share. */
body[data-section="vehicle-change"] { --section: #2563eb; }
body[data-section="fare-change"]    { --section: #4d7c0f; }
body[data-section="sensor-change"]  { --section: #9333ea; }
body[data-section="device-change"]  { --section: #c2410c; }
body[data-section="device-return"]  { --section: #9f1239; }

.topbar { border-bottom: 3px solid var(--section); transition: border-color .18s; }
.topbar h1 { color: var(--section); transition: color .18s; }
.topbar h1::before {
  content: ''; display: inline-block; width: 4px; height: 17px;
  background: var(--section); border-radius: 2px;
  margin-right: 9px; vertical-align: -2px;
}
body[data-section="default"] .topbar h1::before { display: none; }

/* The table head picks it up too, so a printed list matches its screen. */
body[data-section="receipt"] table.data thead th,
body[data-section="sensor"] table.data thead th,
body[data-section="accounts"] table.data thead th,
body[data-section="customer"] table.data thead th,
body[data-section="meter"] table.data thead th,
body[data-section="vehicle-change"] table.data thead th,
body[data-section="fare-change"] table.data thead th,
body[data-section="sensor-change"] table.data thead th,
body[data-section="device-change"] table.data thead th,
body[data-section="device-return"] table.data thead th,
body[data-section="job"] table.data thead th,
body[data-section="code"] table.data thead th,
body[data-section="dealer"] table.data thead th {
  border-bottom: 2px solid var(--section);
}

/* ------------------------- trial mode ----------------------------- */

.trial-card.on { border-color: #f0b429; box-shadow: 0 0 0 2px rgba(240, 180, 41, .22), var(--shadow); }
.trial-card.on .card-head { background: var(--amber-100); }
.trial-counts { display: flex; flex-wrap: wrap; gap: 7px; }
.trial-counts span {
  background: var(--line-2); border: 1px solid var(--line); border-radius: 20px;
  padding: 4px 12px; font-size: 12.5px;
}
.trial-counts b { color: var(--ink); }

/* A running trial is worth noticing from anywhere. */
body.trial-on .topbar::after {
  content: '🧪 Trial running';
  margin-left: auto; align-self: center;
  background: var(--amber-100); color: #a26100; border: 1px solid #fde68a;
  padding: 3px 11px; border-radius: 20px; font-size: 12px; font-weight: 700;
}
