/* Iykolex International — Accounts
   Colours of the money columns come straight from the original spreadsheet. */

@font-face { font-family: "Iykolex Sans"; font-weight: 400; font-display: swap; src: url("/fonts/iykolex-sans-regular.woff2") format("woff2"); }
@font-face { font-family: "Iykolex Sans"; font-weight: 700; font-display: swap; src: url("/fonts/iykolex-sans-bold.woff2") format("woff2"); }

:root {
  color-scheme: light;
  /* spreadsheet column colours */
  --clr: #0000FF;        /* CLR CHGR (Dr) */
  --driver: #7F6000;     /* DRIVER */
  --pay: #274E13;        /* PAYMENT (Cr.) */
  --bal: #FF0000;        /* TOTAL BAL. */
  --ink: #111;
  --muted: #6b6b6b;
  --grid: #d4d4d4;
  --grid-strong: #111;
  --bg: #fff;
  --soft: #f4f5f7;
  --primary: #0a2bd1;
  --primary-press: #0820a3;
  --danger: #d60000;
  --radius: 12px;
  --kb: 0px;                 /* keyboard height, set by app.js */
  --vvh: 100vh;              /* visible viewport height, set by app.js */
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-right: env(safe-area-inset-right, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --search-h: 48px;
  font-family: "Iykolex Sans", Calibri, Carlito, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { font-size: 16px; line-height: 1.35; min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--grid);
  padding: calc(var(--sa-top) + 8px) calc(var(--sa-right) + 12px) 10px calc(var(--sa-left) + 12px);
}
.topbar-row { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.brand { font-size: 12px; font-weight: 700; letter-spacing: .12em; color: var(--muted); white-space: nowrap; }
.spacer { flex: 1; }
.page-title {
  margin: 6px 0 0; text-align: center; font-size: 22px; font-weight: 700; letter-spacing: .01em;
  text-transform: uppercase; overflow-wrap: anywhere;
}
.page-title .pencil { font-size: 14px; color: var(--muted); margin-left: 6px; vertical-align: middle; }
.page-title.clickable { cursor: pointer; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 40px; height: 40px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--grid); background: #fff; font-size: 15px; font-weight: 700;
}
.icon-btn:active { background: var(--soft); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------------------------------------------------------------- content */
main { padding: 0 calc(var(--sa-right) + 12px) 0 calc(var(--sa-left) + 12px); }
.page-home main { padding-bottom: calc(var(--search-h) + 96px + var(--sa-bottom)); }
.page-account main { padding-bottom: calc(110px + var(--sa-bottom)); }
.page-form main, .page-users main { padding-bottom: calc(40px + var(--sa-bottom)); }

.muted { color: var(--muted); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bal { color: var(--bal); }

/* ---------------------------------------------------------------- home table */
.owners { width: 100%; border-collapse: collapse; margin-top: 12px; }
.owners th {
  text-align: left; font-size: 13px; letter-spacing: .06em; padding: 10px 8px;
  border-bottom: 2px solid var(--grid-strong);
}
.owners th.bal-h { color: var(--bal); text-align: right; }
.owners td { padding: 12px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.owners td.name { font-weight: 700; text-transform: uppercase; overflow-wrap: anywhere; }
.owners td.balance { text-align: right; color: var(--bal); font-weight: 700; }
.owners td.act { width: 1%; padding-right: 0; }
.owners tr { cursor: pointer; }
.owners tr:active td { background: var(--soft); }
.owners mark { background: #fff2a8; color: inherit; border-radius: 3px; padding: 0 1px; }
.view-btn {
  white-space: nowrap; border: 1.5px solid var(--primary); color: var(--primary); background: #fff;
  border-radius: 999px; padding: 6px 10px; font-size: 13px; font-weight: 700;
}
.view-btn:active { background: var(--primary); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .btn { margin-top: 14px; }
.count { color: var(--muted); font-size: 13px; text-align: center; margin: 14px 0 0; }

/* ---------------------------------------------------------------- search bar + FAB */
.searchbar {
  position: fixed; z-index: 30;
  left: calc(var(--sa-left) + 12px); right: calc(var(--sa-right) + 12px);
  bottom: calc(var(--kb) + max(var(--sa-bottom), 12px));
  display: flex; align-items: center; gap: 8px;
  height: var(--search-h); padding: 0 8px 0 14px; border-radius: 999px;
  background: #eef0f3; border: 1px solid transparent; color: var(--muted);
  opacity: .82; transition: bottom .12s ease-out, background .15s, box-shadow .15s, opacity .15s;
}
.searchbar.active {
  background: #fff; opacity: 1; border-color: var(--primary); color: var(--ink);
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
}
.kb-open .searchbar { bottom: calc(var(--kb) + 8px); }
.searchbar svg { width: 20px; height: 20px; flex: none; }
.searchbar input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  font-size: 16px; /* 16px stops iOS zooming in */
}
.searchbar .clear { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%; font-size: 20px; color: var(--muted); }

.fab {
  position: fixed; z-index: 31;
  right: calc(var(--sa-right) + 18px);
  bottom: calc(var(--kb) + max(var(--sa-bottom), 12px) + var(--search-h) + 18px);
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--primary); color: #fff; box-shadow: 0 8px 20px rgba(10,43,209,.35);
  display: flex; align-items: center; justify-content: center; transition: bottom .12s ease-out, transform .1s;
}
.fab:active { transform: scale(.94); background: var(--primary-press); }
.fab svg { width: 28px; height: 28px; }
.kb-open .fab { bottom: calc(var(--kb) + 8px + var(--search-h) + 14px); }
.page-account .fab { bottom: calc(max(var(--sa-bottom), 12px) + 18px); }

/* ---------------------------------------------------------------- account */
.summary {
  display: flex; align-items: baseline; justify-content: center; gap: 10px; flex-wrap: wrap;
  margin: 12px 0 4px;
}
.summary .label { font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.summary .value { font-size: 26px; font-weight: 700; color: var(--bal); }
.hint { text-align: center; font-size: 13px; color: var(--muted); margin: 2px 0 10px; }

.sheet-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--grid); border-radius: 8px;
  margin: 0 calc(-1 * min(12px, 0px));
}
.sheet { border-collapse: collapse; width: 100%; min-width: 1080px; font-size: 14px; }
.sheet th, .sheet td { border: 1px solid var(--grid); padding: 8px 6px; text-align: center; vertical-align: top; }
.sheet thead th {
  font-weight: 700; font-size: 13px; white-space: nowrap; background: #fff;
  border-bottom: 2px solid var(--grid-strong); position: relative;
}
.sheet tr > :first-child { border-left: 0; }
.sheet tr > :last-child { border-right: 0; }
.sheet thead tr > * { border-top: 0; }
.c-clr { color: var(--clr); }
.c-driver { color: var(--driver); }
.c-pay { color: var(--pay); }
.c-bal { color: var(--bal); }
.sheet td.stack div { min-height: 1.35em; white-space: nowrap; }
.sheet tbody tr.row { cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sheet tbody tr.row:hover td { background-color: #fafbff; }
.sheet tbody tr.row:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }
.sheet tr.payment td { background-color: #fbfdf9; }
.sheet tr.payment .label { font-weight: 700; letter-spacing: .02em; }
.sheet tr.payment .c-pay { font-weight: 700; }
.sheet tr.bf td { background-color: #fafafa; font-style: italic; }
/* TOTAL BAL. stays visible on the right while the table scrolls sideways */
.sheet th:last-child, .sheet td:last-child {
  position: sticky; right: 0; z-index: 1; background-color: #fff;
  box-shadow: inset 1px 0 0 var(--grid), -8px 0 10px -8px rgba(0,0,0,.28);
  min-width: 118px;
}
.sheet tr.payment td:last-child { background-color: #fbfdf9; }
.sheet tr.bf td:last-child { background-color: #fafafa; }
.sheet tr.total td { font-weight: 700; padding-top: 12px; padding-bottom: 12px; border-top: 2px solid var(--grid-strong); }
.sheet tr.total .label { text-align: right; letter-spacing: .06em; }

/* long-press feedback: the whole row slowly turns red while holding */
.sheet tbody tr.row.holding td,
.sheet tbody tr.row.holding td:last-child { background-color: #ffd6d6; transition: background-color 1.5s linear; }

/* labels spanning several columns stay on screen while the table scrolls sideways */
.sheet .pin { position: sticky; left: 10px; display: inline-block; }
@media (max-width: 1180px) {
  .sheet tr.payment .label, .sheet tr.total .label { text-align: left !important; }
}

/* ---------------------------------------------------------------- forms */
.form { max-width: 640px; margin: 14px auto 0; }
.field { margin: 0 0 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; letter-spacing: .04em; margin: 0 0 6px; text-transform: uppercase; }
.field label .req { color: var(--danger); }
.opt { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.nt { text-transform: none; }
.field .help { font-size: 13px; color: var(--muted); margin-top: 5px; display: flex; justify-content: space-between; gap: 8px; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1.5px solid var(--grid); border-radius: 10px;
  background: #fff; font-size: 16px; outline: 0;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,43,209,.12); }
.field input[readonly] { background: var(--soft); color: var(--muted); }
.upper { text-transform: uppercase; }
.money-input { position: relative; }
.money-input .naira { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.money-input input { padding-left: 30px; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .12em; color: var(--muted); margin: 22px 0 10px; border-top: 1px solid var(--grid); padding-top: 14px; }
.field.clr label { color: var(--clr); }
.field.driver label { color: var(--driver); }
.field.pay label { color: var(--pay); }
.preview { background: var(--soft); border-radius: 10px; padding: 12px 14px; font-size: 14px; margin: 8px 0 16px; }
.preview .line { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.preview .line.total { font-weight: 700; border-top: 1px solid var(--grid); margin-top: 6px; padding-top: 6px; }
.error-box { background: #fff0f0; border: 1px solid #ffc9c9; color: #a30000; border-radius: 10px; padding: 10px 12px; margin: 0 0 14px; font-size: 15px; }
.error-box .btn { margin-top: 8px; }
.warn-inline { color: #a30000; font-size: 13px; margin-top: 5px; }
.warn-inline button { border: 0; background: none; color: var(--primary); font-weight: 700; padding: 0; text-decoration: underline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 10px; border: 1.5px solid var(--grid);
  background: #fff; font-weight: 700; font-size: 16px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-press); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: #ffb3b3; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.actions { display: flex; gap: 10px; margin-top: 8px; }
.actions .btn { flex: 1; }

/* ---------------------------------------------------------------- dialogs */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,18,30,.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 var(--sa-right) var(--kb) var(--sa-left);
  animation: fade .15s ease-out;
}
.dialog {
  width: 100%; max-width: 560px; background: #fff; border-radius: 18px 18px 0 0;
  max-height: calc(var(--vvh) - var(--sa-top) - 16px); overflow: auto; overscroll-behavior: contain;
  padding: 8px 16px calc(16px + var(--sa-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.2); animation: up .18s ease-out;
}
.kb-open .dialog { padding-bottom: 16px; }
.dialog .grab { width: 40px; height: 5px; border-radius: 3px; background: #d9d9d9; margin: 4px auto 10px; }
.dialog h2 { margin: 0 0 4px; font-size: 19px; }
.dialog .sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.dialog .meta { color: var(--muted); font-size: 12px; margin: 10px 0 0; text-align: center; }
@media (min-width: 700px) {
  .backdrop { align-items: center; }
  .dialog { border-radius: 18px; padding-bottom: 18px; }
  .dialog .grab { display: none; }
}
.backup-status { font-size: 14px; border-radius: 10px; padding: 10px 12px; margin: 0 0 6px; background: var(--soft); color: var(--muted); }
.backup-status.ok { background: #eef8ea; color: var(--pay); }
.backup-status.warn { background: #fff0f0; color: #a30000; }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list button { width: 100%; text-align: left; border: 0; background: none; padding: 14px 6px; font-size: 17px; border-bottom: 1px solid var(--grid); display: flex; align-items: center; gap: 12px; }
.menu-list li:last-child button { border-bottom: 0; }
.menu-list svg { width: 22px; height: 22px; color: var(--primary); }
.menu-list .danger { color: var(--danger); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }

/* ---------------------------------------------------------------- users */
.user-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--grid); border-radius: 12px; padding: 12px; margin: 0 0 10px; }
.user-card .who { flex: 1; min-width: 0; }
.user-card .who b { display: block; overflow-wrap: anywhere; }
.user-card .tag { font-size: 11px; font-weight: 700; color: var(--primary); border: 1px solid var(--primary); border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: 2px; }
.user-card .btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.user-card .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.note { font-size: 14px; color: var(--muted); background: var(--soft); border-radius: 10px; padding: 10px 12px; margin: 14px 0; }

/* ---------------------------------------------------------------- toast + loading */
.toast {
  position: fixed; z-index: 80; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--kb) + max(var(--sa-bottom), 12px) + 96px);
  background: #1d1f24; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 15px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100vw - 32px); text-align: center;
  animation: fade .15s ease-out;
}
.toast.err { background: #b00000; }
.loading { text-align: center; padding: 40px; color: var(--muted); }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(var(--sa-top) + 20px) calc(var(--sa-right) + 20px) calc(var(--sa-bottom) + 20px) calc(var(--sa-left) + 20px); background: linear-gradient(180deg, #f5f7ff, #fff 60%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--grid); border-radius: 18px; padding: 26px 22px; box-shadow: 0 10px 40px rgba(10,43,209,.08); }
.login-card .logo { width: 220px; max-width: 80%; height: auto; display: block; margin: 0 auto 10px; }
.login-card h1 { text-align: center; margin: 0; font-size: 22px; letter-spacing: .04em; }
.login-card p.sub { text-align: center; margin: 4px 0 22px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 18px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

@media (min-width: 900px) {
  .page-title { font-size: 26px; }
  main { padding-left: calc(var(--sa-left) + 28px); padding-right: calc(var(--sa-right) + 28px); }
  .owners { max-width: 900px; margin-left: auto; margin-right: auto; display: table; }
  .searchbar { left: 50%; right: auto; width: min(560px, calc(100vw - 48px)); transform: translateX(-50%); }
  .fab { right: calc(50% - min(280px, calc(50vw - 24px))); }
}
