:root {
  --navy: #00569f;
  --sky: #31a2f0;
  --slate: #34495e;
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e0e5e9;
  --text: #232d37;
  --mute: #75828c;
  --warn-bg: #fff4e3;
  --warn-tx: #a86c0c;
  --good-bg: #e2f4ea;
  --good-tx: #188054;
  --soft-blue: #e7f2fb;
  --soft-navy: #deebf7;
  --wa-green: #25d366;
  --wa-bubble: #dcf8c6;
  /* Single source of truth for the app column's width — bottom-nav, bulk-bar
     and the header all key off this instead of hardcoding 480px separately. */
  --app-max-width: 480px;
  /* Shared elevation + radius tokens so tiles/cards/buttons/drawer read as
     one consistent, modern system instead of each picking its own shadow. */
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-md: 0 6px 16px rgba(16,24,40,.09);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
  --radius-lg: 18px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text);
}
#app { max-width: var(--app-max-width); margin: 0 auto; min-height: 100vh; background: var(--bg); box-shadow: 0 0 24px rgba(0,0,0,0.06); position: relative; }

/* On tablet/desktop viewports, use the extra width instead of leaving large
   empty gutters on either side of a narrow fixed column. */
@media (min-width: 700px) {
  :root { --app-max-width: 720px; }
}

.app-header {
  background: linear-gradient(135deg, var(--navy), #0074c2); color: #fff; padding: 16px 20px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px;
  position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow-md);
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.crest { width: 42px; height: 42px; object-fit: contain; flex-shrink: 0; }
.brand-title { font-weight: 700; font-size: 17px; overflow-wrap: break-word; }
.brand-sub { font-size: 12px; color: #d2e4f5; overflow-wrap: break-word; }
.env-badge {
  display: inline-block; font-weight: 800; font-size: 10.5px; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 20px; cursor: pointer; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.5);
}
.env-badge.testing { background: #e0a300; color: #2a1c00; }
.env-badge.live { background: #1f9d55; color: #fff; }
.header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 0 1 auto; justify-content: flex-end; }
.back-btn { background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 12px; cursor: pointer;
  padding: 7px 12px; border-radius: 10px; white-space: nowrap; transition: background .15s ease, transform .15s ease; }
.back-btn:hover { background: rgba(255,255,255,.28); }
.back-btn:active { transform: scale(.94); }

/* Below ~480px wide (small phones, or a squeezed webview), the brand block
   and the row of header buttons don't both fit on one line — stack the
   buttons onto their own row instead of letting them overlap/crush the title. */
@media (max-width: 480px) {
  .header-right { flex-basis: 100%; justify-content: flex-start; }
}

main#view { padding: 16px 16px 96px; min-height: calc(100vh - 74px); max-width: 100%; overflow-x: auto; }

.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--app-max-width); background: #fff; border-top: 1px solid var(--line);
  display: flex; z-index: 50; box-shadow: 0 -2px 10px rgba(0,0,0,.05);
}
.bottom-nav .nav-item {
  flex: 1; text-align: center; padding: 9px 2px 8px; cursor: pointer; color: var(--mute);
  font-size: 10.5px; font-weight: 600; border-top: 2px solid transparent;
}
.bottom-nav .nav-item .nav-icon { font-size: 19px; display: block; margin-bottom: 2px; }
.bottom-nav .nav-item.active { color: var(--navy); border-top-color: var(--navy); }

