/* =========================================================================
   Design tokens — light theme (shadcn-like, slate neutrals)
   ========================================================================= */
:root {
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --foreground: #0f172a;
  --text: #1e293b;
  --muted: #64748b;            /* 4.7:1 on white */
  --border: #e2e8f0;
  --input: #cbd5e1;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-soft-border: #bfdbfe;
  --ring: rgba(37, 99, 235, .35);

  --success: #059669;
  --success-hover: #047857;
  --success-soft: #ecfdf5;
  --success-border: #a7f3d0;
  --destructive: #dc2626;
  --destructive-soft: #fef2f2;
  --destructive-border: #fecaca;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;

  /* spreadsheet palette (matches the original Google Sheet, contrast-tuned) */
  --sheet-line: #334155;
  --sheet-label: #dfe3e8;
  --sheet-red: #b91c1c;        /* 4.7:1 on label gray */
  --sheet-blue: #1e4e8c;
  --slot-filled: #fff27a;
  --slot-free: #fffbd6;
  --slot-none: #f1f5f9;

  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, .25);

  --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --control-h: 40px;
  --control-h-sm: 34px;
  color-scheme: light;
}

@media (pointer: coarse) {
  :root { --control-h: 44px; --control-h-sm: 40px; }
}

/* =========================================================================
   Base
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font: 400 16px/1.55 var(--font); color: var(--text); background: var(--background);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3 { color: var(--foreground); line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
strong { font-weight: 600; color: var(--foreground); }
em { font-style: normal; color: var(--muted); font-weight: 400; }
code {
  font: 500 .85em/1.4 ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; word-break: break-all;
}
.icon { flex-shrink: 0; display: inline-block; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: #bfdbfe; }

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--foreground); color: #fff; font-weight: 600; transition: top .15s var(--ease);
}
.skip-link:focus { top: 12px; text-decoration: none; }
main:focus { outline: none; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding-inline: 20px; }
.main { padding-block: 32px 80px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.accent { color: var(--destructive); }
.danger-text { color: var(--destructive) !important; }
.stack { display: grid; gap: 16px; align-content: start; }
.hint { margin-top: 12px; }

/* =========================================================================
   Top bar
   ========================================================================= */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .82); backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 12px 20px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; color: var(--foreground); font-weight: 700; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; box-shadow: 0 2px 6px rgba(37, 99, 235, .3); }
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 11px;
  border-radius: var(--radius-sm); color: var(--muted); font-size: .9375rem; font-weight: 500;
  transition: color .15s var(--ease), background-color .15s var(--ease);
}
.nav a:hover { color: var(--foreground); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-soft); }
.nav-sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.nav-user { padding-left: 5px !important; }
.nav-logout { margin: 0; }
.nav-logout-label { display: none; }
.nav-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; }
.burger {
  display: none; width: 44px; height: 44px; border-radius: var(--radius-sm); cursor: pointer;
  flex-direction: column; justify-content: center; align-items: center; gap: 5px;
}
.burger:hover { background: var(--surface-2); }
.burger span { display: block; width: 20px; height: 2px; background: var(--foreground); border-radius: 2px; transition: transform .2s var(--ease), opacity .2s; }
.nav-toggle:focus-visible + .burger { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-toggle:checked + .burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle:checked + .burger span:nth-child(2) { opacity: 0; }
.nav-toggle:checked + .burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--destructive); color: #fff; font-size: .75rem; font-weight: 700; line-height: 1;
}

/* =========================================================================
   Avatars, pills, status
   ========================================================================= */
.avatar {
  display: inline-grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 999px;
  background: linear-gradient(135deg, #dbeafe, #e0e7ff); color: #1e40af; font-weight: 700; font-size: .9375rem;
  border: 1px solid #c7d2fe;
}
.avatar-sm { width: 26px; height: 26px; font-size: .75rem; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; vertical-align: middle;
  font-size: .75rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.pill-primary { background: var(--primary-soft); border-color: var(--primary-soft-border); color: var(--primary-hover); }
.pill-ok { background: var(--success-soft); border-color: var(--success-border); color: var(--success-hover); }
.pill-warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
a.pill:hover { text-decoration: none; filter: brightness(.97); }

.status-line { display: flex; align-items: center; gap: 10px; }
.status-dot { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; flex-shrink: 0; }
.status-ok { background: var(--success-soft); color: var(--success); border: 1px solid var(--success-border); }

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h); padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--input); background: var(--surface); color: var(--foreground);
  font: inherit; font-size: .9375rem; font-weight: 600; line-height: 1; cursor: pointer; white-space: nowrap;
  text-decoration: none !important; box-shadow: var(--shadow-xs);
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--primary); }
.btn[disabled], .btn.is-loading { opacity: .65; cursor: progress; }
.btn-sm { min-height: var(--control-h-sm); padding: 0 12px; font-size: .875rem; gap: 6px; }
.btn-lg { min-height: 46px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: var(--control-h); }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .3), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-hover); border-color: var(--success-hover); }
.btn-danger { background: var(--surface); border-color: var(--destructive-border); color: var(--destructive); }
.btn-danger:hover { background: var(--destructive-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--foreground); }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn:focus-visible { position: relative; z-index: 1; }
.btn-group .btn[aria-current] { color: var(--primary); }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); cursor: pointer; transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--foreground); }

