:root {
  --y: #ffd500;
  --y-d: #e6c000;
  --ink: #1f1f1f;
  --ink-2: #4a4a4a;
  --mute: #8a8a8a;
  --line: #e7e7e7;
  --bg: #f4f4f2;
  --card: #ffffff;
  --ok: #1f9d55;
  --stop: #1f1f1f;
  --warn: #fff4cc;
  --red: #c62828;
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: #fff; border-bottom: 4px solid var(--y); }
.top .logo { height: 38px; display: block; }
.top-r { text-align: right; min-width: 0; }
.top-r .who { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-r .role { font-size: 12px; color: var(--mute); }
.demo-bar { background: var(--ink); color: var(--y); font-size: 12.5px; text-align: center; padding: 6px 12px; }
.demo-bar button { background: none; border: 0; color: #fff; text-decoration: underline; padding: 0 0 0 6px; font-size: 12.5px; }

main { max-width: 760px; margin: 0 auto; padding: 16px 14px calc(96px + var(--safe-b)); }
h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); margin: 22px 2px 8px; font-weight: 700; }

/* ---------- bottom tabs ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--ink); padding-bottom: var(--safe-b); }
.tabs button { flex: 1; background: none; border: 0; color: #bdbdbd; padding: 9px 4px 8px; font-size: 11.5px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tabs button svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--y); }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.05); margin-bottom: 12px; }
.card.flat { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.click { cursor: pointer; }
.row.click:active { background: #fafafa; }
.row .main { flex: 1; min-width: 0; }
.row .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { font-size: 13px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2.wrap, .row .t1.wrap { white-space: normal; }
.row .val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-head { display: flex; justify-content: space-between; padding: 8px 16px; background: #fafafa; font-size: 13px; font-weight: 700; color: var(--ink-2); border-top: 1px solid var(--line); }
.day-head:first-child { border-top: 0; }
.empty { text-align: center; color: var(--mute); padding: 26px 16px; font-size: 14px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: #eee; color: var(--ink-2); vertical-align: 1px; margin-left: 4px; }
.tag.y { background: var(--y); color: var(--ink); }
.tag.g { background: #dff3e7; color: var(--ok); }
.tag.r { background: #fde3e3; color: var(--red); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: #fff; border-radius: var(--r); padding: 12px; }
.kpi .k { font-size: 12px; color: var(--mute); }
.kpi .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- buttons & forms ---------- */
.btn { display: block; width: 100%; border: 0; border-radius: var(--r); padding: 14px 16px; font-weight: 700; background: #e9e9e6; }
.btn.y { background: var(--y); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink-2); font-weight: 600; }
.btn.danger { background: #fde3e3; color: var(--red); }
.btn.sm { display: inline-block; width: auto; padding: 8px 14px; border-radius: 10px; font-size: 14px; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.big { font-size: 22px; letter-spacing: .06em; padding: 22px; border-radius: 18px; margin: 14px 0 8px; box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.btn.big.go { background: var(--y); }
.btn.big.go:not(:disabled):active { background: var(--y-d); transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.btn.big.stop { background: var(--stop); color: #fff; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }

label.f { display: block; font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 10px 0 5px; }
input.i, select.i, textarea.i { width: 100%; border: 1.5px solid #dcdcdc; border-radius: 11px; padding: 11px 12px; background: #fff; outline: none; }
input.i:focus, select.i:focus, textarea.i:focus { border-color: var(--ink); }
textarea.i { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }
.err { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 1em; }
.hint { font-size: 13px; color: var(--mute); margin-top: 8px; }

/* ---------- login ---------- */
.login { max-width: 400px; margin: 0 auto; padding: calc(40px + var(--safe-t)) 20px 40px; }
.login .logo { width: 210px; display: block; margin: 0 auto 6px; }
.login .sub { text-align: center; color: var(--mute); margin-bottom: 26px; }
.login .card { padding: 20px; }
.demo-pick { margin-top: 18px; }
.demo-pick .btn { margin-top: 8px; }

/* ---------- clock ---------- */
.hello { font-size: 22px; font-weight: 800; margin: 2px 2px 2px; }
.today { color: var(--ink-2); margin: 0 2px 6px; }
.today b { font-variant-numeric: tabular-nums; }
.jobs { display: grid; gap: 8px; }
.job { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 14px; background: #fff; border: 2px solid transparent; border-radius: var(--r); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.job .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #cfcfcf; flex: none; }
.job .n { font-weight: 700; }
.job .a { font-size: 13px; color: var(--mute); }
.job.sel { border-color: var(--ink); }
.job.sel .dot { border-color: var(--ink); background: radial-gradient(circle, var(--ink) 0 5px, var(--y) 6px); }

.run { background: var(--ink); color: #fff; text-align: center; padding: 22px 16px 24px; }
.run-label { display: inline-flex; align-items: center; gap: 8px; color: var(--y); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74,222,128,.7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }
.run-job { font-size: 22px; font-weight: 800; margin-top: 8px; }
.run-since { color: #bdbdbd; font-size: 14px; }
.run-timer { font-size: 52px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; margin-top: 8px; color: var(--y); }
.warn { background: var(--warn); border: 1.5px solid var(--y-d); }
.warn b { display: block; margin-bottom: 4px; }

.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { width: 72px; height: 72px; border-radius: 10px; background: #eee center/cover; border: 0; padding: 0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-add { width: 72px; height: 72px; border-radius: 10px; border: 2px dashed #cfcfcf; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--ink-2); cursor: pointer; line-height: 1.2; }

/* ---------- month switcher, filters ---------- */
.month { display: flex; align-items: center; justify-content: space-between; background: #fff; border-radius: var(--r); padding: 6px; margin-bottom: 12px; }
.month button { background: none; border: 0; width: 44px; height: 40px; border-radius: 10px; font-size: 20px; }
.month button:active { background: #f0f0f0; }
.month .m { font-weight: 800; text-transform: capitalize; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.filters select { padding: 9px 10px; font-size: 14px; }
.toolbar { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin: 4px 0 10px; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--mute); font-weight: 700; padding: 10px 16px 6px; }
table.t td { padding: 10px 16px; border-top: 1px solid var(--line); }
table.t .r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.click { cursor: pointer; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }
.modal h2 { margin-top: 0; }
.modal .btns { margin-top: 16px; }
.photo-full { width: 100%; border-radius: 12px; display: block; background: #eee; min-height: 120px; }
.toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 60; font-size: 14px; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--red); }
.spin { text-align: center; padding: 60px 0; color: var(--mute); }
.offline { background: var(--red); color: #fff; font-size: 12.5px; text-align: center; padding: 5px; }
