/* ============================================
   WEDDING INVITE PORTAL - MAIN STYLESHEET

   To rebrand: change the CSS variables below.
   Design rule: a 55-year-old uncle should be able to use this
   without help. Big targets, big text, high contrast, calm colour.
   ============================================ */

:root {
  /* ---- Brand colour ---- */
  --primary-color: #a3402c;
  --primary-dark: #7c2f20;
  --primary-soft: #f6e7e0;
  --secondary-color: #2f6f65;
  --secondary-soft: #e3efec;
  --gold: #b3872f;

  /* ---- Semantic colour ---- */
  --success-color: #2e7d4f;
  --success-soft: #e1f3e6;
  --warning-color: #9c6c1c;
  --warning-soft: #fbf0da;
  --error-color: #b3392f;
  --error-soft: #fbe6e3;
  --info-color: #35707f;
  --info-soft: #e3eef1;

  /* ---- Neutrals ---- */
  --text-color: #251f1c;
  --muted-color: #776b60;
  --bg-color: #faf5ef;
  --surface-color: #ffffff;
  --surface-alt: #fbf3ea;
  --border-color: #e6dccf;

  /* ---- Shape & elevation ---- */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 8px rgba(60, 40, 25, 0.06);
  --shadow: 0 10px 28px rgba(60, 40, 25, 0.09);
  --shadow-lg: 0 20px 48px rgba(60, 40, 25, 0.14);
  --shadow-xl: 0 30px 70px rgba(45, 28, 16, 0.20);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* ---- Spacing scale ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* ---- Type ---- */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;

  --transition: 160ms ease;
  --transition-slow: 280ms ease;
}

/* ============================================
   SECTION: Base
   ============================================ */
* { box-sizing: border-box; }

/* The `hidden` attribute and a class that sets its own `display`
   (banner, badge, flex rows, ...) have equal specificity, so whichever
   is declared later in this file wins -- silently defeating `hidden`
   on any element that also carries such a class. This keeps `hidden`
   authoritative everywhere, the same way it already had to be forced
   for .modal-backdrop below. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--text-color);
  background:
    radial-gradient(circle at 8% -4%, rgba(163, 64, 44, 0.10), transparent 34%),
    radial-gradient(circle at 96% 0%, rgba(47, 111, 101, 0.08), transparent 30%),
    var(--bg-color);
  background-attachment: fixed;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--text-color);
  letter-spacing: -0.012em;
  font-weight: 600;
}
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.12; margin: var(--space-7) 0 var(--space-2); }
h2 { font-size: clamp(22px, 2.6vw, 28px); line-height: 1.25; margin: var(--space-7) 0 var(--space-4); position: relative; }
h3 { font-size: 20px; margin: var(--space-5) 0 var(--space-3); }

a { color: var(--primary-color); text-decoration-thickness: 1.5px; }
a:hover { color: var(--primary-dark); }
code {
  background: var(--surface-alt); padding: 1px 6px;
  border-radius: 4px; font-size: 14px; border: 1px solid var(--border-color);
}

h2::after {
  content: "";
  display: block;
  width: 46px; height: 3px; margin-top: 10px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--primary-color), var(--gold));
}

.muted { color: var(--muted-color); }
.small { font-size: 14px; }
.center { text-align: center; }
.grow { flex: 1 1 200px; }

*:focus-visible {
  outline: 3px solid rgba(163, 64, 44, 0.35);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================
   SECTION: Icons
   ============================================ */
.icon { display: inline-block; vertical-align: -4px; flex-shrink: 0; }
.icon-lg { width: 28px; height: 28px; }

/* ============================================
   SECTION: Layout & grid
   ============================================ */
