:root {
  --navy: #0f3d5e; --ink: #1c2833; --muted: #6b7a88; --bg: #f4f6f8; --card: #fff; --line: #e1e6eb;
  --green: #1e8e4e; --amber: #c77c02; --red: #c0392b; --orange: #f5a623;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { padding-bottom: env(safe-area-inset-bottom); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
a { color: var(--navy); }

header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: var(--navy); color: #fff; }
header .brand { font-weight: 700; letter-spacing: .3px; }
header nav { display: flex; gap: 4px; }
header nav a { color: #cfe0ee; text-decoration: none; padding: 6px 8px; border-radius: 8px; font-size: 15px; }
@media (max-width: 430px) { header .brand { font-size: 14px; } header nav { gap: 0; } header nav a { padding: 6px 6px; font-size: 14px; } }
header nav a.on { background: rgba(255,255,255,.16); color: #fff; }
#netbar { background: var(--amber); color: #fff; text-align: center; padding: 6px; font-size: 14px; font-weight: 600; }
#netbar.red { background: var(--red); }

main { max-width: 560px; margin: 0 auto; padding: 14px; }
main.wide { max-width: 960px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 0 0 10px; }

label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font-size: 16px; padding: 11px 12px; border: 1px solid #c9d2da; border-radius: 10px; background: #fff; color: var(--ink); }
textarea { min-height: 70px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
input[type=datetime-local] { min-width: 0; font-size: 15px; padding: 10px 8px; }
@media (max-width: 420px) { .row { flex-direction: column; gap: 0; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px;
  padding: 12px 16px; font-size: 16px; font-weight: 600; cursor: pointer; background: #e4e9ee; color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.go { background: var(--green); color: #fff; }
.btn.stop { background: var(--red); color: #fff; }
.btn.warn { background: var(--orange); color: #1c2833; }
.btn.ghost { background: transparent; border: 1px solid #c9d2da; }
.btn.ghost.light { color: #fff; border-color: rgba(255,255,255,.5); }
.btn.big { width: 100%; padding: 20px; font-size: 20px; border-radius: 16px; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.sm { padding: 7px 10px; font-size: 14px; border-radius: 9px; }
.linkbtn { background: none; border: 0; color: var(--navy); text-decoration: underline; font-size: 15px; padding: 8px 0; cursor: pointer; }
.actions { display: grid; gap: 10px; margin-top: 14px; }
.actions.two { grid-template-columns: 1fr 1fr; }

.status { text-align: center; padding: 22px 16px; }
.status .big-state { font-size: 26px; font-weight: 700; }
.status .since { color: var(--muted); margin-top: 4px; }
.status .elapsed { font-size: 40px; font-variant-numeric: tabular-nums; font-weight: 300; margin-top: 8px; }
.status.in { border-color: #b7e0c6; background: #f2fbf5; }
.status.break { border-color: #f2d49b; background: #fffaf0; }

.banner { border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.banner.red { background: #fdecea; border: 1px solid #f3b8b1; }
.banner.amber { background: #fff6e5; border: 1px solid #f2d49b; }

.daynav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.daynav button { background: none; border: 0; font-size: 26px; color: var(--navy); padding: 0 12px; cursor: pointer; }
.daynav button:disabled { opacity: .25; }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: center; }
.totals b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }

.punch { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.punch:first-child { border-top: 0; }
.punch .t { width: 78px; font-weight: 600; font-variant-numeric: tabular-nums; }
.punch .what { flex: 1; min-width: 0; }
.punch .what .sub { font-size: 13px; color: var(--muted); }
.punch img { width: 48px; height: 48px; object-fit: cover; border-radius: 10px; cursor: pointer; background: #ddd; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.green { background: var(--green); } .dot.amber { background: var(--amber); } .dot.red { background: var(--red); }
.flag { display: inline-block; font-size: 12px; padding: 2px 7px; border-radius: 20px; margin: 2px 4px 0 0; }
.flag.amber { background: #fff1d6; color: #7a4c00; } .flag.red { background: #fde0dc; color: #8e2418; }
.shift-head { font-size: 13px; color: var(--muted); margin: 12px 0 2px; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  max-width: 92vw; padding: 14px 18px; border-radius: 14px; color: #fff; font-weight: 600; z-index: 30;
  box-shadow: 0 6px 24px rgba(0,0,0,.2); background: var(--ink); pointer-events: none; }
#toast.green { background: var(--green); } #toast.amber { background: var(--amber); } #toast.red { background: var(--red); }

#camera { position: fixed; inset: 0; z-index: 20; background: #000; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 14px); }
.cam-box { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 16px; }
#cam-video { width: 100%; max-height: 100%; object-fit: cover; transform: scaleX(-1); border-radius: 16px; background: #111; }
.cam-msg { color: #fff; text-align: center; min-height: 22px; margin: 12px 0; }
.cam-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

#lightbox { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; }
#lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 12px; }

.card.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 20px; background: #e4e9ee; }
.pill.in { background: #d9f2e3; color: #145c33; }
.pill.off { background: #eee; color: #888; }
.copybox { display: flex; gap: 8px; margin-top: 8px; }
.copybox input { font-size: 13px; }
.err { color: var(--red); font-size: 14px; min-height: 18px; margin-top: 8px; }
.ok { color: var(--green); font-size: 14px; margin-top: 8px; }
code.secret { display: block; word-break: break-all; background: #f0f3f6; padding: 10px; border-radius: 8px; font-size: 14px; }

.totals.three { grid-template-columns: 1fr 1fr 1fr; }
.warn-text { color: var(--amber); }
.punch.pending { opacity: .85; }
.punch.pending .t { color: var(--amber); }
.install-card { border-color: #f2d49b; background: #fffaf0; }
.install-card ol { padding-left: 20px; margin: 8px 0; line-height: 1.5; }
.card.timer.on { border-color: #b9cde0; background: #f3f8fc; }
.tm-proj { font-size: 20px; font-weight: 700; margin-top: 2px; }
.elapsed.small-el { font-size: 30px; font-variant-numeric: tabular-nums; font-weight: 300; margin: 6px 0 2px; }
.wday { padding: 10px 0; border-top: 1px solid var(--line); }
.wday:first-child { border-top: 0; }
.wday.empty { color: var(--muted); padding: 6px 0; }
.wday-h { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.wline { font-size: 14px; margin: 5px 0 0 16px; }
.timer-line { color: #234; }
table.plain { min-width: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.off td { color: var(--muted); }
.gap-top { margin-top: 10px; }
