/* ==================== CSS RESET & BASE ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
* { -webkit-tap-highlight-color: transparent; }

html {
  scrollbar-gutter: stable;
}

:root {
  color-scheme: light;
  --primary: #b55d3d;
  --primary-strong: #94472c;
  --primary-dark: #94472c;
  --primary-light: #f5dfd4;
  --primary-soft: #fcf2eb;
  --on-primary: #fff9f4;

  --success: #4f7d4e;
  --success-light: #e7f1e5;
  --success-strong: #3d6440;
  --danger: #b54845;
  --danger-light: #f7e3e2;
  --danger-strong: #983d3a;
  --warning: #aa7a2f;
  --warning-light: #f8eedb;
  --warning-ink: #7d5922;
  --warning-ink-strong: #8b641f;

  --on-success: #f6fff6;
  --on-danger: #fff7f7;

  --gray-50: #faf7f2;
  --gray-100: #f3ede4;
  --gray-200: #e7dccf;
  --gray-300: #d7c7b6;
  --gray-400: #ac9884;
  --gray-500: #7d6d5d;
  --gray-600: #5f5348;
  --gray-700: #473e36;
  --gray-800: #302922;

  --surface: #fffdf9;
  --surface-2: #fff7ef;
  --page-glow-1: #fff8ef;
  --page-glow-2: #f6ece0;
  --page-base-1: #f8f3eb;
  --page-base-2: #f4ede3;
  --page-base-3: #f0e6d7;
  --header-bg: rgba(255, 251, 245, 0.9);
  --header-shadow: 0 6px 16px rgba(69, 50, 33, 0.07);
  --mobile-nav-bg: rgba(255, 251, 245, 0.96);
  --input-bg: #fffdfa;
  --button-outline-hover-bg: #fff3e6;
  --button-outline-hover-border: #c8b29c;
  --table-head-bg: #fcf3e8;
  --table-row-hover: #fff7ee;
  --table-row-highlight: #fde9dc;
  --login-radial: rgba(255, 245, 232, 0.95);
  --login-base-1: #f2e5d6;
  --login-base-2: #e8d5c3;
  --status-toggle-bg: #fffdfa;
  --date-shell-hover-end: #fff3e8;
  --date-shell-active-end: #ffefdf;
  --stats-summary-start: #fffdf9;
  --stats-summary-end: #f8f4ee;
  --import-preview-start: #fffefb;
  --import-preview-end: #fff9f2;
  --import-preview-change-bg: rgba(125, 109, 93, 0.06);
  --import-preview-change-bg-new: rgba(181, 93, 61, 0.08);
  --modal-overlay-bg: rgba(38, 27, 17, 0.42);
  --speaker-hero-end: #fff8f2;
  --chart-accepted: #16a34a;
  --chart-declined: #b54845;
  --chart-line: #2f5d9f;
  --chart-point-fill: #fffdf9;
  --chart-grid: rgba(125, 109, 93, 0.18);
  --chart-text: #5f5348;
  --theme-color: #b55d3d;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 8px 22px rgba(56, 40, 24, 0.08);
  --shadow-lg: 0 18px 44px rgba(56, 40, 24, 0.14);
  --ring: 0 0 0 3px rgba(181, 93, 61, 0.2);

  --toast-bg: var(--gray-800);
  --toast-on-bg: var(--gray-100);
  --toast-dismiss-bg: rgba(255, 255, 255, 0.2);
  --toast-dismiss-hover-bg: rgba(255, 255, 255, 0.3);
  --danger-border: rgba(181, 72, 69, 0.35);
  --radius-xs: 6px;
  --radius-md: 14px;
  --radius-modal: 16px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --primary: #cd7f58;
    --primary-strong: #e1936d;
    --primary-dark: #f2c7b1;
    --primary-light: #4e3024;
    --primary-soft: #2f1d16;
    --on-primary: #fff8f2;

    --success: #86bb84;
    --success-light: #18301e;
    --success-strong: #a4d6a1;
    --danger: #d9817c;
    --danger-light: #381b1a;
    --danger-strong: #efaaa6;
    --warning: #d5aa5f;
    --warning-light: #3a2b10;
    --warning-ink: #e8bf7d;
    --warning-ink-strong: #f6d9a6;
    --on-success: #f8fff8;
    --on-danger: #fff7f6;

    --gray-50: #17110e;
    --gray-100: #211813;
    --gray-200: #322620;
    --gray-300: #4b3a32;
    --gray-400: #7c6a5f;
    --gray-500: #a99487;
    --gray-600: #cbbbae;
    --gray-700: #e6d9cf;
    --gray-800: #fbf5ef;

    --surface: #16110f;
    --surface-2: #1d1613;
    --page-glow-1: rgba(112, 63, 42, 0.22);
    --page-glow-2: rgba(69, 44, 36, 0.26);
    --page-base-1: #140f0d;
    --page-base-2: #1b1412;
    --page-base-3: #241a17;
    --header-bg: rgba(18, 14, 12, 0.88);
    --header-shadow: 0 10px 22px rgba(0, 0, 0, 0.34);
    --mobile-nav-bg: rgba(20, 15, 13, 0.96);
    --input-bg: #1f1714;
    --button-outline-hover-bg: #2a1e19;
    --button-outline-hover-border: #6d564b;
    --table-head-bg: #241b17;
    --table-row-hover: #211813;
    --table-row-highlight: #34211b;
    --login-radial: rgba(98, 56, 38, 0.24);
    --login-base-1: #1b1412;
    --login-base-2: #2a1d18;
    --status-toggle-bg: #1f1714;
    --date-shell-hover-end: #2a1d18;
    --date-shell-active-end: #32221b;
    --stats-summary-start: #1c1512;
    --stats-summary-end: #251b17;
    --import-preview-start: #1d1512;
    --import-preview-end: #261b16;
    --import-preview-change-bg: rgba(203, 187, 174, 0.08);
    --import-preview-change-bg-new: rgba(205, 127, 88, 0.14);
    --modal-overlay-bg: rgba(7, 5, 4, 0.72);
    --speaker-hero-end: #241915;
    --chart-accepted: #86bb84;
    --chart-declined: #d9817c;
    --chart-line: #8bb4e8;
    --chart-point-fill: #16110f;
    --chart-grid: rgba(201, 184, 172, 0.16);
    --chart-text: #cbbbae;
    --theme-color: #1a1412;
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.42);
    --ring: 0 0 0 3px rgba(205, 127, 88, 0.28);
    --toast-bg: var(--gray-200);
    --toast-on-bg: var(--gray-800);
    --danger-border: rgba(217, 129, 124, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]),
  :root[data-theme="auto"] {
    color-scheme: dark;
    --primary: #cd7f58;
    --primary-strong: #e1936d;
    --primary-dark: #f2c7b1;
    --primary-light: #4e3024;
    --primary-soft: #2f1d16;
    --on-primary: #fff8f2;

    --success: #86bb84;
    --success-light: #18301e;
    --success-strong: #a4d6a1;
    --danger: #d9817c;
    --danger-light: #381b1a;
    --danger-strong: #efaaa6;
    --warning: #d5aa5f;
    --warning-light: #3a2b10;
    --warning-ink: #e8bf7d;
    --warning-ink-strong: #f6d9a6;
    --on-success: #f8fff8;
    --on-danger: #fff7f6;

    --gray-50: #17110e;
    --gray-100: #211813;
    --gray-200: #322620;
    --gray-300: #4b3a32;
    --gray-400: #7c6a5f;
    --gray-500: #a99487;
    --gray-600: #cbbbae;
    --gray-700: #e6d9cf;
    --gray-800: #fbf5ef;

    --surface: #16110f;
    --surface-2: #1d1613;
    --page-glow-1: rgba(112, 63, 42, 0.22);
    --page-glow-2: rgba(69, 44, 36, 0.26);
    --page-base-1: #140f0d;
    --page-base-2: #1b1412;
    --page-base-3: #241a17;
    --header-bg: rgba(18, 14, 12, 0.88);
    --header-shadow: 0 10px 22px rgba(0, 0, 0, 0.34);
    --mobile-nav-bg: rgba(20, 15, 13, 0.96);
    --input-bg: #1f1714;
    --button-outline-hover-bg: #2a1e19;
    --button-outline-hover-border: #6d564b;
    --table-head-bg: #241b17;
    --table-row-hover: #211813;
    --table-row-highlight: #34211b;
    --login-radial: rgba(98, 56, 38, 0.24);
    --login-base-1: #1b1412;
    --login-base-2: #2a1d18;
    --status-toggle-bg: #1f1714;
    --date-shell-hover-end: #2a1d18;
    --date-shell-active-end: #32221b;
    --stats-summary-start: #1c1512;
    --stats-summary-end: #251b17;
    --import-preview-start: #1d1512;
    --import-preview-end: #261b16;
    --import-preview-change-bg: rgba(203, 187, 174, 0.08);
    --import-preview-change-bg-new: rgba(205, 127, 88, 0.14);
    --modal-overlay-bg: rgba(7, 5, 4, 0.72);
    --speaker-hero-end: #241915;
    --chart-accepted: #86bb84;
    --chart-declined: #d9817c;
    --chart-line: #8bb4e8;
    --chart-point-fill: #16110f;
    --chart-grid: rgba(201, 184, 172, 0.16);
    --chart-text: #cbbbae;
    --theme-color: #1a1412;
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.42);
    --ring: 0 0 0 3px rgba(205, 127, 88, 0.28);
    --toast-bg: var(--gray-200);
    --toast-on-bg: var(--gray-800);
    --danger-border: rgba(217, 129, 124, 0.35);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 14%, var(--page-glow-1) 0%, transparent 42%),
    radial-gradient(circle at 88% 4%, var(--page-glow-2) 0%, transparent 34%),
    linear-gradient(160deg, var(--page-base-1) 0%, var(--page-base-2) 58%, var(--page-base-3) 100%);
}

h1, h2, h3 { letter-spacing: -0.01em; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--primary-dark); text-decoration: none; }

button,
a,
.toast,
.toast-container {
  caret-color: transparent;
}

input,
textarea,
select {
  caret-color: auto;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

/* ==================== LAYOUT ==================== */
.app-header {
  background: var(--header-bg);
  color: var(--gray-800);
  border-bottom: 1px solid rgba(125, 109, 93, 0.2);
  backdrop-filter: blur(10px);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--header-shadow);
}

