button, .btn, .tab, .btn-icon, .card, input, select, textarea, a, summary, .kpi-item, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

:root {
  --radius: 8px;
  --radius-sm: 6px;
  --radius-full: 9999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #121215;
  --card: #18181b;
  --card-hover: #222226;
  --border: #27272a;
  --border-hover: #3f3f46;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  
  /* Primary Action Token (Solid High-Contrast Neutral) */
  --btn-primary-bg: #ffffff;
  --btn-primary-text: #09090b;
  --btn-primary-hover: #e4e4e7;
  
  /* Active Selection & Focus Tokens */
  --accent: #f4f4f5;
  --accent-dim: rgba(255, 255, 255, 0.08);
  --accent-border: rgba(255, 255, 255, 0.22);
  --accent-text: #09090b;
  --accent-glow: rgba(255, 255, 255, 0.1);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  
  /* Semantic Status Colors */
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --danger: #ef4444;
  --surface-alt: #141418;
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.12);
  --blue: #38bdf8;
  --blue-dim: rgba(56, 189, 248, 0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --grain: 0;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f8f8f8;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hover: #f4f4f5;
  --border: #e4e4e7;
  --border-hover: #d4d4d8;
  --text: #09090b;
  --text-muted: #71717a;
  
  /* Primary Action Token */
  --btn-primary-bg: #09090b;
  --btn-primary-text: #ffffff;
  --btn-primary-hover: #27272a;
  
  /* Active Selection & Focus Tokens */
  --accent: #09090b;
  --accent-dim: rgba(9, 9, 11, 0.06);
  --accent-border: rgba(9, 9, 11, 0.22);
  --accent-text: #ffffff;
  --accent-glow: rgba(9, 9, 11, 0.08);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  
  /* Semantic Status Colors */
  --green: #059669;
  --green-dim: rgba(5, 150, 105, 0.08);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.08);
  --danger: #dc2626;
  --surface-alt: #f4f4f5;
  --orange: #d97706;
  --orange-dim: rgba(217, 119, 6, 0.08);
  --blue: #0284c7;
  --blue-dim: rgba(2, 132, 199, 0.08);
  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.08);
  --grain: 0;
}
  --blue: #2471a3;
  --blue-dim: rgba(36, 113, 163, 0.08);
  --purple: #7c5cbf;
  --purple-dim: rgba(124, 92, 191, 0.1);
  --grain: 0.02;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(72px + var(--safe-bottom));
  overflow-x: hidden;
  position: relative;
}

.kpi-val, .badge, .tab-badge, .timestamp, .activity-ts, .msg-date, .card-fee {
  font-variant-numeric: tabular-nums;
}

/* ─── HEADER ─── */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + var(--safe-top)) 16px 8px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-top h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-top h1 span {
  color: var(--text-muted);
  font-weight: 400;
}
.header-user {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: var(--radius-full);
  margin-left: 6px;
  text-transform: capitalize;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timestamp {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

@media (max-width: 430px) {
  .timestamp { display: none; }
  .header-top h1 > span:not(.brand-mark):not(.header-user) { display: none; }
}

#refresh-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
}
#refresh-btn:active { background: var(--card); }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:active { background: var(--card); }

/* ─── KPI STRIP ─── */
.kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0 4px;
}

.kpi-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px 12px 4px 10px;
  flex-shrink: 0;
  font-size: 12px;
}
.kpi-item::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kpi-item:nth-child(1)::before { background: var(--blue); }
.kpi-item:nth-child(2)::before { background: var(--orange); }
.kpi-item:nth-child(3)::before { background: var(--accent); }
.kpi-item:nth-child(4)::before { background: var(--red); }
.kpi-item:nth-child(5)::before { background: var(--green); }
.kpi-item:nth-child(6)::before { background: var(--green); }

.kpi-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
}

.kpi-item.target {
  background: var(--accent-dim);
  border-color: var(--accent-border);
}
.kpi-item.target::before { background: var(--accent); }

.kpi-label { color: var(--text-muted); font-size: 11px; }
.kpi-val { font-weight: 600; font-size: 13px; }

