/* === Font === */
@font-face {
  font-family: 'Good Sans';
  src: url('/fonts/GoodSans-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Good Sans';
  src: url('/fonts/GoodSans-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Good Sans';
  src: url('/fonts/GoodSans-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a1a1a;
  --primary-light: #333333;
  --primary-dark: #000000;
  --accent: #c9a96e;
  --accent-light: #f0e6d2;
  --bg: #faf8f4;
  --bg-warm: #f5f0e8;
  --sidebar-bg: #1a1a1a;
  --sidebar-text: #a8a29e;
  --sidebar-active: #c9a96e;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #5a5650;
  --text-muted: #8c857d;
  --border: #e0dbd4;
  --border-light: #ebe7e0;
  --success: #2d7a4f;
  --warning: #b8860b;
  --danger: #c0392b;
  --info: #4a7c8a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
}

body {
  font-family: 'Good Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* === Sidebar === */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .sidebar-logo {
  height: 22px;
  width: auto;
  margin-bottom: 6px;
  display: block;
}

.sidebar-brand .sidebar-logo path { fill: #ffffff; }

.sidebar-brand small {
  font-size: 11px;
  color: var(--sidebar-text);
  opacity: 0.6;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}

.sidebar-nav {
  list-style: none;
  padding: 16px 0;
  flex: 1;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 14px;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
  text-decoration: none;
}

.sidebar-nav li a.active {
  background: rgba(201,169,110,0.1);
  color: var(--sidebar-active);
  border-left-color: var(--sidebar-active);
  font-weight: 600;
}

.sidebar-nav li a .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 0;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 14px;
  font-family: 'Good Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  cursor: pointer;
  transition: color 0.15s ease;
}

.sidebar-logout:hover { color: #fff; }

/* === Main Content === */
.main {
  margin-left: 240px;
  flex: 1;
  padding: 28px 32px;
  min-width: 0;
}

.page-header { margin-bottom: 24px; }
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.page-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* === Cards === */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* === Metric Cards Grid === */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  padding: 20px;
  text-align: center;
}

.metric-card .metric-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.metric-card .metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
  font-weight: 500;
}

.metric-card.primary .metric-value { color: var(--primary); }
.metric-card.success .metric-value { color: var(--success); }
.metric-card.warning .metric-value { color: var(--warning); }
.metric-card.danger .metric-value  { color: var(--danger); }

/* === Tables === */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}

table tr:hover td { background: var(--bg); }

table td.truncate {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Badges === */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pending    { background: #fef3c7; color: #92400e; }
.badge-active     { background: #e8f5e9; color: #1b5e20; }
.badge-paused     { background: var(--bg-warm); color: var(--text-secondary); }
.badge-completed  { background: #e8f5e9; color: #1b5e20; }
.badge-stopped    { background: #fce4e4; color: #991b1b; }

.badge-qualified     { background: #e8f5e9; color: #1b5e20; }
.badge-needs-review  { background: #fef3c7; color: #92400e; }
.badge-reject        { background: #fce4e4; color: #991b1b; }

.badge-interested    { background: #e8f5e9; color: #1b5e20; }
.badge-question      { background: var(--accent-light); color: #7c6a3a; }
.badge-not-interested { background: #fef3c7; color: #92400e; }
.badge-unsubscribe   { background: #fef3c7; color: #92400e; }
.badge-angry         { background: #fce4e4; color: #880e4f; }
.badge-ooo           { background: var(--bg-warm); color: var(--text-secondary); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.4;
  font-family: 'Good Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-secondary { background: var(--bg-warm); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* === Filter Bar === */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.filter-bar .filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-bar label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="email"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  min-width: 140px;
  font-family: 'Good Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.filter-bar select:focus,
.filter-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.08);
}

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  font-size: 13px;
}

.pagination button {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  font-family: 'Good Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.pagination button:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; pointer-events: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

/* === Validation Checklist === */
.check-list { list-style: none; }
.check-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.check-list li:last-child { border-bottom: none; }
.check-pass { color: var(--success); font-weight: 700; }
.check-fail { color: var(--danger); font-weight: 700; }

/* === Detail grid === */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-grid .detail-item label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.detail-grid .detail-item p {
  font-size: 14px;
  color: var(--text);
  margin-top: 2px;
}

/* === Thread === */
.thread { display: flex; flex-direction: column; gap: 16px; }
.thread-message {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}
.thread-message.sent { background: var(--bg); border-color: var(--border); }
.thread-message.received { background: #f0faf4; border-color: #c8e6c9; }
.thread-message .thread-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.thread-message .thread-body { white-space: pre-wrap; font-size: 14px; line-height: 1.6; }

/* === Forms === */
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Good Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  resize: vertical;
  min-height: 120px;
}
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.08);
}

/* === Utility === */
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; }
.mb-20 { margin-bottom: 20px; }

/* === Login === */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: var(--bg);
}
.login-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  padding: 40px;
  width: 360px;
  text-align: center;
}
.login-box h2 { margin-bottom: 24px; font-size: 20px; }
.login-box input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  font-family: 'Good Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.login-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.08);
}

/* === Slideout === */
.slideout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 200;
}
.slideout {
  position: fixed;
  top: 0;
  right: 0;
  width: 560px;
  max-width: 90vw;
  height: 100vh;
  background: var(--card-bg);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  z-index: 201;
  overflow-y: auto;
  padding: 24px;
}
.slideout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.slideout-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

/* === Timeline === */
.timeline-item {
  position: relative;
  padding-left: 24px;
  padding-bottom: 16px;
  border-left: 2px solid var(--border-light);
  margin-left: 6px;
}
.timeline-item:last-child { border-left-color: transparent; }

.timeline-dot {
  position: absolute;
  left: -7px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid var(--card-bg);
}

.timeline-item.type-send .timeline-dot       { background: #4f46e5; }
.timeline-item.type-open .timeline-dot       { background: #0ea5e9; }
.timeline-item.type-click .timeline-dot      { background: #2563eb; }
.timeline-item.type-reply .timeline-dot      { background: #9333ea; }
.timeline-item.type-note .timeline-dot       { background: #6b7280; }
.timeline-item.type-stage_change .timeline-dot { background: #d97706; }
.timeline-item.type-intake_submission .timeline-dot { background: #16a34a; }
.timeline-item.type-draft_reply .timeline-dot { background: #a855f7; }
.timeline-item.type-research .timeline-dot   { background: #0d9488; }

.classification-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cls-interested     { background: #e8f5e9; color: #1b5e20; }
.cls-not-interested { background: #fef3c7; color: #92400e; }
.cls-question       { background: var(--accent-light); color: #7c6a3a; }
.cls-ooo            { background: var(--bg-warm); color: var(--text-secondary); }
.cls-angry          { background: #fce4e4; color: #880e4f; }
.cls-unsubscribe    { background: #fce4e4; color: #991b1b; }

.collapsible-toggle {
  font-size: 12px;
  color: var(--info);
  cursor: pointer;
  font-weight: 500;
}
.collapsible-toggle:hover { text-decoration: underline; }

/* === Chat (AI Queue Builder) === */
.chat-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg);
}

.chat-messages {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}

.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant {
  align-self: flex-start;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-bottom-left-radius: 4px;
}

.chat-msg-content { white-space: pre-wrap; }

/* === Toast overrides === */
[data-solid-toast] {
  font-family: 'Good Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 13px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

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

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand .sidebar-logo, .sidebar-brand small { display: none; }
  .sidebar-nav li a span:not(.nav-icon) { display: none; }
  .sidebar-nav li a { justify-content: center; padding: 12px; }
  .sidebar-logout span:not(.nav-icon) { display: none; }
  .sidebar-logout { justify-content: center; }
  .main { margin-left: 60px; padding: 16px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .slideout { width: 100vw; max-width: 100vw; }
}
