:root {
  --brand: #64000a; --brand-2: #a91d3c; --bg: #f6f5f4; --card: #fff; --ink: #1f1f22; --muted: #6b6b72;
  --line: #e5e2df; --ok: #1d7a46; --ok-bg: #e5f4ea; --bad: #a91d3c; --bad-bg: #fbe9ed; --warn-bg: #fff4dc;
  --field: #fff; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151416; --card: #1f1d20; --ink: #ecebee; --muted: #a09ca4; --line: #343036; --field: #19181a;
    --ok: #6fd39b; --ok-bg: #173323; --bad: #ff8ea6; --bad-bg: #3b1820; --warn-bg: #3a3017; --brand-2: #e04b6b;
    --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
a { color: var(--brand-2); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code { font-size: .85em; background: var(--bg); padding: .1em .35em; border-radius: 4px; }

/* layout */
header.top { background: var(--brand); color: #fff; padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 5; }
header.top img { width: 34px; height: 34px; }
header.top .title { font-weight: 650; letter-spacing: .02em; }
header.top .spacer { flex: 1; }
header.top .who { font-size: .85rem; opacity: .85; }
header.top button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); }
nav.tabs { display: flex; gap: .25rem; overflow-x: auto; padding: .5rem 1rem 0; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 54px; z-index: 4; }
nav.tabs button { border: 0; background: none; padding: .6rem .8rem; border-bottom: 3px solid transparent; border-radius: 0; color: var(--muted); font-weight: 550; white-space: nowrap; }
nav.tabs button.on { color: var(--brand-2); border-color: var(--brand-2); }
main.wrap { max-width: 1040px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: .6rem; }
.between { justify-content: space-between; }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; width: 100%; }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox] { width: auto; }
.check { display: flex; gap: .45rem; align-items: center; color: var(--ink); font-size: .95rem; margin: .3rem 0; }
.field { flex: 1 1 160px; min-width: 0; }
.btn, button { font: inherit; font-weight: 550; border-radius: 8px; padding: .5rem .9rem; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.btn.primary, button.primary { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.btn.danger, button.danger { color: var(--bad); border-color: currentColor; background: transparent; }
button.link { border: 0; background: none; color: var(--brand-2); padding: .2rem .3rem; }
button:disabled { opacity: .5; cursor: default; }
.btn.big { width: 100%; padding: .8rem; font-size: 1.05rem; }

/* status */
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .55rem; border-radius: 99px; background: var(--bg); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--ink); }
.status-big { display: flex; align-items: center; gap: .9rem; }
.status-big .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--bad); flex: none; }
.status-big .dot.ok { background: var(--ok); }
.status-big strong { font-size: 1.2rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: .45rem .9rem; }
.seg button.on { background: var(--brand-2); color: #fff; }

/* tables / lists */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 550; font-size: .8rem; }
.scroll { overflow-x: auto; }
.opt { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; margin-bottom: .8rem; }
.opt .digit { width: 2rem; height: 2rem; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-weight: 700; flex: none; }
.absence { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-top: 1px dashed var(--line); font-size: .9rem; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .4rem; }
.day { border: 1px solid var(--line); border-radius: 8px; padding: .4rem .5rem; font-size: .82rem; }
.day.open { border-color: var(--ok); }
.day b { display: block; }
.hours-row { display: grid; grid-template-columns: 90px 1fr; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.hours-row input { width: 92px; }
.counter { font-size: .8rem; color: var(--muted); text-align: right; }
.preview { white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: .7rem; font-size: .9rem; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); z-index: 10; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); color: #fff; }

/* public pages */
body.public { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card.narrow { width: 100%; max-width: 400px; text-align: center; }
.card.narrow .logo { width: 72px; height: 72px; margin: .5rem auto 1rem; display: block; }
.card.narrow form { text-align: left; }
.ok { color: var(--ok); }

@media (max-width: 600px) {
  main.wrap { padding: .75rem 16px; }
  header.top .who { display: none; }
  .hours-row { grid-template-columns: 70px 1fr; }
}

/* installed web app (iOS standalone): keep content clear of the notch */
header.top { padding-top: calc(.6rem + env(safe-area-inset-top)); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
nav.tabs { top: calc(54px + env(safe-area-inset-top)); }
main.wrap { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
.manual h2 { margin-top: 1.4rem; } .manual h2:first-child { margin-top: 0; }
.manual li { margin-bottom: .3rem; }
