:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7686;
  --line: #e2e6ec;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-bg: #e8f6ee;
  --err: #b42318;
  --err-bg: #fdecea;
  --warn-bg: #fff6e0;
  --radius: 10px;
  --nav: 220px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

.topbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 1rem; height: 56px; padding: 0 1rem;
  background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); }
.biz { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.who { color: var(--muted); white-space: nowrap; }
.narrow-form { max-width: 360px; }
.side { position: fixed; top: 56px; bottom: 0; left: 0; width: var(--nav); padding: 1rem .5rem; background: var(--card);
  border-right: 1px solid var(--line); overflow-y: auto; }
.side a { display: block; padding: .5rem .75rem; border-radius: 8px; color: var(--text); }
.side a:hover { background: var(--bg); text-decoration: none; }
.side a.active { background: #e8efff; color: var(--accent); font-weight: 600; }
.content { margin-left: var(--nav); padding: 1.5rem; max-width: calc(1100px + var(--nav)); }
.narrow { max-width: 440px; margin: 0 auto; padding: 2rem 1rem; }
.public-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.row.wrap { flex-wrap: wrap; }
.card .row:last-child { margin-bottom: 0; }
.grow { flex: 1; min-width: 180px; }
label.full { flex-basis: 100%; }
.row.between { justify-content: space-between; align-items: center; }
.tabs { display: flex; gap: .25rem; }
.tabs a { padding: .4rem .8rem; border-radius: 8px; color: var(--text); }
.tabs a.active { background: #e8efff; color: var(--accent); font-weight: 600; }
/* long lists scroll inside the card; the header row stays visible */
.table-scroll { max-height: 65vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.table-scroll table { min-width: 1000px; }
.table-scroll thead th { position: sticky; top: 0; background: var(--card); z-index: 1; box-shadow: 0 1px 0 var(--line); }
td.nowrap { white-space: nowrap; }
.table-scroll.short { max-height: 420px; }
.table-scroll.short table { min-width: 0; }
th.num, td.num { text-align: right; white-space: nowrap; }
.neg { color: var(--err); }
tfoot th { position: sticky; bottom: 0; background: var(--card); color: var(--text); font-size: .9rem; text-transform: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: .5rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .9rem; }
.stat b { font-size: 1.6rem; line-height: 1.3; }
.stat small { color: var(--muted); }
.stat.pos b { color: var(--ok); }
.stat.neg b { color: var(--err); }
.grid2.top { align-items: start; }
.tabs.wrap { flex-wrap: wrap; }
p.small { font-size: .85rem; }
.bar { height: 4px; background: var(--bg); border-radius: 2px; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
td.actions { white-space: nowrap; }
td.actions form { display: inline-flex; gap: .25rem; }
table.appts td { vertical-align: middle; }
td.status .reason { font-size: .8rem; color: var(--muted); max-width: 240px; white-space: normal; margin-top: .2rem; }
details.history summary { font-size: .8rem; color: var(--accent); cursor: pointer; margin-top: .2rem; }
details.history ul { margin: .3rem 0 0; padding-left: 1rem; font-size: .8rem; color: var(--muted); white-space: normal; min-width: 260px; }
details.fix summary { list-style: none; min-height: 30px; padding: .2rem .5rem; font-size: .85rem; }
details.fix summary::-webkit-details-marker { display: none; }
details.fix form { margin: .4rem 0 0; }
details.fix input[name=reason] { min-width: 220px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.item-row { display: flex; gap: .5rem; align-items: flex-end; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.item-row:last-child { border-bottom: 0; }
.item-row .row { margin: 0; flex: 1; }
.inline { display: inline; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
input, select, textarea { font: inherit; color: var(--text); padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd3ff; border-color: var(--accent); }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; }
input.num { width: 120px; }
textarea { resize: vertical; }

button, .button { font: inherit; display: inline-flex; align-items: center; gap: .3rem; min-height: 38px; padding: .45rem .9rem; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; }
button:hover, .button:hover { background: var(--bg); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(.95); }
button.danger, .danger { color: var(--err); }
button.link { border: 0; background: none; min-height: 0; padding: .2rem .4rem; color: var(--accent); }
button.link.danger { color: var(--err); }
.lang button.current { font-weight: 700; color: var(--text); }
td.actions button { min-height: 30px; padding: .2rem .5rem; font-size: .85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
tr.cancelled td.actions, tr.cancelled td:nth-child(6) { text-decoration: none; }
table.schedule input[type=time] { width: 130px; }
form.stack > button { align-self: flex-start; }
td.sched span { display: inline-block; margin-right: .6rem; white-space: nowrap; font-size: .9rem; }

.muted { color: var(--muted); }
.help { white-space: pre-line; color: var(--muted); }
.flash { padding: .7rem 1rem; border-radius: 8px; margin: 0 0 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.ok-text { color: var(--ok); font-weight: 600; }
.warn { background: var(--warn-bg); padding: .6rem .8rem; border-radius: 8px; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .8rem; background: var(--bg); }
.badge.booked { background: #e8efff; color: var(--accent); }
.badge.done { background: var(--ok-bg); color: var(--ok); }
.badge.no_show { background: var(--warn-bg); color: #8a5a00; }
.badge.cancelled { background: var(--err-bg); color: var(--err); }
ol.steps { padding-left: 1.2rem; margin: 0 0 1rem; }
ol.steps li { margin: .35rem 0; }
ol.steps li.done a { color: var(--ok); }
ol.steps li.done::marker { content: "✓  "; color: var(--ok); }
ul.plain { list-style: none; padding: 0; margin: 0 0 1rem; }
ul.plain li { padding: .3rem 0; }

@media (max-width: 760px) {
  .side { position: static; width: auto; display: flex; overflow-x: auto; padding: .5rem; border-right: 0;
    border-bottom: 1px solid var(--line); }
  .side a { white-space: nowrap; }
  .content { margin-left: 0; padding: 1rem; }
  .biz { display: none; }
  table { display: block; overflow-x: auto; }
  .item-row { flex-direction: column; align-items: stretch; }
}
