/* Mobile-first. Everything is sized for a thumb on a phone held one-handed. */

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --line: #2a2f3a;
  --text: #eef1f6;
  --muted: #98a2b3;
  --accent: #4f8cff;
  --accent-ink: #ffffff;
  --good: #3ddc97;
  --warn: #ffb020;
  --danger: #ff5c5c;
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --line: #dde3ec;
    --text: #121721;
    --muted: #5b6675;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

/*
 * The `hidden` attribute only gets `display: none` from the UA stylesheet, so
 * any author rule setting `display` silently beats it. Several components here
 * do exactly that (.sheet, .login, .callout, .report, .brand-logo), which left
 * hidden full-screen overlays painted over the app and eating every click.
 * This keeps `hidden` meaning hidden, whatever a component sets.
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--danger); font-size: .88rem; margin: .5rem 0 0; }

/* ── Layout ─────────────────────────────────────────── */

.view { padding: 1rem; max-width: 640px; margin: 0 auto; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(env(safe-area-inset-top) + .75rem) 1rem .75rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.hello { font-weight: 650; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.card.subtle { background: var(--surface-2); }

/* ── Forms ──────────────────────────────────────────── */

label { display: block; font-size: .85rem; font-weight: 600; margin: .9rem 0 .35rem; color: var(--muted); }

input, select, textarea {
  width: 100%;
  padding: .8rem .9rem;
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  appearance: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit; font-weight: 600;
  border-radius: 12px; border: 1px solid transparent;
  padding: .8rem 1rem;
  cursor: pointer;
  transition: transform .06s ease, opacity .15s ease;
}
button:active { transform: scale(.985); }
button:disabled { opacity: .45; cursor: not-allowed; }

.primary { background: var(--accent); color: var(--accent-ink); }
.danger { background: var(--danger); color: #fff; }
.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.block { display: block; width: 100%; margin-top: 1rem; }
.big { padding: 1.05rem; font-size: 1.05rem; }
.small-btn { padding: .45rem .7rem; font-size: .82rem; }

/* ── Login ──────────────────────────────────────────── */

.login { display: grid; place-items: center; min-height: 100dvh; padding-bottom: 1rem; }
.login-inner { width: 100%; max-width: 380px; }
.brand { text-align: center; margin-bottom: 1.5rem; }
.brand-mark {
  width: 64px; height: 64px; margin: 0 auto .75rem;
  display: grid; place-items: center;
  font-size: 30px; border-radius: 20px;
  background: var(--accent); color: #fff;
}
.brand-mark.big { width: 72px; height: 72px; font-size: 34px; }

/* ── Timer ──────────────────────────────────────────── */

.timer-card { text-align: center; }
.timer-status {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .8rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--good); margin-bottom: .5rem;
}
.pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--good);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.elapsed {
  font-size: clamp(2.9rem, 17vw, 4.2rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.05;
  margin: .25rem 0;
}
.project-line { font-weight: 600; margin-bottom: .2rem; }
.adjust { text-align: left; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.timer-card label, .timer-card textarea { text-align: left; }

.started-line {
  display: block; width: 100%;
  padding: .7rem .9rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text); font-weight: 600; text-align: center;
  cursor: pointer;
}

.last-project {
  display: block;
  background: none; border: 0; padding: .3rem 0 0;
  font-size: .8rem; color: var(--muted); text-align: left; cursor: pointer;
}
.last-project strong { color: var(--accent); font-weight: 600; }

/* ── Suggestions ────────────────────────────────────── */

.suggestions { display: grid; gap: .5rem; margin: .75rem 0; }
.suggestion {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  width: 100%; text-align: left;
  padding: .8rem .9rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text); font-weight: 500;
}
.suggestion.top { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.suggestion .name { font-weight: 650; }
.suggestion .why { font-size: .78rem; color: var(--muted); }
.confidence {
  flex: none; font-size: .72rem; font-weight: 700;
  padding: .25rem .5rem; border-radius: 999px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
}
.confidence.high { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }

/* ── Lists ──────────────────────────────────────────── */

.list { display: grid; gap: .6rem; }

.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 1rem 0 .1rem; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
}

.entry {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .85rem .95rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.entry .main { min-width: 0; }
.entry .title { font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .meta { font-size: .8rem; color: var(--muted); }
.entry .right { text-align: right; flex: none; }
.entry .hours { font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; font-size: .68rem; font-weight: 700;
  padding: .18rem .45rem; border-radius: 6px; letter-spacing: .04em;
  text-transform: uppercase; margin-left: .35rem; vertical-align: middle;
}
.badge.billed { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.badge.pending { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge.open { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

.bill { padding: .95rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.bill-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.bill-num { font-weight: 680; }
.payments { margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--line); display: grid; gap: .35rem; }
.payment { display: flex; justify-content: space-between; font-size: .85rem; }
.payment .pay-amount { color: var(--good); font-weight: 620; font-variant-numeric: tabular-nums; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; text-align: center; }
.stat-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ── Tab bar ────────────────────────────────────────── */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  /* Flex, not a fixed grid: the Admin tab appears only for admins, and the
     remaining tabs must absorb the space either way. */
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; border-radius: 0;
  color: var(--muted); font-size: .7rem; font-weight: 600;
}
.tab span { font-size: 1.15rem; line-height: 1; }
.tab.active { color: var(--accent); }

.vendor-select { margin-top: .5rem; padding: .5rem .7rem; font-size: .88rem; }

/* ── Time wheel picker ──────────────────────────────────
   Date on its own row, then the time as one big HH : MM. Each wheel shows
   exactly one 56px row — neighbouring values stay hidden; the chevrons are
   the scroll affordance. ITEM_H in timewheel.js must match the 56px here. */

.dtpick { display: block; }
.dtpick-date { width: 100%; margin-bottom: .5rem; }

.dtpick-time { display: flex; align-items: center; justify-content: center; gap: .5rem; }
.dtpick-colon {
  font-size: 2rem;
  font-weight: 700;
  line-height: 56px;
  color: var(--muted);
}

.wheelwrap { display: flex; flex-direction: column; align-items: stretch; width: 5.2rem; flex: none; }
.wheel {
  height: calc(56px + 2px); /* border-box: content stays one 56px item */
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  scrollbar-width: none;
  overscroll-behavior: contain;
}
.wheel::-webkit-scrollbar { display: none; }
.wheel-item {
  height: 56px;
  line-height: 56px;
  text-align: center;
  scroll-snap-align: start;
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.wheel-step {
  background: none;
  border: 0;
  padding: .15rem 0;
  font-size: .65rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.wheel-step:active { color: var(--accent); transform: none; }

/* ── Overlays ───────────────────────────────────────── */

.sheet {
  position: fixed; inset: 0; z-index: 50;
  display: grid; align-items: end;
  background: rgba(0, 0, 0, .55);
}
.sheet-inner {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 1.25rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto;
  width: 100%; max-width: 640px; margin: 0 auto;
  text-align: center;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet form { text-align: left; }

.banner {
  position: sticky; top: 0; z-index: 40;
  padding: .5rem 1rem; text-align: center;
  font-size: .82rem; font-weight: 600;
  background: var(--warn); color: #201400;
}
.banner.syncing { background: var(--accent); color: #fff; }

/* ── Branding ───────────────────────────────────────── */

.brand-logo {
  max-width: 180px; max-height: 72px;
  margin: 0 auto .75rem; display: block;
  object-fit: contain;
}
.topbar-logo { height: 28px; max-width: 110px; object-fit: contain; flex: none; }
.topbar-text { flex: 1; min-width: 0; }
.topbar-text .hello { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Setup wizard ───────────────────────────────────── */

.steps {
  display: flex; flex-wrap: wrap; gap: .35rem;
  list-style: none; margin: 0 0 1rem; padding: 0;
  font-size: .72rem; font-weight: 600;
}
.steps li {
  flex: 1 1 auto; text-align: center;
  padding: .35rem .4rem; border-radius: 8px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line);
}
.steps li.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.steps li.done { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }

.setup-panel { text-align: left; }

.callout {
  display: block; margin-top: .75rem; padding: .7rem .8rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  font-size: .82rem; word-break: break-all;
}
.callout.warn {
  background: color-mix(in srgb, var(--warn) 14%, var(--surface-2));
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  word-break: normal;
}
.callout .cred {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem; font-weight: 700;
  margin: .35rem 0; padding: .45rem .6rem;
  background: var(--surface); border-radius: 8px;
  user-select: all;
}

.report { margin-top: .9rem; display: grid; gap: .3rem; }
.report-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
  font-size: .85rem; padding: .4rem .55rem;
  background: var(--surface-2); border-radius: 8px;
}
.report-status { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.report-row.created .report-status { color: var(--good); }
.report-row.exists .report-status { color: var(--muted); }
.report-row.failed .report-status { color: var(--danger); }
.report-row.skipped .report-status { color: var(--warn); }
.report-detail { padding: 0 .55rem .3rem; }

label.check {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 500; color: var(--text); margin-top: 1rem;
}
label.check input { width: auto; flex: none; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1rem);
  z-index: 60;
  padding: .7rem 1.1rem; border-radius: 999px;
  background: var(--text); color: var(--bg);
  font-size: .87rem; font-weight: 600;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
  max-width: 90vw;
}
