/* CloudPunch design system: calm, high-contrast, one primary action per screen,
   large touch targets, plain language. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --fill: rgba(118, 118, 128, .12);
  --text: #000000;
  --muted: rgba(60, 60, 67, .6);
  --faint: rgba(60, 60, 67, .3);
  --border: rgba(60, 60, 67, .18);
  --bar: rgba(249, 249, 249, .82);
  --accent: #2563eb;          /* primary blue: links, selection */
  --accent-fill: #2563eb;     /* filled primary buttons, white text */
  --go-fill: #16a34a;         /* Clock In */
  --green: #15803d;           /* "on the clock" text */
  --red: #dc2626;
  --orange: #ff9500;
  --brand: var(--accent);
  --brand-ink: #ffffff;
  --brand-soft: rgba(37, 99, 235, .1);
  --danger: var(--red);
  --danger-strong: #dc2626;   /* Clock Out / destructive fills */
  --danger-soft: rgba(255, 59, 48, .12);
  --warn: #c93400;
  --warn-soft: rgba(255, 149, 0, .14);
  --ok: #248a3d;
  --ok-soft: rgba(52, 199, 89, .14);
  --radius: 12px;
  --shadow: none;
  --tabbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10;
    --surface: #16191e;
    --fill: rgba(118, 118, 128, .24);
    --text: #ffffff;
    --muted: rgba(235, 235, 245, .6);
    --faint: rgba(235, 235, 245, .3);
    --border: rgba(84, 84, 88, .6);
    --bar: rgba(22, 22, 24, .82);
    --accent: #60a5fa;
    --green: #4ade80;
    --red: #f87171;
    --orange: #ff9f0a;
    --brand-soft: rgba(96, 165, 250, .16);
    --warn: #ff9f0a;
    --warn-soft: rgba(255, 159, 10, .18);
    --ok: #30d158;
    --ok-soft: rgba(48, 209, 88, .18);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.35 var(--font);
  letter-spacing: -.01em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: 34px; line-height: 1.15; }