.app-header h1 {
  font-size: 1.05rem;
  font-weight: 650;
  white-space: nowrap;
}

.nav-tabs { display: flex; gap: 0.35rem; }

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--gray-600);
  padding: 0.42rem 0.78rem;
  border-radius: 999px;
  font-size: 0.84rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

.icon-inline svg {
  width: 100%;
  height: 100%;
  display: block;
}

.nav-icon {
  width: 1rem;
  height: 1rem;
}

.nav-tab:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: rgba(181, 93, 61, 0.25);
}
.nav-tab:active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: rgba(181, 93, 61, 0.25);
}

.nav-tab.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: rgba(181, 93, 61, 0.32);
  font-weight: 650;
}

.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin-right: -0.5rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  padding: 0.25rem;
}

.menu-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.theme-option-list {
  display: grid;
  gap: 0.75rem;
}

.theme-option {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--gray-300);
  background: var(--surface-2);
  color: var(--gray-700);
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.16s ease;
}

.theme-option:hover {
  border-color: rgba(181, 93, 61, 0.28);
  background: var(--primary-soft);
}

.theme-option.active {
  border-color: rgba(181, 93, 61, 0.36);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.theme-option-main {
  font-weight: 650;
}

.theme-option-meta {
  font-size: 0.84rem;
  color: var(--gray-500);
}

.edit-badge {
  background: var(--warning-light);
  color: var(--warning-ink-strong);
  border: 1px solid rgba(170, 122, 47, 0.34);
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
  margin-left: 0.5rem;
}

.app-title-row {
  min-width: 0;
  row-gap: 0.32rem;
}

.main-content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.4rem 1rem 2.25rem;
  animation: pageEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-focus-target {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
  pointer-events: none;
}

.app-focus-target:focus {
  outline: none;
  box-shadow: none;
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pageExit {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-3px); }
}

.main-content.page-exit {
  animation: pageExit 0.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: none;
}