.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { flex: 1; min-width: 110px; padding: 9px 10px; border-radius: 10px;
  border: 1px solid var(--line); font-size: 13px; background: #fff; }

.bulk-bar {
  position: fixed; bottom: 58px; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--app-max-width);
  background: var(--text); color: #fff; padding: 10px 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; z-index: 45; box-shadow: 0 -2px 10px rgba(0,0,0,.15);
}
.bulk-bar .count { font-size: 13px; font-weight: 700; }
.bulk-bar .actions { display: flex; gap: 8px; }
.bulk-bar button { border: none; border-radius: 8px; padding: 8px 12px; font-size: 12px; font-weight: 700; cursor: pointer; }
.bulk-bar .clear-btn { background: transparent; color: #cfd6dc; }
.row-checkbox { margin-right: 10px; transform: scale(1.2); }

h1.page-title { font-size: 20px; margin: 0 0 4px; color: var(--text); }
p.page-sub { color: var(--mute); font-size: 13px; margin: 0 0 16px; }

.summary-strip {
  display: flex; background: var(--soft-navy); border-radius: 14px; padding: 14px 6px; margin-bottom: 16px;
}
.summary-strip .stat { flex: 1; text-align: center; }
.summary-strip .stat .label { font-size: 11px; font-weight: 700; color: var(--navy); text-transform: uppercase; }
.summary-strip .stat .value { font-size: 16px; font-weight: 700; color: var(--text); margin-top: 2px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .meta { color: var(--mute); font-size: 13px; }

.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
.tile:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); border-color: #b8dcf5; }
.tile:active { transform: translateY(-1px); }
.tile .icon-badge {
  width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(135deg, var(--soft-blue), #cfe8fb);
  display: flex; align-items: center; justify-content: center; font-size: 21px; margin-bottom: 10px;
}
.tile .tile-label { font-weight: 700; font-size: 13.5px; letter-spacing: -.01em; }
.tile.tile-locked { position: relative; opacity: .55; cursor: not-allowed; }
.tile.tile-locked:hover { transform: none; box-shadow: var(--shadow-sm); }
.tile.tile-locked .icon-badge { filter: grayscale(1); }
.tile-lock-badge {
  position: absolute; top: 10px; right: 10px; font-size: 13px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); display: flex;
  align-items: center; justify-content: center;
}
.menu-drawer .drawer-item.drawer-item-locked { opacity: .55; }

.stat-cards { display: flex; gap: 12px; margin-bottom: 18px; }
.stat-card { flex: 1; border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-sm); }
.stat-card.blue { background: var(--soft-blue); color: var(--navy); }
.stat-card.warn { background: var(--warn-bg); color: var(--warn-tx); }
.stat-card .label { font-size: 12px; font-weight: 700; }
.stat-card .value { font-size: 20px; font-weight: 700; margin-top: 4px; }

