:root {
  --paper: #eef2f6;
  --surface: #ffffff;
  --ink: #13233f;
  --muted: #5b6b82;
  --line: #d5dde7;
  --work: #0f7b6c;
  --work-soft: #d6efe9;
  --pause: #b7790a;
  --pause-soft: #f6e8c8;
  --out: #24427a;
  --alert: #b3261e;
  --alert-soft: #f8dcd9;
  --plan: #c9d3e0;
  --radius-l: 18px;
  --radius-s: 8px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1626;
    --surface: #17223a;
    --ink: #e6ecf5;
    --muted: #9aa8bd;
    --line: #2a3853;
    --work: #3fc1a8;
    --work-soft: #12382f;
    --pause: #e2ad3e;
    --pause-soft: #3d3014;
    --out: #8fb0ee;
    --alert: #ff8a80;
    --alert-soft: #45201d;
    --plan: #2c3b58;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--work); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; line-height: 1.2; }
h2 { font-size: 1.125rem; line-height: 1.3; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* ---------- Shell ---------- */
.screen {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 96px);
  display: grid;
  gap: 20px;
}
.screen.plain { padding-bottom: 32px; }
.topline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.tabs {
  position: fixed; inset: auto 0 0 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.tabs a {
  display: grid; justify-items: center; gap: 2px;
  padding: 10px 4px 12px;
  color: var(--muted); text-decoration: none; font-size: 0.75rem; font-weight: 500;
}
.tabs a svg { width: 22px; height: 22px; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] svg { color: var(--work); }

/* ---------- Clock ---------- */
.clock { display: grid; gap: 2px; }
.clock .time { font-size: clamp(3.5rem, 18vw, 5rem); font-weight: 300; line-height: 1; letter-spacing: -0.04em; }
.clock .date { color: var(--muted); }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 600;
  background: var(--plan); color: var(--ink);
  white-space: nowrap;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.in_progress { background: var(--work-soft); color: var(--work); }
.status.on_break { background: var(--pause-soft); color: var(--pause); }
.status.present { background: var(--surface); color: var(--out); border: 1px solid var(--line); }
.status.incomplete, .status.absent { background: var(--alert-soft); color: var(--alert); }

/* ---------- Day card: the time strip ---------- */
.daycard {
  background: var(--surface);
  border-radius: var(--radius-l);
  padding: 16px;
  display: grid; gap: 14px;
}
.strip { position: relative; height: 44px; }
.strip .tick { position: absolute; top: 14px; bottom: 14px; width: 1px; background: var(--line); }
.strip .plan { position: absolute; top: 10px; bottom: 10px; border-radius: 8px; background: var(--plan); }
.strip .seg { position: absolute; top: 6px; bottom: 6px; border-radius: 6px; background: var(--work); }
.strip .seg.open { background: repeating-linear-gradient(135deg, var(--work) 0 6px, color-mix(in srgb, var(--work) 70%, transparent) 6px 12px); }
.strip .gap { position: absolute; top: 18px; bottom: 18px; background: var(--pause); border-radius: 2px; }
.strip .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); border-radius: 1px; }
.strip-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.75rem; margin-top: -6px; }

.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.figure { display: grid; gap: 0; }
.figure b { font-size: 1.25rem; font-weight: 600; line-height: 1.2; }
.figure span { color: var(--muted); font-size: 0.8125rem; }
.figure.warn b { color: var(--alert); }

/* ---------- Punch ---------- */
.punch { display: grid; gap: 10px; }
.btn {
  appearance: none; border: 0; cursor: pointer;
  border-radius: 14px; padding: 14px 18px;
  font-weight: 600; font-size: 1rem;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line);
  min-height: 48px;
}
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { border: 0; color: #fff; font-size: 1.25rem; min-height: 72px; border-radius: var(--radius-l); }
.btn.primary.check_in { background: var(--work); }
.btn.primary.check_out { background: var(--out); }
.btn.primary.break_in { background: var(--pause); }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0e1626; } }
.btn.primary small { display: block; font-size: 0.8125rem; font-weight: 500; opacity: 0.85; }
.btn-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.btn-row > * { min-width: 0; }
.btn.link { background: none; border: 0; padding: 8px 0; color: var(--out); font-weight: 600; min-height: auto; text-align: left; }
.btn.danger { color: var(--alert); }

