:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #64707d;
  --line: #e2e7ec;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e6f4f2;
  --side: #10232f;
  --side-ink: #c9d6df;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #b54708;
  --warn-soft: #fff4e5;
  --ok: #067647;
  --ok-soft: #e7f6ee;
  --c-booked: #3b82f6;
  --c-active: #16a34a; /* sedang disewa: hijau */
  --c-returned: #94a3b8;
  --c-outsource: #8b5cf6;
  --c-open: #db2777;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f3f5f7;
  --hover: #f7fafa;
  --input-line: #cfd6dd;
  --input-line-hover: #c5ced6;
  --label: #36414c;
  --os-row: #f6f2ff;
  --today-col: #d5efe9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}

/* Dark theme: switched with the button in the side menu, remembered in the browser. */
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0e161d;
  --panel: #16212b;
  --surface: #16212b;
  --surface-2: #1b2732;
  --surface-3: #1a252f;
  --hover: #1f2e3b;
  --ink: #e4ecf2;
  --muted: #94a3b1;
  --line: #273541;
  --input-line: #35444f;
  --input-line-hover: #4a5b68;
  --label: #c8d4de;
  --brand: #14968a;
  --brand-soft: #123a36;
  --side: #0a1218;
  --danger: #f97066;
  --danger-soft: #3b1c1a;
  --warn: #f5a524;
  --warn-soft: #3a2a12;
  --ok: #4ccf8e;
  --ok-soft: #133627;
  --os-row: #221a36;
  --today-col: #12403b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