.main-content.page-enter {
  animation: pageEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==================== CARDS & COMPONENTS ==================== */
.card,
.stat-card,
.family-card,
.modal,
.login-card {
  background: var(--surface);
  border: 1px solid rgba(125, 109, 93, 0.14);
  box-shadow: var(--shadow);
}

.card {
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.06rem;
  font-weight: 650;
  margin-bottom: 1rem;
  color: var(--gray-800);
}

.card-title-inline { margin-bottom: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.875rem;
  transition: transform 0.16s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover { background: var(--primary-strong); }
.btn-primary:active { background: var(--primary-strong); }

.btn-success {
  background: var(--success);
  color: var(--on-success);
}

.btn-success:hover { background: var(--success-strong); }
.btn-success:active { background: var(--success-strong); }

.btn-danger {
  background: var(--danger);
  color: var(--on-danger);
}

.btn-danger:hover { background: var(--danger-strong); }
.btn-danger:active { background: var(--danger-strong); }

.btn-outline {
  background: var(--surface-2);
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-outline:hover {
  background: var(--button-outline-hover-bg);
  border-color: var(--button-outline-hover-border);
}
.btn-outline:active {
  background: var(--button-outline-hover-bg);
  border-color: var(--button-outline-hover-border);
}

.btn-sm { padding: 0.35rem 0.72rem; font-size: 0.79rem; }
.btn-icon { padding: 0.38rem; min-width: 2rem; }

.button-icon {
  width: 1rem;
  height: 1rem;
}

.form-group { margin-bottom: 1rem; }

.form-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(120px, 1fr);
  gap: 0.7rem;
}

.form-label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--gray-600);
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.56rem 0.72rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: var(--input-bg);
  color: var(--gray-800);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.form-input.field-error,
.form-select.field-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(181, 72, 69, 0.2);
}

.field-error-message {
  color: var(--danger);
  font-size: 0.78rem;
  margin-top: 0.25rem;
  font-weight: 500;
}

.form-input-sm { padding: 0.32rem 0.48rem; font-size: 0.83rem; }

.badge {
  display: inline-block;
  padding: 0.16rem 0.52rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 650;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }

.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid transparent;
}

.alert-info {
  background: var(--primary-light);
  border-color: rgba(181, 93, 61, 0.24);
  color: var(--primary-dark);
}

.alert-success {
  background: var(--success-light);
  border-color: rgba(79, 125, 78, 0.2);
  color: var(--success-strong);
}

.alert-warning {
  background: var(--warning-light);
  border-color: rgba(170, 122, 47, 0.22);
  color: var(--warning-ink);
}

/* ==================== TABLE ==================== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(125, 109, 93, 0.16);
  border-radius: var(--radius);
  background: var(--surface);
}

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

th,
td {
  padding: 0.62rem 0.75rem;
  border-bottom: 1px solid rgba(125, 109, 93, 0.14);
  white-space: nowrap;
}

table:not(.print-table) th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--table-head-bg);
  color: var(--gray-700);
  font-weight: 700;
  text-align: left;
}

tr { transition: background-color 0.15s ease; }
tr:hover { background: var(--table-row-hover); }
tr.highlight { background: var(--table-row-highlight) !important; }
tr.no-speaker-row td {
  opacity: 0.72;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

/* ==================== LOGIN PAGE ==================== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background:
    radial-gradient(circle at top, var(--login-radial) 0%, transparent 46%),
    linear-gradient(155deg, var(--login-base-1) 0%, var(--login-base-2) 100%);
}

.login-card {
  border-radius: var(--radius-lg);
  padding: 2.3rem;
  max-width: 420px;
  width: 100%;
}

.login-card h1 { text-align: center; font-size: 1.5rem; margin-bottom: 0.45rem; }
.login-card p { text-align: center; color: var(--gray-500); margin-bottom: 1.35rem; font-size: 0.92rem; }
.login-card .form-input { padding: 0.75rem; font-size: 1rem; }
.login-card .btn { width: 100%; padding: 0.75rem; font-size: 1rem; }
.login-card .btn:disabled,
.login-card .form-input:disabled {
  cursor: wait;
  opacity: 0.72;
}
.login-error { color: var(--danger); font-size: 0.85rem; margin-top: 0.5rem; text-align: center; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--gray-400);
  font-size: 0.85rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}
.btn-biometric-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem;
  font-size: 1.05rem;
}
.login-passkey-setup {
  display: block;
  margin: 0.85rem auto 0;
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.login-passkey-setup:disabled {
  cursor: wait;
  opacity: 0.65;
}
.biometric-icon svg {
  width: 1.3em;
  height: 1.3em;
}
.login-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid rgba(125, 109, 93, 0.16);
  color: var(--gray-600);
  font-size: 0.9rem;
}
.login-status[hidden] { display: none !important; }
.login-status.background {
  background: var(--primary-soft);
  border-color: rgba(181, 93, 61, 0.2);
  color: var(--primary-dark);
}
.login-status-startup {
  margin-top: 1rem;
}
.login-status-spinner {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.setup-link { text-align: center; margin-top: 1rem; font-size: 0.86rem; }

/* ==================== SCHEDULE TABLE ==================== */

@keyframes rowEnter {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.schedule-row {
  animation: rowEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--row-i, 0) * 0.03s);
}

.schedule-row td { vertical-align: middle; padding: 0.35rem 0.5rem; }

.date-full, .date-short, .date-compact { display: none; }
.date-full { display: inline; }

.date-clickable {
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: inherit;
}
button.family-name-link {
  font-family: inherit;
  line-height: inherit;
  color: inherit;
  text-align: inherit;
}

