:root {
  --bg: #f3f4f1;
  --card: #ffffff;
  --ink: #1c1f1d;
  --muted: #66706a;
  --line: #dde1dc;
  --brand: #1f4d3a;
  --brand-ink: #ffffff;
  --brand-edge: #1f4d3a;
  --brand-deep: #1f4d3a;
  --accent: #e8a317;
  --ok: #1f7a4a;
  --ok-bg: #e3f3e9;
  --bad: #b3261e;
  --bad-bg: #fbe7e5;
  --warn-bg: #fff4d6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.04);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--brand-deep); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* top bar */
.topbar {
  background: var(--brand); color: var(--brand-ink);
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  position: sticky; top: 0; z-index: 5;
}
.topbar { border-bottom: 1px solid var(--brand-edge); }
.topbar .brand { font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
.topbar .brand::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--accent); }
.topbar .spacer { flex: 1; }
.topbar a, .topbar button.link { color: var(--brand-ink); opacity: .9; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 560px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.row > .shrink { flex: 0 0 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-deep); outline-offset: 0; border-color: var(--brand-deep); }
input[type=checkbox] { width: auto; margin-right: 6px; transform: scale(1.15); }
.check { display: flex; align-items: center; font-size: .95rem; color: var(--ink); font-weight: 500; }

button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--brand-edge); border-radius: 9px; padding: 10px 16px;
  background: var(--brand); color: var(--brand-ink); cursor: pointer; white-space: nowrap;
}
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
button.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
button.ghost { background: transparent; color: var(--brand-deep); padding: 6px 8px; border-color: transparent; }
button.link { background: none; border: 0; padding: 0; color: var(--brand-deep); text-decoration: underline; font-weight: 500; }
button.sm { padding: 6px 10px; font-size: .85rem; }

/* big clock buttons */
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.big-actions button { padding: 22px 12px; font-size: 1.15rem; border-radius: 14px; }
.big-actions .full { grid-column: 1 / -1; }
.btn-in { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-out { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-break { background: var(--accent); color: #2b1d00; border-color: var(--accent); }

.status { display: flex; align-items: center; gap: 12px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #b9c0bb; flex: 0 0 auto; }
.dot.working { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.dot.break { background: var(--accent); box-shadow: 0 0 0 4px var(--warn-bg); }
.status .big { font-size: 1.4rem; font-weight: 700; }
.timer { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbf9; position: sticky; top: 0; }
tbody tr:hover { background: #fafbf9; }
tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: #7a5300; }
.badge.grey { background: #eceeeb; color: var(--muted); }

/* tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; background: var(--card); padding: 0 12px; position: sticky; top: 48px; z-index: 4; }
.tabs button { background: none; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 12px 12px 10px; }
.tabs button.active { color: var(--brand-deep); border-bottom-color: var(--brand-deep); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .8rem; color: var(--muted); }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

.day { border-top: 1px solid var(--line); padding: 12px 0; }
.day:first-child { border-top: 0; }
.day-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: #eef2ee; border-radius: 8px; padding: 3px 9px; font-size: .85rem; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,20,17,.45); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; z-index: 20; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 720px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 40; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.error { background: var(--bad); }

.login-card { max-width: 380px; margin: 9vh auto 0; }
.login-card h1 { margin-bottom: 4px; }
.stack > * + * { margin-top: 12px; }
.note { background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.help { font-size: .85rem; color: var(--muted); margin-top: 6px; }
details summary { cursor: pointer; font-weight: 600; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
@media print { .topbar, .tabs, .no-print, button { display: none !important; } .card { box-shadow: none; } }
