/* Fonts loaded in base.html */

:root {
  /* Preshift brand — https://preshift.co.uk */
  --cream: #f6f1e6;
  --peach: #efe7d2;
  --ink: #0e0e10;
  --ink-soft: #2a2a2e;
  --mute: #6e6a60;
  --coral: #ff5e1a;
  --coral-dark: #e54e0f;
  --indigo: #2e2aff;
  --sage: #88b385;
  --white: #ffffff;
  --rule: #1a1a1c;

  /* Semantic surfaces (switch fully in dark mode) */
  --bg-0: var(--cream);
  --bg-1: var(--white);
  --bg-2: var(--peach);
  --bg-3: #faf6ee;
  --border: var(--ink);
  --border-subtle: rgba(14, 14, 16, 0.12);
  --shadow: rgba(14, 14, 16, 0.08);

  --line: var(--border-subtle);
  --line-strong: rgba(14, 14, 16, 0.2);
  --text: var(--ink);
  --text-dim: var(--mute);
  --text-faint: #8a8579;
  --accent: var(--coral);
  --accent-dim: rgba(255, 94, 26, 0.12);
  --accent-text: var(--coral-dark);
  --ok: #4d7f4a;
  --ok-dim: rgba(136, 179, 133, 0.25);
  --warn: #b45309;
  --warn-dim: rgba(255, 184, 77, 0.25);
  --fail: #b91c1c;
  --fail-dim: rgba(185, 28, 28, 0.1);
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Bricolage Grotesque", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --radius: 6px;
  --radius-lg: 10px;
  --header-h: 4.25rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); font-size: 0.84em; }
.muted { color: var(--text-dim); }
.hint { color: var(--text-faint); font-size: 0.82rem; margin: 0.35rem 0 0; }
.accent { color: var(--coral); }

a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--coral); text-decoration: underline; }

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg-1) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.shell-header-inner {
  height: var(--header-h);
  max-width: 88rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.25rem;
}

.shell-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-width: 8.5rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.shell-brand:hover {
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: auto;
  height: 2rem;
  max-width: 9rem;
}

.brand-sub {
  display: block;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0.28rem;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-1);
  cursor: pointer;
}

.nav-toggle-bar {
  display: block;
  width: 1rem;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.shell-nav {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.nav-track {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.28rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--bg-1) 60%, transparent);
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}

.nav-item::after {
  display: none;
}

.nav-item:hover {
  color: var(--text);
  text-decoration: none;
  background: color-mix(in srgb, var(--bg-1) 70%, transparent);
}

.nav-item.is-active {
  color: var(--text);
  font-weight: 600;
  background: var(--bg-1);
  box-shadow: 0 1px 3px var(--shadow), 0 0 0 1px var(--line);
}

.nav-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.72;
}

.nav-item.is-active .nav-icon {
  color: var(--coral);
  opacity: 1;
}

.shell-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.meta-status {
  display: flex;
  align-items: center;
  padding: 0.35rem 0.65rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.meta-chip {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-1);
  border: 1.5px solid var(--border);
  color: var(--text-dim);
}

.meta-user {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.35rem 0.25rem 0.3rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  max-width: 14rem;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--coral-dark);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-email {
  font-size: 0.72rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem !important;
  min-width: 0;
}

.btn-icon svg {
  width: 1rem;
  height: 1rem;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.live-dot::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--text-faint);
}

.live-dot.live { color: var(--ok); }
.live-dot.live::before { background: var(--sage); }
.live-dot.syncing { color: var(--coral-dark); }
.live-dot.syncing::before { background: var(--coral); animation: pulse 1.2s infinite; }
.live-dot.down::before { background: var(--fail); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.shell-main {
  flex: 1;
  padding: 1.75rem 2rem 3rem;
  max-width: 88rem;
  width: 100%;
  margin: 0 auto;
}

.page-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.page-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.toolbar-actions, .inline-form { display: flex; gap: 0.5rem; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-accent {
  background: var(--coral);
  color: var(--white);
  border: 2px solid var(--border);
  box-shadow: 2px 2px 0 var(--shadow);
}
.btn-accent:hover:not(:disabled) {
  background: var(--coral-dark);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--shadow);
}
.btn-ghost {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--text); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.78rem; }
.btn:disabled:not(.is-busy) { opacity: 0.45; cursor: not-allowed; }
.btn.is-busy {
  opacity: 0.92;
  cursor: wait;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.spinner {
  display: inline-block;
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid var(--line-strong);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

.spinner-sm {
  width: 0.85rem;
  height: 0.85rem;
  border-width: 2px;
}

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

.config-panels {
  position: relative;
  min-height: 12rem;
  min-width: 0;
}

.config-panels.is-loading {
  pointer-events: none;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg-0) 72%, transparent);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(2px);
}

