:root {
  color-scheme: dark;
  --bg: #10110f;
  --bg-deep: #0b0c0b;
  --surface: #181a17;
  --surface-raised: #20231f;
  --surface-soft: #282c27;
  --surface-hover: #2d312c;
  --line: #33372f;
  --line-strong: #50564b;
  --text: #f6f5ef;
  --text-soft: #d8d9d1;
  --muted: #9ea399;
  --primary: #ef7b45;
  --primary-hover: #f58b58;
  --primary-ink: #251109;
  --primary-soft: rgba(239, 123, 69, 0.13);
  --success: #72c998;
  --success-soft: rgba(114, 201, 152, 0.12);
  --danger: #ed7777;
  --danger-soft: rgba(237, 119, 119, 0.11);
  --warning: #e7b76a;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.025), 0 8px 30px rgba(0, 0, 0, 0.13);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
  --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

html {
  min-width: 320px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% -10%, rgba(239, 123, 69, 0.08), transparent 32rem),
    radial-gradient(circle at 100% 40%, rgba(114, 201, 152, 0.035), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open { overflow: hidden; }

button,
input,
textarea,
select {
  font: inherit;
}

button { letter-spacing: 0; }

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

a { color: inherit; }

svg {
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

::selection {
  background: rgba(239, 123, 69, 0.3);
  color: var(--text);
}

:focus-visible {
  outline: 3px solid rgba(239, 123, 69, 0.38);
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(51, 55, 47, 0.78);
  background: rgba(16, 17, 15, 0.82);
  backdrop-filter: blur(18px) saturate(135%);
}

.topbar-inner {
  width: min(1280px, 100%);
  min-height: 76px;
  margin: 0 auto;
  padding:
    max(12px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    12px
    max(24px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand,
.topbar-actions {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(239, 123, 69, 0.34);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent),
    var(--primary-soft);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
  color: var(--primary);
  font-size: 20px;
  font-weight: 800;
}

.brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.brand-text strong {
  overflow: hidden;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text > span {
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  flex: 0 0 auto;
  gap: 8px;
}

.admin-badge {
  min-height: 32px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(114, 201, 152, 0.22);
  border-radius: 999px;
  background: var(--success-soft);
  color: #a5ddbd;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(114, 201, 152, 0.1);
}

/* Controls */
.btn {
  position: relative;
  min-height: 42px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 100ms ease;
}

.btn:active:not(:disabled),
.nav-btn:active:not(:disabled),
.icon-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 6px 20px rgba(239, 123, 69, 0.14);
  color: var(--primary-ink);
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  box-shadow: 0 8px 24px rgba(239, 123, 69, 0.22);
}

.btn-ghost {
  border-color: var(--line);
  background: rgba(32, 35, 31, 0.58);
  color: var(--text-soft);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.btn-soft {
  width: 100%;
  min-height: 44px;
  padding-right: 12px;
  justify-content: space-between;
  border-color: var(--line);
  background: var(--surface-raised);
  color: var(--text-soft);
  text-align: left;
}

.btn-soft:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-hover);
  color: var(--text);
}

.btn-soft.danger { color: #efadad; }
.btn-soft.danger:hover:not(:disabled) { border-color: rgba(237, 119, 119, 0.38); }
.btn.full { width: 100%; }

.btn.is-loading {
  color: transparent;
  pointer-events: none;
}

.btn.is-loading svg,
.btn.is-loading span {
  opacity: 0;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: var(--text);
  animation: spin 650ms linear infinite;
}

.btn-primary.is-loading::after { color: var(--primary-ink); }

.text-btn {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.text-btn:hover:not(:disabled) { color: var(--primary-hover); }

/* Main layout */
.layout {
  width: min(1280px, 100%);
  margin: 30px auto 64px;
  padding:
    0 max(24px, env(safe-area-inset-right))
    0 max(24px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  align-items: start;
  gap: 22px;
}

.calendar-card,
.legend-card {
  border: 1px solid var(--line);
  background: rgba(24, 26, 23, 0.9);
  box-shadow: var(--shadow-sm);
}

.calendar-card {
  min-width: 0;
  padding: 22px;
  border-radius: var(--radius-lg);
}

.legend-card {
  position: sticky;
  top: 98px;
  overflow: hidden;
  border-radius: var(--radius);
}

.cal-header {
  min-height: 55px;
  margin-bottom: 21px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 14px;
}

.cal-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.eyebrow,
.stats-eyebrow,
.section-kicker {
  display: block;
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
  line-height: 1.4;
  text-transform: uppercase;
}

.cal-title h2 {
  margin: 2px 0 1px;
  font-size: clamp(18px, 2vw, 23px);
  font-weight: 750;
  letter-spacing: -0.035em;
  text-align: center;
}

.nav-btn,
.modal-close,
.icon-btn {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--text-soft);
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 100ms ease;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 13px;
}

.nav-btn:hover:not(:disabled),
.modal-close:hover,
.icon-btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-hover);
  color: var(--text);
}

.calendar-body {
  position: relative;
  min-height: 420px;
}

.weekdays,
.grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekdays {
  margin-bottom: 8px;
  padding: 0 2px;
}

.weekdays span {
  padding: 4px 0;
  color: #858b80;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

.cell {
  position: relative;
  min-width: 0;
  aspect-ratio: 1.06;
  padding: 9px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #30342d;
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--text-soft);
  text-align: left;
  isolation: isolate;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms var(--ease);
}

button.cell {
  width: 100%;
  font: inherit;
  cursor: pointer;
}

.cell.empty {
  border-color: transparent;
  background: transparent;
}

.cell.weekend:not(.has-type) { background: #1d201c; }

.cell.clickable:hover {
  z-index: 2;
  border-color: var(--line-strong);
  background-color: var(--surface-hover);
  box-shadow: 0 9px 25px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.cell .fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.22;
}

.cell.has-type {
  border-color: rgba(255, 255, 255, 0.12);
}

.cell.has-type::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(150deg, transparent 42%, rgba(0, 0, 0, 0.2));
  pointer-events: none;
}

.cell .daynum {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.cell.today {
  border-color: rgba(239, 123, 69, 0.7);
  box-shadow: inset 0 0 0 1px rgba(239, 123, 69, 0.18);
}

.cell.today .daynum {
  background: var(--primary);
  box-shadow: 0 5px 16px rgba(239, 123, 69, 0.24);
  color: var(--primary-ink);
}

.cell-foot {
  z-index: 1;
  min-width: 0;
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 5px;
}

.cell-people {
  min-width: 0;
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
}

.cell-people span {
  width: 20px;
  height: 20px;
  margin-left: -4px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(24, 26, 23, 0.9);
  border-radius: 50%;
  background: var(--person);
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.25);
  color: #151612;
  font-size: 8px;
  font-weight: 850;
}

.note-dot {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  background: rgba(15, 16, 14, 0.42);
  color: rgba(255, 255, 255, 0.85);
}

.note-dot svg { width: 11px; height: 11px; }

.grid.is-loading { opacity: 0.18; }

.calendar-status {
  position: absolute;
  inset: 28px 0 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 14px;
  background: rgba(24, 26, 23, 0.9);
  color: var(--muted);
  text-align: center;
}

.calendar-status strong {
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
}

.calendar-status > span:last-of-type {
  max-width: 320px;
  font-size: 11px;
}

.calendar-status[data-state="error"] .spinner {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(237, 119, 119, 0.3);
  background: var(--danger-soft);
  animation: none;
}

.calendar-status[data-state="error"] .spinner::after {
  content: "!";
  display: grid;
  place-items: center;
  color: var(--danger);
  font-size: 16px;
  font-weight: 800;
}

.spinner {
  width: 20px;
  height: 20px;
  display: inline-block;
  border: 2px solid var(--line-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Sidebar */
.side-section { padding: 20px; }
.side-section + .side-section { border-top: 1px solid var(--line); }

.side-section h2 {
  margin: 4px 0 15px;
  font-size: 14px;
  font-weight: 730;
  letter-spacing: -0.015em;
}

.month-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.month-summary div {
  min-width: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
}

.month-summary strong {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.month-summary span {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
  list-style: none;
}

.legend li {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  font-size: 11px;
}

.legend li > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend .legend-empty {
  color: var(--muted);
  line-height: 1.5;
}

.swatch,
.bar-swatch {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
}

.legend .swatch {
  width: 13px;
  height: 13px;
}

.admin-tools {
  padding: 19px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.admin-tools .eyebrow { margin-bottom: 3px; }

.admin-tools.attention {
  animation: attention 700ms var(--ease);
}

@keyframes attention {
  30% { background: var(--primary-soft); }
}

.hint {
  margin: 0;
  padding: 17px 20px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.65;
}

.hint strong { color: var(--text-soft); }

/* Modals and forms */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 20px;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 5, 0.78);
  backdrop-filter: blur(7px);
  animation: fade-in 170ms ease-out;
}

.modal-panel {
  position: relative;
  width: min(540px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 27px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 220ms var(--ease);
}

.modal-panel.narrow { width: min(430px, calc(100vw - 40px)); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
}

.modal-panel h3 {
  margin: 5px 42px 6px 0;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.035em;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

.modal-close svg { width: 17px; height: 17px; }

.muted {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.field { margin: 20px 0; }

.field label,
.field-label {
  margin-bottom: 8px;
  display: block;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
}

.label-hint {
  margin-left: 5px;
  color: var(--muted);
  font-weight: 450;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  background: var(--surface-raised);
  color: var(--text);
  caret-color: var(--primary);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder,
textarea::placeholder { color: #747a70; }

input:hover,
textarea:hover,
select:hover { border-color: var(--line-strong); }

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  background: #232620;
  box-shadow: 0 0 0 3px rgba(239, 123, 69, 0.11);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.modal-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-start;
  gap: 9px;
}

.error,
.success {
  margin: 10px 0;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 11px;
  line-height: 1.45;
}

.error {
  border: 1px solid rgba(237, 119, 119, 0.2);
  background: var(--danger-soft);
  color: #f0abab;
}

.success {
  border: 1px solid rgba(114, 201, 152, 0.2);
  background: var(--success-soft);
  color: #a5ddbd;
}

/* Meetup editor */
.type-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.type-choice {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 100ms ease;
}

.type-choice:hover { border-color: var(--line-strong); }

.type-choice.selected {
  border-color: rgba(239, 123, 69, 0.58);
  background: var(--primary-soft);
  color: var(--text);
}

.type-choice .swatch {
  width: 19px;
  height: 19px;
  border-radius: 6px;
}

.type-choice .name {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-choice .check {
  width: 22px;
  height: 22px;
  margin-left: auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 11px;
  font-weight: 850;
  opacity: 0;
  transform: scale(0.75);
  transition: opacity 150ms ease, transform 150ms var(--ease);
}

.type-choice.selected .check {
  opacity: 1;
  transform: scale(1);
}

.attendance-choices {
  margin: 21px 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.attendance-group + .attendance-group { margin-top: 19px; }

.attendance-heading {
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.attendance-heading span {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.attendance-heading small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.participant-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.participant-choice {
  position: relative;
  min-width: 0;
  min-height: 82px;
  padding: 11px 7px;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.participant-choice:hover { border-color: var(--line-strong); }

.participant-choice.selected {
  border-color: var(--person, var(--primary));
  background: var(--surface-soft);
  color: var(--text);
}

.participant-choice .participant-check {
  position: absolute;
  top: 7px;
  right: 8px;
  color: var(--person);
  font-weight: 800;
  opacity: 0;
}

.participant-choice.selected .participant-check { opacity: 1; }

.participant-avatar,
.person-dot {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--person);
  color: #151612;
  font-weight: 850;
}

.participant-avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.person-dot {
  width: 19px;
  height: 19px;
  font-size: 8px;
}

/* Type management */
.types-list {
  margin: 20px 0 17px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
}

.type-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 42px 42px;
  gap: 8px;
}

.type-row input[type="color"],
.add-type input[type="color"] {
  width: 44px;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-raised);
  cursor: pointer;
}

.icon-btn {
  width: 42px;
  height: 44px;
  border-radius: 11px;
  color: var(--muted);
}

.icon-btn.del:hover { border-color: rgba(237, 119, 119, 0.45); color: var(--danger); }
.icon-btn.save { color: var(--success); font-weight: 850; }
.icon-btn svg { width: 16px; height: 16px; }

.add-type {
  padding-top: 17px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px auto;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.types-empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* Read-only detail */
.view-types {
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.view-type {
  padding: 13px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.view-type > .swatch {
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

.view-type-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.view-attendees {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attendance-missing {
  color: var(--warning);
  font-size: 10px;
  font-weight: 500;
}

.view-note { margin-top: 9px; }

.view-note-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.note-box {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Generic async states */
.state-panel {
  min-height: 300px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.state-panel strong {
  margin-top: 5px;
  color: var(--text);
  font-size: 14px;
}

.state-panel > span:last-of-type {
  max-width: 370px;
  font-size: 11px;
}

.state-panel .btn { margin-top: 8px; }

.state-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(237, 119, 119, 0.25);
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
}

/* Statistics */
.stats-panel {
  width: min(1140px, calc(100vw - 40px));
  padding: 30px;
}

.stats-head { padding-right: 42px; }
.stats-eyebrow,
.section-kicker { margin-bottom: 4px; }

.stats-head h2 {
  margin: 0 0 5px;
  font-size: 26px;
  font-weight: 760;
  letter-spacing: -0.04em;
}

.stats-head .muted { margin: 0; }
.stats-body { margin-top: 20px; }

.stats-filters {
  position: sticky;
  top: -30px;
  z-index: 4;
  margin: 0 -30px 20px;
  padding: 12px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(24, 26, 23, 0.94);
  backdrop-filter: blur(12px);
}

.period-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.period-tabs button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.period-tabs button:hover { color: var(--text); }

.period-tabs button.active {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.person-filter {
  min-width: 175px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.person-filter span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.person-filter select {
  min-height: 36px;
  padding: 6px 28px 6px 9px;
  font-size: 10px;
}

.data-notice {
  margin-bottom: 13px;
  padding: 10px 12px;
  border: 1px solid rgba(231, 183, 106, 0.18);
  border-left: 3px solid var(--warning);
  border-radius: 8px;
  background: rgba(231, 183, 106, 0.07);
  color: #d8c199;
  font-size: 10px;
  line-height: 1.5;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
}

.kpi {
  min-width: 0;
  min-height: 118px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-raised);
}

.kpi.primary { border-top: 2px solid var(--primary); }
.kpi.success { border-top: 2px solid var(--success); }

.kpi-label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.35;
}

.kpi-val {
  margin: 8px 0 5px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
}

.kpi-sub {
  min-height: 26px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.stats-section {
  min-width: 0;
  margin-top: 23px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.stats-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 26px;
}

.section-heading {
  min-height: 40px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.section-value {
  max-width: 48%;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  line-height: 1.45;
  text-align: right;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(105px, 155px) minmax(60px, 1fr) 42px;
  align-items: center;
  gap: 10px;
}

.bar-label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-swatch {
  width: 11px;
  height: 11px;
}

.bar-track,
.coverage-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.bar-fill,
.coverage-track span {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 999px;
  background: var(--primary);
}

.bar-val {
  font-size: 10px;
  font-weight: 750;
  text-align: right;
}

.stat-note,
.empty-copy {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.stat-note strong { color: var(--text); }

.col-chart {
  height: 178px;
  padding-top: 8px;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  overflow-x: auto;
}

.col {
  min-width: 34px;
  height: 100%;
  flex: 1 0 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.col-val {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.col-bar {
  width: 62%;
  border-radius: 5px 5px 1px 1px;
  background: linear-gradient(to top, #c85f31, var(--primary));
}

.col-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.2;
  text-align: center;
}

.weekday-chart {
  height: 178px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.weekday-chart > div {
  min-width: 0;
  display: grid;
  grid-template-rows: 18px 1fr 18px;
  gap: 4px;
  color: var(--muted);
  font-size: 8px;
  text-align: center;
}

.weekday-count { font-weight: 750; }

.weekday-bar {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 5px 5px 1px 1px;
  background: var(--surface-raised);
}

.weekday-bar i {
  position: absolute;
  right: 21%;
  bottom: 0;
  left: 21%;
  border-radius: 4px 4px 0 0;
  background: var(--success);
}

.weekday-chart .top { color: var(--text); }
.weekday-chart .top .weekday-bar i { background: var(--primary); }

.person-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.person-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-raised);
}

.person-card-top {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.person-card-top > span:nth-child(2) {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.person-card-top strong { font-size: 11px; }

.person-card-top small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.person-card-top b {
  font-size: 22px;
  letter-spacing: -0.04em;
}

.person-bar {
  height: 5px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.person-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.combination-summary {
  margin-bottom: 17px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-raised);
}

.combination-summary div {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.combination-summary div + div { border-left: 1px solid var(--line); }
.combination-summary span { color: var(--muted); font-size: 8px; }
.combination-summary b { font-size: 19px; }

.coverage-head {
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.coverage-head strong {
  font-size: 25px;
  letter-spacing: -0.04em;
}

.coverage-head span { color: var(--muted); font-size: 9px; }
.coverage-track span { background: var(--success); }
.compact-bars { margin-top: 19px; }

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.comparison-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-raised);
}

.comparison-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.comparison-head strong.up { color: var(--success); }
.comparison-head strong.down { color: #efa2a2; }

.comparison-values {
  margin-top: 15px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 10px;
}

.comparison-values span:not(.comparison-vs) {
  display: flex;
  flex-direction: column;
  color: var(--muted);
  font-size: 8px;
}

.comparison-values b {
  color: var(--text);
  font-size: 25px;
  letter-spacing: -0.04em;
}

.comparison-vs {
  padding-bottom: 3px;
  color: var(--muted);
  font-size: 8px;
}

.stats-timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stats-timeline li {
  min-height: 40px;
  display: grid;
  grid-template-columns: 50px 12px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}

.stats-timeline time {
  padding-top: 1px;
  color: var(--muted);
  font-size: 8px;
}

.timeline-marker {
  position: relative;
  width: 9px;
  height: 9px;
  margin-top: 2px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--type);
  box-shadow: 0 0 0 1px var(--type);
}

.stats-timeline li:not(:last-child) .timeline-marker::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 3px;
  width: 1px;
  height: 31px;
  background: var(--line);
}

.stats-timeline li div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-timeline strong {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-timeline small { color: var(--muted); font-size: 8px; }

.stats-empty {
  min-height: 300px;
  padding: 54px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
}

.stats-empty::before {
  content: "0";
  width: 42px;
  height: 42px;
  margin-bottom: 5px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-raised);
  color: var(--muted);
  font-weight: 800;
}

.stats-empty strong { color: var(--text); font-size: 14px; }
.stats-empty span { font-size: 10px; }

/* Toast */
.toast {
  position: fixed;
  right: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 80;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  color: var(--text-soft);
  font-size: 11px;
  animation: toast-in 220ms var(--ease);
}

.toast[data-tone="success"] {
  border-color: rgba(114, 201, 152, 0.32);
  background: #1d2921;
}

.toast[data-tone="error"] {
  border-color: rgba(237, 119, 119, 0.34);
  background: #2b1e1e;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* Responsive */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }

  .legend-card {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .side-section + .side-section {
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .admin-tools,
  .hint { grid-column: 1 / -1; }

  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-split { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (max-width: 680px) {
  .topbar-inner {
    min-height: 64px;
    padding:
      max(9px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      9px
      max(14px, env(safe-area-inset-left));
    gap: 10px;
  }

  .brand { gap: 9px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 12px; font-size: 18px; }
  .brand-text strong { font-size: 14px; }
  .brand-text > span { display: none; }
  .admin-badge { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { min-width: 40px; min-height: 40px; padding: 8px 11px; }
  .topbar-actions .btn svg { width: 17px; height: 17px; }
  .hide-sm { display: none; }

  .layout {
    margin: 14px auto 40px;
    padding:
      0 max(10px, env(safe-area-inset-right))
      0 max(10px, env(safe-area-inset-left));
    gap: 12px;
  }

  .calendar-card {
    padding: 14px 9px 11px;
    border-radius: 17px;
  }

  .cal-header {
    min-height: 50px;
    margin-bottom: 12px;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 8px;
  }

  .nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .cal-title h2 { font-size: 17px; }
  .cal-title .eyebrow { display: none; }
  .text-btn { font-size: 10px; }
  .calendar-body { min-height: 330px; }
  .weekdays, .grid { gap: 4px; }
  .weekdays { margin-bottom: 4px; }
  .weekdays span { padding: 3px 0; font-size: 8px; }

  .cell {
    min-height: 44px;
    aspect-ratio: 0.9;
    padding: 5px;
    border-radius: 8px;
  }

  .cell.clickable:hover {
    box-shadow: none;
    transform: none;
  }

  .cell .daynum {
    width: 21px;
    height: 21px;
    border-radius: 7px;
    font-size: 10px;
  }

  .cell-people span {
    width: 15px;
    height: 15px;
    margin-left: -3px;
    border-width: 1px;
    font-size: 6px;
  }

  .note-dot {
    width: 15px;
    height: 15px;
    border: 0;
    background: transparent;
  }

  .note-dot svg { width: 10px; height: 10px; }

  .legend-card {
    grid-template-columns: 1fr;
    border-radius: 15px;
  }

  .side-section { padding: 17px; }

  .side-section + .side-section {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
  }

  .modal {
    padding: 0;
    place-items: end stretch;
  }

  .modal-panel,
  .modal-panel.narrow,
  .stats-panel {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    padding: 22px 17px max(20px, calc(env(safe-area-inset-bottom) + 13px));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
    animation: sheet-in 230ms var(--ease);
  }

  @keyframes sheet-in {
    from { transform: translateY(100%); }
  }

  .modal-panel::before {
    content: "";
    width: 34px;
    height: 4px;
    margin: -10px auto 15px;
    display: block;
    border-radius: 999px;
    background: var(--line-strong);
  }

  .modal-panel h3 { font-size: 19px; }
  .modal-close { top: 17px; right: 14px; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; min-height: 46px; }
  .participant-choices { gap: 6px; }
  .participant-choice { min-height: 76px; }

  .type-row {
    grid-template-columns: 40px minmax(0, 1fr) 40px 40px;
    gap: 6px;
  }

  .type-row input[type="color"] { width: 40px; }
  .type-row .icon-btn { width: 40px; }

  .add-type { grid-template-columns: minmax(0, 1fr) 44px; }
  .add-type .btn { grid-column: 1 / -1; min-height: 44px; }

  .stats-head h2 { font-size: 22px; }
  .stats-body { margin-top: 16px; }

  .stats-filters {
    top: -22px;
    margin: 0 -17px 16px;
    padding: 10px 17px;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .period-tabs {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .period-tabs::-webkit-scrollbar { display: none; }
  .period-tabs button { flex: 0 0 auto; }
  .person-filter { width: 100%; }
  .person-filter select { flex: 1; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { min-height: 106px; padding: 13px; }
  .kpi-val { font-size: 25px; }
  .person-grid { grid-template-columns: 1fr; }
  .comparison-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: minmax(88px, 125px) minmax(45px, 1fr) 38px; gap: 7px; }
  .section-heading { min-height: 35px; }
  .section-value { max-width: 45%; }

  .toast {
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: 16px;
    max-width: none;
    text-align: center;
  }
}

@media (max-width: 390px) {
  .brand-text { display: none; }
  .legend { grid-template-columns: 1fr; }
  .cell { padding: 4px; }
  .cell-people span:nth-child(n + 3) { display: none; }
}

@media (hover: none) {
  .cell.clickable:hover {
    border-color: var(--line);
    background-color: var(--surface-raised);
    box-shadow: none;
    transform: none;
  }
}

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