/* RunDesk Dashboard - Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

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

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-hover: #1a1a26;
  --border: #1e1e2e;
  --border-light: #2a2a3e;
  --text: #e8e8ed;
  --text-secondary: #a0a0b8;
  --muted: #6a6a82;
  --accent: #5ce0d8;
  --accent-dim: rgba(92, 224, 216, 0.08);
  --accent-hover: rgba(92, 224, 216, 0.15);
  --warm: #f0c674;
  --red: #f05c5c;
  --red-dim: rgba(240, 92, 92, 0.1);
  --green: #5cf07a;
  --green-dim: rgba(92, 240, 122, 0.1);
  --purple: #7c6cf0;
  --purple-dim: rgba(124, 108, 240, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
}

/* ======== Layout ======== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ======== Sidebar ======== */
.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.sidebar-logo .logo-dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.sidebar-logo h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sidebar-logo span {
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 20px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  padding: 16px 12px 8px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item .icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-account {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.account-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--bg);
}

.account-details {
  flex: 1;
  min-width: 0;
}

.account-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-email {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ======== Main Content ======== */
.main-content {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ======== Top Bar ======== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 40;
}

.top-bar h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ======== Stats Bar ======== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 24px 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.15s ease;
}

.stat-card:hover {
  border-color: var(--border-light);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.warm .stat-value { color: var(--warm); }
.stat-card.green .stat-value { color: var(--green); }

/* ======== Inbox Layout ======== */
.inbox-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Thread List */
.thread-list {
  width: 420px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.thread-list-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.thread-list-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.filter-pills {
  display: flex;
  gap: 6px;
}

.filter-pill {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'DM Sans', sans-serif;
}

.filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

/* Thread Item */
.thread-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.thread-item:hover {
  background: var(--surface-hover);
}

.thread-item.active {
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
}

.thread-item.unread::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.thread-from {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.thread-from-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.thread-time {
  font-size: 0.75rem;
  color: var(--muted);
}

.thread-subject {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-snippet {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.thread-tag {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-needs-reply {
  background: var(--red-dim);
  color: var(--red);
}

.tag-draft-ready {
  background: var(--accent-dim);
  color: var(--accent);
}

.tag-replied {
  background: var(--green-dim);
  color: var(--green);
}

.tag-informational {
  background: var(--purple-dim);
  color: var(--purple);
}

.tag-high {
  background: var(--red-dim);
  color: var(--red);
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

/* Thread Detail Panel */
.thread-detail {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.thread-detail-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
}

.thread-detail-empty .icon {
  font-size: 3rem;
  opacity: 0.3;
}

.thread-detail-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.thread-detail-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
}

.thread-detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

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

/* Messages */
.messages-container {
  flex: 1;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  max-width: 90%;
}

.message-bubble.outbound {
  align-self: flex-end;
  background: var(--accent-dim);
  border-color: rgba(92, 224, 216, 0.2);
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.message-sender {
  font-weight: 600;
  font-size: 0.85rem;
}

.message-time {
  font-size: 0.75rem;
  color: var(--muted);
}

.message-body {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* AI Draft Section */
.ai-draft-section {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 28px;
}

.ai-draft-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ai-draft-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-draft-title h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.ai-badge {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: var(--bg);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tone-selector {
  display: flex;
  gap: 6px;
}

.tone-btn {
  font-size: 0.75rem;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
}

.tone-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.draft-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  min-height: 120px;
  margin-bottom: 16px;
  position: relative;
}

.draft-textarea {
  width: 100%;
  min-height: 120px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}

.draft-textarea::placeholder {
  color: var(--muted);
}

.draft-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.draft-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.draft-confidence {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ======== Buttons ======== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.btn-primary:hover {
  background: #4dd0c8;
  border-color: #4dd0c8;
}

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--surface-hover);
}

.btn-danger {
  color: var(--red);
  border-color: rgba(240, 92, 92, 0.3);
}

.btn-danger:hover {
  background: var(--red-dim);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

/* ======== Loading ======== */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  z-index: 10;
}

.ai-thinking {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--accent-dim);
  border: 1px solid rgba(92, 224, 216, 0.15);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
}

.ai-thinking .dots {
  display: flex;
  gap: 4px;
}

.ai-thinking .dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: dotPulse 1.4s ease-in-out infinite;
}

.ai-thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.ai-thinking .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ======== Toast ======== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

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

/* ======== Mobile Responsive ======== */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: block;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    padding: 16px;
  }

  .inbox-layout {
    flex-direction: column;
  }

  .thread-list {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .top-bar {
    padding: 12px 16px;
  }

  .thread-detail-header,
  .messages-container,
  .ai-draft-section {
    padding: 16px;
  }
}

/* ======== Ambient Glow ======== */
.glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}

.glow-1 { background: var(--accent); top: -200px; right: -100px; }
.glow-2 { background: var(--purple); bottom: 20%; left: -200px; }

/* ======== Subscription Sidebar Card ======== */
.sidebar-sub {
  padding: 12px 16px;
}

.sub-card {
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}

.sub-card.demo {
  background: rgba(240, 198, 116, 0.06);
  border: 1px solid rgba(240, 198, 116, 0.15);
}

.sub-card.pro {
  background: rgba(92, 224, 216, 0.06);
  border: 1px solid rgba(92, 224, 216, 0.15);
}

.sub-status {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}

.sub-card.demo .sub-status { color: var(--warm); }
.sub-card.pro .sub-status { color: var(--accent); }

.sub-desc {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.sub-btn {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: none;
}

.sub-card.demo .sub-btn {
  background: var(--warm);
  color: var(--bg);
}

.sub-card.demo .sub-btn:hover {
  background: #e8bc5c;
}

.sub-card.pro .sub-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(92, 224, 216, 0.3);
}

.sub-card.pro .sub-btn:hover {
  background: var(--accent-dim);
}

/* ======== Activate Banner ======== */
.activate-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  background: linear-gradient(90deg, rgba(92, 224, 216, 0.06), rgba(124, 108, 240, 0.06));
  border-bottom: 1px solid var(--border);
}

.activate-banner.hidden { display: none; }

.activate-content {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  flex-wrap: wrap;
}

.activate-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.activate-text strong {
  color: var(--accent);
}

.activate-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.activate-input {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  outline: none;
  width: 220px;
  transition: border-color 0.15s ease;
}

.activate-input:focus {
  border-color: var(--accent);
}

.activate-btn {
  padding: 7px 18px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.activate-btn:hover {
  background: #4dd0c8;
}

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

.activate-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.15s;
}

.activate-close:hover {
  color: var(--text);
}

/* ======== Upgrade Prompt (in-app) ======== */
.upgrade-prompt {
  background: var(--surface);
  border: 1px solid rgba(240, 198, 116, 0.2);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  margin: 16px 0;
}

.upgrade-prompt h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
  color: var(--warm);
}

.upgrade-prompt p {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.upgrade-prompt .upgrade-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}

.upgrade-prompt .upgrade-link:hover {
  background: #4dd0c8;
  transform: translateY(-1px);
}

/* Demo mode badge */
.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6rem;
  background: rgba(240, 198, 116, 0.15);
  color: var(--warm);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pro-badge-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6rem;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: var(--bg);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 8px;
}