/* Text for screen readers only. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 768px) {
  .date-full { display: none; }
  .date-short { display: inline; }
}

@media (max-width: 480px) {
  .date-short { display: none; }
  .date-compact {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
  }
  .date-compact-day,
  .date-compact-month { display: block; }
  .date-compact-month { font-size: 0.7em; }
}

.status-chip {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid transparent;
}

@keyframes chipPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.status-chip.pulse {
  animation: chipPulse 0.35s ease;
}

.inline-status,
.status-picker-btn,
.clickable-name {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.family-name-link {
  display: inline-block;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-xs);
  background: var(--gray-50);
  font-size: 0.8rem;
}

.family-name-link.inactive {
  color: var(--gray-500);
  border-color: var(--gray-200);
  background: var(--gray-100);
}

.family-name-break { display: none; }

.family-name-display {
  font-size: 1rem;
}

.host-cell-content {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.3rem;
}

.schedule-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.oratore-cell-content {
  display: flex;
  align-items: center;
  min-width: 0;
}

.oratore-status {
  display: flex;
  align-items: center;
  margin-right: 0.3rem;
}

.oratore-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  min-width: 0;
  flex: 1;
}

.oratore-info small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

.schedule-note-fallback {
  display: inline-flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
  margin-left: 0.3rem;
  max-width: 100%;
}

.schedule-note-primary {
  font-weight: 600;
  color: var(--gray-700);
}

.schedule-note-secondary {
  color: var(--gray-500);
}

.form-input-readonly {
  background: var(--gray-50);
  color: var(--gray-600);
  cursor: default;
}

.schedule-col-date {
  width: 1%;
}

.schedule-col-host,
.schedule-col-speaker {
  min-width: 0;
}

.status-chip svg,
.status-option svg {
  width: 16px;
  height: 16px;
  display: block;
}

.status-chip.empty { background: var(--gray-100); color: var(--gray-500); border-color: var(--gray-300); }
.status-chip.pending { background: var(--warning-light); color: var(--warning-ink-strong); border-color: rgba(170, 122, 47, 0.35); }
.status-chip.accepted { background: var(--success-light); color: var(--success); border-color: rgba(79, 125, 78, 0.3); }
.status-chip.declined { background: var(--danger-light); color: var(--danger); border-color: rgba(181, 72, 69, 0.3); }

.status-toggle {
  display: inline-flex;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  padding: 0.14rem;
  background: var(--status-toggle-bg);
  gap: 0.15rem;
}

.status-option {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--gray-500);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.status-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.status-option:hover { background: var(--gray-100); }
.status-radio:checked + .status-option.empty { background: var(--gray-200); color: var(--gray-700); }
.status-radio:checked + .status-option.pending { background: var(--warning-light); color: var(--warning-ink-strong); }
.status-radio:checked + .status-option.accepted { background: var(--success-light); color: var(--success); }
.status-radio:checked + .status-option.declined { background: var(--danger-light); color: var(--danger); }
.status-radio:focus-visible + .status-option { box-shadow: var(--ring); }

.printed-badge {
  margin-top: 0.2rem;
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 650;
  padding: 0.06rem 0.42rem;
  border-radius: 999px;
  color: var(--warning-ink);
  background: var(--warning-light);
  border: 1px solid rgba(170, 122, 47, 0.28);
}

.recommendation {
  margin-top: 0.28rem;
  background: var(--success-light);
  border-radius: 999px;
  padding: 0.12rem 0.52rem;
  font-size: 0.73rem;
  display: inline-flex;
}

.past-row { opacity: 0.62; }
.today-row { box-shadow: inset 3px 0 0 var(--primary); }
.own-family-row > td { background: var(--primary-light); }
.own-family-row .family-name-display { font-weight: 650; }

/* ==================== STATS ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  border-radius: var(--radius);
  padding: 1.2rem;
  text-align: center;
}

.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary-dark); }
.stat-label { font-size: 0.83rem; color: var(--gray-500); margin-top: 0.3rem; }
.chart-container { position: relative; height: 300px; max-height: 40vh; }
.chart-container-lg { height: 400px; }

.stats-overall-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(125, 109, 93, 0.14);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--stats-summary-start) 0%, var(--stats-summary-end) 100%);
}

.stats-overall-kicker {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.stats-overall-value {
  margin-top: 0.18rem;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.stats-overall-detail {
  font-size: 0.92rem;
  color: var(--gray-600);
  white-space: nowrap;
}

.stats-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stats-filter-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
}

.stats-filter-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--gray-600);
}

.stats-filter-field .form-input {
  width: auto;
}

.stats-info-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  margin-left: 0.3rem;
  vertical-align: middle;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--gray-600);
  font-size: 0.72rem;
  font-weight: 700;
  font-style: italic;
  cursor: help;
}

.stats-info-badge .icon-inline {
  width: 0.8rem;
  height: 0.8rem;
}

.stats-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.stats-resolution-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  padding: 0.18rem;
  border: 1px solid rgba(125, 109, 93, 0.16);
  border-radius: 999px;
  background: var(--surface-2);
}

.stats-resolution-btn {
  border: none;
  background: transparent;
  color: var(--gray-600);
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.stats-resolution-btn:hover {
  background: rgba(181, 93, 61, 0.08);
  color: var(--primary-dark);
}

.stats-resolution-btn.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.stats-family-totals {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.stats-family-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(125, 109, 93, 0.14);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.stats-family-row.inactive {
  background: var(--gray-100);
  border-color: rgba(125, 109, 93, 0.1);
  opacity: 0.7;
}

.stats-family-name {
  min-width: 0;
  font-weight: 600;
  color: var(--gray-700);
}

.stats-family-metrics {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  flex-shrink: 0;
}

.stats-family-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.08rem;
}

.stats-family-metric-label {
  font-size: 0.72rem;
  color: var(--gray-500);
}

.stats-family-total {
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--primary-dark);
}

.stats-family-total-success {
  color: var(--success);
}

/* ==================== FAMILY CARDS ==================== */
.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 1rem;
}

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.family-card {
  border-radius: var(--radius);
  padding: 1rem;
  border-left: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  animation: cardEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--card-i, 0) * 0.03s);
}

.family-card.inactive {
  border-left-color: var(--gray-300);
  opacity: 0.68;
}

.family-name { font-weight: 650; font-size: 1.03rem; }
.family-meta { font-size: 0.82rem; color: var(--gray-500); }

.family-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.55rem;
}

/* ==================== PRINT STYLES ==================== */
.print-preview {
  max-width: 780px;
  margin: 0 auto;
  background: linear-gradient(180deg, #fffefb 0%, #fffdf9 100%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(125, 109, 93, 0.18);
  box-shadow: 0 18px 40px rgba(58, 43, 29, 0.08);
  padding: 2rem 2.2rem 2.15rem;
}

.print-sheet-header {
  text-align: center;
}

.print-sheet-title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
  font-weight: 700;
  color: #403126;
}

.print-sheet-meta {
  margin-top: 0.32rem;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  color: #7a6251;
}

.print-sheet-divider {
  height: 1px;
  margin: 1.35rem 0 1rem;
  background: linear-gradient(90deg, rgba(143, 130, 119, 0) 0%, rgba(143, 130, 119, 0.5) 20%, rgba(143, 130, 119, 0.5) 80%, rgba(143, 130, 119, 0) 100%);
}

.print-quarter-title {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
  color: #473e36;
}

.date-range-controls,
.print-controls {
  background: var(--surface);
  border: 1px solid rgba(125, 109, 93, 0.16);
  border-radius: var(--radius);
  padding: 0.95rem;
  margin-bottom: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  box-shadow: 0 6px 18px rgba(56, 40, 24, 0.06);
}

.date-range-controls .form-group,
.print-controls .form-group { margin-bottom: 0; }

.date-range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.date-range-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.date-range-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.date-range-icon {
  width: 2.3rem;
  height: 2.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  flex-shrink: 0;
}

.date-range-icon-svg {
  width: 1.05rem;
  height: 1.05rem;
}

.date-range-title {
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--gray-800);
}

.date-range-summary {
  margin-top: 0.1rem;
  font-size: 0.8rem;
  color: var(--gray-500);
}

.date-range-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.date-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}

.date-field-label {
  margin-bottom: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--gray-500);
}

