/* ---------- tokens ---------- */
:root {
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --bg: #f5f6fa;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #e9e7ff 0%, transparent 60%), radial-gradient(900px 500px at 110% 0%, #e0f2fe 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f6;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --line: #e6e8f0;
  --line-2: #d7dbe7;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef2ff;
  --accent-text: #4338ca;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --today: #fff7e6;
  --today-line: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px -4px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 64px -16px rgba(15, 23, 42, 0.28);
  --radius: 14px;
  --radius-sm: 10px;
  --ring: 0 0 0 4px rgba(79, 70, 229, 0.16);
  /* person colors: hsl(var(--h) ...) */
  --p-s: 78%;
  --p-bg-l: 95%;
  --p-fg-l: 36%;
  --p-solid-l: 58%;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d14;
    --bg-grad: radial-gradient(1000px 520px at 5% -10%, rgba(99, 102, 241, 0.16) 0%, transparent 60%), radial-gradient(800px 480px at 110% 0%, rgba(14, 165, 233, 0.10) 0%, transparent 55%);
    --surface: #131722;
    --surface-2: #171c29;
    --surface-3: #1e2433;
    --text: #e6e9f2;
    --text-2: #a3abbf;
    --text-3: #6b7489;
    --line: #232a3a;
    --line-2: #2d3548;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --accent-soft: rgba(129, 140, 248, 0.14);
    --accent-text: #c7d2fe;
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.12);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --today: rgba(245, 158, 11, 0.08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, 0.7);
    --ring: 0 0 0 4px rgba(129, 140, 248, 0.25);
    --p-s: 70%;
    --p-bg-l: 20%;
    --p-fg-l: 78%;
    --p-solid-l: 62%;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; display: block; }
:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn svg.i { width: 16px; height: 16px; }
.btn-primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3), 0 6px 16px -6px rgba(79, 70, 229, 0.55);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); filter: brightness(1.07); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-soft-danger { color: var(--danger); background: transparent; border-color: transparent; box-shadow: none; }
.btn-soft-danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn-lg { height: 44px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled], .btn.loading { opacity: 0.6; pointer-events: none; }
.btn.loading::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer; transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn[disabled] { opacity: 0.35; pointer-events: none; }
.icon-btn svg.i { width: 16px; height: 16px; }

input:not([type=radio]):not([type=checkbox]), select {
  height: 38px; width: 100%; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--text-3); }
input:hover, select:hover { border-color: var(--text-3); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field em { font-style: normal; font-weight: 400; color: var(--text-3); }
.form-error { color: var(--danger); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 20px; padding: 24px; position: relative; overflow: hidden; }
.auth-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(600px 400px at 20% 20%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(500px 360px at 80% 80%, rgba(168, 85, 247, 0.18), transparent 60%),
    radial-gradient(400px 300px at 85% 15%, rgba(14, 165, 233, 0.14), transparent 60%);
  filter: blur(8px);
}
.auth-card {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 18px;
  padding: 32px; border-radius: 20px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-foot { color: var(--text-3); font-size: 12.5px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1440px; margin: 0 auto; height: 60px; padding: 0 24px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px -2px rgba(79, 70, 229, 0.5);
}
.brand-mark svg.i { width: 17px; height: 17px; }
.brand-mark-lg { width: 48px; height: 48px; border-radius: 14px; }
.brand-mark-lg svg.i { width: 26px; height: 26px; }
.nav { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-3); }
.nav-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border: none; border-radius: 9px; background: transparent; color: var(--text-2);
  font-weight: 550; cursor: pointer; transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.nav-btn svg.i { width: 16px; height: 16px; }
.nav-btn:hover { color: var(--text); }
.nav-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center;
}
.spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; font-weight: 550; }
.user-chip .role { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }

/* ---------- layout ---------- */
main { max-width: 1440px; margin: 0 auto; padding: 28px 24px 64px; }
.tab-panel { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .muted { margin-top: 4px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 180px; font-weight: 550; box-shadow: var(--shadow-sm); }
.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.seg-btn { height: 36px; min-width: 38px; padding: 0 12px; border: none; background: transparent; cursor: pointer; font-weight: 550; display: grid; place-items: center; color: var(--text); }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn:hover { background: var(--surface-2); }
.seg-btn svg.i { width: 16px; height: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head .muted { font-size: 13px; margin-top: 2px; }
.section { margin-bottom: 28px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); margin-bottom: 12px; }
.count { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); letter-spacing: 0; }
.count:empty { display: none; }

/* ---------- avatars & person colors ---------- */
.avatar {
  --size: 32px;
  width: var(--size); height: var(--size); flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: calc(var(--size) * 0.38); font-weight: 700; letter-spacing: 0.02em;
  color: #fff; background: linear-gradient(135deg, hsl(var(--h) var(--p-s) var(--p-solid-l)), hsl(calc(var(--h) + 30) var(--p-s) calc(var(--p-solid-l) - 8%)));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.avatar.sm { --size: 24px; }
.avatar.lg { --size: 44px; }
.avatar.xl { --size: 56px; }
.avatar.empty { background: var(--surface-3); color: var(--text-3); }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.hero:empty { display: none; }
.stat {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.stat-label { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin-top: 2px; }
.stat-sub { font-size: 12.5px; color: var(--text-2); }
.stat.now {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, hsl(var(--h) 70% 52%), hsl(calc(var(--h) + 35) 70% 46%));
  box-shadow: 0 12px 32px -12px hsl(var(--h) 70% 45% / 0.7);
}
.stat.now .stat-label, .stat.now .stat-sub { color: rgba(255, 255, 255, 0.85); }
.stat.now .avatar { background: rgba(255, 255, 255, 0.22); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4); }
.stat.now::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 70%);
}
.live { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }

/* ---------- calendar grid ---------- */
.grid-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; scrollbar-width: thin; }
.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--line); }
.grid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  padding: 12px 6px 10px; font-weight: 600; text-align: center; min-width: 78px;
}
.day-name { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.day-num { display: inline-grid; place-items: center; min-width: 30px; height: 30px; margin-top: 3px; border-radius: 9px; font-size: 15px; font-weight: 650; color: var(--text); }
.day-month { display: block; font-size: 10.5px; color: var(--text-3); height: 14px; }
.grid thead th.weekend .day-name { color: var(--accent); opacity: 0.75; }
.grid thead th.today .day-num { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 4px 10px -2px rgba(79, 70, 229, 0.5); }
.grid thead th.today .day-name { color: var(--accent); opacity: 1; }
.grid .week-start { border-left: 1px solid var(--line-2); }
.grid td { padding: 6px 4px; height: 58px; text-align: center; vertical-align: middle; }
.grid td.past { background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--surface-3) 45%, transparent) 6px 7px); }
.grid td.today, .grid thead th.today { background-color: var(--today); }
.grid tbody tr:last-child > * { border-bottom: none; }
.grid tbody tr:hover > td { background-color: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.grid tbody tr:hover > td.today { background-color: var(--today); }

.person-cell {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  text-align: left; padding: 8px 16px 8px 18px; min-width: 210px;
  border-right: 1px solid var(--line);
}
.grid thead .person-cell { z-index: 3; background: var(--surface-2); vertical-align: bottom; }
.person { display: flex; align-items: center; gap: 10px; }
.person-name { font-weight: 600; white-space: nowrap; }
.person-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.person-cell .you { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); margin-left: 6px; vertical-align: 1px; }
tr.me .person-cell { box-shadow: inset 3px 0 0 var(--accent); }

.shift {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 100%; max-width: 64px; height: 36px; border-radius: 10px;
  background: hsl(var(--h) var(--p-s) var(--p-bg-l));
  color: hsl(var(--h) var(--p-s) var(--p-fg-l));
  box-shadow: inset 0 0 0 1px hsl(var(--h) var(--p-s) var(--p-solid-l) / 0.35);
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  transition: transform 0.15s, box-shadow 0.15s;
}
.shift::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: hsl(var(--h) var(--p-s) var(--p-solid-l)); }
.shift.past { opacity: 0.45; filter: saturate(0.6); }
.shift.today-shift { background: linear-gradient(135deg, hsl(var(--h) 72% 54%), hsl(calc(var(--h) + 30) 72% 48%)); color: #fff; box-shadow: 0 6px 16px -6px hsl(var(--h) 70% 45% / 0.8); }
.shift.today-shift::before { background: rgba(255, 255, 255, 0.7); }
.shift.swapped { box-shadow: inset 0 0 0 1.5px hsl(var(--h) var(--p-s) var(--p-solid-l)); background-image: repeating-linear-gradient(135deg, transparent 0 5px, hsl(var(--h) var(--p-s) var(--p-solid-l) / 0.14) 5px 7px); }
.shift.swapped::after {
  content: ""; position: absolute; top: -5px; right: -5px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c3aed' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 4 3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7'/%3E%3C/svg%3E") center / 10px no-repeat;
  box-shadow: 0 0 0 1.5px hsl(270 70% 60%);
}
td.clickable { cursor: pointer; }
td.clickable .shift:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -6px hsl(var(--h) 70% 45% / 0.6), inset 0 0 0 1.5px hsl(var(--h) var(--p-s) var(--p-solid-l)); }
.grid-empty { padding: 56px 24px; text-align: center; }
.grid-empty svg.i { width: 36px; height: 36px; margin: 0 auto 12px; color: var(--text-3); }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 14px; color: var(--text-2); font-size: 12.5px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-chip { width: 26px !important; height: 18px !important; border-radius: 6px !important; }
.legend-chip::before { left: 4px; top: 4px; bottom: 4px; width: 2px; }
.legend-chip.swapped::after { top: -4px; right: -4px; width: 12px; height: 12px; background-size: 8px; }
.legend-today { width: 18px; height: 18px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.legend-hint { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--text-3); }
.legend-hint svg.i { width: 14px; height: 14px; }