.container { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

.row { display: flex; align-items: flex-start; }
.row.gap { gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.row.end { justify-content: flex-end; }

.centered-page {
  min-height: 78vh; display: flex;
  align-items: center; justify-content: center;
  padding: var(--space-6) 0;
}

/* ---- Top navigation ---- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250, 245, 239, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 8px 24px rgba(60, 40, 25, 0.04);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: nowrap; gap: var(--space-4);
  padding-top: 14px; padding-bottom: 14px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 600; font-size: 21px;
  text-decoration: none; color: var(--primary-dark); flex: 0 0 auto;
  transition: transform var(--transition);
}
.brand:hover { transform: translateY(-1px); }
.brand-logo {
  display: block; width: 40px; height: 40px; object-fit: contain; border-radius: 8px;
  box-shadow: 0 2px 8px rgba(60, 40, 25, 0.12);
}

.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--surface-color);
  color: var(--text-color); cursor: pointer;
}

.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.nav a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-pill);
  text-decoration: none; color: var(--muted-color); font-size: 15px; font-weight: 600;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.nav a:hover { background: var(--primary-soft); color: var(--primary-dark); }
.nav a.active { background: var(--primary-color); color: #fff; }
.nav a.active .icon { color: #fff; }
.nav-muted { color: var(--muted-color) !important; }

.footer {
  margin-top: var(--space-8); padding: var(--space-6) 0;
  border-top: 1px solid var(--border-color); text-align: center;
}

/* ============================================
   SECTION: Card component
   ============================================ */
.card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  transition: box-shadow var(--transition-slow), transform var(--transition-slow), border-color var(--transition-slow);
}
.auth-card {
  width: min(440px, 100%); text-align: center; box-shadow: var(--shadow-xl);
  border-color: rgba(230, 220, 207, 0.7);
}
.auth-card .form-group { text-align: left; }
.logo { max-width: 110px; margin-bottom: var(--space-3); }

/* ============================================
   SECTION: Buttons
   ============================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 24px;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: var(--surface-color); color: var(--text-color);
  font-size: 15.5px; font-family: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 220ms var(--ease), box-shadow var(--transition), background var(--transition), filter var(--transition);
}
.btn:hover { filter: brightness(0.97); transform: translateY(-1px) scale(1.015); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn-primary {
  background: linear-gradient(155deg, var(--primary-color), var(--primary-dark));
  color: #fff; box-shadow: 0 10px 22px rgba(163, 64, 44, 0.28);
}
.btn-primary:hover { filter: brightness(1.04); box-shadow: 0 14px 28px rgba(163, 64, 44, 0.34); }
.btn-ghost { background: var(--surface-color); border-color: var(--border-color); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-danger { background: var(--error-color); color: #fff; box-shadow: none; }
.btn-danger:hover { background: #922e26; }
.btn-block { width: 100%; }
.btn-small { min-height: 38px; padding: 6px 16px; font-size: 13.5px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn .spinner {
  width: 16px; height: 16px; margin-right: 2px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   SECTION: Forms
   ============================================ */
.form-group { margin-bottom: var(--space-5); }
label, .label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 15px; }
input[type=text], input[type=email], input[type=tel], input[type=url],
input[type=password], input[type=date], input[type=time], input[type=number],
input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  font-size: 16px; font-family: inherit; color: var(--text-color);
  background: var(--surface-color); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input[type=color] { width: 64px; min-height: 48px; padding: 4px; }
textarea { min-height: auto; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none; box-shadow: 0 0 0 3px rgba(163, 64, 44, 0.18); border-color: var(--primary-color);
}
.helper { display: block; color: var(--muted-color); font-size: 13.5px; margin-top: 6px; }

/* ============================================
   SECTION: Reminder timeline
   A wrapping row of fields, not a table -- so "Time" and "Remove"
   never end up off-screen behind a horizontal scrollbar. Each field
   drops to its own line as the window narrows instead of the row
   overflowing.
   ============================================ */
.reminder-list {
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-color);
}
.reminder-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-5);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}
.reminder-row:last-child { border-bottom: none; }
.reminder-row:hover { background: var(--surface-alt); }
.reminder-empty { padding: var(--space-4) var(--space-5); margin: 0; }
.reminder-field { display: flex; flex-direction: column; gap: 6px; }
.reminder-field-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted-color);
}
.reminder-field-on { flex: 0 0 auto; align-items: center; }
.reminder-field-on input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--primary-color); }
.reminder-field-name { flex: 1 1 160px; min-width: 150px; }
.reminder-field-days { flex: 1 1 190px; min-width: 180px; }
.reminder-field-message { flex: 2 1 220px; min-width: 210px; }
.reminder-field-time { flex: 0 1 160px; min-width: 140px; }
.reminder-field-actions { flex: 0 0 auto; margin-left: auto; }
@media (max-width: 640px) {
  .reminder-row { padding: var(--space-4); }
  .reminder-field-actions { margin-left: 0; width: 100%; }
  .reminder-field-actions .btn { width: 100%; }
}

.check { display: flex; align-items: center; gap: 10px; font-weight: 400; margin-bottom: 10px; cursor: pointer; }
.check input { width: 21px; height: 21px; flex: 0 0 auto; accent-color: var(--primary-color); }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }

.steps { padding-left: 22px; }
.steps li { margin-bottom: 14px; }