:root[data-theme='dark'] .b-booked { background: #1d3557; color: #93c5fd; }
:root[data-theme='dark'] .b-active { background: #0f2e1d; color: #4ade80; }
:root[data-theme='dark'] .dep-held-amt { color: var(--ok); }
:root[data-theme='dark'] .b-returned, :root[data-theme='dark'] .b-service { background: #26333f; color: #cbd5e1; }
:root[data-theme='dark'] .b-open { background: #3d1429; color: #f9a8d4; }
:root[data-theme='dark'] .b-outsource { background: #2a1f48; color: #c4b5fd; }
:root[data-theme='dark'] td.rcpt-yes { background: #143a28; }
:root[data-theme='dark'] td.rcpt-no { background: #3d1e1e; }
:root[data-theme='dark'] .car.out { background: #2d2312; border-color: #5a4520; }
:root[data-theme='dark'] .notice.info { color: #7fd6cb; }
:root[data-theme='dark'] table.cal td.day.svc { background: repeating-linear-gradient(45deg, #1d2833, #1d2833 4px, #25323e 4px, #25323e 8px); }
:root[data-theme='dark'] .modal-bg { background: rgba(0, 0, 0, 0.6); }
:root[data-theme='dark'] .btn-primary:hover { background: #12857a; border-color: #12857a; }
.theme-toggle { width: 100%; margin-top: 18px; justify-content: center; background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.12); color: var(--side-ink); }
.theme-toggle:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.2); color: #fff; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center, table.list th.center, table.list td.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 230px; background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px 18px; color: #fff; }
.brand small { display: block; color: var(--side-ink); font-size: 12px; }
.logo { background: var(--brand); color: #fff; font-weight: 800; border-radius: 8px; padding: 8px 6px; font-size: 13px; letter-spacing: 0.5px; }
.side nav a { display: block; color: var(--side-ink); text-decoration: none; padding: 9px 10px; border-radius: 8px; margin: 1px 0; }
.side nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side nav a.active { background: rgba(255, 255, 255, 0.13); color: #fff; font-weight: 600; }
.side nav a.nav-new { background: var(--brand); color: #fff; font-weight: 600; margin: 8px 0; text-align: center; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: #7d93a3; padding: 16px 10px 4px; }
.main { flex: 1; min-width: 0; }
.topbar { display: none; }
#app { padding: 24px 28px 60px; max-width: 1500px; }

/* Page header */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 16px 18px 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value.ok { color: var(--ok); }
.stat .value.warn { color: var(--warn); }
.stat a { text-decoration: none; color: inherit; }

/* Buttons & forms */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; }
button:hover, .btn:hover { border-color: var(--input-line-hover); background: var(--surface-2); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn-primary:hover { background: #0d665f; border-color: #0d665f; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #f3b8b2; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-link { border: none; background: none; color: var(--brand); padding: 0; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label.field > span { font-weight: 600; color: var(--label); }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid var(--input-line); border-radius: 8px; padding: 8px 10px; background: var(--surface); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 118, 110, 0.25); border-color: var(--brand); }
textarea { resize: vertical; min-height: 64px; }
/* Date and time boxes: type into the day / month / year / hour / minute; the icon at the right end opens the picker. */
input[type='date'], input[type='time'] { cursor: text; }
input[type='date']::-webkit-calendar-picker-indicator, input[type='time']::-webkit-calendar-picker-indicator {
  cursor: pointer; width: 22px; height: 22px; padding: 7px; margin: -6px -8px -6px 4px; border-radius: 8px; opacity: 0.75;
  background-size: 22px 22px; background-position: center; background-repeat: no-repeat;
}
input[type='date']::-webkit-calendar-picker-indicator:hover, input[type='time']::-webkit-calendar-picker-indicator:hover {
  opacity: 1; background-color: rgba(15, 118, 110, 0.14);
}
input[type='checkbox'], input[type='radio'] { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; }
.filters input[type='search'] { min-width: 240px; }
/* Small total tiles that sit in the filter row; they move as one group */
.filters .filter-totals { display: flex; gap: 8px; flex-wrap: nowrap; margin-left: auto; }
.filters .filter-total { padding: 6px 14px; display: flex; flex-direction: column; justify-content: center; }
.filters .filter-total .label { font-size: 11px; }
.filters .filter-total .value { font-size: 18px; margin-top: 0; line-height: 1.2; }

.seg { display: inline-flex; border: 1px solid var(--input-line); border-radius: 9px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 9px 18px; }
.seg button.on { background: var(--brand); color: #fff; font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
/* Headers follow their column: right-aligned over number columns */
table.list th.num { text-align: right; }
table.list th.sortable { cursor: pointer; user-select: none; }
/* Column resize grip on the right edge of each heading */
table.list th { position: relative; }
.col-grip { position: absolute; top: 0; right: -4px; width: 9px; height: 100%; cursor: col-resize; z-index: 2; }
.col-grip::after { content: ''; position: absolute; top: 25%; bottom: 25%; left: 4px; width: 1px; background: var(--line); }
table.list th:hover .col-grip::after, .col-grip:hover::after { background: var(--brand); width: 2px; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }
table.list th.sortable:hover { color: var(--ink); }
table.list th.sortable::after { content: '↕'; margin-left: 5px; opacity: 0.35; font-size: 11px; }
table.list th[aria-sort='ascending']::after { content: '▲'; opacity: 1; color: var(--brand); }
table.list th[aria-sort='descending']::after { content: '▼'; opacity: 1; color: var(--brand); }
table.list th[aria-sort='ascending'], table.list th[aria-sort='descending'] { color: var(--ink); }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: none; }
table.list tbody tr.click { cursor: pointer; }
table.list tbody tr.click:hover td { background: var(--hover); }
/* Tight tables (Expense): rows about 20% lower */
table.list.tight td { padding: 6px 7px; line-height: 1.3; }
table.list.tight th { padding: 8px 7px; }
/* Columns hug their content (30% less side padding); the .grow column takes the spare width. */
table.list.tight th, table.list.tight td { width: 1%; white-space: nowrap; }
table.list.tight .grow { width: auto; white-space: normal; }
table.list.tight th:first-child, table.list.tight td:first-child { padding-left: 14px; }
table.list.tight th:last-child, table.list.tight td:last-child { padding-right: 14px; }
table.list.tight .badge { font-size: 11px; padding: 1px 7px; }
.row-note { color: var(--muted); font-size: 12px; }
/* Expense list: fixed column shares so Kategori, Kereta, Amaun and Resit use the spare width too. */
table.list.expense-main { table-layout: fixed; }
table.list.expense-main th, table.list.expense-main td { overflow: hidden; text-overflow: ellipsis; }
table.list.expense-main th:nth-child(1) { width: 11%; }
table.list.expense-main th:nth-child(2) { width: 31%; }
table.list.expense-main th:nth-child(3) { width: 15%; }
table.list.expense-main th:nth-child(4) { width: 11%; }
table.list.expense-main th:nth-child(5) { width: 14%; }
table.list.expense-main th:nth-child(6) { width: 8%; }
table.list.expense-main th:nth-child(7) { width: 10%; }
/* Expense already in Akaun Niaga (tick) or failed to send (!) */
.akaun-tick { color: var(--ok); font-weight: 700; }
.akaun-err { color: var(--danger); font-weight: 700; }
.akaun-line { margin-top: 10px; font-size: 13px; color: var(--muted); }
.akaun-line .err { color: var(--danger); margin-top: 4px; }
/* Inline Cash/Bank picker in the expense table */
table.list.expense-main td.pay-cell { padding-top: 0; padding-bottom: 0; }
.pay-pick { width: 100%; padding: 2px 4px; font-size: inherit; min-height: 0; height: auto; }
.stats.compact { gap: 10px; margin-bottom: 14px; }
.stats.compact .stat { padding: 10px 14px; }
.stats.compact .stat .value { font-size: 19px; margin-top: 2px; }
/* Tempahan: SMA and outsource boxes use the same fixed column widths so they line up. */
table.list.bk-list { table-layout: fixed; }
table.list.bk-list th:nth-child(1) { width: 6.5%; }
table.list.bk-list th:nth-child(2) { width: 12.5%; }
table.list.bk-list th:nth-child(3) { width: 8%; }
table.list.bk-list th:nth-child(4) { width: 8%; }
table.list.bk-list th:nth-child(5) { width: 9%; }
table.list.bk-list th:nth-child(6) { width: 9%; }
table.list.bk-list th:nth-child(7) { width: 3.5%; }
table.list.bk-list th:nth-child(8) { width: 6.2%; }
table.list.bk-list th:nth-child(9) { width: 9.5%; }
table.list.bk-list th:nth-child(10) { width: 6.2%; }
table.list.bk-list th:nth-child(11) { width: 6.2%; }
table.list.bk-list th:nth-child(12) { width: 6.2%; }
table.list.bk-list th:nth-child(13) { width: 5.7%; }
table.list.bk-list th:nth-child(14) { width: 3.5%; }
table.list.bk-list th:nth-child(14), table.list.bk-list td:nth-child(14) { padding-left: 2px; padding-right: 2px; text-align: center; }
.dep-held { color: var(--warn); }
.dep-back { color: var(--ok); }
/* The Booking page uses the full screen width. */
#app:has(.bk-list) { max-width: none; }
/* Nothing may stick out of its cell, so the box never needs a sideways scrollbar. */
table.list.bk-list td { overflow: hidden; overflow-wrap: anywhere; }
/* Pick up / Drop off dates: today, tomorrow, the day after */
/* Booking list: the pick-up / drop-off time, a little larger so it stands out. */
.list-time { font-size: 1.12em; font-weight: 600; white-space: nowrap; }
/* Pick-up / drop-off: only the time is coloured (today orange, tomorrow red, the day after blue). */
.list-time.due-d0, .due-legend .due-d0 { color: var(--c-tag-green); font-weight: 700; }
.list-time.due-d1, .due-legend .due-d1 { color: var(--danger); font-weight: 700; }
.list-time.due-d2, .due-legend .due-d2 { color: var(--c-booked); font-weight: 700; }
/* Booking list for SMA cars: about 15 rows, then scroll inside the box with the heading and totals kept in view. */
.bk-scroll { overflow-y: auto; }
.bk-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); }
.bk-scroll tfoot td { position: sticky; bottom: 0; z-index: 1; }
.due-legend { margin: -6px 0 12px; gap: 14px; }
/* Booking that started before the filtered period: shown but not counted */
table.list.bk-list tr.carry td { opacity: 0.5; }
/* Compact rows */
table.list.bk-list td { padding: 5px 8px; line-height: 1.3; }
table.list.bk-list th { padding: 7px 8px; }
table.list.bk-list th:first-child, table.list.bk-list td:first-child { padding-left: 14px; }
table.list.bk-list .badge { font-size: 11px; padding: 1px 7px; }
table.list.bk-list .badge + .badge { margin-top: 2px; }
table.list.bk-list .badge { white-space: normal; }
table.list.bk-list td.nowrap { white-space: normal; }
table.list tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-booked { background: #e8f0fe; color: #1d4ed8; }
.b-active { background: #e7f6ee; color: #067647; } /* sedang disewa: hijau */
.dep-held-amt { color: var(--ok); font-weight: 600; } /* deposit dibayar, belum dipulangkan: hijau */
.b-returned { background: #eef1f4; color: #475569; }
.b-open { background: #fde7f1; color: #be185d; }
.ag-ok { background: #e6f6ec; color: #0a7d3b; }
table.list.bk-list .badge.ag-ok, table.list.bk-list .badge.ag-wait, table.list.bk-list .badge.ag-no { white-space: nowrap; }
.ag-wait { background: #fff4d6; color: #8a5a00; }
.ag-no { background: #f1f3f5; color: #6b7480; }
:root[data-theme='dark'] .ag-ok { background: #12351f; color: #86efac; }
:root[data-theme='dark'] .ag-wait { background: #3a2c0a; color: #fcd34d; }
:root[data-theme='dark'] .ag-no { background: #2a2f36; color: #9aa4af; }
.b-cancelled { background: var(--danger-soft); color: var(--danger); }
.b-sma { background: var(--brand-soft); color: var(--brand); }
.b-outsource { background: #f1ebff; color: #6d28d9; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-err { background: var(--danger-soft); color: var(--danger); }
.b-free { background: var(--ok-soft); color: var(--ok); }
/* Expense amounts: green = has a receipt (goes to the accounts), pink = no receipt */
td.rcpt-yes { background: #dcf3e4; }
td.rcpt-no { background: #fde4e4; }
.rcpt-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin: 0 4px 0 10px; }
.b-service { background: #eef1f4; color: #475569; }

/* Dashboard car cards */
.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.car { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.car.out { background: #fffaf0; border-color: #f5dfb8; }
.car.service { background: var(--surface-3); }
.car .plate { font-weight: 800; letter-spacing: 0.5px; }
.car .model { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.car .info { font-size: 13px; margin-top: 6px; }
.car a { text-decoration: none; }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.mini-list li:last-child { border-bottom: none; }

/* Calendar */
.cal-wrap { overflow-x: auto; }
table.cal { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1100px; table-layout: fixed; }
table.cal th, table.cal td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); height: 38px; padding: 0; font-size: 12px; text-align: center; }
table.cal thead th { background: var(--surface-2); color: var(--muted); font-weight: 600; height: 44px; line-height: 1.15; position: sticky; top: 0; z-index: 4; }
table.cal thead th.we { background: var(--danger-soft); color: var(--danger); }
table.cal thead th.today { background: var(--brand); color: #fff; }
table.cal .carcol { width: 170px; text-align: left; padding: 4px 10px; position: sticky; left: 0; background: var(--surface); z-index: 5; }
table.cal thead .carcol { z-index: 6; background: var(--surface-2); }
table.cal .carcol b { display: block; font-size: 13px; }
table.cal .carcol small { color: var(--muted); }
table.cal .sumcol { width: 72px; font-weight: 600; }
table.cal td.day { cursor: pointer; position: relative; }
table.cal td.day:hover { background: var(--brand-soft); }
/* Today: a green band from the date heading down to the last row. */
table.cal td.day.today, table.cal td.day.today.we { background: var(--today-col); box-shadow: inset 2px 0 var(--brand), inset -2px 0 var(--brand); }
table.cal td.day.we { background: var(--surface-3); }
table.cal td.day.svc { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 4px, #e5e7eb 4px, #e5e7eb 8px); cursor: default; }
.seg-bar { position: absolute; top: 5px; bottom: 5px; left: 0; right: 0; color: #fff; font-size: 11px; font-weight: 600; overflow: visible; text-decoration: none; white-space: nowrap; text-overflow: ellipsis; padding: 0 3px; line-height: 28px; text-align: left; }
.seg-bar.booked { background: var(--c-booked); }
.seg-bar.active { background: var(--c-active); }
.seg-bar.returned { background: var(--c-returned); }
.seg-bar.outsource { background: var(--c-outsource); }
.seg-bar.open { background: var(--c-open); }
.seg-bar.tag-green { background: var(--c-tag-green); }
/* Car going back today: the days before today shown grey (done). */
.seg-bar.as-returned { background: var(--c-returned); }
.seg-bar.open-ext { background: repeating-linear-gradient(45deg, var(--c-open), var(--c-open) 5px, #f472b6 5px, #f472b6 10px); }
.seg-bar.start { left: 3px; border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.seg-bar.end { right: 3px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.seg-bar.half-start { left: 50%; }
.seg-bar.half-end { right: 50%; }
.seg-bar.stack { top: 50%; bottom: 3px; line-height: 15px; }
.seg-bar.stack-top { top: 3px; bottom: 50%; line-height: 15px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
.free-cell { color: var(--ok); }
.legend.cal-legend { margin: 0; padding: 10px 18px 14px; }
.month-nav { display: flex; gap: 6px; align-items: center; }
.month-nav b { min-width: 150px; text-align: center; font-size: 16px; }

/* Booking form */
.days-badge { background: var(--brand); color: #fff; border-radius: 10px; padding: 8px 14px; text-align: center; min-width: 90px; }
.days-badge b { display: block; font-size: 24px; line-height: 1.1; }
.days-badge small { font-size: 11px; opacity: 0.9; }
.addon-row { display: grid; grid-template-columns: 1fr 140px 36px; gap: 8px; margin-bottom: 8px; }
.summary { position: sticky; top: 16px; }
.summary .row { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.summary .row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 16px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--brand-soft); color: #0b5e57; }
.akaun-box { border: 1px dashed var(--input-line); border-radius: 10px; padding: 12px 14px; }
.radio-list label { display: flex; gap: 8px; padding: 6px 0; align-items: flex-start; cursor: pointer; }

/* Picker */
.picker { position: relative; }
.picker-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--input-line); border-radius: 8px; box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12); z-index: 20; max-height: 260px; overflow-y: auto; margin-top: 4px; }
.picker-list div { padding: 8px 10px; cursor: pointer; }
.picker-list div:hover, .picker-list div.hl { background: var(--brand-soft); }
/* Add-on list shows every preset: no fixed height, no scrolling. */
.picker-list.addon-list { max-height: none; overflow: visible; z-index: 30; right: auto; width: max-content; min-width: 100%; max-width: 320px; }
.picker-list.addon-list div { white-space: nowrap; }
.picker-list .new { color: var(--brand); font-weight: 600; border-top: 1px solid var(--line); }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(16, 24, 40, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 620px; padding: 22px; box-shadow: 0 20px 50px rgba(16, 24, 40, 0.25); }
.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--side); color: #fff; padding: 11px 18px; border-radius: 9px; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); }

/* Laporan + monthly payments side panel */
.report-layout { display: grid; gap: 18px; align-items: start; }
/* The report page uses the full screen width so the side panel sits at the far right and the tables are not cut off. */
#app:has(.report-layout) { max-width: none; }
.report-main { min-width: 0; }
@media (min-width: 1200px) {
  .report-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  /* Expense: content kept to about 1260px with the payments panel right beside it. */
  .expense-layout { grid-template-columns: minmax(0, 1260px) 320px; justify-content: start; }
  /* Line the panel up with the summary tiles (top offset set from app.js). */
  .expense-layout .report-aside { margin-top: var(--aside-offset, 0px); }
  .report-aside { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
}
.dues .dues-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dues .dues-head h2 { margin: 0; }
.dues-nav { justify-content: space-between; margin: 12px 0 10px; }
.dues-nav b { min-width: 0; font-size: 14px; }
.dues-sum { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; font-size: 13px; }
.dues-list { list-style: none; margin: 0; padding: 0; }
.due { display: flex; gap: 8px; padding: 5px 6px; border-bottom: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.due:last-child { border-bottom: none; }
.due.late { background: var(--danger-soft); }
.due.soon { background: var(--warn-soft); }
.due.paid { padding: 3px 6px; }
.due.paid .due-name, .due.paid .due-amt { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.due.paid .due-amt { background: none; }
.due-check { padding-top: 1px; cursor: pointer; }
.due-check input { width: 16px; height: 16px; cursor: pointer; }
.due-body { flex: 1; min-width: 0; cursor: pointer; }
.due-top { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: baseline; gap: 6px; }
.due-day { font-size: 12px; font-weight: 700; color: var(--brand); }
.due-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.due-amt { font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 5px; border-radius: 5px; font-size: 12px; }
.due-meta { display: flex; gap: 5px; align-items: center; margin: 2px 0 0 36px; min-width: 0; }
.due-meta .badge { font-size: 11px; padding: 0 6px; flex-shrink: 0; }
.due-note { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dues h2 { font-size: 15px; }
.dues-nav { margin: 8px 0 6px; }

/* Print */
.print-only { display: none; }
@media print {
  .side, .topbar, .no-print, .page-head .actions, .filters { display: none !important; }
  .print-only { display: block; }
  #app { padding: 0; max-width: none; }
  body { background: #fff; }
  .panel, .stat { box-shadow: none; break-inside: avoid; }
  table.list th, table.list td { padding: 5px 7px; font-size: 11px; }
}

/* Mobile */
@media (max-width: 900px) {
  .addon-row { grid-template-columns: minmax(0, 1fr) 90px 36px; }
  /* Fixed-width tables would squash on a phone: let them keep their size and scroll sideways. */
  table.list.expense-main, table.list.bk-list { table-layout: auto; min-width: 900px; }
  table.list.expense-main td, table.list.bk-list td { white-space: nowrap; }
  .side { position: fixed; left: -240px; z-index: 40; transition: left 0.2s; }
  .side.open { left: 0; box-shadow: 0 0 40px rgba(0, 0, 0, 0.3); }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--side); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 30; }
  .menu-btn { background: none; border: none; color: #fff; font-size: 20px; padding: 2px 6px; }
  #app { padding: 16px 16px 60px; }
  .form-layout { grid-template-columns: 1fr; }
  .summary { position: static; }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .filters input[type='search'] { min-width: 0; flex: 1 1 100%; }
}

/* View-only mode (staff over NetBird): hide every control that changes data */
.view-only-note { display: none; }
body.view-only .view-only-note { display: block; margin: 12px 12px 0; padding: 6px 10px; border-radius: 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--warn); border: 1px solid currentColor; }
body.view-only :is(.nav-new, [data-nav=tetapan], #syncAll, #addCar, #addCust, #addSup, #addExp, #dueAdd, #mSave, #mDel, #mSync, #delBtn, #editCust, #addAddon, #agreeBtn, #daysAuto, [data-status], #bf button[type=submit], #bf .btn-danger, a[href="#/tempahan/baru"]) { display: none !important; }

/* Ringkasan tahunan */
table.list.year-summary td.neg { color: var(--danger); }
table.list.year-summary td.pos { color: var(--ok); }
table.list.year-summary td.strong, table.list.year-summary tfoot td { font-weight: 700; }

/* Charts (Ringkasan Tahunan): palette validated for colour-blind separation on both surfaces */
:root { --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a; --viz-grid: #e8ebee; --viz-base: #b8c0c8; --viz-band: rgba(15, 23, 42, 0.04); }
:root[data-theme='dark'] { --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-grid: #22303c; --viz-base: #3a4a58; --viz-band: rgba(255, 255, 255, 0.05); }
.panel.viz { padding: 14px 16px 8px; margin-bottom: 16px; }
.viz-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.viz-head h2 { margin: 0; font-size: 14px; }
.viz-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.viz-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.viz-key.s1 { background: var(--viz-1); } .viz-key.s2 { background: var(--viz-2); } .viz-key.s3 { background: var(--viz-3); }
.viz-box { position: relative; }
.viz-svg { width: 100%; height: auto; display: block; }
.viz-svg .viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-svg .viz-base { stroke: var(--viz-base); stroke-width: 1; }
.viz-svg .viz-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-svg .viz-s1 { fill: var(--viz-1); } .viz-svg .viz-s2 { fill: var(--viz-2); } .viz-svg .viz-s3 { fill: var(--viz-3); }
.viz-svg .viz-band { fill: transparent; } .viz-svg .viz-band.on { fill: var(--viz-band); }
.viz-svg .viz-hit { fill: transparent; cursor: default; }
.viz-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; line-height: 1.6; white-space: nowrap; color: var(--ink); }

/* Sidebar menu order editing */
.side.nav-editing #nav > * { position: relative; cursor: grab; outline: 1px dashed rgba(255, 255, 255, 0.18); outline-offset: -1px; border-radius: 8px; margin: 3px 0; padding-right: 64px; }
.side.nav-editing #nav > .dragging { opacity: 0.4; }
.side.nav-editing #nav > .nav-label { padding-top: 8px; padding-bottom: 8px; }
.nav-tools { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
.nav-tools button { padding: 0 6px; min-height: 22px; height: 22px; font-size: 10px; line-height: 1; background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.15); color: var(--side-ink); }
.nav-tools button:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }
.nav-edit-bar { margin-top: 14px; padding: 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.06); color: var(--side-ink); }
.nav-edit-bar > div { display: flex; gap: 6px; margin-top: 8px; }
.nav-edit-bar > div button { flex: 1; justify-content: center; }
.nav-edit-bar > div button:not(.btn-primary) { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.15); color: var(--side-ink); }
.nav-edit-bar[hidden], #navEdit[hidden] { display: none; }
#navEdit { margin-top: 18px; }
#navEdit + .view-only-note + .theme-toggle, #navEdit ~ #themeBtn { margin-top: 8px; }
body.view-only #navEdit { display: none !important; }

#nav > [hidden] { display: none !important; }

/* Staff (view only) do not see booking money */
body.view-only .money { display: none !important; }

/* Calendar bar colour menu (owner) */
:root { --c-tag-green: #f59e0b; } /* pick up hari ini / ditanda: oren (the name is historical) */
.seg-bar.tag-green.open-ext { background: repeating-linear-gradient(45deg, var(--c-tag-green), var(--c-tag-green) 5px, #fcd34d 5px, #fcd34d 10px); }
.seg-bar[data-bar] { cursor: pointer; }
.bar-menu { position: fixed; z-index: 60; min-width: 180px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.bar-menu-head { display: flex; flex-direction: column; padding: 6px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.bar-menu button, .bar-menu a { display: flex; align-items: center; gap: 8px; width: 100%; justify-content: flex-start; background: transparent; border: 0; padding: 8px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 13px; min-height: 0; }
.bar-menu button:hover, .bar-menu a:hover { background: var(--hover); }
.bar-menu a { border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; margin-top: 4px; color: var(--brand); }
.seg-swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex-shrink: 0; }
.seg-swatch.booked { background: var(--c-booked); } .seg-swatch.active { background: var(--c-active); } .seg-swatch.returned { background: var(--c-returned); }
.seg-swatch.outsource { background: var(--c-outsource); } .seg-swatch.open { background: var(--c-open); } .seg-swatch.tag-green { background: var(--c-tag-green); }

/* Security deposit box (booking form) */
.deposit-akaun { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.deposit-akaun h3 { margin: 0; font-size: 13px; }
.dep-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dep-row input, .dep-row select { width: auto; }
.dep-done { color: var(--ok); font-weight: 600; }
.dep-done a { font-weight: 400; margin-left: 6px; }

/* Road tax reminder */
.nav-badge { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.roadtax-alert ul { margin: 6px 0 0; padding-left: 18px; }
.roadtax-alert li { margin: 4px 0; }
.roadtax-alert .btn-sm { margin-left: 8px; padding: 2px 8px; font-size: 12px; }
.rt-soon { color: var(--warn); font-weight: 700; }
.rt-over { color: var(--danger); font-weight: 700; }

/* Booking list: click a name, phone, plate or date to copy it */
.copy-phone { cursor: copy; border-bottom: 1px dashed transparent; }
.copy-phone:hover { border-bottom-color: currentColor; }
.copy-all { padding: 0 4px; margin-left: 2px; font-size: 13px; line-height: 1.4; background: transparent; border: 1px solid transparent; border-radius: 6px; cursor: copy; opacity: 0.75; }
.copy-all:hover { opacity: 1; border-color: var(--line, #2a3441); }

/* Booking list: "Sudah hantar / Belum hantar" to Akaun Niaga */
.sent-pick { width: 100%; padding: 2px 2px; font-size: 12px; font-weight: 600; border-radius: 6px; border: 1px solid transparent; cursor: pointer; }
.sent-pick.sent-yes { background: #16a34a; color: #fff; }
.sent-pick.sent-no { background: #0b0f14; color: #fff; border-color: #3a4552; }
.sent-pick option { background: #1b2430; color: #fff; }

/* Booking form: "Bayaran penuh" under Jumlah dibayar */
div.field.money { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
div.field.money > label { font-weight: 600; color: var(--label); }
.pay-full { align-self: flex-start; }

/* Signed-in user and log-out button in the side menu (app on the internet only). */
.user-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; color: var(--side-ink); }
