:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-pressed: #e9e9ee;
  --label: #000000;
  --secondary: #6c6c70;
  --tertiary: #aeaeb2;
  --separator: rgba(60, 60, 67, .18);
  --accent: #1b5377;
  --accent-tint: rgba(27, 83, 119, .12);
  --accent-text: #1b5377;
  --green: #248a3d;
  --green-tint: rgba(52, 199, 89, .16);
  --red: #d70015;
  --red-fill: #e0252f;
  --amber: #a05a00;
  --amber-tint: rgba(255, 149, 0, .16);
  --bar: rgba(249, 249, 249, .86);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-pressed: #2c2c2e;
    --label: #ffffff;
    --secondary: #98989f;
    --tertiary: #636366;
    --separator: rgba(84, 84, 88, .55);
    --accent: #2f7fb3;
    --accent-tint: rgba(100, 170, 220, .18);
    --accent-text: #7cc0ee;
    --green: #30d158;
    --red: #ff6961;
    --red-fill: #e0342e;
    --amber: #ffb340;
    --bar: rgba(29, 29, 31, .86);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
a { color: var(--accent-text); }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 96px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.head { padding: 8px 4px 2px; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; }
.large { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.eyebrow { color: var(--secondary); font-size: 15px; font-weight: 500; }
.muted { color: var(--secondary); }
.muted-center { color: var(--secondary); text-align: center; padding: 22px 8px; }
.tip { color: var(--secondary); font-size: 14px; text-align: center; padding: 2px 16px; }
.empty { text-align: center; color: var(--secondary); padding: 64px 16px; }

.card { background: var(--card); border-radius: var(--radius); padding: 20px; }
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.group-title {
  color: var(--secondary); font-size: 13px; font-weight: 400; text-transform: uppercase;
  letter-spacing: .02em; padding: 8px 16px 0; margin-bottom: -8px;
}

.row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px;
  padding: 10px 14px 10px 16px; text-align: left; position: relative;
}
.row + .row::before, .row + .toggle::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--separator);
}
button.row:active { background: var(--card-pressed); }
.row .icon { width: 16px; height: 16px; color: var(--tertiary); stroke-width: 2.4; }
.row-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-value { color: var(--secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.stack { flex-direction: column; align-items: stretch; gap: 2px; }
.row-line { display: flex; align-items: center; gap: 10px; }
.row-sub { color: var(--secondary); font-size: 14px; overflow-wrap: anywhere; }
.flag { color: var(--amber); font-size: 13px; font-weight: 500; }
.toggle { cursor: pointer; }

.switch {
  appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 31px; margin: 0; flex: none;
  background: rgba(120, 120, 128, .32); position: relative; transition: background .2s; cursor: pointer;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }

.btn {
  display: flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 18px;
  border-radius: var(--radius); background: var(--accent); color: #fff; font-weight: 600; text-decoration: none;
  transition: opacity .12s, transform .12s;
}
.btn:active { opacity: .78; transform: scale(.985); }
.btn:disabled { opacity: .5; }
.btn.wide { width: 100%; }
.btn.big { min-height: 58px; font-size: 19px; }
.btn.tinted { background: var(--accent-tint); color: var(--accent-text); }
.btn.danger { background: var(--red-fill); color: #fff; }
.btn.plain-danger { background: transparent; color: var(--red); font-weight: 500; }
.link { color: var(--accent-text); font-size: 17px; min-height: 44px; padding: 0 4px; }
.link.center { align-self: center; margin-top: 8px; }
.link.add { font-weight: 600; }

.clock-area { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 44px 0 22px; }
.punch {
  width: min(62vw, 232px); aspect-ratio: 1; border-radius: 50%; color: #fff; font-size: 30px; font-weight: 700;
  letter-spacing: -.01em; transition: transform .12s;
}
.punch.in { background: var(--accent); box-shadow: 0 14px 34px rgba(27, 83, 119, .34), inset 0 0 0 6px rgba(255, 255, 255, .13); }
.punch:active { transform: scale(.96); }
.clock-status { color: var(--secondary); }

.on-clock { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 26px 20px 28px; }
.job-name { font-size: 22px; font-weight: 600; margin-top: 8px; overflow-wrap: anywhere; }
.timer { font-size: 58px; font-weight: 300; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.since { color: var(--secondary); font-size: 15px; }

.badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.badge.green { background: var(--green-tint); color: var(--green); }
.badge.amber { background: var(--amber-tint); color: var(--amber); }
.badge.blue { background: var(--accent-tint); color: var(--accent-text); }

.banner {
  background: var(--accent-tint); color: var(--accent-text); border-radius: var(--radius); padding: 12px 14px;
  font-size: 15px; text-align: left; width: 100%;
}
.banner.warn { background: var(--amber-tint); color: var(--amber); }

.total { text-align: center; display: flex; flex-direction: column; gap: 4px; }
.total.flat { padding: 12px 0 4px; background: transparent; }
.total-number { font-size: 44px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.segmented { display: flex; background: rgba(118, 118, 128, .16); border-radius: 9px; padding: 2px; }
.segment { flex: 1; min-height: 36px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.segment.active { background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, .16); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px 8px; text-align: center; }
.stat-number { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--secondary); font-size: 13px; margin-top: 2px; }
.stat.alert .stat-number { color: var(--amber); }

.week-nav { display: flex; align-items: center; justify-content: space-between; }
.week-label { font-weight: 600; }
.nav-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--accent-text); }
.nav-btn:disabled { color: var(--tertiary); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; z-index: 5;
  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: 1px solid var(--separator);
}
.tab {
  flex: 1; max-width: 160px; min-height: 54px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; color: var(--secondary); font-size: 11px; font-weight: 500;
}
.tab.active { color: var(--accent-text); }

dialog.sheet {
  position: fixed; inset: auto 0 0; margin: 0 auto; width: 100%; max-width: 560px; max-height: 88dvh;
  border: 0; padding: 0; background: var(--bg); color: var(--label); border-radius: 14px 14px 0 0;
  overflow-y: auto; animation: rise .24s cubic-bezier(.2, .8, .3, 1);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .38); animation: fade .24s; }
@keyframes rise { from { transform: translateY(40px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 6px;
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.sheet-head h2 { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.sheet-body { padding: 8px 16px calc(env(safe-area-inset-bottom) + 22px); display: flex; flex-direction: column; gap: 12px; }
.sheet-text { color: var(--secondary); text-align: center; padding: 4px 8px; }
.pin { text-align: center; font-size: 46px; font-weight: 700; letter-spacing: .14em; font-variant-numeric: tabular-nums; padding: 12px 0 2px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 13px; color: var(--secondary); padding-left: 4px; }
.field-hint { font-size: 13px; color: var(--secondary); padding-left: 4px; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; font-size: 17px;
  border: 1px solid var(--separator); background: var(--card); -webkit-appearance: none; appearance: none;
}
.card input { background: var(--bg); border-color: transparent; }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.login {
  max-width: 400px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  gap: 16px; padding: calc(env(safe-area-inset-top) + 24px) 16px calc(env(safe-area-inset-bottom) + 24px);
}
.login-logo { width: 156px; height: auto; align-self: center; border-radius: 12px; padding: 8px; background: #fff; }
.login-title { text-align: center; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.login-foot { color: var(--secondary); font-size: 14px; text-align: center; }
.login > .link { align-self: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 72px); z-index: 20;
  max-width: calc(100vw - 32px); width: max-content; background: rgba(40, 40, 42, .94); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 15px; animation: fade .2s;
}
.toast.bad { background: #c1272d; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