.loading-overlay-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  background: var(--bg-1);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--shadow);
  font-size: 0.84rem;
  color: var(--text-dim);
}

.inline-alert.is-loading,
#clickup-lists-status.is-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.is-refreshing {
  opacity: 0.62;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

body.sync-in-progress #dash-hero {
  box-shadow: 4px 4px 0 var(--shadow), 0 0 0 2px color-mix(in srgb, var(--coral) 35%, transparent);
}

body.sync-in-progress #sync-status.run {
  animation: sync-pulse 1.4s ease-in-out infinite;
}

@keyframes sync-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.84rem;
  border: 1px solid var(--line);
}
.flash-ok { background: var(--ok-dim); border: 1.5px solid var(--sage); color: var(--ok); }
.flash-err { background: var(--fail-dim); border: 1.5px solid var(--fail); color: var(--fail); }

.toast-stack {
  position: fixed;
  top: calc(var(--header-h) + 0.75rem);
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast-stack > div, .ws-toast-item {
  padding: 0.65rem 0.9rem;
  background: var(--bg-1);
  border: 2px solid var(--border);
  border-left: 4px solid var(--coral);
  border-radius: var(--radius);
  font-size: 0.82rem;
  box-shadow: 4px 4px 0 var(--shadow);
  pointer-events: auto;
  color: var(--text);
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric {
  background: var(--bg-1);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: 3px 3px 0 var(--shadow);
}

.metric-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 0.35rem;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.panel {
  background: var(--bg-1);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 3px 3px 0 var(--shadow);
}

.panel.flush { border-radius: var(--radius-lg); }

.recent-sync-runs { margin-top: 10px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--border);
  background: var(--bg-2);
}

.panel-head h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
}

.panel-body { padding: 1.25rem; }

.data-grid {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
  font-size: 0.84rem;
}

.data-grid.wide { grid-template-columns: 9rem 1fr; }
.data-grid dt { color: var(--text-faint); font-weight: 500; }
.data-grid dd { margin: 0; }

.status-tag {
  display: inline-flex;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-3);
  color: var(--text-dim);
  border: 1px solid var(--line);
}

.status-tag.ok { background: var(--ok-dim); color: var(--ok); border: 1px solid var(--sage); }
.status-tag.fail { background: var(--fail-dim); color: var(--fail); border: 1px solid var(--fail); }
.status-tag.run { background: var(--accent-dim); color: var(--accent-text); border: 1px solid var(--coral); }
.status-tag.idle { color: var(--text-dim); border: 1px solid var(--line-strong); }

.signal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.signal {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius);
  background: var(--bg-3);
  border: 1.5px solid var(--line-strong);
  font-size: 0.84rem;
}

.signal-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--text-faint);
}

.signal.up .signal-dot { background: var(--sage); }
.signal.down .signal-dot { background: var(--fail); }
.signal-state { font-size: 0.75rem; color: var(--text-faint); }

.code-block {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: var(--radius);
  background: var(--bg-3);
  border: 2px solid var(--border);
  font-family: var(--mono);
  font-size: 0.78rem;
  overflow-x: auto;
  color: var(--fail);
}

.inline-alert {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--warn-dim);
  border: 1.5px solid var(--warn);
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.data-table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
}

