:root {
  --fg: #1c2824;
  --muted: #3d4f48;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --soft: #e7eeea;
  --line: #d5e0da;
  --brand: #1e4d48;
  --brand-fg: #ffffff;
  --brand-soft: #e5f0ec;
  --ok: #0c5c45;
  --ok-bg: #e7f6ef;
  --warn: #7a4e0d;
  --warn-bg: #fff8eb;
  --err: #8a3030;
  --err-bg: #fdf2f2;
  --free: #0c6b4a;
  --free-bg: #e8f5ef;
  --off: #7a3a3a;
  --off-bg: #f8eeee;
  --off-line: #edd4d4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 40, 36, 0.05);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { max-width: 1080px; width: 100%; margin: 0 auto; padding: 1.75rem 1.15rem 4rem; flex: 1; }
main:focus { outline: none; }
a { color: var(--brand); text-underline-offset: 0.15em; }
a:hover { color: #163b37; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}
h1 { font-size: clamp(1.55rem, 2.4vw, 2rem); font-weight: 640; letter-spacing: -0.02em; line-height: 1.2; margin: 0 0 0.85rem; }
h2 { font-size: 1.15rem; font-weight: 640; margin: 1.75rem 0 0.65rem; letter-spacing: -0.01em; }
h3 { font-size: 1.02rem; margin: 1.1rem 0 0.4rem; }
p { margin: 0.55rem 0; }
code { background: var(--soft); padding: 0.12rem 0.4rem; border-radius: 6px; font-size: 0.92em; }
code.wrap { word-break: break-all; }
.muted, small { color: var(--muted); }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 40rem; }

.skip {
  position: absolute; left: 0.75rem; top: 0.75rem; transform: translateY(-150%);
  background: var(--surface); color: var(--fg); padding: 0.55rem 0.8rem; border-radius: 8px;
  z-index: 20; box-shadow: var(--shadow);
}
.skip:focus { transform: none; }

.env-banner {
  background: #f6e6c0; color: #5c3d0a; text-align: center;
  padding: 0.45rem 1rem; font-weight: 600; font-size: 0.88rem;
}

.site-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem;
  padding: 0.7rem 1.15rem; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.header-bar { display: flex; align-items: center; gap: 0.75rem; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 680; text-decoration: none; color: var(--fg); font-size: 1.05rem; letter-spacing: -0.02em; }
.brand-mark { width: 1.55rem; height: 1.55rem; border-radius: 0.45rem; background: var(--brand); flex: none; box-shadow: inset 0 0 0 5px #d7ebe4; }
.nav-toggle { display: none; }
.primary-nav ul { display: flex; flex-wrap: wrap; gap: 0.15rem; list-style: none; margin: 0; padding: 0; }
.primary-nav a {
  display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0.3rem 0.7rem;
  border-radius: 999px; text-decoration: none; color: var(--fg); font-size: 0.94rem;
}
.primary-nav a:hover { background: var(--soft); }
.primary-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.logout { margin-left: auto; display: flex; align-items: center; gap: 0.65rem; }
.user { color: var(--muted); font-size: 0.92rem; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-footer { border-top: 1px solid var(--line); padding: 1.25rem 1rem 1.5rem; text-align: center; font-size: 0.92rem; background: var(--surface); }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem 0.85rem; }
.site-footer nav a { text-decoration: none; }
.area-admin .site-header { box-shadow: inset 0 -3px 0 #d7ebe4; }
.area-accounting .site-header { box-shadow: inset 0 -3px 0 #d5e4ea; }
.area-teacher .site-header { box-shadow: inset 0 -3px 0 #d7ebe4; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  font: inherit; min-height: 2.75rem; padding: 0.55rem 1.05rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  cursor: pointer; text-decoration: none; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button:hover, .button:hover { border-color: #b7c9c0; background: #f7faf8; }
button.primary, .button.primary { background: var(--brand); color: var(--brand-fg); border-color: var(--brand); font-weight: 650; }
button.primary:hover, .button.primary:hover { background: #163b37; color: #fff; }
button.danger { color: var(--err); border-color: #e7c4c4; background: #fff; }
button.link { border: 0; background: none; min-height: 2.5rem; padding: 0.2rem 0.35rem; color: var(--brand); text-decoration: underline; border-radius: 6px; }
.button.google { font-weight: 650; }

.stack { display: grid; gap: 0.95rem; max-width: 34rem; margin: 1rem 0; }
.stack label { display: grid; gap: 0.3rem; }
.inline, form.inline { display: inline; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; margin: 0.75rem 0; }
.field { display: grid; gap: 0.3rem; }
input, select, textarea {
  font: inherit; font-size: 1rem; padding: 0.65rem 0.75rem; min-height: 2.75rem;
  border: 1px solid #c5d0ca; border-radius: 10px; background: #fff; color: var(--fg); width: 100%; max-width: 100%;
}
textarea { min-height: 6rem; resize: vertical; }
.inline-form input, .inline-form select, td input, td select, td button { width: auto; }
label.check, label.choice { display: flex !important; gap: 0.65rem; align-items: flex-start; grid-template-columns: none; }
label.check input, label.choice input { width: 1.25rem; height: 1.25rem; min-height: 1.25rem; margin-top: 0.15rem; accent-color: var(--brand); flex: none; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; display: grid; gap: 0.65rem; background: var(--surface); }
legend { font-weight: 650; padding: 0 0.25rem; }
.hint { font-size: 0.9rem; color: var(--muted); }

.notice { border: 1px solid #c9ddd6; border-left: 4px solid var(--brand); background: var(--brand-soft); padding: 0.85rem 1rem; border-radius: var(--radius); margin: 1rem 0; }
.notice-ok { border-color: #b7dfcc; border-left-color: var(--ok); background: var(--ok-bg); }
.notice-warn { border-color: #ead7b0; border-left-color: #b8862e; background: var(--warn-bg); }
.notice-error { border-color: #efd0d0; border-left-color: var(--err); background: var(--err-bg); }
.notice-title { display: block; margin-bottom: 0.25rem; }
.bank-warning { border: 1px solid #ead7b0; background: var(--warn-bg); padding: 1rem 1.05rem; border-radius: var(--radius); margin: 1rem 0; }
.bank-warning h2 { margin-top: 0; color: var(--warn); font-size: 1.05rem; letter-spacing: 0; }
.bank-stop { color: var(--err); background: var(--err-bg); border: 1px solid #efd0d0; border-radius: var(--radius); padding: 0.75rem 0.85rem; font-weight: 700; }
.confirm-box { border: 1px solid #b7cdc6; padding: 1rem; border-radius: var(--radius); background: var(--surface); }
.panel, .bank-details, .upload, .auth, .hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.15rem 1.2rem; box-shadow: var(--shadow);
}
.hero { max-width: 42rem; }
.auth { max-width: 28rem; }

.copyable { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin: 0.65rem 0; padding: 0.7rem 0.8rem; background: var(--soft); border-radius: 12px; }
.copy-label { min-width: 5rem; color: var(--muted); font-size: 0.9rem; }
.copy-value { font-size: 1.05rem; padding: 0.4rem 0.55rem; background: #fff; }

dl.summary, dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1rem; margin: 0.5rem 0; }
dl.summary dt, dl.kv dt { color: var(--muted); }
dl.summary dd, dl.kv dd { margin: 0; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0.75rem 0 1rem; }
table { border-collapse: collapse; width: 100%; margin: 0.75rem 0; font-size: 0.95rem; background: var(--surface); border-radius: 12px; }
th, td { border-bottom: 1px solid var(--line); padding: 0.7rem 0.65rem; text-align: left; vertical-align: top; }
th { background: #eef3f0; font-weight: 650; font-size: 0.82rem; letter-spacing: 0.02em; }
tr:last-child td { border-bottom: 0; }
ul.list { padding-left: 1.2rem; }
ul.list li { margin: 0.35rem 0; }

.status { display: inline-block; font-size: 0.78rem; line-height: 1.3; padding: 0.2rem 0.55rem; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); color: var(--fg); }
.status-confirmed, .status-converted_to_booking, .status-synced, .status-completed { background: var(--ok-bg); color: var(--ok); border-color: #b7dfcc; }
.status-slot_unavailable, .status-manual_action, .status-failed_retry, .status-declined, .status-expired { background: var(--err-bg); color: var(--err); border-color: #efd0d0; }
.status-receipt_uploaded, .status-bank_credit_verified, .status-awaiting_free_review { background: var(--warn-bg); color: var(--warn); border-color: #ead7b0; }
.tag { font-size: 0.78rem; background: var(--brand-soft); color: var(--brand); padding: 0.1rem 0.45rem; border-radius: 999px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.85rem; list-style: none; padding: 0; margin: 0.5rem 0 1rem; }
.card {
  display: grid; gap: 0.35rem; align-content: start;
  border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.05rem;
  text-decoration: none; color: var(--fg); background: var(--surface); box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
a.card:hover { border-color: #9dbeb4; }
.card.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: #f7fbf9; }
.card strong { font-size: 1.85rem; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; color: var(--brand); line-height: 1.1; }
.card.alert { border-color: #e4c98a; background: #fffaf1; }
.card.alert strong { color: #8a5a12; }
.card h3 { margin: 0; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; }
.day h3 { font-size: 1rem; margin: 0 0 0.4rem; text-transform: capitalize; }
.slots { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.slot { display: inline-flex; align-items: center; justify-content: center; min-height: 2.5rem; padding: 0.35rem 0.7rem; border: 1px solid var(--brand); border-radius: 10px; text-decoration: none; }
.slot:hover { background: var(--brand); color: #fff; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.legend { display: inline-block; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.9em; }
.legend.on { background: var(--free-bg); color: var(--free); border: 1px solid var(--free); }
.legend.off { background: var(--off-bg); color: var(--off); border: 1px solid var(--off-line); }
.text-off { color: var(--off); }
.slot-grid th.day-full { color: var(--off); }
.slot-grid th.day-full small { display: block; font-weight: 500; text-transform: none; }
.avail-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 1.25rem; padding-bottom: 0.25rem; }
.scroll-hint { display: none; }
.slot-grid th:first-child, .slot-grid td:first-child, .avail-grid th:first-child {
  position: sticky; left: 0; background: var(--bg); z-index: 1;
}
.slot-grid, .avail-grid { border-collapse: separate; border-spacing: 5px; width: max-content; min-width: 100%; background: transparent; margin: 0; }
.slot-grid th, .avail-grid th { font-weight: 650; font-size: 0.82rem; padding: 0.25rem 0.35rem; white-space: nowrap; text-transform: capitalize; border: 0; background: transparent; }
.slot-grid td, .avail-grid td { padding: 0; border: 0; background: transparent; }
.slot-grid .slot { display: grid; place-items: center; min-width: 4.4rem; min-height: 2.75rem; text-align: center; padding: 0.35rem 0.45rem; border-radius: 10px; font-variant-numeric: tabular-nums; }
.slot-grid .slot.free { border: 1px solid var(--free); background: var(--free-bg); color: var(--free); font-weight: 680; }
.slot-grid .slot.free:hover, .slot-grid .slot.free:focus-visible { background: var(--free); color: #fff; }
.slot-grid .slot.off { border: 1px solid var(--off-line); background: var(--off-bg); color: var(--off); cursor: not-allowed; font-weight: 500; }
.avail-cell { display: block; cursor: pointer; }
.avail-cell input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.avail-cell > span { display: block; width: 3.4rem; height: 2.4rem; border-radius: 8px; border: 1px solid var(--off-line); background: var(--off-bg); }
.avail-cell input:checked + span { background: var(--free-bg); border-color: var(--free); box-shadow: inset 0 0 0 2px var(--free); }
.avail-cell input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.avail-cell:hover > span { filter: brightness(0.97); }

.steps { margin: 0 0 1.15rem; }
.steps ol { display: flex; gap: 0.65rem; list-style: none; margin: 0; padding: 0; }
.steps li { flex: 1; display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.88rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--line); }
.steps li.current { color: var(--fg); font-weight: 680; border-bottom-color: var(--brand); }
.steps li.done { color: var(--brand); border-bottom-color: #9dbeb4; }
.step-n { width: 1.6rem; height: 1.6rem; border-radius: 999px; display: grid; place-items: center; background: var(--soft); font-size: 0.8rem; flex: none; }
.steps li.current .step-n { background: var(--brand); color: #fff; }
.steps li.done .step-n { background: var(--brand-soft); color: var(--brand); }
.choice-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.pager { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; }
.pager a { display: inline-flex; align-items: center; min-height: 2.75rem; }
.facts { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.55rem; }
.facts li { background: var(--soft); border-radius: 12px; padding: 0.75rem 0.9rem; }
.or { text-align: center; color: var(--muted); }
pre.mail { white-space: pre-wrap; background: var(--soft); padding: 1rem; border-radius: var(--radius); }
.code { font-size: 1.35rem; letter-spacing: 0.18em; }

.cookie-banner {
  position: fixed; inset: auto 0 0 0; background: var(--surface); border-top: 1px solid var(--line);
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px rgba(28, 40, 36, 0.06); z-index: 8;
}
.cookie-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.cookie-actions .close { margin-left: auto; width: 2.75rem; }
body.has-cookie main { padding-bottom: 9rem; }

@media (max-width: 860px) {
  .site-header { position: static; }
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .site-header { display: grid; grid-template-columns: 1fr; align-items: stretch; }
  .header-bar { width: 100%; }
  .logout { margin-left: 0; justify-content: space-between; padding-top: 0.15rem; }
  html.js .primary-nav { display: none; }
  html.js .primary-nav.is-open { display: block; }
  .primary-nav ul { flex-direction: column; gap: 0; }
  .primary-nav a { display: flex; border-radius: 10px; min-height: 2.75rem; }
  .user { max-width: none; }
}
@media (max-width: 640px) {
  main { padding: 1.15rem 0.9rem 3.5rem; }
  dl.summary, dl.kv { grid-template-columns: 1fr; }
  dl.summary dd, dl.kv dd { margin-bottom: 0.35rem; }
  .choice-row { display: grid; }
  .choice-row .button { width: 100%; }
  .scroll-hint { display: block; margin: 0.2rem 0 0.6rem; }
  .slot-grid, .avail-grid { border-spacing: 3px; }
  .slot-grid .slot { min-width: 2.7rem; min-height: 2.75rem; font-size: 0.75rem; padding: 0.2rem; }
  .slot-grid th, .avail-grid th { font-size: 0.7rem; }
  .avail-cell > span { width: 2.7rem; height: 2.5rem; }
  .steps ol { gap: 0.35rem; }
  .step-label { line-height: 1.2; }
  table:not(.slot-grid):not(.avail-grid) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card strong { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