.date-input-shell {
  border: 1px solid rgba(125, 109, 93, 0.18);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border-radius: var(--radius-md);
  padding: 0.16rem;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.date-input-shell:hover {
  border-color: rgba(181, 93, 61, 0.3);
  background: linear-gradient(180deg, var(--surface) 0%, var(--date-shell-hover-end) 100%);
}

.date-input-shell:active {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--date-shell-active-end) 100%);
}

.date-input-shell:focus-within {
  border-color: rgba(181, 93, 61, 0.44);
  box-shadow: var(--ring);
}

.date-input {
  min-height: 3rem;
  padding: 0.82rem 0.9rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  font-size: 0.95rem;
  line-height: 1.2;
  box-shadow: none !important;
  cursor: pointer;
}

.date-input:focus {
  border-color: transparent;
  box-shadow: none;
}

.date-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  padding: 0.18rem;
}

.date-range-controls-compact {
  padding: 0.55rem 0.65rem;
  gap: 0.45rem;
  border-radius: var(--radius-md);
}

.date-range-controls-compact {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(200px, 0.9fr);
  align-items: end;
}

.date-range-controls-compact .date-range-fields {
  gap: 0.5rem;
}

.date-range-controls-compact .date-range-extra {
  justify-content: flex-start;
  align-self: end;
  min-width: 0;
}

.date-input-shell-compact {
  border-radius: var(--radius-sm);
  padding: 0.08rem;
}

.date-input-compact {
  min-height: 2.15rem;
  padding: 0.42rem 0.6rem;
  font-size: 0.83rem;
}

.form-select-compact {
  min-height: 2.15rem;
  padding: 0.42rem 2rem 0.42rem 0.6rem;
  font-size: 0.83rem;
}

.date-field-group-family {
  min-width: min(220px, 100%);
  margin-bottom: 0;
}

.date-range-reset {
  align-self: flex-start;
  white-space: nowrap;
}

.date-range-extra {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.print-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--gray-700);
  white-space: nowrap;
}

.filter-reset-hidden {
  visibility: hidden;
  pointer-events: none;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.92rem;
  color: #433327;
}

.print-col-date {
  width: 22%;
}

.print-col-host {
  width: 29%;
}

.print-col-speaker {
  width: 49%;
}

.print-table th,
.print-table td {
  padding: 0.82rem 0.8rem;
  border-bottom: 1px solid #a99a8f;
}

.print-table thead th {
  background: #f2e8dc;
  color: #5e4a3b;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-top: 1px solid #8f8277;
  border-bottom: 1px solid #8f8277;
  position: static;
  text-align: left;
}

.print-table tbody td:first-child {
  font-weight: 650;
  color: #4b3a2f;
}

.print-table tbody td:nth-child(1),
.print-table tbody td:nth-child(2) {
  vertical-align: middle;
  text-align: left;
}

.print-table tbody td:nth-child(3) {
  vertical-align: top;
  text-align: left;
}

.print-month-group-even td {
  background: rgba(242, 232, 220, 0.28);
}

.print-month-group-odd td {
  background: transparent;
}

.print-month-start td {
  border-top: 2px solid #8f8277;
}

.print-date-value {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.print-host-name {
  display: block;
  font-weight: 700;
  color: #3f3024;
  line-height: 1.35;
  text-align: left;
}

.print-speaker-cell {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  align-items: flex-start;
}

.print-speaker-name {
  font-weight: 500;
  color: #5f4d3f;
}

.print-speaker-congregation {
  font-size: 0.8rem;
  line-height: 1.3;
  color: #867468;
}

.print-speaker-note {
  line-height: 1.35;
  color: #6a584b;
}

.print-table tbody tr:last-child td {
  border-bottom-color: #8f8277;
}

.modal-import-preview {
  max-width: 760px;
}

.import-preview {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.import-preview-file {
  font-size: 0.88rem;
  color: var(--gray-600);
}

.import-preview-cutoff {
  margin-bottom: 0;
}

.import-preview-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.import-summary-card {
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(125, 109, 93, 0.14);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.import-summary-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.import-summary-value {
  margin-top: 0.18rem;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.import-preview-note {
  font-size: 0.88rem;
  color: var(--gray-700);
}

.import-preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: 44vh;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.import-preview-row {
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(125, 109, 93, 0.14);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--import-preview-start) 0%, var(--import-preview-end) 100%);
}

.import-preview-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.import-preview-row-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.import-preview-merged {
  font-size: 0.76rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.import-preview-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  margin-top: 0.45rem;
  font-size: 0.84rem;
  color: var(--gray-700);
}

.import-preview-changes {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px dashed rgba(125, 109, 93, 0.22);
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.import-preview-change {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.8rem;
  color: var(--gray-600);
}

.import-preview-change-label {
  font-weight: 700;
  color: var(--gray-700);
}

.import-preview-change-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.55rem;
  align-items: stretch;
}

.import-preview-change-side {
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--import-preview-change-bg);
  min-width: 0;
}

.import-preview-change-side-new {
  background: var(--import-preview-change-bg-new);
}

.import-preview-change-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.import-preview-change-value {
  margin-top: 0.18rem;
  color: var(--gray-700);
  word-break: break-word;
}

.import-preview-change-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  font-weight: 700;
}

.import-preview-empty {
  padding: 0.95rem 1rem;
  border: 1px dashed rgba(125, 109, 93, 0.24);
  border-radius: var(--radius);
  text-align: center;
  color: var(--gray-500);
}

/* ==================== MODAL ==================== */
body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* A dialog below a confirmation stays visible; the confirmation's backdrop
   dims both. */
.modal-overlay.modal-overlay-underneath {
  background: transparent;
  backdrop-filter: none;
}

.modal {
  position: relative;
  border-radius: var(--radius-modal);
  padding: 1.4rem;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  animation: popIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(125, 109, 93, 0.18);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--gray-600);
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.16s ease;
}

.modal-close:hover {
  background: var(--primary-soft);
  border-color: rgba(181, 93, 61, 0.22);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

.modal-close-icon {
  width: 0.9rem;
  height: 0.9rem;
}

.modal-title { font-size: 1.08rem; font-weight: 650; margin-bottom: 1rem; }
.modal-title[tabindex="-1"]:focus { outline: none; }

.modal-confirm {
  max-width: 460px;
}

.modal-signal-message {
  max-width: 680px;
}

.confirm-message {
  font-size: 0.95rem;
  color: var(--gray-700);
  line-height: 1.6;
}

/* Shown only where the Programma row hides its own action buttons. */
.modal-actions .modal-action-mobile { display: none; }

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.signal-message-hint {
  margin-top: 0.2rem;
  font-size: 0.84rem;
  color: var(--gray-500);
}

.signal-cantico-row {
  display: flex;
  align-items: flex-end;
  gap: 0.7rem;
}

.signal-cantico-fields {
  flex: 1 1 auto;
  min-width: 0;
  grid-template-columns: minmax(0, 96px) minmax(0, 1fr);
}

.signal-cantico-fields .form-group {
  margin-bottom: 0;
}

.signal-cantico-save {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  padding: 0;
  border-radius: 50%;
}

.message-center-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.message-center-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--gray-300);
  background: var(--surface-2);
  color: var(--gray-600);
  font-size: 0.86rem;
}

