/* Happy Cake — cash report. Employee app is phone-first; admin page is desktop-first. */
:root {
  --brand: #00AEFF;          /* logo blue: used for surfaces, not for text on white */
  --accent: #0077C2;         /* darker brand blue: buttons/links, 4.8:1 with white */
  --accent-soft: #E3F4FF;
  --accent-text: #ffffff;
  --bg: #F3F6F9;
  --card: #ffffff;
  --text: #16202A;
  --muted: #637081;
  --line: #E1E6EC;
  --ok: #157A47;
  --ok-bg: #E4F5EC;
  --danger: #C62828;
  --danger-bg: #FDECEA;
  --star: #F5A623;
  --input-bg: #ffffff;
  --locked-bg: #EEF1F5;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16,32,48,.06), 0 4px 14px rgba(16,32,48,.05);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #3BB4F5;
    --accent-soft: #10304A;
    --accent-text: #04121C;
    --bg: #0F1419;
    --card: #182028;
    --text: #E8EDF2;
    --muted: #96A3B2;
    --line: #2A3540;
    --ok: #4CC38A;
    --ok-bg: #143022;
    --danger: #FF6B6B;
    --danger-bg: #3A1C1C;
    --input-bg: #121920;
    --locked-bg: #222C36;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: block; height: 38px; width: auto; border-radius: 8px; flex: none; }
.topbar .who { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar a, .linkbtn {
  color: var(--accent); background: none; border: 0; font-size: 15px; font-weight: 500;
  padding: 10px 8px; margin: -2px -8px; cursor: pointer; text-decoration: none; border-radius: 8px;
}
.linkbtn:hover { background: var(--accent-soft); }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 32px; }

h1 { font-size: 24px; line-height: 1.2; margin: 4px 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 16px; margin-bottom: 12px;
}

/* ---------- inputs ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], select {
  width: 100%; min-height: 54px; padding: 12px 14px;
  font-size: 18px; color: var(--text);
  background: var(--input-bg); border: 1.5px solid var(--line); border-radius: 12px;
  outline: none; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[readonly] { background: var(--locked-bg); color: var(--muted); }
input.money { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
input.money::placeholder { color: #A9B2BD; font-weight: 400; }
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; padding: 14px 18px;
  border: 0; border-radius: 14px; cursor: pointer; text-decoration: none;
  font-size: 18px; font-weight: 650;
  background: var(--accent); color: var(--accent-text);
}
.btn:active:not(:disabled) { transform: translateY(1px); filter: brightness(.95); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--card); color: var(--accent); border: 1.5px solid var(--line); }
.btn.small { display: inline-flex; width: auto; min-height: 42px; padding: 8px 16px; font-size: 15px; border-radius: 10px; }
.btn.danger { background: var(--danger); color: #fff; }
.btn + .btn { margin-top: 10px; }

.error { color: var(--danger); background: var(--danger-bg); padding: 10px 12px; border-radius: 10px; margin: 0 0 12px; }
.ok-inline { color: var(--ok); background: var(--ok-bg); padding: 10px 12px; border-radius: 10px; margin: 0 0 12px; font-weight: 600; }
.center { text-align: center; color: var(--muted); padding: 40px 0; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- login ---------- */
.brand-big { display: block; width: 150px; height: auto; border-radius: 18px; margin: 8px 0 22px; box-shadow: var(--shadow); }
@media (max-width: 599px) {
  #view-login, #loginView { padding-top: 6vh; }
}

/* ---------- employee: points list ---------- */
.loc-list { display: flex; flex-direction: column; gap: 10px; }
.loc-row {
  display: flex; align-items: stretch;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.loc {
  flex: 1; min-width: 0; min-height: 76px; padding: 12px 16px; text-align: left;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  background: none; color: var(--text); border: 0; cursor: pointer;
}
.loc .name { font-size: 19px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc .status { font-size: 14px; color: var(--muted); }
.loc:active:not(:disabled) { background: var(--locked-bg); }
.loc:disabled { cursor: default; }
.loc-row.done { background: var(--ok-bg); border-color: transparent; box-shadow: none; }
.loc-row.done .status { color: var(--ok); font-weight: 600; }
.star {
  flex: none; width: 64px; border: 0; border-left: 1px solid var(--line); background: none;
  font-size: 28px; line-height: 1; color: #B9C1CB; cursor: pointer;
}
.star[aria-pressed="true"] { color: var(--star); }
.star:active { background: var(--locked-bg); }
.loc-row.fav { border: 2px solid var(--accent); }
.loc-row.fav:not(.done) .status { color: var(--accent); font-weight: 600; }
.loc-row.fav.done { border-color: var(--ok); }

.loc-row.blocked { opacity: .55; box-shadow: none; }
.today-done {
  display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; padding: 14px 16px;
  background: var(--ok-bg); color: var(--ok); border-radius: var(--radius); text-decoration: none;
}
.today-done span { color: var(--text); font-size: 14px; opacity: .8; }

/* Bottom tabs (employee app) */
body.with-tabbar main { padding-bottom: calc(96px + var(--safe-bottom)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  display: flex; justify-content: center;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 260px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600;
}
.tabbar a .ico { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabbar a.active { color: var(--accent); background: var(--accent-soft); }
.tabbar a.active .ico { filter: none; opacity: 1; }

/* History list */
.history { display: flex; flex-direction: column; gap: 10px; }
.hist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.hist summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; }
.hist summary::-webkit-details-marker { display: none; }
.hist[open] summary { border-bottom: 1px solid var(--line); }
.hist .h-date { flex: none; width: 52px; display: flex; flex-direction: column; align-items: center; padding: 6px 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent); line-height: 1.1; }
.hist .h-date b { font-size: 17px; }
.hist .h-date small { font-size: 11px; opacity: .8; }
.hist .h-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hist .h-main b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .h-main small, .hist .h-total small { color: var(--muted); font-size: 12.5px; }
.hist .h-total { flex: none; display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.hist .h-total b { font-size: 16px; white-space: nowrap; }
.hist .h-total.neg b { color: var(--danger); }
.hist .h-body { padding: 10px 14px 14px; }
#historyMore { margin-top: 12px; }

/* ---------- employee: report form ---------- */
.back { display: inline-block; margin-bottom: 6px; }
.form-head { margin-bottom: 12px; }
.form-head .date { color: var(--muted); }
.exp-row { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.exp-row > span { flex: 1; font-size: 16px; }
.exp-row input { width: 52%; min-height: 50px; font-size: 18px; }
.total-row { display: flex; justify-content: space-between; padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--line); font-weight: 650; }

.result { text-align: center; padding: 18px 16px; }
.result .label { color: var(--muted); font-size: 15px; font-weight: 600; }
.result .value { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: -.5px; }
.result.negative .value { color: var(--danger); }
.result .warn { color: var(--danger); font-size: 14px; margin-top: 6px; font-weight: 600; }

/* Sticky action bar: the main button is always under the thumb */
.has-actionbar { padding-bottom: calc(110px + var(--safe-bottom)); }
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.actionbar-inner { max-width: 528px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.actionbar .ab-total { flex: none; min-width: 0; line-height: 1.15; }
.actionbar .ab-total span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.actionbar .ab-total b { font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actionbar .ab-total.negative b { color: var(--danger); }
.actionbar .btn { flex: 1; margin: 0; }
.actionbar .btn.secondary { flex: 0 0 34%; }

/* Summary (confirm / done) */
.summary { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.summary td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.summary td:last-child { text-align: right; font-weight: 650; white-space: nowrap; }
.summary tr.indent td:first-child { padding-left: 16px; color: var(--muted); }
.summary tr.indent td:last-child { font-weight: 400; }
.summary tr.big td { font-size: 21px; font-weight: 800; border-bottom: 0; padding-top: 14px; }
.summary tr.big.negative td:last-child { color: var(--danger); }
.notice { text-align: center; color: var(--danger); font-weight: 650; margin: 14px 0 6px; }
.meta { color: var(--muted); font-size: 14px; margin-top: 10px; }
.ok-banner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--ok); background: var(--ok-bg); padding: 18px 14px; border-radius: var(--radius);
  font-size: 20px; font-weight: 750; text-align: center; margin-bottom: 14px;
}
.ok-banner .tick { width: 52px; height: 52px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 30px; }

/* ================= Admin (desktop-first) ================= */
main.wide { max-width: 1400px; padding: 20px 24px 40px; }
.admin-shell { display: block; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  color: var(--text); cursor: pointer; white-space: nowrap; text-align: left; font-weight: 500;
}
.tabs button:hover { background: var(--accent-soft); }
.tabs button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
@media (min-width: 960px) {
  .admin-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
  .tabs { flex-direction: column; position: sticky; top: 76px; margin: 0; }
  .tabs button { border: 0; background: transparent; padding: 11px 14px; font-size: 15px; }
  .tabs button.active { background: var(--accent); }
}
.topbar .navlink { color: var(--text); font-weight: 550; padding: 8px 12px; margin: 0; border-radius: 10px; }
.topbar .navlink:hover { background: var(--accent-soft); }
.topbar .navlink.active { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 600px) { .topbar .navlink { padding: 8px 6px; font-size: 14px; } }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.subtabs a { padding: 10px 16px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subtabs a:hover { color: var(--text); }
.subtabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 19px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; flex-wrap: wrap; }
.panel-head h1 { margin: 0; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
.kpi .k-sub { font-size: 12px; color: var(--muted); }

/* Today status chips */
.status-today { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.status-today .st-title { font-weight: 650; margin-right: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 14px; font-weight: 550; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.miss { background: var(--danger-bg); color: var(--danger); }

/* Filters toolbar */
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.filters label.field { flex: 0 1 170px; margin: 0; }
.filters label.field.grow { flex: 1 1 200px; }
.filters input, .filters select { min-height: 42px; font-size: 15px; padding: 8px 12px; }
.filters select { padding-right: 34px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button { min-height: 42px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; font-size: 14px; }
.presets button:hover, .presets button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.filters .spacer { flex: 1 0 0; }

/* Data tables */
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; padding: 0; max-height: calc(100vh - 330px); min-height: 160px; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { text-align: left; color: var(--muted); font-weight: 650; font-size: 12.5px; text-transform: uppercase; letter-spacing: .3px;
  position: sticky; top: 0; z-index: 1; background: var(--card); }
table.data td.num, table.data th.num { text-align: right; }
table.data td.neg { color: var(--danger); }
table.data tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg) 55%, var(--card)); }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--accent-soft); }
table.data td.strong { font-weight: 750; }
table.data tfoot td { font-weight: 750; border-top: 2px solid var(--line); border-bottom: 0; position: sticky; bottom: 0; background: var(--card); }
table.data tr.inactive td { color: var(--muted); }
table.data .center { padding: 30px 0; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; background: var(--locked-bg); color: var(--muted); }
.pill.on { background: var(--ok-bg); color: var(--ok); }

/* Dialogs */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(10,20,30,.45); }
dialog form { padding: 20px 22px; }
dialog h2 { font-size: 19px; margin-bottom: 14px; }
dialog .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
dialog label.field { margin-bottom: 12px; }
dialog label.field input, dialog label.field select { min-height: 44px; font-size: 16px; }
dialog .row { display: flex; gap: 10px; margin-top: 10px; }
dialog .row .btn { margin-top: 0; }
dialog .dlg-result { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; background: var(--accent-soft); border-radius: 12px; margin: 4px 0 6px; }
dialog .dlg-result b { font-size: 22px; font-variant-numeric: tabular-nums; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; }
.input-with-btn .btn { flex: none; min-height: 44px; }
.cred { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 8px; }
.cred-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cred-row:last-child { border-bottom: 0; }
.cred-row span { color: var(--muted); }
.cred-row b { font-family: ui-monospace, Consolas, monospace; font-size: 17px; word-break: break-all; text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions button { border: 1px solid var(--line); background: var(--card); color: var(--accent); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.row-actions button:hover { background: var(--accent-soft); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
@media (max-width: 520px) { dialog .grid2 { grid-template-columns: 1fr; } }
