:root {
  --bg: #f3f6f9;
  --card: #ffffff;
  --ink: #14212b;
  --muted: #5f6f7c;
  --line: #dde4ea;
  --accent: #0b74c4;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0fb;
  --good: #1a8a4a;
  --good-soft: #e2f4ea;
  --warn: #a85d00;
  --warn-soft: #fff1dc;
  --bad: #c2312b;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f161c;
    --card: #182129;
    --ink: #e8eef3;
    --muted: #93a3b0;
    --line: #2a3640;
    --accent: #4aa8f0;
    --accent-ink: #06121c;
    --accent-soft: #15324a;
    --good: #5fd08f;
    --good-soft: #143322;
    --warn: #f0b35a;
    --warn-soft: #3a2a12;
    --bad: #ff7b73;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 12px 16px 48px; }
.wide { max-width: 980px; }
header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 14px;
}
header.top h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
header.top a, .linkbtn {
  color: var(--muted); font-size: 14px; text-decoration: none;
  background: none; border: 0; padding: 8px; cursor: pointer; font: inherit;
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
label.lbl, .lbl {
  display: block; font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px;
}
.lbl small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
input[type=text], input[type=tel], input[type=date], input[type=password], input[type=number] {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; min-height: 48px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
/* iOS Safari gives date inputs an intrinsic min width that ignores width:100% */
input[type=date] {
  -webkit-appearance: none; appearance: none;
  display: block; min-width: 0; max-width: 100%;
}
input[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 2px solid var(--line); border-radius: 12px;
  padding: 14px 10px; min-height: 76px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.tile b { font-size: 17px; }
.tile span { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.tile[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); }
.tile[aria-pressed=true] span { color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px;
  min-height: 44px; cursor: pointer;
}
.chip[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.btn {
  font: inherit; font-weight: 600; font-size: 17px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); padding: 14px 18px;
  min-height: 52px; cursor: pointer; width: 100%;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.small { width: auto; min-height: 40px; font-size: 15px; padding: 8px 14px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.good { background: var(--good); color: #fff; }

.daterow { display: flex; gap: 10px; align-items: center; }
.daterow input { flex: 1; }
.datehint { font-size: 14px; color: var(--muted); margin-top: 6px; }
.datehint.warn { color: var(--warn); font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; }
.list .main { flex: 1; min-width: 0; }
.list .main b { display: block; }
.list .main small { color: var(--muted); }
.list .amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.x {
  background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1;
  width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
}
.x:hover { color: var(--bad); background: var(--bg); }

.sumline { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.sumline h2 { font-size: 17px; margin: 0; }
.sumline .big { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 16px 0; }
.notice { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.good { background: var(--good-soft); color: var(--good); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px;
  font-weight: 600; transition: transform .2s ease; max-width: calc(100% - 32px);
  z-index: 10;
}
#toast.show { transform: translate(-50%, 0); }
#toast.err { background: var(--bad); color: #fff; }

/* admin */
/* Bottom tab bar on phones, top tabs on wider screens */
.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
}
.navbar button, .navbar a {
  flex: 1; max-width: 120px; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font: inherit; font-size: 11px; font-weight: 600; color: var(--muted);
  background: none; border: 0; border-radius: 10px; padding: 6px 2px;
  min-height: 52px; cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.navbar svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.navbar [aria-selected=true] { color: var(--accent); }
.navbar [aria-selected=true] svg { stroke-width: 2.2; }
.navbar .dot { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; font-style: normal; }
#app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
@media (min-width: 720px) {
  .navbar {
    position: static; justify-content: flex-start; gap: 4px; margin-bottom: 14px;
    border: 1px solid var(--line); border-radius: 12px; padding: 4px; box-shadow: none;
  }
  .navbar button, .navbar a { flex-direction: row; justify-content: center; gap: 8px; font-size: 15px; max-width: none; min-height: 44px; }
  .navbar svg { width: 18px; height: 18px; }
  .navbar [aria-selected=true] { background: var(--accent-soft); color: var(--ink); }
  .navbar a { margin-left: auto; flex: 0 0 auto; padding: 6px 14px; }
  .navbar .dot { position: static; }
  #app { padding-bottom: 48px; }
}
.dot { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #fff; font-size: 12px; line-height: 18px; margin-left: 4px; text-align: center; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi.hero { grid-column: span 2; background: var(--good-soft); border-color: transparent; }
.kpi.hero .v { font-size: 30px; color: var(--good); }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .v.neg, .cashbig.neg { color: var(--bad); }
@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(5, 1fr); }
  .kpi.hero { grid-column: auto; grid-row: span 2; display: flex; flex-direction: column; justify-content: center; }
  .kpi.hero .v { font-size: 36px; }
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}
.cashcard {
  width: 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px;
}
.cashcard span { color: var(--muted); font-size: 14px; }
.cashcard b { font-size: 20px; font-variant-numeric: tabular-nums; }
.cashcard small { margin-left: auto; color: var(--accent); font-weight: 600; }
.cashbig { font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.leftbox { background: var(--accent-soft); border-radius: 10px; padding: 12px; margin-bottom: 14px; font-size: 15px; }
.leftbox b { font-size: 18px; font-variant-numeric: tabular-nums; }
.leftbox.neg { background: var(--warn-soft); color: var(--warn); }
details summary { list-style-position: inside; }
.chartbox { position: relative; height: 220px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 8px 4px; border-top: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; border-top: 0; }
th:first-child, td:first-child { text-align: left; }
tfoot td { font-weight: 700; }
.scroll { overflow-x: auto; }
.range { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.range .chip { padding: 8px 14px; min-height: 40px; font-size: 14px; }
.custom { display: none; gap: 8px; margin-bottom: 12px; }
.custom.on { display: flex; }
.custom input { flex: 1 1 0; min-width: 0; min-height: 42px; padding: 8px; font-size: 15px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; }
.badge.approved { background: var(--good-soft); color: var(--good); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.open { background: var(--bg); color: var(--muted); }
.week { display: flex; flex-direction: column; gap: 10px; }
.week .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.week .nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 13px; color: var(--muted); }
.week .nums b { display: block; color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.week .actions { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.setrow { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, minmax(0, 90px)); gap: 8px; align-items: center; margin-bottom: 8px; }
.setrow input { min-width: 0; min-height: 42px; padding: 8px; font-size: 15px; }
.pinbox { max-width: 320px; margin: 12vh auto 0; text-align: center; }
.pinbox input { text-align: center; font-size: 28px; letter-spacing: 0.4em; margin: 12px 0; }
.hidden { display: none !important; }
@media (max-width: 719px) {
  body:has(.navbar:not(.hidden)) #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
select {
  width: 100%; font: inherit; font-size: 17px; font-weight: 600; color: var(--ink);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6f7c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 18px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 40px 12px 12px; min-height: 52px;
  -webkit-appearance: none; appearance: none; cursor: pointer;
}
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