/* ─── BOTTOM TAB BAR ─── */
nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 8px calc(6px + var(--safe-bottom));
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.tab .tab-icon { font-size: 20px; line-height: 1; display: flex; }
.tab .tab-icon svg { width: 20px; height: 20px; }
.tab.active { color: var(--text); background: var(--card); border: 1px solid var(--border); font-weight: 600; }
.tab:active { background: var(--card); }

.tab-badge {
  position: absolute;
  top: 2px;
  right: 50%;
  margin-right: -22px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transform: scale(0.85);
  pointer-events: none;
}

/* ─── API BANNER ─── */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--red-dim);
  border: 1px solid rgba(255, 71, 87, 0.2);
  border-radius: var(--radius-sm);
  margin: 8px 16px 0;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red);
}
.banner.hidden { display: none; }
.banner .btn { flex-shrink: 0; }

/* ─── VIEWS ─── */
.view {
  display: none;
  padding: 12px 16px calc(80px + var(--safe-bottom));
  max-width: 640px;
  margin: 0 auto;
}
.view.active { display: block; }

.view-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.view-head h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.badge {
  background: var(--card);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

/* ─── CARDS ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.15s ease;
}
@media (hover: hover) {
  .card:hover { border-color: var(--accent-border); }
  .kpi-item:hover { border-color: var(--accent-border); }
  .btn-icon:hover, #refresh-btn:hover { background: var(--card-hover); border-color: var(--accent-border); color: var(--text); }
  .tab:hover { color: var(--text); }
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.card-meta {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease, filter 0.15s ease, transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-sm { padding: 10px 14px; min-height: 40px; font-size: 12px; }
.btn.primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.btn.primary:active { box-shadow: none; }
.btn.danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.25);
}
@media (hover: hover) {
  .btn:hover { background: var(--card-hover); border-color: var(--border-hover); }
  .btn.primary:hover {
    background: var(--btn-primary-hover);
    border-color: var(--btn-primary-hover);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  .btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
  }
  .btn:disabled:hover { background: var(--card); border-color: var(--border); filter: none; box-shadow: none; }
}

/* ─── FORM ELEMENTS ─── */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}
@media (min-width: 768px) {
  .form-row {
    flex-direction: row;
    align-items: flex-start;
  }
}
.form-row > .form-group {
  margin-bottom: 0;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  min-width: 0;
  width: 100%;
}
.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.input, .textarea, select.input {
  display: block;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 12px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, .textarea:focus, select.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input-sm, select.input-sm {
  padding: 8px 12px;
  font-size: 13px;
  min-height: 40px;
}
.contacts-search-input {
  padding: 8px 12px;
  font-size: 13px;
  min-height: 40px;
}
.textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}
select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}
[data-theme="light"] select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.field {
  margin-bottom: 10px;
}
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── SUB / EMPTY ─── */
.sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px 20px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.section-subtitle {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ─── DRAFT SPECIFIC ─── */
.draft-item {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}
.draft-item:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.orig { margin-bottom: 10px; }
.orig summary {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
}
.orig-body {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 6px;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.4;
}

/* ─── THREAD ─── */
.thread-details { margin-bottom: 10px; }
.thread-details summary {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
}
.thread-box {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.msg-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
}
.msg-date { color: var(--text-muted); }
.msg-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.msg-body { white-space: pre-wrap; }

/* ─── PIPELINE ─── */
.pipeline-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.deal-card:active { border-color: var(--accent); }

.deal-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px 2px 6px;
  border-radius: var(--radius-full);
  margin-bottom: 6px;
}
.deal-state::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.deal-state.lead { background: var(--blue-dim); color: var(--blue); }
.deal-state.lead::before { background: var(--blue); }
.deal-state.pitched { background: var(--orange-dim); color: var(--orange); }
.deal-state.pitched::before { background: var(--orange); }
.deal-state.option { background: var(--accent-dim); color: var(--accent); }
.deal-state.option::before { background: var(--accent); }
.deal-state.hold { background: var(--red-dim); color: var(--red); }
.deal-state.hold::before { background: var(--red); }
.deal-state.confirmed { background: var(--green-dim); color: var(--green); }
.deal-state.confirmed::before { background: var(--green); }
.deal-state.played { background: var(--green-dim); color: var(--green); }
.deal-state.played::before { background: var(--green); }