.btn {
  display: block; width: 100%; padding: 14px; border-radius: var(--radius-md); border: none;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; text-align: center;
  text-decoration: none; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); box-shadow: var(--shadow-md); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline { background: #fff; border: 2px solid var(--navy); color: var(--navy); box-shadow: none; }
.btn-outline.mute { border-color: var(--mute); color: var(--mute); }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; display: inline-block; }
.btn-wa { background: var(--wa-green); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.pill { display: inline-block; padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.pill.good { background: var(--good-bg); color: var(--good-tx); }
.pill.warn { background: var(--warn-bg); color: var(--warn-tx); }
.pill.blue { background: var(--soft-blue); color: var(--navy); }
.pill.grey { background: #edf0f2; color: var(--mute); }

/* In-transit route animation for Lorry Trips — a dashed road scrolls
   beneath a gently-bobbing truck while a trip is ongoing (implies motion
   without the truck itself lurching back and forth); once marked
   delivered, the truck parks at the destination end, the road turns solid
   green, and everything stops moving. */
.transit-track {
  position: relative; height: 36px; border-radius: 18px;
  background: var(--soft-blue); border: 1px solid var(--line); margin: 10px 0;
  display: flex; align-items: center; padding: 0 12px; overflow: hidden;
}
.transit-track.delivered { background: #e8f5e9; }
.transit-road {
  position: absolute; left: 16px; right: 16px; top: 50%; height: 3px; transform: translateY(-50%);
  border-radius: 2px;
  background-image: repeating-linear-gradient(90deg, var(--sky) 0 10px, transparent 10px 22px);
  background-size: 32px 3px;
  animation: transit-road-scroll 0.9s linear infinite;
}
.transit-track.delivered .transit-road {
  background-image: none; background-color: var(--good-tx, #2e7d32); animation: none;
}
@keyframes transit-road-scroll {
  from { background-position: 0 0; }
  to { background-position: -32px 0; }
}
.transit-truck {
  position: relative; z-index: 1; font-size: 18px; line-height: 1;
  animation: transit-bob 1s ease-in-out infinite;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.15));
}
.transit-track.delivered .transit-truck { animation: none; margin-left: auto; }
@keyframes transit-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
.transit-track.delivered .transit-truck::after { content: " ✅"; }
.transit-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--mute); font-weight: 700; margin-top: 2px; }
.transit-labels span:first-child::before { content: "📍 "; }
.transit-labels span:last-child::before { content: "🏁 "; }

.segmented { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented .seg { flex: 1; padding: 10px 4px; text-align: center; font-size: 12px; font-weight: 700; color: var(--mute); cursor: pointer; }
.segmented .seg.active { background: var(--navy); color: #fff; border-radius: 8px; margin: 2px; }

label.field-label { display: block; font-weight: 700; font-size: 14px; margin: 14px 0 6px; }
input[type=text], input[type=number], input[type=date], input[type=password],
input[type=file], input[type=tel], input[type=email], input[type=search], textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  font-size: 14px; background: #fff; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--navy); }
.home-search-wrap input[type=search] { border-radius: 999px; padding-left: 18px; }
#home-search-results .drawer-item:hover { background: var(--soft-blue); }
#home-search-results .drawer-item:last-child { border-bottom: none !important; }

.emi-day-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 6px; }
.emi-day-btn {
  padding: 9px 0; border-radius: 9px; border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink, #1a1a1a);
  transition: background .12s, color .12s, border-color .12s;
}
.emi-day-btn:hover { background: var(--soft-blue); }
.emi-day-btn.selected { background: var(--navy); color: #fff; border-color: var(--navy); }

.settings-fab {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px;
  border-radius: 999px; border: none; cursor: pointer; font-size: 12.5px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--navy), #3b5f8f);
  box-shadow: var(--shadow-sm, 0 2px 6px rgba(0,0,0,.12));
  transition: transform .15s ease, box-shadow .15s ease;
}
.settings-fab:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.settings-fab:active { transform: translateY(0); }
.settings-fab-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.18);
  font-size: 13px; transition: transform .35s ease;
}
.settings-fab:hover .settings-fab-icon { transform: rotate(90deg); }
.upload-box {
  border: 2px dashed var(--line); border-radius: 14px; padding: 24px; text-align: center; cursor: pointer;
}
.upload-box .icon { font-size: 28px; }
.upload-box .title { color: var(--navy); font-weight: 700; margin-top: 6px; }
.upload-box .sub { color: var(--mute); font-size: 12px; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th { text-align: left; background: var(--navy); color: #fff; padding: 8px; font-size: 12px; }
table.data-table td { padding: 8px; border-bottom: 1px solid var(--line); }
table.data-table tr:nth-child(even) { background: #fafbfc; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,20,35,.55); display: flex; align-items: center;
  justify-content: center; z-index: 100; padding: 20px;
}
.modal-card { background: #fff; border-radius: 18px; padding: 26px; max-width: 400px; width: 100%; text-align: center; }
.modal-card .warn-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--warn-bg); color: var(--warn-tx);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; margin: 0 auto 14px; }
.modal-card h3 { margin: 0 0 10px; }
.modal-card p { color: var(--mute); font-size: 14px; margin-bottom: 18px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 12px 20px; border-radius: 10px; font-size: 13px; z-index: 200; max-width: 90%;
}

.wa-bubble { background: var(--wa-bubble); border-radius: 16px; padding: 18px; white-space: pre-wrap;
  font-size: 14px; line-height: 1.6; color: #1e3223; }

.section-title { font-weight: 800; font-size: 14.5px; letter-spacing: .01em; margin: 20px 0 10px; color: var(--text); }
.helper-text { color: var(--mute); font-size: 12px; margin-top: 4px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--mute); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 13px; margin-right: 10px; }
.avatar.selected { background: var(--navy); }
.staff-row { display: flex; align-items: center; padding: 12px; border: 2px solid var(--line); border-radius: 12px;
  margin-bottom: 10px; cursor: pointer; }
.staff-row.selected { border-color: var(--navy); background: var(--soft-navy); }

.split-bar { height: 14px; border-radius: 8px; background: var(--line); overflow: hidden; display: flex; margin: 8px 0; }
.split-bar .free { background: var(--sky); }
.split-bar .reserved { background: #ffbb5a; }

.charge-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #fff; }
.final-total-box { background: linear-gradient(135deg, var(--navy), #0074c2); color: #fff; border-radius: var(--radius-lg);
  padding: 16px 18px; margin: 14px 0; box-shadow: var(--shadow-md); }
.final-total-box .label { font-size: 13px; color: #d2e4f5; }
.final-total-box .value { font-size: 24px; font-weight: 800; margin-top: 4px; }

.empty-state { text-align: center; color: var(--mute); padding: 40px 20px; font-size: 14px; }
a { color: var(--navy); }

/* ---- Auth / login ---- */
#view input[type=text], #view input[type=password] { margin-bottom: 4px; }
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; margin: -16px -16px -96px;
  background: linear-gradient(180deg, var(--navy) 0%, #0074c2 42%, var(--bg) 100%);
}
.login-card {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 36px 26px 28px; max-width: 320px; width: 100%; text-align: center;
}
.login-crest { width: 66px; height: 66px; margin-bottom: 14px; }
.login-title { font-size: 20px; font-weight: 800; margin: 0 0 4px; color: var(--text); }
.login-sub { color: var(--mute); font-size: 13.5px; margin: 0 0 24px; }
.login-card label.field-label { text-align: left; }
.login-support-link { display: block; margin-top: 20px; font-size: 12.5px; color: var(--navy);
  font-weight: 600; text-decoration: none; }
.login-support-link:hover { text-decoration: underline; }

/* ---- Notifications ---- */
.notif-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%;
  background: #e2483a; border: 1.5px solid var(--navy); }
#notif-bell-btn { position: relative; }
.notif-panel {
  /* Anchored to #app (its positioned ancestor), not the browser viewport —
     so it stays under the bell icon instead of floating off to the far
     right of the window on wide/desktop screens where #app is a centered,
     narrower column. */
  position: absolute; top: 60px; right: 10px; width: 320px; max-width: 90vw; max-height: 70vh; overflow-y: auto;
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 300; padding: 10px;
}
.notif-panel .notif-item { padding: 10px 12px; border-radius: 10px; margin-bottom: 6px; font-size: 12.5px;
  background: var(--bg); border-left: 3px solid var(--line); }
.notif-panel .notif-item.unread { border-left-color: var(--navy); background: var(--soft-navy); }
.notif-panel .notif-time { color: var(--mute); font-size: 10.5px; margin-top: 3px; }
.notif-panel .notif-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 8px; }

/* ---- Hamburger drawer menu (top-left, every accessible section) ---- */
.menu-btn { font-size: 17px; padding: 6px 10px; margin-right: 2px; }
.menu-drawer-overlay { position: fixed; inset: 0; background: rgba(10,20,35,.45); z-index: 400;
  backdrop-filter: blur(1.5px); }
.menu-drawer {
  position: fixed; top: 0; left: -300px; bottom: 0; width: 280px; max-width: 82vw;
  background: #fff; z-index: 401; box-shadow: var(--shadow-lg);
  overflow-y: auto; padding: 14px 0 24px; transition: left .22s cubic-bezier(.2,.9,.3,1);
}
.menu-drawer.open { left: 0; }
.menu-drawer .drawer-head { display: flex; justify-content: space-between; align-items: center;
  padding: 4px 16px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.menu-drawer .drawer-head b { font-size: 16px; }
.menu-drawer .drawer-close { background: var(--bg); border: none; font-size: 16px; cursor: pointer; color: var(--mute);
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  transition: background .15s ease; }
.menu-drawer .drawer-close:hover { background: var(--line); }
.menu-drawer .drawer-section-title { font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; color: var(--mute); padding: 14px 16px 6px; }
.menu-drawer .drawer-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  margin: 2px 8px; border-radius: 12px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  transition: background .12s ease; }
.menu-drawer .drawer-item:hover, .menu-drawer .drawer-item.active { background: var(--soft-blue); }
.menu-drawer .drawer-item .drawer-icon { font-size: 15px; width: 30px; height: 30px; border-radius: 9px;
  background: var(--bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ---- GST/tax deadline banner ---- */
.gst-banner { background: linear-gradient(135deg, #a13d3d, #7a2b2b); color: #fff; border-radius: 14px;
  padding: 14px 16px; margin-bottom: 16px; position: relative; }
.gst-banner .gst-title { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.gst-banner .gst-item { font-size: 12.5px; opacity: .95; margin-top: 2px; }
.gst-banner .gst-close { position: absolute; top: 8px; right: 10px; background: rgba(255,255,255,.2); border: none;
  color: #fff; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1; }
.gst-banner .gst-actions { margin-top: 10px; display: flex; gap: 8px; }
.gst-banner .gst-actions button { font-size: 11.5px; padding: 6px 10px; border-radius: 8px; border: none; cursor: pointer; }

/* ---- Photo upload preview ---- */
.photo-upload-box { border: 2px dashed var(--line); border-radius: 14px; padding: 16px; text-align: center; cursor: pointer; }
.photo-upload-box img { max-width: 100%; max-height: 160px; border-radius: 10px; margin-top: 8px; }

/* ---- Vault ---- */
.vault-secret { font-family: monospace; letter-spacing: 1px; }

/* ---- Role badge ---- */
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 700;
  background: var(--soft-navy); color: var(--navy); margin-left: 6px; vertical-align: middle; }
