.center { display: grid; place-items: center; min-height: 60dvh; padding: 24px; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.warn { color: var(--warn); }
.danger { color: var(--bad); }
.pre { white-space: pre-wrap; }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 10px 0 0; }
.stack { display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.alert { background: var(--bad-bg); color: var(--ink); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); padding: 12px 14px; border-radius: 10px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }

label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
input:not([type=checkbox]):not([type=color]), select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent);
  background: var(--card); font-weight: 400;
}
input[type=color] { width: 64px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: none; padding: 2px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.grid2, .grid3 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--bad); }
.btn.sm { min-height: 36px; padding: 6px 12px; }
.btn:focus-visible, .link:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 2px; text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* shell */
.shell { max-width: 1100px; margin: 0 auto; padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px 0; background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.top .brand { flex: 1; min-width: 0; }
.top .brand select { min-height: 36px; width: auto; font-weight: 600; }
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--ink); }
.topnav a[aria-current=page] { background: var(--soft); font-weight: 600; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .topnav { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: grid; justify-items: center; gap: 2px; font-size: .72rem; color: var(--muted); text-decoration: none; padding: 4px; min-height: 48px; }
  .tabbar a[aria-current=page] { color: var(--accent); font-weight: 600; }
}
.login { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.login form { width: min(400px, 100%); }

/* inbox */
.today { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.today .alert { grid-column: 1 / -1; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; }
.stat .n { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span:last-child { color: var(--muted); font-size: .82rem; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs button, .tabs a { flex: none; border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 999px; cursor: pointer; text-decoration: none; color: var(--ink); min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.tabs [aria-selected=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.count { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 700; }
.search { max-width: 420px; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.row { display: grid; gap: 10px; }
.row-main { color: inherit; text-decoration: none; display: grid; gap: 3px; }
.row-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions .btn { flex: 1 1 auto; }
.decline { background: var(--soft); border-radius: 10px; padding: 12px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.b-pending { background: var(--warn-bg); color: var(--warn); }
.b-confirmed { background: var(--ok-bg); color: var(--ok); }
.b-declined, .b-cancelled, .b-expired { background: var(--bad-bg); color: var(--bad); }
.back { justify-self: start; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; }
.kv > span { color: var(--muted); }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv > span { margin-top: 8px; font-size: .8rem; } }
details summary { cursor: pointer; font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.mstat { font-size: .72rem; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; background: var(--soft); }
.m-sent { color: var(--ok); background: var(--ok-bg); } .m-failed { color: var(--bad); background: var(--bad-bg); } .m-queued { color: var(--warn); background: var(--warn-bg); }
.mail-preview { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-top: 8px; }

/* calendar */
.cal-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cal-bar select, .cal-bar input:not([type=checkbox]) { width: auto; min-height: 36px; }
.tl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.tl { border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.tl th, .tl td { padding: 0; border-bottom: 1px solid var(--line); height: 44px; }
.tl thead th { position: sticky; top: 0; background: var(--card); font-size: .72rem; font-weight: 600; width: 40px; min-width: 40px; text-align: center; color: var(--muted); line-height: 1.1; }
.tl thead th span { display: block; font-weight: 400; }
.tl thead th.is-today { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.tl thead th.we { background: var(--soft); }
.tl-name { position: sticky; left: 0; z-index: 2; background: var(--card); text-align: left !important; padding: 0 10px !important; width: 150px !important; min-width: 150px; max-width: 150px; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--line); }
.tl-group td { background: var(--soft); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 4px 10px; height: auto; color: var(--muted); position: sticky; left: 0; }
.cell { width: 40px; height: 43px; border: 0; border-left: 1px solid color-mix(in srgb, var(--line) 50%, transparent); background: transparent; cursor: pointer; display: block; }
.cell:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cell.sel { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.bar { width: calc(100% - 4px); margin: 0 2px; height: 34px; border-radius: 8px; border: 0; cursor: pointer; font-size: .78rem; font-weight: 600; text-align: left; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.k-booked { background: var(--booked); color: #fff; }
.k-hold { background: var(--hold); color: var(--ink); border: 1px dashed var(--warn) !important; }
.k-blocked { background: repeating-linear-gradient(45deg, var(--block) 0 6px, color-mix(in srgb, var(--block) 80%, #fff) 6px 12px); color: #fff; }
.k-turnover { background: var(--turn); color: var(--muted); font-weight: 400; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 12px; border-radius: 3px; display: inline-block; }
.sheet { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 6; box-shadow: 0 -8px 30px rgb(0 0 0 / .12); }
@media (min-width: 761px) { .sheet { bottom: 16px; } }

/* rules & units */
.rule.off { opacity: .75; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; flex: none; }
.switch input { width: 44px; height: 26px; appearance: none; background: var(--line); border-radius: 999px; position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / .2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.weekdays { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.weekdays legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.indent { margin-left: 18px; }
.unit-head { width: 100%; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; align-items: center; }
.code { background: var(--soft); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .82rem; white-space: pre; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; padding: 12px 18px; border-radius: 999px; font-weight: 600; box-shadow: 0 8px 30px rgb(0 0 0 / .2); max-width: calc(100vw - 32px); }
.toast-ok { background: var(--ink); color: var(--bg); }
.toast-bad { background: var(--bad); color: #fff; }
@media (min-width: 761px) { .toast { bottom: 24px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 640px) {
  .tl-name { width: 108px !important; min-width: 108px; max-width: 108px; font-size: .78rem; padding: 0 8px !important; }
}