.deal-title { font-size: 15px; font-weight: 600; }
.deal-details {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.deal-next {
  font-size: 12px;
  color: var(--accent);
  margin-top: 8px;
}

/* ─── DETAIL MODAL (pipeline) ─── */
.deal-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s;
}
.deal-detail-sheet {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  animation: slideUp 0.2s ease-out;
}
.sheet-header { margin-bottom: 4px; }
.sheet-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.sheet-title { font-size: 18px; font-weight: 700; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.sheet-actions .btn { flex: 1; min-width: 120px; }
.sheet-section { margin-top: 18px; }
.sheet-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.sheet-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sheet-section-head .sheet-section-title { margin-bottom: 0; }
.sheet-deal {
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.deal-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.deal-row-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.thread-group {
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.thread-group summary {
  padding: 10px 12px;
  min-height: 40px;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.msg-row { padding: 8px 12px; border-top: 1px solid var(--accent-border); }
.msg-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.msg-row-subject { font-size: 13px; font-weight: 600; margin-top: 2px; }
.msg-row-body {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.deal-detail-sheet .activity-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid var(--accent-border);
  font-size: 14px;
}
.deal-detail-sheet .activity-row:last-child { border-bottom: none; }
.deal-detail-sheet .activity-row .sub { flex-basis: 100%; margin-top: 2px; }
.new-deal-form {
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 8px 0 4px;
}
@media (hover: hover) {
  .sheet-deal:hover { border-color: var(--accent); }
  .thread-group summary:hover { background: var(--card); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── CONFIRM DIALOG ─── */
.confirm-dialog {
  border: none;
  padding: 0;
  background: transparent;
  overflow: visible;
}
.confirm-dialog:not([open]) { display: none !important; }
.confirm-dialog[open] {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  animation: fadeIn 0.15s;
}
.confirm-dialog::backdrop { background: transparent; }
.dialog-body {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 400px;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  animation: slideUp 0.2s ease-out;
}
@media (min-width: 768px) {
  .confirm-dialog[open] { align-items: center; }
  .dialog-body {
    max-width: 520px;
    border-radius: var(--radius);
    padding: 24px;
    animation: dialogPop 0.18s ease-out;
  }
}
@keyframes dialogPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.dialog-body h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
}
.dialog-lines {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
  white-space: pre-wrap;
}
.dialog-actions {
  display: flex;
  gap: 8px;
}
.dialog-actions .btn { flex: 1; }

/* ─── NEARBY GIGS DIALOG ─── */
.nearby-dialog {
  border: none;
  padding: 0;
  background: transparent;
  overflow: visible;
}
.nearby-dialog:not([open]) { display: none !important; }
.nearby-dialog[open] {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  animation: fadeIn 0.15s;
}
.nearby-dialog::backdrop { background: transparent; }
.nearby-body { max-width: 440px; }
.nearby-radius {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}
.nearby-radius label {
  font-size: 13px;
  color: var(--text-muted);
}
.nearby-radius .input { width: 110px; }
.nearby-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40dvh;
  overflow-y: auto;
  margin-bottom: 14px;
}
.nearby-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.nearby-item input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.nearby-item-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nearby-item-text .sub { font-size: 12px; }
@media (min-width: 768px) {
  .nearby-dialog[open] { align-items: center; }
}

/* ─── ONBOARDING ─── */
.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.onboarding-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.onboarding-num {
  flex: 0 0 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent, #0a0a0e);
  font-size: 13px;
  font-weight: 700;
}
.onboarding-step-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.onboarding-step-body .btn { align-self: flex-start; margin-top: 6px; }

/* ─── CALENDAR ─── */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0 12px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.cal-dow {
  text-align: center;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 0;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--surface-alt, var(--surface));
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 6px;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.cal-empty { background: transparent; }
.cal-ring { border-color: var(--accent); }
.cal-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-d {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.cal-daynum {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.cal-dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
}
.cal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.cal-more {
  font-size: 9px;
  color: var(--text-muted);
}
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 2px 14px;
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── SENT OUTREACH + ACTIVITY ─── */
.body-pre {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-alt, var(--surface));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin: 8px 0;
  max-height: 240px;
  overflow-y: auto;
}
.outbound-card summary {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
}
.activity-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.activity-row {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.activity-row:last-child { border-bottom: none; }
.activity-ts {
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.activity-event {
  font-weight: 600;
  flex-shrink: 0;
}
.activity-detail {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.chip-active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-border);
}

/* ─── STATE CHIPS ─── */
.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  background: var(--card-hover);
  color: var(--text-muted);
  border: 1px solid transparent;
  flex-shrink: 0;
  text-transform: capitalize;
}
.state-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.state-chip.lead, .state-chip.nudge, .state-chip.sent, .state-chip.queued { background: var(--blue-dim); color: var(--blue); }
.state-chip.pitched, .state-chip.chase { background: var(--orange-dim); color: var(--orange); }
.state-chip.option { background: var(--accent-dim); color: var(--accent); }
.state-chip.hold, .state-chip.logistics { background: var(--purple-dim); color: var(--purple); }
.state-chip.confirmed, .state-chip.replied { background: var(--green-dim); color: var(--green); }
.state-chip.played { background: var(--green); color: #000; }
.state-chip.declined, .state-chip.cancelled, .state-chip.lost, .state-chip.bounced, .state-chip.error { background: var(--red-dim); color: var(--red); }
.state-chip.parked, .state-chip.other { background: var(--card-hover); color: var(--text-muted); }
.state-chip.priority-target { background: var(--accent-dim); color: var(--accent); }
.state-chip.priority-warm { background: var(--orange-dim); color: var(--orange); }
.state-chip.priority-cold { background: var(--card-hover); color: var(--text-muted); }
.state-chip.score-high { background: var(--green-dim); color: var(--green); }
.state-chip.score-mid { background: var(--orange-dim); color: var(--orange); }
.state-chip.score-low { background: var(--card-hover); color: var(--text-muted); }
.state-chip.payment { background: var(--blue-dim); color: var(--blue); }
.state-chip.paid { background: var(--green-dim); color: var(--green); }
.state-chip.pending { background: var(--card-hover); color: var(--text-muted); }
.state-chip.overdue { background: var(--red-dim); color: var(--red); }
.state-chip.stale {
  background: transparent;
  border: 1px dashed var(--text-muted);
  color: var(--text-muted);
}
.state-chip.stale::before { display: none; }
.state-chip.offer-flag { background: var(--red-dim); color: var(--red); }
.state-chip.offer-counter {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-border);
  cursor: pointer;
  font-family: inherit;
}
@media (hover: hover) {
  .state-chip.offer-counter:hover { border-color: var(--accent); }
}

/* ─── STATE TRANSITION BUTTONS ─── */
.btn-state-lead { background: var(--blue-dim); color: var(--blue); border-color: var(--blue); }
.btn-state-pitched { background: var(--orange-dim); color: var(--orange); border-color: var(--orange); }
.btn-state-option { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-border); }
.btn-state-hold { background: var(--purple-dim); color: var(--purple); border-color: var(--purple); }
.btn-state-confirmed, .btn-state-played { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.btn-state-declined, .btn-state-lost, .btn-state-cancelled { background: var(--red-dim); color: var(--red); border-color: var(--red); }
@media (hover: hover) {
  .btn-state-lead:hover, .btn-state-pitched:hover, .btn-state-option:hover, .btn-state-hold:hover,
  .btn-state-confirmed:hover, .btn-state-played:hover, .btn-state-declined:hover, .btn-state-lost:hover, .btn-state-cancelled:hover {
    filter: brightness(1.2);
  }
}

/* ─── DRAFTING PLACEHOLDER ─── */
.followup-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0 14px;
}
.followup-bar-label {
  font-size: 13px;
  color: var(--text-muted);
}
.switch {
  width: 52px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt, var(--surface));
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s, background 0.15s;
}
.switch.on { background: var(--accent-dim); border-color: var(--accent-border); }
.switch.on::after { transform: translateX(22px); background: var(--accent); }
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.drafting-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 10px 0;
}
.drafting-warn { color: var(--danger, #ff6b6b); }
.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TOASTS ─── */
.toasts-container {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}
.toast {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  pointer-events: auto;
  animation: toastIn 0.2s ease-out;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.toast-action {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  flex-shrink: 0;
}
@media (hover: hover) {
  .toast-action:hover { background: var(--accent); color: #000; }
}
.toast-success { border-color: var(--green); color: var(--green); }
.toast-error { border-color: var(--red); color: var(--red); }
.toast.fade-out { opacity: 0; transform: translateY(-8px); transition: all 0.2s; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── OUTREACH ─── */
.outreach-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}
.outreach-options .form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.outreach-options select.input {
  padding: 8px 12px;
  font-size: 13px;
  padding-right: 34px;
}

.links-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.link-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  cursor: pointer;
  padding: 5px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.link-check:active { transform: scale(0.96); }
.link-check input[type="checkbox"] { display: none; }
.link-check:has(input:checked) {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}

.picker-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  padding: 14px;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}
.picker-item:active { background: var(--card-hover); }
.picker-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.picker-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.picker-details strong { font-size: 14px; }
.picker-details .sub { font-size: 12px; }

.picker-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}
.picker-head .btn { align-self: flex-start; }

/* ─── OUTREACH REWORK ─── */
.picker-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.picker-tools .input { flex: 1 1 100%; padding: 8px 12px; font-size: 13px; min-height: 40px; }
.picker-tools .btn { flex: 1; }

.contact-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}
.contact-dot.replied { background: var(--green); }
.contact-dot.sent { background: var(--blue); }
.contact-dot.pipeline { background: var(--orange); }
.contact-dot.blocked { background: var(--red); }
.contact-status {
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
  text-transform: capitalize;
}
.contact-status.replied { color: var(--green); }
.contact-status.sent { color: var(--blue); }
.contact-status.pipeline { color: var(--orange); }
.contact-status.blocked { color: var(--red); }

.draft-fail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
}
.draft-fail .sub { color: var(--red); }
.draft-fail .btn { align-self: flex-start; }

.outbound-preview {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 4px;
}
.outbound-subject { font-size: 13px; }
.outbound-preview-body {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.links-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 8px;
  flex-basis: 100%;
}
.link-check .link-desc { color: var(--text-muted); font-weight: 400; }

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.draft-progress {
  align-self: flex-start;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}

.outreach-options-details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 12px;
}
.outreach-options-details summary {
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 2px;
  color: var(--text);
  transition: color 0.15s ease;
}
@media (hover: hover) {
  .outreach-options-details summary:hover { color: var(--accent); }
}