.advanced {
  margin-bottom: var(--space-4); padding: var(--space-4);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.advanced summary { cursor: pointer; font-weight: 700; color: var(--primary-dark); list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "▸ "; }
.advanced[open] summary { margin-bottom: 12px; }
.advanced[open] summary::before { content: "▾ "; }

.tabs { display: flex; gap: 6px; margin: var(--space-5) 0; background: var(--surface-alt); padding: 5px; border-radius: var(--radius-pill); }
.tab {
  flex: 1; min-height: 44px; border: none;
  border-radius: var(--radius-pill); background: transparent;
  font: inherit; font-weight: 700; cursor: pointer; color: var(--muted-color);
  transition: background var(--transition), color var(--transition);
}
.tab:hover { color: var(--text-color); }
.tab.active { background: var(--surface-color); color: var(--primary-dark); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in var(--transition-slow) var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } }

/* ============================================
   SECTION: Stats, functions, messages
   ============================================ */
.stat-row, .event-row, .connection-grid, .preview-grid, .speed-row, .message-list {
  display: grid; gap: var(--space-5);
}
.stat-row { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.event-row { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.connection-grid, .preview-grid { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.speed-row { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.message-list { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: var(--space-5); }

.stat {
  display: flex; flex-direction: column; gap: 6px; justify-content: center;
  min-height: 118px; border-top: 4px solid var(--primary-color);
  transition: transform var(--transition-slow), box-shadow var(--transition-slow);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--primary-soft); color: var(--primary-dark); margin-bottom: 2px;
}
.stat-label { color: var(--muted-color); font-size: 14px; font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 34px; font-weight: 600; line-height: 1.1; }
.stat-value.small-value { font-size: 18px; font-family: var(--font); font-weight: 700; }
.stat-success { border-top-color: var(--success-color); }
.stat-success .stat-icon { background: var(--success-soft); color: var(--success-color); }
.stat-success .stat-value { color: var(--success-color); }
.stat-warning { border-top-color: var(--warning-color); }
.stat-warning .stat-icon { background: var(--warning-soft); color: var(--warning-color); }
.stat-warning .stat-value { color: var(--warning-color); }
.stat-info { border-top-color: var(--info-color); }
.stat-info .stat-icon { background: var(--info-soft); color: var(--info-color); }
.stat-info .stat-value { color: var(--info-color); }

.event-card, .function-block { border-top: 6px solid var(--accent, var(--primary-color)); }
.event-card { transition: transform var(--transition-slow), box-shadow var(--transition-slow); }
.event-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.function-block { padding: var(--space-6); }
.function-block h2::after { display: none; }
.function-title { margin: 0; font-size: 27px; }

.message-card {
  background: var(--surface-alt); margin-bottom: 0; border: 1px solid var(--border-color);
  transition: box-shadow var(--transition-slow), border-color var(--transition-slow);
}
.message-card:hover { box-shadow: var(--shadow-sm); border-color: var(--accent, var(--border-color)); }
.message-label {
  font-family: var(--font-display); font-weight: 600; font-size: 19px;
  border-style: solid; background: var(--surface-color);
}

/* Attachment slot inside a message */
.media-slot { margin-bottom: 10px; }
.media-attached {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; background: var(--surface-color);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}
.media-icon { display: inline-flex; color: var(--primary-color); }
.media-name {
  flex: 1 1 140px; font-weight: 600; word-break: break-all; font-size: 15px;
}
.no-media { padding: 8px 0; }

.media-template-warning {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 10px; margin-bottom: 0; font-size: 14.5px; padding: 14px 16px;
}
.media-template-warning .icon { margin-top: 2px; color: var(--warning-color); }

.speed-option {
  display: block; padding: var(--space-4); cursor: pointer;
  border: 2px solid var(--border-color); border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
}
.speed-option:hover { border-color: var(--gold); }
.speed-option.selected { border-color: var(--primary-color); background: var(--primary-soft); }
.speed-name { display: block; font-size: 18px; font-weight: 700; margin: 6px 0; }

/* ============================================
   SECTION: Tables
   ============================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.table-scroll {
  max-height: 460px; overflow-y: auto;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}
.table-scroll .table { border-radius: 0; }
.table-scroll thead th {
  position: sticky; top: 0; z-index: 2;
  box-shadow: 0 1px 0 var(--border-color);
}
@media (max-width: 780px) {
  /* Once rows stack into cards, a fixed viewport height fights the
     card layout rather than helping it -- let the page scroll instead. */
  .table-scroll { max-height: none; overflow-y: visible; border: none; }
}
.table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.table th, .table td {
  padding: 13px 12px; text-align: left; border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.table th {
  font-size: 12.5px; text-transform: uppercase; font-weight: 700;
  letter-spacing: 0.05em; color: var(--muted-color); background: var(--surface-alt);
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-alt); }
.table input[type=checkbox] { width: 21px; height: 21px; accent-color: var(--primary-color); }
.table select, .table input[type=text] { min-height: 42px; font-size: 14.5px; }
.bulk-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3);
}