/* =========================================================================
   Forms
   ========================================================================= */
input, select, textarea {
  width: 100%; min-height: var(--control-h); padding: 8px 12px;
  font: inherit; font-size: .9375rem; color: var(--foreground);
  background: var(--surface); border: 1px solid var(--input); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs); transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
textarea { resize: vertical; min-height: 72px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: .875rem; font-weight: 600; color: var(--foreground); }
.field > span em { font-weight: 400; margin-left: 4px; }
.form { display: grid; gap: 16px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form-actions-end { justify-content: flex-end; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form.grow { flex: 1; min-width: 200px; }
form { margin: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: .9375rem; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; accent-color: var(--primary); box-shadow: none; cursor: pointer; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.align-start { align-items: start; }

/* =========================================================================
   Surfaces
   ========================================================================= */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.stack > .card, .stack > form.card, .split > .card { margin-bottom: 0; }
.card-title { font-size: 1.0625rem; margin-bottom: 14px; display: flex; gap: 8px; align-items: baseline; }
.card-title .muted { font-weight: 500; font-size: .875rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
  padding: 14px 0; border-top: 1px solid var(--border);
}
.list-row:first-child { border-top: 0; padding-top: 0; }
.list-row:last-child { padding-bottom: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.flash {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; margin-bottom: 20px;
  border-radius: var(--radius); border: 1px solid; font-weight: 500; box-shadow: var(--shadow-xs);
  animation: flash-in .25s var(--ease);
}
.flash .icon { margin-top: 2px; }
.flash-success { background: var(--success-soft); border-color: var(--success-border); color: #065f46; }
.flash-error { background: var(--destructive-soft); border-color: var(--destructive-border); color: #991b1b; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.callout {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.callout-primary { background: linear-gradient(135deg, #eff6ff, #f5f3ff); border-color: var(--primary-soft-border); }
.callout-icon {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius); flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-soft-border);
}
.callout-text { display: grid; gap: 1px; flex: 1; min-width: 200px; }
.callout .inline-form select { width: auto; min-width: 190px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin-top: 6px; }
.page-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; font-size: .875rem; font-weight: 500; color: var(--muted); }
.back-link:hover { color: var(--primary); }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }

.empty-state { text-align: center; padding: 72px 16px; display: grid; justify-items: center; gap: 10px; }
.empty-state p { margin-bottom: 12px; }
.empty-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); margin-bottom: 6px;
}

/* =========================================================================
   Auth
   ========================================================================= */
.auth { display: grid; place-items: center; min-height: calc(100vh - 240px); }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 16px; padding: 32px; box-shadow: var(--shadow-md); }
.auth-head { display: grid; justify-items: center; text-align: center; gap: 6px; margin-bottom: 4px; }
.auth-head h1 { font-size: 1.5rem; }
.auth-logo { width: 60px; height: 60px; border-radius: 14px; margin-bottom: 8px; box-shadow: 0 10px 24px -8px rgba(37, 99, 235, .6); }

/* =========================================================================
   Public page / weeks
   ========================================================================= */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 28px; }
.hero h1 { font-size: 2rem; }
.hero p { margin-top: 6px; }
.legend { display: flex; gap: 8px 18px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; font-size: .875rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid #c9bd3a; }
.swatch-filled { background: var(--slot-filled); }
.swatch-free { background: var(--slot-free); border-style: dashed; }

.week { margin-bottom: 40px; }
.week-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.week-title { font-size: 1.1875rem; font-weight: 700; }
.week-meta { margin-left: auto; font-size: .875rem; color: var(--muted); }
.week-meta strong { color: var(--success-hover); }
.week-empty {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 28px 20px;
  color: var(--muted); text-align: center;
  background: var(--surface); border: 1px dashed var(--input); border-radius: var(--radius-lg);
}
.week-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; margin-top: 20px; }
.share-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 28px; padding: 16px 18px; }
.link-url { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }

/* =========================================================================
   Week table — spreadsheet style
   ========================================================================= */