.data-table th {
  background: var(--bg-2);
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

.data-table tbody tr:hover td { background: rgba(255, 94, 26, 0.04); }
.data-table .empty { text-align: center; color: var(--text-faint); padding: 2.5rem; }
.truncate { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip {
  display: inline-flex;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
}

.chip-ok { background: var(--ok-dim); color: var(--ok); border-color: transparent; }
.chip-warn { background: var(--warn-dim); color: var(--warn); border-color: transparent; }

.link-mono { font-family: var(--mono); font-size: 0.82rem; }

/* Configuration layout */
.config-layout {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0.75rem;
  min-height: 32rem;
}

.config-rail {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--bg-1);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  align-self: start;
}

.config-tab {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.config-tab:hover { background: var(--bg-2); color: var(--text); }
.config-tab.is-active { background: var(--accent-dim); color: var(--accent-text); font-weight: 600; }

.config-panel { display: none; }
.config-panel.is-visible { display: block; }

.field-group {
  border: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.field-group legend {
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0;
  margin-bottom: 0.25rem;
}

.field-group-desc {
  margin: 0 0 0.85rem;
  font-size: 0.8rem;
  color: var(--text-faint);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.85rem;
}

.field-grid.two-col { grid-template-columns: repeat(2, 1fr); }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--bg-1);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.84rem;
}

.field textarea { resize: vertical; min-height: 6rem; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field small { font-size: 0.75rem; color: var(--text-faint); }

.input-unit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-unit input { flex: 1; }
.input-unit span { font-size: 0.78rem; color: var(--text-faint); }

.form-footer {
  padding-top: 1rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.stack-gap { display: flex; flex-direction: column; gap: 1.25rem; }

.subpanel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.subpanel-head h3 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}

.table-editor {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-editor-head {
  display: grid;
  grid-template-columns: 1fr 6rem 2.5rem;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-2);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 2px solid var(--border);
}

.clickup-list-select select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg-1);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.inline-alert.warn {
  border-color: var(--warn);
  color: var(--text);
}

.field .clickup-list-select + small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-dim);
  font-size: 0.72rem;
}
.table-editor-head.cols-3 { grid-template-columns: 1fr 6rem 2.5rem; }
.table-editor-head.cols-venues { grid-template-columns: 1.2fr 5rem 1fr 1fr 2.5rem; }
.table-editor-row.cols-venues { grid-template-columns: 1.2fr 5rem 1fr 1fr 2.5rem; }

.table-editor-body { display: flex; flex-direction: column; }

.table-editor-row {
  display: grid;
  grid-template-columns: 1fr 6rem 2.5rem;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-top: 1px solid var(--line);
  align-items: center;
}

