/* ================================ Klok ================================ */
:root {
  --paper: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --ink: #16202b;
  --ink-soft: #45525f;
  --ink-faint: #6b7683;
  --hairline: #dce1e7;
  --accent: #0b7c74;
  --accent-ink: #075a54;
  --accent-contrast: #ffffff;
  --accent-wash: #e1f0ee;
  --warn: #c0492a;
  --warn-wash: #f6e7e1;
  --good: #1f8f5f;
  --ring: rgba(11, 124, 116, 0.35);
  --nav-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e141a;
    --surface: #161f27;
    --surface-2: #1e2932;
    --ink: #e7ecf1;
    --ink-soft: #aebac5;
    --ink-faint: #7e8b97;
    --hairline: #283542;
    --accent: #35b7ac;
    --accent-ink: #7fd6cf;
    --accent-contrast: #06231f;
    --accent-wash: #14322f;
    --warn: #f0774b;
    --warn-wash: #38211a;
    --good: #46c98a;
    --ring: rgba(53, 183, 172, 0.4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, .display {
  font-family: "Archivo", system-ui, sans-serif;
  letter-spacing: -0.02em;
  margin: 0;
}
a { color: var(--accent-ink); text-decoration: none; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* -------------------------------- layout ---------------------------- */
.app { max-width: 460px; margin: 0 auto; padding: 18px 16px calc(var(--nav-h) + 24px); }
header.top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
header.top .brand { flex: 1; display: flex; align-items: center; gap: 8px; }
header.top .brand b { font-family: "Archivo"; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.mark { width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, #0f8f85, #075a54); flex: none; position: relative; }
.mark::after { content: ""; position: absolute; inset: 5px; border: 2px solid #fff;
  border-radius: 50%; border-right-color: transparent; transform: rotate(35deg); }

.icon-btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 11px;
  color: var(--ink-soft); cursor: pointer;
}
.icon-btn:active { transform: scale(.95); }

/* -------------------------------- cards ----------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}
.card.flush { padding: 0; overflow: hidden; }
.card.accent { border-color: var(--accent); }
.card.dashed { border-style: dashed; text-align: center; color: var(--ink-faint); }

.label {
  font-size: .68rem; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-faint);
}
.muted { color: var(--ink-faint); }
.small { font-size: .8rem; }
.stat { font-family: "Archivo", system-ui, sans-serif; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos { color: var(--good); }
.neg { color: var(--warn); }
.divider { height: 1px; background: var(--hairline); margin: 12px -16px; }

/* ------------------------------- controls --------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 46px; padding: 0 1.05rem; border-radius: 12px;
  font: inherit; font-weight: 600; font-size: .92rem;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: transform .08s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent-ink); }
.btn.danger { color: var(--warn); }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 .8rem; font-size: .84rem; border-radius: 10px; }

input, select {
  width: 100%; min-height: 46px; padding: 0 .8rem; border-radius: 12px;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1rem;
}
input[type="time"], input[type="date"] { min-width: 0; }
input:focus, select:focus, .btn:focus-visible, .chip:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--ring);
}
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; margin-bottom: 5px; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 10px; }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }

.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .45rem .7rem; border-radius: 999px;
  border: 1px solid var(--hairline); background: var(--surface);
  color: var(--ink-soft); font-size: .82rem; font-weight: 500;
  cursor: pointer; user-select: none; min-height: 0;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* segmented control */
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.segmented button {
  flex: 1; border: 0; border-radius: 9px; padding: 8px 6px; font: inherit;
  font-weight: 600; font-size: .84rem; color: var(--ink-faint); background: transparent; cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* switch */
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--hairline); transition: background .15s ease;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s ease;
}
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ------------------------------- hero ------------------------------- */
.hero { text-align: center; padding: 26px 16px 20px; }
.hero .status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: .9rem; color: var(--ink-faint); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.dot.in { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent); }
.hero .balance { font-family: "Archivo"; font-weight: 800; font-size: 3.2rem; line-height: 1;
  letter-spacing: -.03em; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.hero .under { font-size: .82rem; color: var(--ink-faint); }
.punch {
  width: 100%; margin-top: 20px; min-height: 56px; border: 0; border-radius: 14px;
  font: inherit; font-family: "Archivo"; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em;
  color: var(--accent-contrast); background: var(--accent); cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.punch:active { transform: scale(.98); }
.punch.stop { background: var(--warn); }
.punch:disabled { opacity: .5; }

/* ------------------------------- tables ----------------------------- */
.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
.list th, .list td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.list th:first-child, .list td:first-child { text-align: left; }
.list thead th { font: inherit; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tr.tap { cursor: pointer; }
.list tr.tap:active td { background: var(--surface-2); }
.list tr.weekend td { color: var(--ink-faint); }
.list tfoot td { font-weight: 700; border-top: 2px solid var(--hairline); border-bottom: 0; }
.list .num { font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

/* ------------------------------- bars ------------------------------- */
.bars { display: flex; align-items: flex-end; gap: 7px; margin-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.bars .track { width: 100%; height: 96px; display: flex; align-items: flex-end; }
.bars .bar { width: 100%; border-radius: 5px 5px 0 0; background: var(--surface-2); min-height: 3px; }
.bars .bar.hi { background: var(--accent); }
.bars .cap { font-size: .62rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.bars .lab { font-size: .62rem; color: var(--ink-faint); }

/* -------------------------------- nav ------------------------------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; max-width: 460px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--hairline);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: none; cursor: pointer; padding: 9px 4px 10px;
  font: inherit; font-size: .6rem; font-weight: 500; color: var(--ink-faint);
}
nav.tabs button[aria-current="page"] { color: var(--accent-ink); }
nav.tabs svg { width: 21px; height: 21px; }

/* ------------------------------ overlays ---------------------------- */
.sheet-bg {
  position: fixed; inset: 0; z-index: 40; background: rgba(9, 15, 20, .55);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet {
  background: var(--surface); width: 100%; max-width: 460px;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto; animation: rise .2s ease;
}
.sheet h3 { font-size: 1.15rem; margin-bottom: 4px; }
.sheet .grab { width: 36px; height: 4px; border-radius: 999px; background: var(--hairline); margin: -6px auto 12px; }
@media (min-width: 520px) {
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 18px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: .6; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%);
  z-index: 60; background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 999px; font-size: .84rem; font-weight: 600;
  max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: rise .2s ease;
}

/* -------------------------------- auth ------------------------------ */
.auth { max-width: 380px; margin: 12vh auto 0; padding: 0 18px; text-align: center; }
.auth .mark { width: 40px; height: 40px; border-radius: 12px; margin: 0 auto 14px; }
.auth h1 { font-size: 1.8rem; }
.auth form { text-align: left; margin-top: 6px; }
.auth .btn.block { margin-top: 4px; }

code {
  display: block; background: var(--surface-2); border: 1px solid var(--hairline);
  padding: 9px 11px; border-radius: 10px; font-size: .78rem; word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
[hidden] { display: none !important; }