h2 { font-size: 22px; }
h3 { font-size: 17px; font-weight: 600; }
code { background: var(--fill); padding: .1em .35em; border-radius: 6px; font-size: .85em; word-break: break-all; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }
.right { text-align: right; }
.pre { white-space: pre-wrap; }
.err-text { color: var(--red); }
.mono, .tnum { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.container { max-width: 600px; margin: 0 auto; padding: 0 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
.container.wide { max-width: 1200px; padding-bottom: 48px; }
.large-title { padding: 20px 4px 12px; }
.large-title .eyebrow { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }

/* Grouped inset list */
.section-header { margin: 28px 16px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); display: flex; justify-content: space-between; }
.section-header .tnum { text-transform: none; }
.section-footer { margin: 6px 16px 0; font-size: 13px; color: var(--muted); }
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; list-style: none; margin: 0; padding: 0; }
.list > li, .list > .row-item { position: relative; }
.list > li + li::before, .list > .row-item + .row-item::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--border);
}
.cell {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 11px 16px;
  color: var(--text); background: none; border: 0; width: 100%; font: inherit; text-align: left;
}
button.cell, a.cell { cursor: pointer; }
button.cell:active, a.cell:active { background: var(--fill); }
.cell .grow { flex: 1; min-width: 0; }
.cell .title { display: block; }
.cell .subtitle { display: block; font-size: 15px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .value { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell.chevron::after {
  content: ""; width: 8px; height: 8px; border: solid var(--faint); border-width: 2px 2px 0 0;
  transform: rotate(45deg); margin-left: 4px; flex: none;
}
.cell.destructive { color: var(--red); justify-content: center; }
.cell.action { color: var(--accent); }
.cell .check { color: var(--accent); font-weight: 600; }
.icon-badge {
  width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; flex: none; color: #fff;
}
.icon-badge svg { width: 18px; height: 18px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--border);
}
.tabbar a {
  flex: 0 1 120px; display: grid; justify-items: center; gap: 2px; padding: 7px 0 5px;
  font-size: 10px; font-weight: 500; color: var(--muted);
}
.tabbar a svg { width: 26px; height: 26px; }
.tabbar a.active { color: var(--accent); }

/* ---------- Clock screen ---------- */
.clock-hero { text-align: center; padding: 8px 0 4px; }
.status-line { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; color: var(--muted); }
.status-line.on { color: var(--green); }
.status-line.on::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.hero-time { font-size: clamp(56px, 18vw, 76px); font-weight: 200; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 6px 0 2px; }
.hero-sub { color: var(--muted); font-size: 15px; }

.big-button {
  width: 188px; height: 188px; border-radius: 50%; border: 0; margin: 28px auto 8px; display: grid; place-items: center;
  font: 600 24px/1 var(--font); letter-spacing: -.01em; color: #fff; cursor: pointer;
  background: var(--go-fill);
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--go-fill) 14%, transparent), 0 10px 28px color-mix(in srgb, var(--go-fill) 30%, transparent);
  transition: transform .15s ease, box-shadow .2s;
}
.big-button:active { transform: scale(.96); }
.big-button.stop { background: var(--danger-strong); box-shadow: 0 0 0 10px color-mix(in srgb, var(--danger-strong) 14%, transparent), 0 10px 28px color-mix(in srgb, var(--danger-strong) 30%, transparent); }
.big-button:disabled { opacity: .6; }
.big-button span { display: grid; gap: 6px; justify-items: center; }
.big-button small { font-size: 15px; font-weight: 500; opacity: .85; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.quick-action {
  display: grid; justify-items: center; gap: 6px; padding: 16px 8px; border-radius: var(--radius); border: 0;
  background: var(--surface); color: var(--accent); font: 600 15px/1.2 var(--font); cursor: pointer;
}
.quick-action svg { width: 28px; height: 28px; }
.quick-action:active { background: var(--fill); }

.summary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.summary-tile { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.summary-tile .label { font-size: 13px; color: var(--muted); }
.summary-tile .num { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* ---------- Photos & notes ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; margin: 0; }
.gallery.inset { background: var(--surface); border-radius: var(--radius); padding: 4px; }
.tile {
  position: relative; margin: 0; border-radius: 8px; overflow: hidden; background: var(--fill);
  aspect-ratio: 1; cursor: pointer; color: inherit; border: 0; padding: 0;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.pending img { filter: brightness(.6); }
.tile .spinner { position: absolute; inset: 0; margin: auto; }
.tile.failed::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 28px; background: rgba(255, 59, 48, .55); }
.tile.doc { display: grid; place-content: center; text-align: center; gap: 4px; padding: 8px; }
.tile.doc svg { width: 30px; height: 30px; color: var(--accent); margin: 0 auto; }
.doc-name { font-size: 12px; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.note-cell .note-body { white-space: pre-wrap; }
.note-cell .note-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- Buttons & inputs (shared with admin) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--accent-fill); color: #fff; font: 600 17px/1 var(--font); cursor: pointer; white-space: nowrap;
}
.btn:active { opacity: .8; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.ghost { background: var(--brand-soft); color: var(--accent); }
.btn.danger { background: var(--danger-strong); color: #fff; }
.btn.ghost.danger { background: var(--danger-soft); color: var(--red); }
.btn.small { min-height: 32px; padding: 0 14px; font-size: 15px; border-radius: 999px; }
.btn.block { width: 100%; min-height: 50px; }
.linklike { background: none; border: 0; font: inherit; color: var(--accent); cursor: pointer; padding: 0; }
.icon-btn { background: var(--fill); border: 0; width: 30px; height: 30px; border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; color: var(--muted); display: grid; place-items: center; }

input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 0; border-radius: 10px; padding: 11px 14px; min-height: 44px;
  box-shadow: inset 0 0 0 .5px var(--border);
}
textarea { resize: none; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.btn:focus-visible, .cell:focus-visible, .tabbar a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"] { width: auto; min-height: 0; box-shadow: none; accent-color: var(--accent); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); padding-left: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

/* ---------- Sign in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px 80px; }
.auth-inner { width: 100%; max-width: 360px; text-align: center; }
.app-icon { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, .15); }
.auth h1 { font-size: 28px; }
.auth p { margin: 6px 0 24px; }
.auth .list input { box-shadow: none; border-radius: 0; background: transparent; padding: 13px 16px; }
.auth .list input:focus { box-shadow: none; }
.auth .btn { margin-top: 20px; }

/* ---------- Sheets / modals ---------- */
.modal {
  border: 0; padding: 0; background: var(--bg); color: var(--text);
  width: min(560px, 100vw); max-width: 100vw; border-radius: 14px;
}
.modal.large { width: min(900px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(0, 0, 0, .4); }
.modal-inner { display: flex; flex-direction: column; max-height: 90vh; }
.modal header { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 16px 16px 8px; }
.modal header h2 { font-size: 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 16px; }
.modal-body { padding: 8px 16px 16px; overflow-y: auto; }
@media (max-width: 600px) {
  .modal, .modal.large { margin: auto 0 0; width: 100vw; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal[open] { animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
}
@keyframes sheet-up { from { transform: translateY(100%); } }

/* Confirm sheet */
.action-sheet { border: 0; padding: 0; width: min(420px, 100vw); margin: auto auto 0; background: var(--surface); color: var(--text); border-radius: 20px 20px 0 0; }
@media (min-width: 601px) { .action-sheet { margin: auto; border-radius: 20px; } }
.action-sheet::backdrop { background: rgba(0, 0, 0, .45); }
.action-sheet[open] { animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
.action-sheet .sheet { padding: 24px 20px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 10px; text-align: center; }
.action-sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--faint); margin: -12px auto 6px; }
.action-sheet .msg strong { display: block; font-size: 20px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.action-sheet .msg { color: var(--muted); margin-bottom: 8px; }
.action-sheet .btn { min-height: 52px; }
.action-sheet .cancel { min-height: 48px; background: none; border: 0; font: 600 17px/1 var(--font); color: var(--muted); cursor: pointer; }

.lightbox { display: grid; gap: 12px; justify-items: center; }
.lightbox img { max-width: 100%; max-height: 70vh; border-radius: 10px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  opacity: 0; pointer-events: none; display: flex; align-items: center; gap: 10px;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  max-width: calc(100vw - 32px); font-weight: 600; font-size: 15px; transition: .22s; z-index: 100;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .toast-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: var(--go-fill); color: #fff; flex: none; }
.toast.error .toast-icon { background: var(--danger-strong); }
.admin .toast { bottom: 24px; }

/* ---------- Admin ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.brand img { border-radius: 6px; }
.topbar nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; position: relative; }
.topbar nav a, .topbar nav .linklike { padding: 6px 12px; border-radius: 8px; color: var(--text); font-size: 15px; }
.topbar nav a:hover { background: var(--fill); }
.topbar nav a.active { background: var(--fill); font-weight: 600; }
.menu { position: absolute; right: 0; top: 110%; min-width: 220px; display: grid; gap: 4px; z-index: 20; }
.menu .linklike { text-align: left; padding: 8px 0; color: var(--accent); }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; margin: 16px 0; }
.card h2 { font-size: 20px; margin-bottom: 12px; }
.notice { background: var(--warn-soft); color: var(--text); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.row.between { justify-content: space-between; }
.row.between h2 { margin: 0; }
.filters select, .filters input { width: auto; min-width: 140px; flex: 1 1 140px; background: var(--bg); box-shadow: none; }
.filters label { display: flex; align-items: center; gap: 6px; flex: 1 1 180px; font-size: 15px; color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--fill); color: var(--muted); vertical-align: middle; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--danger-soft); color: var(--red); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.live { background: var(--ok-soft); color: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 20px; }
.stat { margin: 0; color: inherit; }
.stat-value { font-size: 34px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid-2 .card { margin: 16px 0 0; }
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-list li + li { border-top: .5px solid var(--border); }
.entry-list a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; color: inherit; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px; border-bottom: .5px solid var(--border); white-space: nowrap; }
th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; }
td.pre { white-space: pre-wrap; min-width: 240px; }
tr.inactive td { color: var(--muted); }
.steps li { margin-bottom: 6px; }
.err-list { color: var(--red); }
.notes { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.notes li { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.detail-block + .detail-block { margin-top: 20px; }
.detail-block h3 { margin-bottom: 8px; }
.admin .modal .gallery { margin-bottom: 8px; }
.usage { display: grid; gap: 6px; margin-top: 14px; }
.meter { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.meter > div { height: 100%; min-width: 2px; background: var(--accent-fill); border-radius: 4px; }
.meter > div.warn { background: var(--orange); }