.where { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9375rem; }
.where svg { flex: none; width: 20px; height: 20px; margin-top: 2px; }
.where.ok { color: var(--work); }
.where.bad { color: var(--alert); }
.where.wait { color: var(--muted); }

.notice { border-radius: var(--radius-s); padding: 12px 14px; background: var(--alert-soft); color: var(--alert); font-size: 0.9375rem; }
.notice.info { background: var(--work-soft); color: var(--work); }
.notice.calm { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }

/* ---------- Lists ---------- */
.list { display: grid; background: var(--surface); border-radius: var(--radius-l); overflow: hidden; }
.row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .mark { width: 4px; align-self: stretch; border-radius: 2px; background: var(--plan); }
.row .mark.present { background: var(--work); }
.row .mark.in_progress { background: var(--work); }
.row .mark.incomplete, .row .mark.absent { background: var(--alert); }
.row .mark.leave, .row .mark.holiday { background: var(--pause); }
.row .main { display: grid; min-width: 0; }
.row .main span { color: var(--muted); font-size: 0.8125rem; }
.row .end { text-align: right; font-weight: 600; }
.row .end span { display: block; color: var(--muted); font-weight: 400; font-size: 0.8125rem; }
.row .end .btn.link { display: block; margin-left: auto; padding: 4px 0 0; font-size: 0.875rem; }
html, body { overflow-x: hidden; }
.empty { padding: 20px 16px; color: var(--muted); }

/* ---------- Stats ---------- */
.month { display: flex; align-items: center; justify-content: space-between; }
.month button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.totals { background: var(--surface); border-radius: var(--radius-l); padding: 16px; display: grid; gap: 16px; }
.totals .lead b { font-size: 2.25rem; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.totals .lead span { color: var(--muted); }
.meter { height: 8px; border-radius: 4px; background: var(--plan); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--work); border-radius: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }

/* ---------- Forms ---------- */
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 500; font-size: 0.9375rem; }
input, select, textarea {
  width: 100%; min-width: 0; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  min-height: 48px;
}
textarea { min-height: 88px; resize: vertical; }
.field-error { color: var(--alert); font-size: 0.875rem; font-weight: 400; }
.panel { background: var(--surface); border-radius: var(--radius-l); padding: 16px; display: grid; gap: 14px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; align-content: center; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand img { width: 44px; height: 44px; }

/* ---------- Scanner ---------- */
.scanner { position: relative; border-radius: var(--radius-l); overflow: hidden; background: #000; aspect-ratio: 1; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; inset: 18%; border: 3px solid #fff; border-radius: 16px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 84px);
  max-width: 488px; margin: 0 auto;
  background: var(--ink); color: var(--paper);
  padding: 12px 16px; border-radius: 12px; font-weight: 500; z-index: 10;
}
@media (prefers-reduced-motion: no-preference) {
  #toast:not([hidden]) { animation: rise 0.18s ease-out; }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } }
}
.lang-pick { text-align: center; } .lang-pick select { padding: 6px 10px; border-radius: 8px; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* punches waiting for internet */
.queued { display: grid; gap: 10px; margin: 16px 0; padding: 14px; border-radius: var(--radius-l); border: 1px dashed var(--pause); background: color-mix(in srgb, var(--pause) 8%, var(--surface)); }
.queued p { margin: 0; }
.row .mark.wait { background: transparent; border: 2px solid var(--pause); }

/* notifications */
.invite, .news { display: grid; gap: 8px; margin: 16px 0; padding: 14px; border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--line); }
.invite p, .news p { margin: 0; }
.news { border-left: 4px solid var(--work); }
.news .btn.link { justify-self: start; padding-left: 0; }
.ok { color: var(--work); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* My contracts (Account) */
#contracts .list { list-style: none; margin: 8px 0 0; padding: 0; background: transparent; }
#contracts li + li { border-top: 1px solid var(--line, #e5e7eb); }
.linkrow { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 10px 0; background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