/* ============================================
   SECTION: Badges & banners
   ============================================ */
.badge {
  display: inline-block; padding: 5px 13px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  background: var(--surface-alt); color: var(--muted-color);
}
.badge-delivered, .badge-read, .badge-confirmed, .badge-completed { background: var(--success-soft); color: var(--success-color); }
.badge-pending, .badge-invited, .badge-queued, .badge-running { background: var(--warning-soft); color: var(--warning-color); }
.badge-failed, .badge-declined, .badge-skipped { background: var(--error-soft); color: var(--error-color); }
.badge-scheduled, .badge-sent { background: var(--info-soft); color: var(--info-color); }
.badge-cancelled { background: var(--surface-alt); color: var(--muted-color); border: 1px solid var(--border-color); }
.badge-session-open { background: var(--success-soft); color: var(--success-color); }
.badge-session-closed { background: var(--surface-alt); color: var(--muted-color); border: 1px solid var(--border-color); }

.meta-template-summary { display: flex; align-items: center; gap: 6px; margin: 0 0 var(--space-3); }
.meta-template-summary .icon { color: var(--muted-color); flex-shrink: 0; }
.meta-status-badge-mini { padding: 2px 10px; font-size: 11px; }
.meta-template-fields { margin-top: 14px; }
.meta-template-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; padding: 4px 0; }
.meta-template-actions { margin-top: 10px; }
.status-approved { background: var(--success-soft); color: var(--success-color); }
.status-pending, .status-not_submitted { background: var(--warning-soft); color: var(--warning-color); }
.status-rejected { background: var(--error-soft); color: var(--error-color); }

.activity-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: var(--space-4) 0 var(--space-5); }
.activity-summary span { padding: 8px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-pill); background: var(--surface-alt); color: var(--muted-color); font-size: 14px; }
.activity-summary strong { color: var(--text-color); }
.meta-id { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-error { display: block; max-width: 240px; margin-top: 5px; color: var(--error-color); }

.dashboard-filters {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr auto; gap: var(--space-3);
  align-items: end; padding: var(--space-4); margin-bottom: var(--space-5);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--surface-alt);
}
.dashboard-filters .form-group { margin: 0; }
.filter-actions { display: flex; gap: 8px; align-items: center; padding-bottom: 0; }
@media (max-width: 900px) { .dashboard-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .dashboard-filters { grid-template-columns: 1fr; } .filter-actions { justify-content: flex-start; } }

.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 20px; border-radius: var(--radius); border-left: 5px solid;
  margin-bottom: var(--space-5); box-shadow: var(--shadow-sm);
}
.banner .icon { margin-top: 2px; flex-shrink: 0; }
.banner-warning { background: var(--warning-soft); border-color: var(--warning-color); }
.banner-warning .icon { color: var(--warning-color); }
.banner-info { background: var(--info-soft); border-color: var(--info-color); }
.banner-info .icon { color: var(--info-color); }
.status-area { min-height: 24px; font-weight: 700; margin-top: 12px; }
.status-ok { color: var(--success-color); }
.status-bad { color: var(--error-color); }

/* ============================================
   SECTION: Phone mockup (pure CSS)
   ============================================ */