.message-center-tab-icon,
.settings-action-icon {
  width: 0.95rem;
  height: 0.95rem;
}

.message-center-tab-icon-signal,
.settings-action-icon-signal,
.message-center-tab-icon-whatsapp,
.settings-action-icon-whatsapp {
  width: 1rem;
  height: 1rem;
}

.icon-inline.message-center-tab-icon-signal svg,
.icon-inline.settings-action-icon-signal svg {
  transform: scale(0.94);
  transform-origin: center;
}

.icon-inline.message-center-tab-icon-whatsapp svg,
.icon-inline.settings-action-icon-whatsapp svg {
  transform: translateY(0.02rem) scale(0.92);
  transform-origin: center;
}

.message-center-tab:hover {
  border-color: rgba(181, 93, 61, 0.28);
  background: var(--primary-soft);
}

.message-center-tab.active {
  border-color: rgba(181, 93, 61, 0.34);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.message-center-tab:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.message-center-actions {
  margin-top: 1rem;
}

.signal-message-preview {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(125, 109, 93, 0.16);
  background: var(--surface-2);
  color: var(--gray-700);
  white-space: pre-wrap;
  line-height: 1.6;
  min-height: 260px;
  overflow-x: auto;
}

.signal-message-preview-tight {
  min-height: 180px;
}

.email-preview-group {
  margin-top: 1rem;
}

.email-preview-shell {
  margin-top: 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(125, 109, 93, 0.16);
  background: var(--surface-2);
  overflow: hidden;
}

.email-preview-shell-editor {
  margin-top: 0;
}

.email-preview-frame {
  width: 100%;
  height: 260px;
  border: 0;
  display: block;
  background: #f8f5f1;
}

.advanced-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--gray-600);
  cursor: pointer;
  margin: 1rem 0;
  padding: 0.5rem;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}

.advanced-toggle input {
  width: 16px;
  height: 16px;
}

.advanced-fields {
  display: none;
  padding-top: 0.5rem;
  border-top: 1px solid var(--gray-200);
  margin-top: 0.5rem;
}

.family-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 60vh;
  overflow-y: auto;
}

.family-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s ease;
}

.family-option:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.scroll-shadow-container {
  position: relative;
  overflow: hidden;
}

.scroll-shadow {
  position: absolute;
  left: 0;
  right: 0;
  height: 16px;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.scroll-shadow--top {
  top: 0;
  background: linear-gradient(to bottom, var(--surface-2) 0%, transparent 100%);
}
.scroll-shadow--bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--surface-2) 0%, transparent 100%);
}
.scroll-shadow.visible {
  opacity: 1;
}

.family-option.selected {
  background: var(--primary-light);
  border-color: var(--primary);
}

.family-option-text {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.08rem;
}

.family-option-name {
  text-align: left;
  font-weight: 600;
}

.family-option-meta {
  font-size: 0.78rem;
  color: var(--gray-500);
  text-align: left;
}

.family-option-icon {
  display: inline-flex;
  margin-right: 0.5rem;
}

.family-option-check {
  display: inline-flex;
  align-items: center;
  color: var(--success);
}

.check-icon {
  width: 1rem;
  height: 1rem;
}

.speaker-contact-modal {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.speaker-contact-hero {
  padding: 1rem 1.05rem;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--speaker-hero-end) 100%);
  border: 1px solid rgba(181, 93, 61, 0.14);
}

.speaker-contact-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-dark);
  margin-bottom: 0.2rem;
  font-weight: 700;
}

.speaker-contact-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.25;
}

.speaker-contact-subtitle {
  margin-top: 0.28rem;
  font-size: 0.95rem;
  color: var(--gray-600);
  line-height: 1.4;
}

.speaker-contact-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.speaker-contact-row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

.email-contact-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.email-field {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid rgba(125, 109, 93, 0.16);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.email-field-label {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray-500);
}

.email-field-value {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-field-copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid rgba(125, 109, 93, 0.18);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--gray-600);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.email-field-copy:hover {
  background: var(--primary-soft);
  border-color: rgba(181, 93, 61, 0.24);
  color: var(--primary-dark);
}

.email-field-copy:disabled {
  opacity: 0.5;
  cursor: default;
}

.email-field-copy-icon {
  width: 0.95rem;
  height: 0.95rem;
}

.speaker-contact-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.speaker-contact-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(125, 109, 93, 0.16);
  background: var(--surface);
}

.speaker-contact-card-static {
  background: var(--surface-2);
}

.speaker-contact-action {
  flex: 1;
  color: inherit;
  transition: transform 0.16s ease, border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.speaker-contact-action:hover {
  transform: translateY(-1px);
  background: var(--primary-soft);
  border-color: rgba(181, 93, 61, 0.24);
  box-shadow: var(--shadow);
}

.speaker-contact-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  flex-shrink: 0;
}

.speaker-contact-icon-svg {
  width: 1.15rem;
  height: 1.15rem;
}

.speaker-contact-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.speaker-contact-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray-500);
}

.speaker-contact-value {
  font-size: 0.96rem;
  color: var(--gray-800);
  word-break: break-word;
}

.speaker-contact-copy-btn {
  width: 3rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(125, 109, 93, 0.16);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--gray-600);
  transition: transform 0.16s ease, border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.speaker-contact-copy-btn:hover {
  transform: translateY(-1px);
  background: var(--primary-soft);
  border-color: rgba(181, 93, 61, 0.24);
  color: var(--primary-dark);
}

.speaker-contact-copy-icon {
  width: 1rem;
  height: 1rem;
}

.speaker-contact-empty {
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius);
  background: var(--gray-50);
  border: 1px dashed var(--gray-300);
  color: var(--gray-500);
  font-size: 0.9rem;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes popOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(6px) scale(0.98); }
}