/* ======== Scrollbar ======== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ======== Connection Status Dot ======== */
.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  margin-left: auto;
  flex-shrink: 0;
}

.connection-dot.connected {
  background: var(--green);
  box-shadow: 0 0 6px rgba(92, 240, 122, 0.4);
}

.connection-dot.demo {
  background: var(--warm);
}

/* ======== Modal ======== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s ease;
  line-height: 1;
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.modal-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 12px;
}

/* ======== Provider Tabs ======== */
.provider-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.provider-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.provider-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

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

.provider-icon {
  font-size: 1.1rem;
}

/* ======== Connect Instructions ======== */
.connect-instructions {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(92, 224, 216, 0.04);
  border: 1px solid rgba(92, 224, 216, 0.1);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.connect-instructions strong {
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}

.connect-instructions p {
  margin: 2px 0;
}

.connect-instructions a {
  color: var(--accent);
  text-decoration: none;
}

.connect-instructions a:hover {
  text-decoration: underline;
}

.instruction-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ======== Form ======== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.15s ease;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
}

.form-group input::placeholder {
  color: var(--muted);
}

.form-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ======== Connect Status ======== */
.connect-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 16px;
  line-height: 1.4;
}

.connect-status.info {
  background: var(--accent-dim);
  border: 1px solid rgba(92, 224, 216, 0.15);
  color: var(--accent);
}

.connect-status.success {
  background: var(--green-dim);
  border: 1px solid rgba(92, 240, 122, 0.15);
  color: var(--green);
}

.connect-status.error {
  background: var(--red-dim);
  border: 1px solid rgba(240, 92, 92, 0.15);
  color: var(--red);
}

/* ======== Modal Actions ======== */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* ======== Connected Account Items ======== */
.connected-account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.connected-account-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connected-account-icon {
  font-size: 1.3rem;
}

.connected-account-email {
  font-size: 0.85rem;
  font-weight: 600;
}

.connected-account-status {
  font-size: 0.72rem;
  color: var(--muted);
}

.connected-account-actions {
  display: flex;
  gap: 6px;
}

/* ======== Mobile Modal Fix ======== */
@media (max-width: 768px) {
  .modal {
    max-width: 100%;
    padding: 20px;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .provider-tabs {
    flex-direction: column;
  }

  .connected-account-item {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .connected-account-actions {
    width: 100%;
  }

  .connected-account-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .tone-selector {
    flex-wrap: wrap;
  }
}