/* ---------- swaps ---------- */
.stack-list { display: flex; flex-direction: column; gap: 10px; }
.swap-card {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  padding: 16px 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); animation: fade 0.25s ease;
}
.swap-card.incoming { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: var(--shadow), 0 0 0 3px var(--accent-soft); }
.swap-flow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.swap-side { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.swap-side .who { font-weight: 650; }
.swap-side .when { font-size: 12.5px; color: var(--text-2); }
.swap-arrow { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.swap-arrow svg.i { width: 16px; height: 16px; }
.swap-meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.swap-note { font-style: italic; }
.swap-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; text-transform: capitalize; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.pending { background: var(--warning-soft); color: var(--warning); }
.pill.accepted { background: var(--success-soft); color: var(--success); }
.pill.rejected, .pill.cancelled { background: var(--surface-3); color: var(--text-2); }
.tag { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); }

.empty {
  display: flex; align-items: center; gap: 14px; padding: 18px 20px;
  border: 1px dashed var(--line-2); border-radius: var(--radius); color: var(--text-2);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.empty svg.i { width: 22px; height: 22px; color: var(--text-3); }
.empty strong { display: block; color: var(--text); font-weight: 600; }

/* ---------- admin ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; margin-bottom: 16px; }
.admin-grid .card + .card { margin-top: 0; }
.item-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid transparent; transition: background 0.15s, border-color 0.15s;
}
.item:hover { background: var(--surface-2); }
.item.selectable { cursor: pointer; }
.item.selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item select { width: 130px; height: 32px; font-size: 13px; }
.sched-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.sched-icon svg.i { width: 18px; height: 18px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input, .inline-form select { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
.add-user { border-top: 1px solid var(--line); padding-top: 12px; }
.add-user summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--accent); padding: 6px 4px; border-radius: 8px; }
.add-user summary::-webkit-details-marker { display: none; }
.add-user summary svg.i { width: 16px; height: 16px; }
.add-user[open] summary { margin-bottom: 12px; }

.rotation-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 32px; }
@media (max-width: 900px) { .rotation-layout { grid-template-columns: 1fr; } }
.subhead { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-2); margin-bottom: 12px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.timeline li { position: relative; padding: 0 0 18px 14px; }
.timeline li::before { content: ""; position: absolute; left: -18px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.timeline li.current::before { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-head { display: flex; align-items: center; gap: 8px; }
.tl-date { font-weight: 650; }
.tl-sub { font-size: 12.5px; color: var(--text-2); margin: 2px 0 8px; }
.avatar-stack { display: flex; flex-wrap: wrap; gap: 4px; }
.rotation-form { display: flex; flex-direction: column; gap: 16px; padding: 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.member-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.member {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 10px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
}
.member .pos { width: 20px; font-size: 12px; font-weight: 700; color: var(--text-3); text-align: center; }
.member .grow { flex: 1; font-weight: 600; }
.member-empty { padding: 14px; text-align: center; color: var(--text-3); border: 1px dashed var(--line-2); border-radius: var(--radius-sm); }

/* ---------- dialogs ---------- */
.modal {
  width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.modal-sm { width: min(400px, calc(100vw - 32px)); }
.modal[open] { animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
.modal::backdrop { background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(3px); }
.modal-body { display: flex; flex-direction: column; gap: 18px; padding: 24px; }
.modal-head { display: flex; gap: 14px; align-items: flex-start; }
.modal-head .muted { font-size: 13px; margin-top: 3px; }
.modal-icon { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.modal-icon.danger { background: var(--danger-soft); color: var(--danger); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.give-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.give-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.option-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; padding: 2px; }
.option {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.option:hover { border-color: var(--line-2); background: var(--surface-2); }
.option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.option-list:focus-visible { box-shadow: none; }
.option .grow { flex: 1; }
.option .date { font-weight: 600; }
.option .who { font-size: 12.5px; color: var(--text-2); }
.option .check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; transition: all 0.15s; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.option:has(input:checked) .check { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--surface); }
.option:has(input:focus-visible) { box-shadow: var(--ring); }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 380px; padding: 11px 14px 11px 12px;
  border-radius: 12px; background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg);
  font-weight: 550; animation: toast-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast svg.i { width: 18px; height: 18px; }
.toast.success svg.i { color: #4ade80; }
.toast.error svg.i { color: #f87171; }
.toast.out { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.96); } }

/* ---------- skeleton ---------- */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .topbar-inner { padding: 0 14px; gap: 10px; }
  .brand-name, .nav-label, .user-chip .name { display: none; }
  .nav-btn { padding: 0 10px; }
  main { padding: 20px 14px 48px; }
  h1 { font-size: 22px; }
  .toolbar { width: 100%; }
  .toolbar select { flex: 1; min-width: 0; }
  .person-cell { min-width: 0; width: 60px; padding: 8px 10px 8px 12px; }
  .person-cell .person > div, .grid thead .person-cell .day-name { display: none; }
  .grid thead th { min-width: 58px; }
  .hero { grid-template-columns: 1fr 1fr; gap: 10px; }
  .hero .stat.now { grid-column: span 2; }
  .stat { padding: 14px; gap: 10px; }
  .stat:not(.now) .avatar { display: none; }
  .stat-value { font-size: 15px; }
  .stat-sub { font-size: 12px; }
  .legend-hint { margin-left: 0; }
  .swap-card { grid-template-columns: 1fr; }
  .swap-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