.table-editor-row input,
.table-editor-row select {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border-radius: 4px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg-1);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.table-editor-row input:focus,
.table-editor-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.row-remove {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.row-remove:hover { background: var(--fail-dim); color: var(--fail); border-color: transparent; }

/* Secret fields */
.secret-input-wrap {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}

.secret-input-wrap .secret-input {
  flex: 1;
  min-width: 0;
}

.secret-toggle {
  flex-shrink: 0;
  width: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.secret-toggle:hover {
  background: var(--coral);
  color: var(--white);
  border-color: var(--border);
}

.secret-toggle svg {
  width: 1rem;
  height: 1rem;
}

.secret-toggle .eye-hide { display: none; }
.secret-input-wrap.is-revealed .secret-toggle .eye-show { display: none; }
.secret-input-wrap.is-revealed .secret-toggle .eye-hide { display: block; }

.chip-source {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-3);
  color: var(--text-faint);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-top: 2px solid var(--border);
  background: var(--bg-2);
  flex-wrap: wrap;
}

.pagination-meta {
  font-size: 0.8rem;
  color: var(--text-faint);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-1);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.page-btn:hover:not(.disabled) {
  background: var(--coral);
  color: var(--white);
  text-decoration: none;
}

.page-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-indicator {
  font-size: 0.78rem;
  color: var(--text-faint);
  padding: 0 0.35rem;
}

/* Overview hero */
.hero-panel {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 1.75rem;
  margin-bottom: 0.75rem;
  background: var(--bg-1);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 4px 4px 0 var(--shadow);
  flex-wrap: wrap;
}

.hero-main { flex: 1; min-width: 14rem; }

.hero-status {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.hero-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.hero-tag { font-size: 0.68rem; }

.hero-title {
  margin: 0 0 0.35rem;
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.hero-sub {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-dim);
}

.hero-kpis {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  padding-left: 1.25rem;
  border-left: 2px solid var(--border);
}

.hero-kpi {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}

.hero-kpi-val {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.hero-kpi-label {
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metrics-row.compact {
  margin-bottom: 0.75rem;
}

.metrics-row.compact .metric {
  padding: 0.85rem 1rem;
}

.metric-value.sm {
  font-size: 1rem;
  word-break: break-all;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.sync-breakdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.sync-stat {
  text-align: center;
  padding: 0.75rem 0.5rem;
  background: var(--bg-3);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
}

.sync-stat-val {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}

.sync-stat-label {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.signal-name { text-transform: capitalize; }

.sm { font-size: 0.78rem; }

.panel.flush .panel-head {
  border-bottom: 1px solid var(--line);
}

@media (max-width: 1200px) and (min-width: 961px) {
  .shell-header-inner {
    gap: 0.75rem;
    padding: 0 1rem;
  }

  .shell-nav {
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
  }

  .shell-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
  }
}

@media (max-width: 960px) {
  .shell-header-inner {
    height: auto;
    min-height: var(--header-h);
    padding: 0.65rem 1rem;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    gap: 0.65rem 0.75rem;
  }

  .shell-brand {
    grid-column: 1;
    grid-row: 1;
  }

  .nav-toggle {
    display: flex;
    grid-column: 2;
    grid-row: 1;
  }

  .shell-meta {
    grid-column: 3;
    grid-row: 1;
  }

  .meta-user .user-email {
    display: none;
  }

  .shell-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    display: none;
    justify-content: stretch;
  }

  .shell-nav.is-open {
    display: flex;
  }

  .nav-track {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    border-radius: var(--radius-lg);
    padding: 0.35rem;
  }

  .nav-item {
    justify-content: flex-start;
    border-radius: var(--radius);
    padding: 0.55rem 0.85rem;
  }

  .shell-main { padding: 1rem; }
  .config-layout { grid-template-columns: 1fr; }
  .config-rail { position: static; flex-direction: row; flex-wrap: wrap; }
  .field-grid.two-col { grid-template-columns: 1fr; }
  .hero-kpis { border-left: none; padding-left: 0; width: 100%; justify-content: flex-start; }
  .sync-breakdown { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .meta-status {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .live-dot.syncing::before { animation: none; }
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  background: var(--accent-dim);
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--coral) 35%, var(--line));
}

.theme-icon {
  width: 1rem;
  height: 1rem;
}
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }

.user-chip {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Login page */
.login-page {
  min-height: 100vh;
  background: var(--bg-0);
}

.login-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-topbar {
  position: fixed;
  top: 1rem;
  right: 1rem;
}

.login-card {
  width: 100%;
  max-width: 24rem;
  padding: 2rem;
  background: var(--bg-1);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 4px 4px 0 var(--shadow);
}

.login-logo {
  height: 2.5rem;
  width: auto;
  max-width: 100%;
  margin-bottom: 1.25rem;
}

.login-title {
  margin: 0 0 0.35rem;
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 400;
}

.login-sub {
  margin: 0 0 1.25rem;
  color: var(--text-dim);
  font-size: 0.875rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.btn-block {
  width: 100%;
  margin-top: 0.25rem;
}

/* Dark theme — remap all semantic tokens */
[data-theme="dark"] {
  color-scheme: dark;

  --cream: #0e0e10;
  --peach: #1f1f22;
  --white: #161618;
  --ink: #f0ebe0;
  --ink-soft: #c8c2b8;
  --mute: #9a958a;
  --rule: #2a2a2e;

  --bg-0: #0e0e10;
  --bg-1: #161618;
  --bg-2: #1f1f22;
  --bg-3: #2a2a2e;
  --border: rgba(240, 235, 224, 0.35);
  --border-subtle: rgba(240, 235, 224, 0.1);
  --shadow: rgba(0, 0, 0, 0.45);

  --line: var(--border-subtle);
  --line-strong: rgba(240, 235, 224, 0.18);
  --text: #f6f1e6;
  --text-dim: #b8b2a6;
  --text-faint: #8a8579;

  --accent-text: #ff8a55;
  --coral-dark: #ff7a45;
  --ok: #88b385;
  --fail: #f87171;
  --warn: #fbbf24;
  --ok-dim: rgba(136, 179, 133, 0.15);
  --warn-dim: rgba(251, 191, 36, 0.12);
  --fail-dim: rgba(248, 113, 113, 0.12);
  --accent-dim: rgba(255, 94, 26, 0.15);
}

[data-theme="dark"] .data-table tbody tr:hover td {
  background: rgba(255, 94, 26, 0.06);
}

[data-theme="dark"] select option,
[data-theme="dark"] .field select option {
  background: var(--bg-1);
  color: var(--text);
}

/* Dashboard redesign */
.dash-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(16rem, 0.9fr);
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.dash-hero-main {
  padding: 1.5rem 1.75rem;
  background: var(--bg-1);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 4px 4px 0 var(--shadow);
}

.dash-hero-top {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.dash-hero-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.dash-hero-title {
  margin: 0 0 0.35rem;
  font-family: var(--serif);
  font-size: 1.85rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.dash-hero-sub {
  margin: 0 0 1.25rem;
  font-size: 0.84rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.dash-automation-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.dash-automation-head h3 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.chip-muted {
  background: var(--bg-3);
  color: var(--text-dim);
  border-color: var(--line);
}

.automation-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.automation-tag {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.65rem 0.85rem;
  min-width: 10rem;
  max-width: 18rem;
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 2px 2px 0 var(--shadow);
}

.automation-tag-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.automation-tag-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.automation-tag-meta {
  font-size: 0.72rem;
  color: var(--text-faint);
  line-height: 1.35;
}

.channel-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.channel-pill.sm {
  font-size: 0.6rem;
  padding: 0.12rem 0.4rem;
}

.channel-email {
  background: color-mix(in srgb, var(--coral) 14%, transparent);
  color: var(--coral);
  border-color: color-mix(in srgb, var(--coral) 28%, transparent);
}

.channel-wa {
  background: rgba(37, 211, 102, 0.12);
  color: #128C7E;
  border-color: rgba(37, 211, 102, 0.35);
}

[data-theme="dark"] .channel-wa {
  color: #6ee7a0;
}

.dash-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  align-content: start;
}

.dash-kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  background: var(--bg-1);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 3px 3px 0 var(--shadow);
  min-height: 5.5rem;
}

.dash-kpi-card.accent {
  background: linear-gradient(145deg, var(--accent-dim), var(--bg-1));
  border-color: color-mix(in srgb, var(--coral) 35%, var(--border));
}

.dash-kpi-val {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.dash-kpi-val.accent,
.dash-kpi-card.accent .dash-kpi-val {
  color: var(--coral);
}

.dash-kpi-label {
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dash-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chart-panel .panel-head.compact {
  padding: 0.85rem 1.1rem 0;
  border-bottom: none;
}

.panel-head.compact h2 {
  font-size: 0.95rem;
}

.chart-body {
  position: relative;
  height: 14rem;
  padding-top: 0.25rem;
}

.chart-body-wide {
  height: 15rem;
}

.chart-wide {
  grid-column: 1 / -1;
}

.dash-mid-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(16rem, 0.8fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.dash-side-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.venue-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.65rem;
}

.venue-card {
  padding: 0.85rem;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}

.venue-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.venue-card-name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
}

.venue-card-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.55rem;
}

.venue-card-routing {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.sync-breakdown-compact {
  grid-template-columns: repeat(2, 1fr);
}

.empty-block {
  grid-column: 1 / -1;
  padding: 0.5rem 0;
}

@media (max-width: 960px) {
  .dash-hero,
  .dash-mid-grid,
  .dash-charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-wide {
    grid-column: auto;
  }
}

[data-theme="dark"] .live-dot.syncing { color: var(--accent-text); }

/* ── Venue conversation panel ── */
.ticket-detail-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 0.45fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.ticket-meta-panel .panel-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.meta-grid {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.meta-grid > div {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
}

.meta-grid dt {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.meta-grid dd {
  margin: 0;
  font-size: 0.88rem;
}

.conversation-panel-host,
.conversation-panel {
  display: flex;
  flex-direction: column;
  min-height: 28rem;
  max-height: calc(100vh - 12rem);
}

.conversation-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--line);
  margin-bottom: 0.65rem;
}

.conversation-panel-title {
  margin: 0;
  font-size: 0.95rem;
}

.conversation-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.35rem 0;
  min-height: 12rem;
}

.conversation-bubble {
  max-width: 85%;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--bg-2);
}

.conversation-bubble.outgoing {
  align-self: flex-end;
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-2));
}

.conversation-bubble.incoming {
  align-self: flex-start;
}

.conversation-bubble-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.conversation-sender {
  font-weight: 600;
}

.conversation-text {
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.conversation-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: end;
  padding-top: 0.65rem;
  border-top: 2px solid var(--line);
  margin-top: 0.65rem;
}

.conversation-input {
  width: 100%;
  resize: vertical;
  min-height: 2.5rem;
  max-height: 8rem;
  padding: 0.55rem 0.65rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.conversation-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.35rem 0;
}

@media (max-width: 960px) {
  .ticket-detail-grid {
    grid-template-columns: 1fr;
  }
}