.sheet-scroll { position: relative; max-width: 100%; width: max-content; }
.sheet-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  border: 1.5px solid var(--sheet-line); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-md);
}
.sheet-wrap:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.sheet-scroll::after {
  content: ""; position: absolute; top: 1.5px; right: 1.5px; bottom: 1.5px; width: 36px; pointer-events: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(15, 23, 42, .12));
  opacity: 0; transition: opacity .2s;
}
.sheet-scroll.has-more::after { opacity: 1; }
.sheet-hint { display: none; }
.sheet-scroll.has-more .sheet-hint {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; font-size: .75rem; color: var(--muted);
}

.sheet { border-collapse: separate; border-spacing: 0; text-align: center; font-weight: 700; color: #111827; }
.sheet th, .sheet td {
  border-right: 1.5px solid var(--sheet-line); border-bottom: 1.5px solid var(--sheet-line);
  padding: 6px 14px; height: 46px; min-width: 156px; vertical-align: middle;
}
.sheet tr > :last-child { border-right: 0; }
.sheet tr:last-child > *, .sheet .th-people { border-bottom: 0; }
.sheet th {
  position: sticky; left: 0; z-index: 2; min-width: 128px;
  background: var(--sheet-label); color: #111827; font-size: 1.0625rem; font-weight: 700;
}
.sheet td { --tint: #fff; background: var(--tint); }
.sheet .c0 { --tint: #dbe8fc; }
.sheet .c1 { --tint: #fff6dc; }
.sheet .c2 { --tint: #d3e5f4; }
.sheet .c3 { --tint: #d9f2e1; }
.sheet .c4 { --tint: #fbe3ec; }
.sheet .c5 { --tint: #e7e1fb; }

.r-title th { font-size: 1.625rem; font-weight: 800; letter-spacing: -.01em; }
.r-title td { font-size: 1.125rem; font-weight: 800; text-transform: uppercase; letter-spacing: .01em; white-space: nowrap; position: relative; height: 54px; }
.r-title td.today { box-shadow: inset 0 4px 0 var(--primary); }
.today-tag {
  position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%);
  font-size: .625rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary);
}
.sheet-edit { display: inline-flex; align-items: center; gap: 6px; color: inherit; border-radius: 6px; padding: 2px 6px; }
.sheet-edit .icon { opacity: .35; transition: opacity .15s; }
.sheet-edit:hover { color: var(--primary); text-decoration: none; }
.sheet-edit:hover .icon, .sheet-edit:focus-visible .icon { opacity: 1; }
.sheet-badge {
  position: absolute; top: 5px; right: 5px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: grid; place-items: center; background: var(--destructive); color: #fff; font-size: .6875rem; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.sheet-badge:hover { text-decoration: none; filter: brightness(1.08); }
.r-place td { color: var(--sheet-red); font-size: 1.125rem; }
.r-day th { color: var(--sheet-red); font-size: 1.625rem; font-weight: 800; }
.r-day td { font-size: 1.875rem; font-weight: 800; font-style: italic; height: 58px; }
.r-time th, .r-time td { background: var(--sheet-label); color: var(--sheet-red); font-size: 1.0625rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.th-people { color: var(--sheet-blue) !important; font-size: 1.125rem !important; line-height: 1.3; }

.sheet .slot { position: relative; padding: 4px 34px; font-size: 1.125rem; font-weight: 500; }
.sheet .slot.filled { background: var(--slot-filled); }
.sheet .slot.free { background: var(--slot-free); padding: 5px 8px; }
.sheet .slot.none { background: var(--slot-none); }
.sheet .past { opacity: .55; }

.slot form { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.slot-x {
  display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px;
  background: transparent; color: #6b6420; cursor: pointer; opacity: .45; transition: opacity .15s, background-color .15s, color .15s;
}
.slot:hover .slot-x, .slot-x:focus-visible { opacity: 1; }
.slot-x:hover { background: rgba(15, 23, 42, .08); color: var(--destructive); }
.slot-add { position: static !important; transform: none !important; }
.slot-add input {
  min-height: 34px; padding: 4px 10px; font-size: .9375rem; text-align: center; font-weight: 500;
  background: rgba(255, 255, 255, .75); border: 1.5px dashed #c9bd3a; box-shadow: none;
}
.slot-add input:focus { background: #fff; border-style: solid; }
.slot-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 36px;
  border: 1.5px dashed #c9bd3a; border-radius: 8px; background: rgba(255, 255, 255, .6);
  color: #5c5517; font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.slot-btn:hover { background: var(--primary); border: 1.5px solid var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(37, 99, 235, .3); }
.slot-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--primary); }

/* =========================================================================
   Dialog
   ========================================================================= */
.dialog {
  border: 1px solid var(--border); border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg); color: var(--text);
}
.dialog[open] { animation: dialog-in .2s var(--ease); }
.dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); }
.dialog > form { padding: 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px -6px 0 0; }
.dialog-head h2 { font-size: 1.25rem; }
.dialog-event {
  display: grid; gap: 6px; padding: 14px 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, #fffbeb, #fef9c3); border: 1px solid var(--warn-border);
}
.dialog-event-title { font-weight: 800; text-transform: uppercase; color: var(--foreground); letter-spacing: .02em; }
.dialog-event-row { display: flex; align-items: center; gap: 8px; font-size: .9375rem; color: #44403c; }
.dialog-event-row .icon { color: var(--sheet-red); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* =========================================================================
   Admin pages
   ========================================================================= */
.req-info { display: grid; gap: 2px; min-width: 0; }
.req-comment {
  font-size: .875rem; margin-top: 6px; color: var(--text); background: var(--surface-2);
  padding: 6px 10px; border-radius: 8px; border-left: 3px solid var(--primary-soft-border);
}
.link-row.is-off .link-info { opacity: .55; }
.link-info { display: grid; gap: 8px; min-width: 0; flex: 1; }
.user-row .inline-form input { width: 170px; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tpl-card { display: grid; gap: 8px; color: var(--text); margin: 0; transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease); }
.tpl-card:hover { text-decoration: none; border-color: var(--primary-soft-border); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tpl-card-head { display: flex; align-items: center; gap: 10px; }
.tpl-card-head strong { margin-right: auto; font-size: 1.0625rem; }
.tpl-days { display: grid; gap: 10px; margin-bottom: 20px; }
.tpl-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 12px; box-shadow: var(--shadow-xs); }
.tpl-day.is-empty { padding-block: 8px; background: transparent; border-style: dashed; box-shadow: none; }
.tpl-day-head { display: flex; align-items: center; gap: 10px; }
.tpl-day-head h3 { margin-right: auto; }
.tpl-day-head h3::first-letter { text-transform: uppercase; }
.tpl-day.is-empty h3 { color: var(--muted); font-weight: 500; margin-right: 0; }
.tpl-day.is-empty .btn { margin-left: auto; }
.tpl-item {
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: 140px minmax(110px, 1fr) minmax(130px, 1.3fr) 104px 104px 76px minmax(120px, 1.3fr) auto;
  padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border);
}
.tpl-item-new { padding: 0; background: none; border: 0; }
.tpl-item .field > span { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tpl-item input, .tpl-item select { min-height: var(--control-h-sm); padding-block: 5px; }
.tpl-item-actions { display: flex; gap: 6px; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1100px) {
  .tpl-item { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tpl-item .f-day, .tpl-item .f-title { grid-column: span 3; }
  .tpl-item .f-place { grid-column: span 6; }
  .tpl-item .f-time, .tpl-item .f-slots { grid-column: span 2; }
  .tpl-item .f-note, .tpl-item-actions { grid-column: span 6; }
}

@media (max-width: 960px) {
  .burger { display: flex; }
  .nav {
    display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 2px;
    padding: 8px 0 14px; border-top: 1px solid var(--border);
  }
  .nav a { min-height: 44px; padding: 0 12px; }
  .nav-sep { width: 100%; height: 1px; margin: 6px 0; }
  .nav-logout .btn { width: 100%; justify-content: flex-start; min-height: 44px; padding: 0 12px; }
  .nav-logout-label { display: inline; }
  .nav-toggle:checked ~ .nav { display: flex; }
}

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .container { padding-inline: 16px; }
  .main { padding-block: 20px 64px; }
  h1 { font-size: 1.5rem; }
  .hero h1 { font-size: 1.75rem; }
  .card { padding: 16px; border-radius: var(--radius); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :last-child { grid-column: span 2; }
  .page-head { align-items: stretch; }
  .toolbar { width: 100%; justify-content: space-between; }
  .row-actions { width: 100%; }
  .user-row .inline-form { flex: 1; }
  .user-row .inline-form input { width: auto; }
  .callout .inline-form { width: 100%; }
  .callout .inline-form select { flex: 1; min-width: 0; }
  .week-meta { margin-left: 0; width: 100%; }
}

@media (max-width: 600px) {
  .sheet th, .sheet td { min-width: 118px; padding: 4px 8px; height: 42px; }
  .sheet th { min-width: 86px; font-size: .8125rem; }
  .r-title th, .r-day th { font-size: 1.125rem; }
  .r-place th, .th-people { font-size: .8125rem !important; }
  .r-title td { font-size: .875rem; height: 48px; }
  .r-place td, .r-time td { font-size: .875rem; }
  .r-day td { font-size: 1.375rem; height: 48px; }
  .sheet .slot { font-size: .9375rem; padding: 4px 26px; }
  .slot-btn { font-size: .8125rem; min-height: 40px; }
  .slot-x { width: 32px; height: 32px; opacity: .8; }
  .dialog > form { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