.modal-overlay-exit {
  animation: fadeOut 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.modal-exit {
  animation: popOut 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 901px) and (max-width: 1024px) {
  .app-header h1 { display: none; }
}

@media (max-width: 900px) {
  .hamburger { display: inline-flex; }

  .app-title-row { min-width: 0; flex-wrap: nowrap; }
  .app-header h1 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-tabs {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 62px;
    left: 0;
    right: 0;
    background: var(--mobile-nav-bg);
    border-bottom: 1px solid rgba(125, 109, 93, 0.18);
    box-shadow: var(--shadow);
    padding: 0.45rem;
    max-height: calc(100vh - 62px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform-origin: top;
    opacity: 0;
    transform: scaleY(0.95);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
  }

  .nav-tabs.open {
    opacity: 1;
    transform: scaleY(1);
    pointer-events: auto;
    visibility: visible;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s;
  }

  .nav-tab {
    min-height: 44px;
    /* Not "all": an inherited visibility transition would keep the first
       item unfocusable for a frame after the menu opens. */
    transition-property: background-color, border-color, color, box-shadow, transform;
    text-align: left;
    padding: 0.72rem 0.92rem;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
  }

  .edit-badge { font-size: 0.58rem; padding: 0.08rem 0.34rem; }
}

@media (max-width: 768px) {
  body { font-size: 14px; }

  .main-content { padding: 0.82rem 0.52rem 1.25rem; }

  .card { padding: 1rem; margin-bottom: 0.74rem; border-radius: var(--radius-md); }
  .card-title { font-size: 0.98rem; margin-bottom: 0.68rem; }

  .btn { padding: 0.5rem 0.75rem; font-size: 0.81rem; }
  .btn-sm { padding: 0.36rem 0.52rem; font-size: 0.75rem; }

  .toolbar { gap: 0.45rem; margin-bottom: 0.75rem; }
  .toolbar .btn { width: 100%; justify-content: center; }
  .date-range-controls,
  .print-controls { padding: 0.8rem; }
  .date-range-controls-compact {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .date-range-header,
  .date-range-extra {
    flex-direction: column;
    align-items: stretch;
  }
  .date-range-actions {
    width: 100%;
    justify-content: stretch;
  }
  .date-range-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .date-range-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .date-range-reset { width: 100%; align-self: stretch; }
  .print-toggle { white-space: normal; }
  .filter-reset-hidden { display: none; }

  /* 16px keeps iOS Safari from zooming into focused fields. */
  .form-input, .form-select, textarea { padding: 0.5rem; font-size: 16px; min-height: 44px; }
  .btn, .btn-sm { min-height: 44px; }
  .form-group { margin-bottom: 0.75rem; }
  .form-label { font-size: 0.8rem; }
  .form-grid-2 { grid-template-columns: minmax(0, 1.35fr) minmax(106px, 1fr); }
  .signal-cantico-fields { grid-template-columns: minmax(0, 84px) minmax(0, 1fr); }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
  .stat-card { padding: 0.74rem; }
  .stat-value { font-size: 1.45rem; }
  .stat-label { font-size: 0.75rem; }
  .stats-overall-summary {
    flex-direction: column;
    align-items: stretch;
  }
  .stats-overall-detail {
    white-space: normal;
  }
  .stats-chart-header {
    flex-direction: column;
    align-items: stretch;
  }
  .stats-resolution-toggle {
    width: 100%;
    justify-content: stretch;
  }
  .stats-resolution-btn {
    flex: 1;
    text-align: center;
  }

  .table-wrap { margin: 0 -0.5rem; padding: 0 0.5rem; overflow-x: hidden; }
  table { font-size: 0.75rem; width: 100%; }
  th, td { padding: 0.4rem 0.35rem; white-space: normal; word-break: break-word; }
  th { white-space: nowrap; }
  .print-preview {
    padding: 1.35rem 1rem 1.45rem;
  }
  .print-sheet-title {
    font-size: 1.55rem;
  }
  .print-sheet-subtitle {
    font-size: 0.88rem;
  }
  .import-preview-summary {
    grid-template-columns: 1fr;
  }
  .import-preview-row-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .import-preview-change-values {
    grid-template-columns: 1fr;
  }
  .import-preview-change-arrow {
    display: none;
  }
  .version-history-item {
    flex-direction: column;
    align-items: stretch;
  }
  .version-history-item .btn {
    width: 100%;
    justify-content: center;
  }

  .schedule-col-date {
    width: 42px;
    min-width: 42px;
    text-align: center;
  }

  .schedule-col-host {
    width: 50%;
  }

  .schedule-table-admin .schedule-col-host {
    width: 45%;
  }

  .schedule-col-speaker {
    width: auto;
  }

  .host-cell-content,
  .oratore-cell-content {
    min-width: 0;
  }

  .oratore-status {
    flex-shrink: 0;
  }

  .oratore-info {
    min-width: 0;
    flex: 1;
  }

  .schedule-table-admin {
    table-layout: fixed;
  }

  .admin-mobile-hide {
    display: none;
  }

  .host-cell-content {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    width: 100%;
  }

  .schedule-col-host .family-name-link {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    padding: 0.3rem 0.4rem;
  }

  /* Clamp on the inner text: padding on the clamped box itself would show
     a sliver of a third line. */
  .schedule-col-host .family-name-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.2;
  }

  .family-name-break { display: inline; }

  .schedule-row .family-select,
  .schedule-row .status-select {
    display: none;
  }

  /* Edit button hidden on mobile - use date-clickable instead */
  .schedule-row .show-edit-btn,
  .schedule-row .show-host-message-btn { display: none; }

  /* Long speaker names wrap to two lines instead of collapsing to "Lu…". */
  .clickable-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    max-width: 100%;
    min-height: 24px;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
    line-height: 1.25;
  }

  .oratore-info small {
    max-width: 100%;
  }

  .hide-mobile { display: none !important; }

  .toast { max-width: calc(100vw - 2rem); font-size: 0.84rem; }
  .toast-container { left: 1rem; right: 1rem; bottom: 0.55rem; }

  .speaker-contact-card {
    padding: 0.8rem 0.85rem;
    gap: 0.7rem;
  }

  .speaker-contact-row {
    gap: 0.5rem;
  }

  .speaker-contact-icon {
    width: 2.2rem;
    height: 2.2rem;
  }

  .speaker-contact-copy-btn {
    width: 2.7rem;
  }

  .modal-close {
    top: 0.45rem;
    right: 0.45rem;
    width: 44px;
    height: 44px;
  }

  .modal-actions .btn { flex: 1 1 auto; justify-content: center; }
  .modal-actions .modal-action-mobile { display: inline-flex; }

  /* Touch targets: at least 44px; inline text buttons grow their hit area
     with padding and an equal negative margin so rows keep their height. */
  .schedule-col-date { width: 52px; min-width: 52px; }
  .date-clickable { min-height: 44px; width: calc(100% + 0.7rem); margin: 0 -0.35rem; }
  .stats-resolution-btn { min-height: 44px; }
  .toast-dismiss::before {
    content: '';
    position: absolute;
    inset: -10px;
  }

  .btn-icon,
  .status-chip,
  .status-option,
  .inline-status,
  .status-picker-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .status-chip,
  .status-option {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  .form-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .modal { padding: 1.1rem; }
  .card { padding: 0.75rem; }
  th, td, .schedule-row td { padding-left: 0.25rem; padding-right: 0.25rem; }
  .schedule-table-admin .schedule-col-host { width: 42%; }
  .schedule-col-date { width: 48px; min-width: 48px; }
  .date-clickable { width: calc(100% + 0.5rem); margin: 0 -0.25rem; }
  .oratore-cell-content, .host-cell-content { gap: 0.2rem; }
  .app-header { padding: 0 0.52rem; }
  .app-header h1 { font-size: 0.88rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.2rem; }
  table { }
  .chart-container { height: 250px; }

  .clickable-name { max-width: 100%; }
  .oratore-info small { max-width: 100%; }

  .family-name-link {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 360px) {
  .date-range-fields { grid-template-columns: minmax(0, 1fr); }
}

/* ==================== OFFLINE BANNER ==================== */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 350;
  background: var(--danger-light);
  border-bottom: 2px solid var(--danger);
  color: var(--danger-strong);
  padding: 0.55rem 1rem;
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  animation: slideIn 0.24s ease;
}
.offline-banner-retry {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--danger-border);
  background: var(--surface);
  color: var(--danger-strong);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.offline-banner-retry:hover {
  background: var(--danger-light);
}
.offline-banner-retry:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ==================== PRINT MEDIA ==================== */
@media print {
  body {
    background: white;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .app-header, .no-print, .btn, .nav-tabs, .hamburger { display: none !important; }
  .main-content { max-width: 100%; padding: 0; margin: 0; }
  .card { box-shadow: none; padding: 0; border: none; }
  .print-preview {
    max-width: none;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: white;
  }
  .print-sheet-title { font-size: 18pt; }
  .print-sheet-subtitle { font-size: 10pt; }
  .print-sheet-meta { font-size: 9pt; }
  .print-sheet-divider { margin: 11pt 0 10pt; }
  .print-table { font-size: 10.5pt; }
  .print-table th,
  .print-table td { padding: 10pt 9pt; }
  .print-month-start td {
    page-break-after: avoid;
  }
  .print-speaker-name { font-weight: 500; }
  .print-speaker-congregation { font-size: 8.5pt; }
  .print-table { page-break-inside: auto; }
  .print-table tr { page-break-inside: avoid; }
  @page { size: A4; margin: 12mm 10mm; }
}

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

/* ==================== LOADING ==================== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1.2rem;
  color: var(--gray-700);
  backdrop-filter: blur(8px);
}

.loading-panel {
  min-width: min(92vw, 360px);
  max-width: 420px;
  padding: 1.5rem 1.35rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(125, 109, 93, 0.18);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.95rem;
  text-align: center;
}

.loading-spinner {
  width: 52px;
  height: 52px;
  border-width: 4px;
}

.spinner-login-btn {
  display: inline-block;
  vertical-align: middle;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-200);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.4rem;
}

.loading-message {
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.4;
}

/* ==================== BUTTON LOADING ==================== */
.family-option.saving {
  pointer-events: none;
  opacity: 0.65;
}
.saving-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* ==================== SKELETON LOADING ==================== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 40%, var(--gray-100) 55%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-input {
  height: 3rem;
  border-radius: var(--radius-sm);
}
.skeleton-btn {
  height: 3rem;
  border-radius: 999px;
}
.skeleton-chart {
  height: 260px;
  border-radius: var(--radius);
}
.login-card-skeleton {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  opacity: 0.7;
}

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  user-select: none;
}

.toast {
  background: var(--toast-bg);
  color: var(--toast-on-bg);
  padding: 0.75rem 2.5rem 0.75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  animation: slideIn 0.24s ease;
  max-width: 350px;
  user-select: none;
  position: relative;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.toast-dismiss {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--toast-dismiss-bg);
  border: none;
  border-radius: 50%;
  color: inherit;
  cursor: pointer;
  padding: 0;
  opacity: 0.75;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
.toast-dismiss .icon-inline {
  width: 14px;
  height: 14px;
}

.toast-dismiss:hover {
  opacity: 1;
  background: var(--toast-dismiss-hover-bg);
}

@keyframes slideIn {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==================== MISC ==================== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}

.empty-state .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.empty-icon {
  width: 3rem;
  height: 3rem;
}

.empty-state p { font-size: 0.95rem; }

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}

.toolbar-spacer { flex: 1; }
.flex-row { display: flex; gap: 0.75rem; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.settings-section { padding: 0; overflow: hidden; }
.settings-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.settings-summary::-webkit-details-marker { display: none; }
.settings-summary:hover { background: var(--gray-50); }
.settings-section[open] > .settings-summary {
  border-bottom: 1px solid rgba(125, 109, 93, 0.14);
}
.settings-summary .card-title { margin-bottom: 0; }
.settings-chevron {
  transition: transform 0.2s ease;
  color: var(--gray-400);
  flex-shrink: 0;
}
.settings-section[open] > .settings-summary .settings-chevron {
  transform: rotate(180deg);
}
.settings-section-body {
  padding: 1.25rem;
}

.settings-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.settings-actions-inline { margin-top: 0.65rem; }
.settings-note { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.5rem; }
.settings-note-tight { margin-top: 0.4rem; }
.info-note { font-size: 0.85rem; color: var(--gray-600); }
.signal-template-input {
  min-height: 11rem;
  resize: vertical;
  line-height: 1.5;
}

.settings-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 0.08rem 0.28rem;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--gray-700);
}

.version-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.version-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(125, 109, 93, 0.14);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.version-history-main {
  min-width: 0;
}

.version-history-time {
  font-weight: 650;
  color: var(--gray-800);
}

.version-history-meta {
  margin-top: 0.18rem;
  font-size: 0.8rem;
  color: var(--gray-500);
}

.version-history-empty {
  margin-top: 0.85rem;
  padding: 0.95rem 1rem;
  border: 1px dashed rgba(125, 109, 93, 0.24);
  border-radius: var(--radius);
  color: var(--gray-500);
  text-align: center;
}
.mb-1 { margin-bottom: 1rem; }
.mt-1 { margin-top: 1rem; }