.section-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.section-head-row .section-subtitle { margin-bottom: 0; }

/* ─── LOADING ─── */
.loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px;
}

.error { color: var(--red); font-size: 13px; }

/* ─── HIDE SCROLLBAR FOR NAV ─── */
nav::-webkit-scrollbar { display: none; }

/* ─── SMALL SCREEN ADJUSTMENTS ─── */
@media (max-width: 480px) {
  .timestamp { display: none; }
}
@media (max-width: 380px) {
  .tab { font-size: 9px; }
  .tab .tab-icon { font-size: 18px; }
  .view { padding: 10px 12px; }
}

/* ─── TABLET / DESKTOP ─── */
@media (min-width: 768px) {
  nav { justify-content: center; }
  .tab {
    flex: 0 1 100px;
    max-width: 100px;
    font-size: 12px;
  }
}

@media (min-width: 1024px) {
  .view { max-width: 720px; }
  .view.wide { max-width: 1080px; }
  .two-pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
  .pane-detail {
    position: sticky;
    top: 96px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}

/* ─── GLOBAL SEARCH OVERLAY ─── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}
.search-overlay.hidden { display: none; }
.search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.search-panel input {
  margin: 12px;
  flex-shrink: 0;
}
.search-results {
  overflow-y: auto;
  padding: 0 12px 12px;
}
.search-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 10px 2px 6px;
}
.search-item {
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
}
@media (hover: hover) {
  .search-item:hover { border-color: var(--accent); }
}
.search-item .sub { font-size: 12px; }

/* ─── ACCESSIBILITY ─── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── SKELETON LOADING ─── */
.skeleton-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  margin-bottom: 8px;
}
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ─── DYTRIS EASTER EGG ─── */
.dytris-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.dytris-modal.hidden { display: none; }
#game-btn svg { width: 18px; height: 18px; }
.dytris-panel {
  position: relative;
  width: 100%;
  max-width: 580px;
  height: min(92vh, 660px);
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.dytris-panel iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #050508;
}
.dytris-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--accent-border);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 767px) {
  .dytris-modal { padding: 0; }
  .dytris-panel {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
}
@media (hover: hover) {
  .dytris-close:hover { background: rgba(255, 255, 255, 0.18); }
}