.phone {
  width: 340px; max-width: 100%; margin: 0 auto;
  border: 12px solid #221c19; border-radius: 36px;
  background: #221c19; box-shadow: var(--shadow-xl);
  transition: transform var(--transition-slow);
}
.phone-screen { min-height: 460px; padding: 20px 14px; background: #e9ddcf; border-radius: 24px; }
.chat-bubble {
  background: #fff; padding: 10px;
  border-radius: 14px 14px 14px 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}
.bubble-media { margin-bottom: 8px; }
.bubble-media-inner {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; background: var(--surface-alt); border-radius: 8px; font-size: 14px;
}
.bubble-media-inner span:first-child { font-size: 24px; display: inline-flex; }
.bubble-text { white-space: pre-wrap; font-size: 15.5px; padding: 0 4px; }
.bubble-links { margin-top: 8px; }
.bubble-link {
  border-top: 1px solid var(--border-color); padding: 10px 4px;
  text-align: center; color: var(--info-color); font-size: 15px; font-weight: 700;
}
.chat-time { font-size: 12px; color: var(--muted-color); margin-top: 4px; text-align: right; padding-right: 4px; }

/* ============================================
   SECTION: Toasts, dialogs, modals
   ============================================ */
.toast-container {
  position: fixed; right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px; z-index: 1000;
}
.toast {
  min-width: 260px; max-width: 380px; padding: 14px 18px;
  border-radius: var(--radius-sm); color: #fff;
  box-shadow: var(--shadow-lg); animation: rise 0.2s ease-out;
}
.toast-success { background: var(--success-color); }
.toast-error { background: var(--error-color); }
.toast-info { background: var(--info-color); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(37, 31, 28, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1001; padding: 20px; animation: fade-in var(--transition);
}
.modal-backdrop[hidden] { display: none; }
.confirm-box { width: min(420px, 92vw); margin: 0; }
.modal { width: min(760px, 96vw); max-height: 90vh; overflow-y: auto; margin: 0; }

/* ============================================
   SECTION: Auth / welcome page
   ============================================ */
.auth-brandline {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--gold); margin-bottom: var(--space-2);
}

/* ============================================
   SECTION: Mobile
   ============================================ */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface-color); border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow); padding: var(--space-3);
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 13px 16px; border-radius: var(--radius-sm); }
  .topbar { position: sticky; }
}

@media (max-width: 640px) {
  h1 { font-size: 26px; }
  .card { padding: var(--space-4); }
  .table { font-size: 14.5px; }
  .message-list { grid-template-columns: 1fr; }
  .row.between { align-items: flex-start; flex-direction: column; gap: 12px; }
  .function-block { padding: var(--space-4); }
  .function-title { font-size: 23px; }
}

/* Responsive "card" tables: headers hide, each cell labels itself.
   Applied only to read-mostly tables; editing-heavy tables (reminders,
   column mapping) keep horizontal scroll instead, since stacking a row
   full of live selects and inputs makes them harder to use, not easier. */
@media (max-width: 780px) {
  .table-responsive thead { display: none; }
  .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td {
    display: block; width: 100%;
  }
  .table-responsive tr {
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    margin-bottom: var(--space-3); padding: var(--space-2) var(--space-3);
    box-shadow: var(--shadow-sm);
  }
  .table-responsive td {
    border-bottom: 1px dashed var(--border-color);
    padding: 10px 2px; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right;
  }
  .table-responsive td:last-child { border-bottom: none; }
  .table-responsive td[data-label]::before {
    content: attr(data-label); font-weight: 700; color: var(--muted-color);
    font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em;
    text-align: left; margin-right: 12px;
  }
  .table-responsive td:not([data-label]) { justify-content: flex-start; }
}

/* ============================================
   SECTION: Decorative background
   Three soft, blurred, slowly-drifting orbs behind everything.
   Fixed + zero-size-impact: they never affect layout or scroll width.
   ============================================ */
.bg-decor { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.bg-orb { position: absolute; border-radius: 50%; filter: blur(60px); animation: orb-drift 24s ease-in-out infinite; }
.bg-orb-1 {
  width: 420px; height: 420px; top: -140px; left: -110px;
  background: radial-gradient(circle, rgba(163, 64, 44, 0.20), transparent 70%);
}
.bg-orb-2 {
  width: 380px; height: 380px; top: 28%; right: -150px;
  background: radial-gradient(circle, rgba(47, 111, 101, 0.18), transparent 70%);
  animation-delay: -8s; animation-duration: 28s;
}
.bg-orb-3 {
  width: 320px; height: 320px; bottom: -120px; left: 32%;
  background: radial-gradient(circle, rgba(179, 135, 47, 0.15), transparent 70%);
  animation-delay: -15s; animation-duration: 32s;
}
@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(28px, -22px) scale(1.06); }
}

/* ============================================
   SECTION: Page + panel entrance
   ============================================ */
main.container { animation: page-enter 0.6s var(--ease) both; }
@keyframes page-enter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* Applied to forms/panels app.js reveals by clearing [hidden] -- the
   keyframe replays automatically every time the element goes from
   display:none back to visible, with no JS of its own required. */
.reveal-panel { animation: fade-in var(--transition-slow) var(--ease) both; }

.modal, .confirm-box { animation: modal-pop var(--transition-slow) var(--ease) both; }
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-orb { animation: none; }
  main.container, .reveal-panel, .modal, .confirm-box, .tab-panel.active { animation: none; }
  html { scroll-behavior: auto; }
}
