/* Base reset */
:root{color-scheme:light;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
body{margin:0;font-size:14px;font-family:system-ui,sans-serif;min-height:100vh}
img{max-width:100%}
[hidden]{display:none!important}

/* Layout: one narrow column like a printed time card — sticky header with tabs, punch panel, then the card rows */
:root{
  --bg:#EDF1F0; --surface:#FFFFFF; --surface-2:#F5F8F7; --ink:#12201C; --muted:#5A6A65; --line:#D6DFDC;
  --accent:#0F6B57; --accent-ink:#FFFFFF; --accent-soft:#DCEFE8;
  --ok:#1C7F52; --ok-soft:#DDF2E6; --late:#A86A12; --late-soft:#FBEEDA; --bad:#B93A34; --bad-soft:#F8E0DE;
  --leave:#4E52B8; --leave-soft:#E5E6FA; --hol:#22719B; --hol-soft:#DDEDF6; --wfh:#7A4FA8; --wfh-soft:#EFE5F8;
  --f-display:"Bricolage Grotesque",ui-sans-serif,system-ui,sans-serif;
  --f-body:"Figtree",ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --f-mono:"JetBrains Mono",ui-monospace,"SFMono-Regular",Menlo,Consolas,monospace;
  --r:14px;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#0C1412; --surface:#141F1C; --surface-2:#1A2824; --ink:#E5EEEA; --muted:#93A49E; --line:#25352F;
  --accent:#3FBF9B; --accent-ink:#04221A; --accent-soft:#173A31;
  --ok:#4CC38A; --ok-soft:#163529; --late:#E3A54A; --late-soft:#3A2C14; --bad:#EE7069; --bad-soft:#3D1E1C;
  --leave:#A0A3F2; --leave-soft:#24264A; --hol:#6FB6DE; --hol-soft:#15303F; --wfh:#C6A0EE; --wfh-soft:#2E2340; color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#0C1412; --surface:#141F1C; --surface-2:#1A2824; --ink:#E5EEEA; --muted:#93A49E; --line:#25352F;
  --accent:#3FBF9B; --accent-ink:#04221A; --accent-soft:#173A31;
  --ok:#4CC38A; --ok-soft:#163529; --late:#E3A54A; --late-soft:#3A2C14; --bad:#EE7069; --bad-soft:#3D1E1C;
  --leave:#A0A3F2; --leave-soft:#24264A; --hol:#6FB6DE; --hol-soft:#15303F; --wfh:#C6A0EE; --wfh-soft:#2E2340; color-scheme:dark}

*{box-sizing:border-box}
body{background:var(--bg);color:var(--ink);font-family:var(--f-body);font-size:15px;line-height:1.5;-webkit-font-smoothing:antialiased}
body::before{content:"";position:fixed;inset:0 0 auto;height:env(safe-area-inset-top,0px);z-index:10;background:var(--bg)}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:8px}
.num{font-family:var(--f-mono);font-variant-numeric:tabular-nums}

header.top{position:sticky;top:env(safe-area-inset-top,0px);z-index:5;background:color-mix(in srgb,var(--bg) 88%,transparent);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid var(--line)}
.wrap{max-width:780px;margin:0 auto;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
.top .wrap{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-block:10px;flex-wrap:wrap}
.brand{display:flex;align-items:center;gap:10px;font-family:var(--f-display);font-weight:700;font-size:18px;letter-spacing:-.01em}
.brand .mark{width:28px;height:28px;border-radius:8px;background:var(--accent);color:var(--accent-ink);display:grid;place-items:center;font-family:var(--f-mono);font-size:12px;font-weight:700}
.tabs{display:flex;gap:2px;background:var(--surface-2);border:1px solid var(--line);border-radius:999px;padding:3px}
.tabs button{border:0;background:transparent;padding:6px 13px;border-radius:999px;font-weight:600;font-size:14px;color:var(--muted)}
.tabs button[aria-selected="true"]{background:var(--surface);color:var(--ink);box-shadow:0 1px 2px rgb(0 0 0/.08)}

main.wrap{padding-block:20px 48px;display:flex;flex-direction:column;gap:18px}
h1,h2,h3{font-family:var(--f-display);margin:0;text-wrap:balance;letter-spacing:-.015em}
.eyebrow{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600}
.muted{color:var(--muted)}
.sec-head{display:flex;justify-content:space-between;align-items:baseline;gap:10px;flex-wrap:wrap}
.sec-head h3{font-size:18px}

/* Today */
.today-head{display:flex;justify-content:space-between;align-items:flex-end;gap:12px;flex-wrap:wrap}
.today-head h1{font-size:clamp(24px,5vw,30px);font-weight:700}
.clock{font-family:var(--f-mono);font-size:clamp(28px,7vw,40px);font-weight:700;letter-spacing:-.02em;font-variant-numeric:tabular-nums;line-height:1}
.panel{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:18px;display:flex;flex-direction:column;gap:16px}
.stamps{display:grid;grid-template-columns:repeat(3,1fr);border:1px dashed var(--line);border-radius:10px;overflow:hidden}
.stamp{padding:12px 14px;display:flex;flex-direction:column;gap:2px;min-width:0}
.stamp+.stamp{border-left:1px dashed var(--line)}
.stamp .v{font-family:var(--f-mono);font-variant-numeric:tabular-nums;font-size:clamp(16px,4.2vw,22px);font-weight:700;white-space:nowrap}
.punch{width:100%;border:0;border-radius:12px;padding:18px;font-family:var(--f-display);font-weight:700;font-size:20px;letter-spacing:.01em;transition:transform .12s ease, filter .12s ease}
.punch:active{transform:scale(.985)}
.punch.in{background:var(--accent);color:var(--accent-ink)}
.punch.out{background:var(--ink);color:var(--bg)}
.punch.out.confirm{background:var(--late);color:#fff}
.punch:hover{filter:brightness(1.06)}
.done{background:var(--ok-soft);color:var(--ok);border-radius:12px;padding:16px;text-align:center;font-weight:600}
.row-actions{display:flex;gap:8px;flex-wrap:wrap}
.btn{border:1px solid var(--line);background:var(--surface);border-radius:10px;padding:9px 14px;font-weight:600;font-size:14px}
.btn:hover{background:var(--surface-2)}
.btn:disabled{opacity:.55;cursor:progress}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.small{padding:6px 12px;font-size:13.5px}
.btn.danger{color:var(--bad)}
.btn.danger.armed{background:var(--bad);border-color:var(--bad);color:#fff}
.mode-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.mode-row .seg{min-width:200px}

.rail{position:relative;height:10px;border-radius:99px;background:var(--surface-2);border:1px solid var(--line);margin-top:6px}
.rail .fill{position:absolute;top:-1px;bottom:-1px;border-radius:99px;background:var(--accent)}
.rail .now{position:absolute;top:-6px;width:2px;height:20px;background:var(--ink);border-radius:2px;transform:translateX(-1px)}
.rail-labels{display:flex;justify-content:space-between;font-size:12px;color:var(--muted);margin-top:6px}

.chip{display:inline-flex;align-items:center;gap:6px;padding:3px 10px;border-radius:999px;font-size:12.5px;font-weight:600;white-space:nowrap}
.chip::before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor}
.tag{display:inline-block;padding:1px 7px;border-radius:6px;font-size:11px;font-weight:700;letter-spacing:.04em;background:var(--wfh-soft);color:var(--wfh);vertical-align:1px}
.s-ok{background:var(--ok-soft);color:var(--ok)}
.s-late{background:var(--late-soft);color:var(--late)}
.s-bad{background:var(--bad-soft);color:var(--bad)}
.s-leave{background:var(--leave-soft);color:var(--leave)}
.s-hol{background:var(--hol-soft);color:var(--hol)}
.s-off{background:var(--surface-2);color:var(--muted)}
.s-live{background:var(--accent-soft);color:var(--accent)}

.week{display:grid;grid-template-columns:repeat(7,1fr);gap:6px}
.wd{border:1px solid var(--line);background:var(--surface);border-radius:10px;padding:8px 6px;display:flex;flex-direction:column;align-items:center;gap:4px;text-align:center;min-width:0}
.wd.off{background:transparent;border-style:dashed}
.wd.is-today{border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.wd .dn{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:600}
.wd .dd{font-family:var(--f-display);font-weight:700;font-size:17px;line-height:1}
.wd .dot{width:8px;height:8px;border-radius:50%;background:currentColor}
.wd .t{font-family:var(--f-mono);font-size:10.5px;color:var(--muted);white-space:nowrap}

/* Month */
.month-bar{display:flex;align-items:center;justify-content:space-between;gap:10px}
.month-bar h2{font-size:24px;text-align:center}
.iconbtn{width:38px;height:38px;border-radius:10px;border:1px solid var(--line);background:var(--surface);display:grid;place-items:center;font-size:18px;flex:none}
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.stat{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:2px;min-width:0}
.stat .v{font-family:var(--f-display);font-weight:700;font-size:24px;line-height:1.1;font-variant-numeric:tabular-nums}
.stat .k{font-size:12px;color:var(--muted)}
.stat.hero{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.stat.hero .k{color:inherit;opacity:.85}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);overflow:hidden}
.card-head,.trow{display:grid;grid-template-columns:76px 1fr 1fr 74px minmax(0,1.3fr);gap:8px;align-items:center;padding:10px 14px}
.card-head{font-size:11.5px;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:600;background:var(--surface-2);border-bottom:1px solid var(--line)}
.trow{width:100%;border:0;border-bottom:1px solid var(--line);background:transparent;text-align:left}
.trow:last-child{border-bottom:0}
.trow:hover{background:var(--surface-2)}
.trow.off{color:var(--muted)}
.trow.off .tdate b{font-weight:500}
.trow.is-today{box-shadow:inset 3px 0 0 var(--accent)}
.tdate{display:flex;flex-direction:column;line-height:1.2}
.tdate b{font-family:var(--f-display);font-size:16px}
.tdate span{font-size:11.5px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}
.trow .num{font-size:14px;white-space:nowrap}
.trow .st{display:flex;justify-content:flex-end;min-width:0}
.trow .st .chip{max-width:100%;overflow:hidden;text-overflow:ellipsis}
.report{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:12px 14px}
.report .rule-text{flex:1 1 220px}

.rule{display:flex;align-items:center;justify-content:space-between;gap:14px;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:12px 14px}
.rule.on{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 35%,var(--line))}
.rule-text{display:flex;flex-direction:column;gap:2px;min-width:0}
.rule-text b{font-family:var(--f-display);font-size:16px}
.rule-text span{font-size:13px;color:var(--muted)}
.switch{flex:none;width:50px;height:30px;border-radius:99px;border:1px solid var(--line);background:var(--surface-2);position:relative;padding:0;transition:background .15s ease}
.switch span{position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:var(--muted);transition:transform .15s ease, background .15s ease}
.switch[aria-checked="true"]{background:var(--accent);border-color:var(--accent)}
.switch[aria-checked="true"] span{transform:translateX(20px);background:var(--accent-ink)}

/* Leave */
.bal{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:8px}
.bcard{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:14px;display:flex;flex-direction:column;gap:6px;min-width:0}
.bcard .name{font-weight:600;font-size:14px;overflow-wrap:anywhere}
.bcard .big{font-family:var(--f-display);font-weight:700;font-size:28px;line-height:1;font-variant-numeric:tabular-nums}
.bcard .big small{font-family:var(--f-body);font-size:13px;font-weight:500;color:var(--muted);margin-left:4px}
.bcard .sub{font-size:12.5px;color:var(--muted)}
.bar{height:6px;border-radius:99px;background:var(--surface-2);overflow:hidden}
.bar i{display:block;height:100%;background:var(--leave);border-radius:99px}
.bcard.over .big{color:var(--bad)}
.bcard.over .bar i{background:var(--bad)}
.list{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);overflow:hidden}
.lrow{display:grid;grid-template-columns:96px minmax(0,1fr) auto;gap:10px;align-items:center;padding:10px 14px;border:0;border-bottom:1px solid var(--line);width:100%;background:transparent;text-align:left}
.lrow:last-child{border-bottom:0}
.lrow:hover{background:var(--surface-2)}
.lrow.past{color:var(--muted)}
.lrow .d{font-family:var(--f-mono);font-size:13px;white-space:nowrap}
.lrow .n{min-width:0;overflow-wrap:anywhere;font-weight:500}
.lrow .w{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}
.next-hol{display:flex;align-items:center;gap:12px;background:var(--hol-soft);color:var(--hol);border-radius:12px;padding:12px 14px;font-weight:600}
.next-hol .when{font-family:var(--f-display);font-size:22px;line-height:1}
.empty-row{padding:18px 14px;color:var(--muted);font-size:14px}

/* Settings */
.field{display:flex;flex-direction:column;gap:6px;min-width:0}
.field label,.flabel{font-weight:600;font-size:14px}
.field input,.field select,.field textarea{border:1px solid var(--line);background:var(--surface-2);border-radius:10px;padding:10px 12px;width:100%;font:inherit;color:var(--ink)}
.field textarea{min-height:150px;font-family:var(--f-mono);font-size:13.5px;line-height:1.5;resize:vertical}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.daypick{display:flex;gap:6px;flex-wrap:wrap}
.daypick label{position:relative}
.daypick input{position:absolute;opacity:0;inset:0}
.daypick span{display:inline-block;padding:7px 12px;border-radius:999px;border:1px solid var(--line);font-weight:600;font-size:13.5px;color:var(--muted)}
.daypick input:checked+span{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.daypick input:focus-visible+span{outline:2px solid var(--accent);outline-offset:2px}
.note{background:var(--surface-2);border-radius:10px;padding:12px 14px;font-size:14px}
.note ul{margin:6px 0 0;padding-left:18px}
.note li+li{margin-top:4px}
.ltrow{display:grid;grid-template-columns:minmax(0,1fr) 92px 38px;gap:8px;align-items:end}
.ltrow .field label{font-size:12px;color:var(--muted);font-weight:600}
.check{display:flex;align-items:center;gap:8px;font-weight:600;font-size:14px}
.check input{width:18px;height:18px;accent-color:var(--accent)}

/* States */
.empty{text-align:center;padding:48px 16px;display:flex;flex-direction:column;gap:8px;align-items:center}
.empty h2{font-size:22px}
.empty p{max-width:42ch;margin:0;color:var(--muted)}

/* Sheet */
.sheet{position:fixed;inset:0;z-index:20;background:rgb(6 14 12/.45);display:flex;align-items:flex-end;justify-content:center}
.sheet-card{background:var(--surface);width:100%;max-width:520px;border-radius:18px 18px 0 0;padding:20px max(18px,env(safe-area-inset-right,0px)) calc(20px + env(safe-area-inset-bottom,0px)) max(18px,env(safe-area-inset-left,0px));display:flex;flex-direction:column;gap:14px;max-height:92%;overflow:auto}
@media (min-width:640px){.sheet{align-items:center}.sheet-card{border-radius:18px}}
.seg{display:grid;grid-auto-columns:1fr;grid-auto-flow:column;background:var(--surface-2);border:1px solid var(--line);border-radius:10px;padding:3px;gap:2px}
.seg label{position:relative;text-align:center}
.seg input{position:absolute;opacity:0;inset:0}
.seg span{display:block;padding:7px 4px;border-radius:8px;font-weight:600;font-size:14px;color:var(--muted)}
.seg input:checked+span{background:var(--surface);color:var(--ink);box-shadow:0 1px 2px rgb(0 0 0/.1)}
.seg input:focus-visible+span{outline:2px solid var(--accent)}
.sheet-actions{display:flex;gap:8px;justify-content:space-between;flex-wrap:wrap}
.sheet-actions .r{display:flex;gap:8px}
.err{color:var(--bad);font-size:13.5px;font-weight:500}
.preview{font-size:13.5px;max-height:180px;overflow:auto;background:var(--surface-2);border-radius:10px;padding:10px 12px}
.preview div{display:flex;gap:10px}
.preview .bad{color:var(--bad)}

.toast{position:fixed;left:50%;bottom:calc(20px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);background:var(--ink);color:var(--bg);padding:10px 16px;border-radius:10px;font-weight:600;font-size:14px;z-index:30;max-width:calc(100% - 32px)}

@media (max-width:560px){
  .stats{grid-template-columns:repeat(2,1fr)}
  .card-head,.trow{grid-template-columns:58px 1fr 1fr 64px;row-gap:4px}
  .card-head .h-st{display:none}
  .trow .st{grid-column:2/-1;justify-content:flex-start}
  .trow .num{font-size:13px}
  .wd .t{display:none}
  .tabs{width:100%}
  .tabs button{flex:1;padding:6px 6px}
  .lrow{grid-template-columns:78px minmax(0,1fr) auto}
}
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
