:root {
  --bg: #05070f;
  --card: #0d1022;
  --panel: #0b122a;
  --panel-2: #0f1836;
  --surface: #0f1421;
  --ink: #e9ecf6;
  --muted: #96a3c7;
  --accent: #75f0c7;
  --accent-2: #ffb86c;
  --border: rgba(255, 255, 255, 0.07);
  --radius: 18px;
}

body.theme-light {
  --bg: #f6f8fb;
  --card: #ffffff;
  --panel: #eef3fb;
  --panel-2: #e6edfa;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #4b5563;
  --accent: #10b981;
  --accent-2: #f59e0b;
  --border: rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
}

.bg-accent {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 20%, rgba(117, 240, 199, 0.18), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(255, 184, 108, 0.16), transparent 25%),
    radial-gradient(circle at 70% 80%, rgba(106, 141, 255, 0.12), transparent 32%);
  filter: blur(5px);
  z-index: 0;
}

body.theme-light .bg-accent {
  background:
    radial-gradient(circle at 12% 20%, rgba(16, 185, 129, 0.15), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(245, 158, 11, 0.12), transparent 25%),
    radial-gradient(circle at 70% 80%, rgba(79, 70, 229, 0.1), transparent 32%);
}

body.theme-light .topbar {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
}

.topbar {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar-nav {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

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

.topbar-brand {
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar h1 { margin: 6px 0 8px; font-size: 2.4rem; letter-spacing: 0.02em; }
.lede { margin: 0; color: var(--muted); max-width: 680px; }
.eyebrow { margin: 0; letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.78rem; color: var(--accent); }
.pill {
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 0.875rem;
  white-space: nowrap;
}

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

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
}

.topbar.light-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 22px 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
}

.theme-toggle {
  min-width: 90px;
  padding: 6px 12px;
  font-size: 0.875rem;
}

.layout {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 22px 24px;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
}

.hidden { display: none !important; }

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: rgba(13, 16, 34, 0.95);
  border-right: 1px solid var(--border);
  box-shadow: 12px 0 30px rgba(0,0,0,0.4);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  z-index: 20;
  padding: 18px;
}

body.theme-light .nav-drawer {
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  box-shadow: 12px 0 30px rgba(0,0,0,0.08);
}

.nav-drawer.open { transform: translateX(0); }

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-link:hover { border-color: rgba(117, 240, 199, 0.4); }
.nav-link.active { background: var(--accent); color: var(--background); border-color: var(--accent); }

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 18px 38px rgba(0,0,0,0.35);
  min-height: 540px;
}

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

.muted { color: var(--muted); margin: 0; }

.conversation-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 70vh;
  overflow: auto;
  padding-right: 4px;
}

.conversation {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conversation-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation:hover { border-color: rgba(255,255,255,0.14); transform: translateY(-1px); }
.conversation.active { border-color: var(--accent); box-shadow: 0 10px 26px rgba(0,0,0,0.35); }
.conversation .contact { margin: 0 0 6px; font-weight: 600; }
.conversation .preview {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}
.conversation .meta { margin: 4px 0 0; color: var(--accent-2); font-size: 0.85rem; }

.chat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 540px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 38px rgba(0,0,0,0.32);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.chip {
  border-radius: 12px;
  padding: 8px 12px;
  background: rgba(117, 240, 199, 0.12);
  color: var(--accent);
  border: 1px solid rgba(117, 240, 199, 0.35);
  font-weight: 600;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 12px 4px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.bubble-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.bubble-row.outbound { align-items: flex-end; }

.bubble {
  max-width: 70%;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: 0 12px 26px rgba(0,0,0,0.25);
}

.bubble.outbound {
  background: linear-gradient(135deg, #79f2c0, #5ad6ff);
  color: #000;
  border: none;
}

.media-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.media-list img {
  max-width: 160px;
  max-height: 160px;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
}
.media-generic {
  max-width: 240px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  padding: 6px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
}
.media-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: #000;
  text-decoration: none;
}
.media-link:hover { border-color: rgba(117, 240, 199, 0.4); }

.media-caption {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.media-link-wrap {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.timestamp {
  color: var(--muted);
  font-size: 0.85rem;
}

.bubble a.message-link {
  color: #000;
  text-decoration: underline;
  word-break: break-all;
}

.composer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attach-row {
  grid-column: 1 / -1;
}

.composer button[type="submit"] {
  justify-self: flex-end;
}

.upload-progress {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.upload-filename {
  margin-top: 4px;
  font-size: 0.88rem;
  color: var(--muted);
}

.upload-progress-bar {
  flex: 1;
  height: 8px;
  background: linear-gradient(135deg, #7df3c6, #59d6ff);
  border-radius: 999px;
  width: 0%;
  transition: width 0.15s ease;
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
}

.upload-progress-text {
  font-size: 0.85rem;
  color: var(--muted);
}

.composer-media-preview {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  max-width: 400px;
}

.composer-media-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
}

.composer-media-preview video {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
}

.composer-media-preview .media-info {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

.field label {
  font-size: 0.9rem;
  color: var(--muted);
}

input, textarea {
  background: rgba(255,255,255,0.03);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: 'Space Grotesk', system-ui, sans-serif;
}

textarea { resize: vertical; min-height: 64px; }
textarea#input-body { min-height: 120px; }

.btn {
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-weight: 600;
}

.btn.primary {
  background: linear-gradient(135deg, #7df3c6, #59d6ff);
  color: #041824;
  border: none;
}

.btn.ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.3);
}

.btn.icon-btn {
  padding: 6px 10px;
  min-width: 0;
  line-height: 1;
  font-size: 1.1rem;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(0,0,0,0.3); }
.btn:active { transform: translateY(0); }

/* Contacts */
.contacts-view {
  display: block;
}

.contacts-panel {
  grid-column: 1 / -1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 18px 38px rgba(0,0,0,0.32);
}

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

.contacts-header-actions {
  display: flex;
  gap: 10px;
}

.contacts-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
}

.contacts-list-card,
.contacts-form-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.contacts-list-card .search {
  width: 100%;
  margin-bottom: 12px;
}

.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 70vh;
  overflow: auto;
}

.contact-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
}

.contact-card:hover { border-color: rgba(117, 240, 199, 0.4); }

.contact-initials {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.contact-name { margin: 0; font-weight: 700; }
.contact-phone { margin: 2px 0; color: var(--muted); }
.contact-email { margin: 0; color: var(--muted); font-size: 0.9rem; }

.contact-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn.small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.btn.icon-only {
  width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.btn.small.danger {
  border-color: rgba(255, 99, 99, 0.7);
  color: #ffb0b0;
}

.contacts-form-card h3 {
  margin-top: 0;
}

.contacts-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
.contacts-actions .spacer {
  flex: 1;
}

.contact-table-wrapper {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

.contact-count {
  margin-top: 10px;
  text-align: right;
  color: var(--muted);
  font-weight: 600;
}

#sales-filter-summary {
  margin: 6px 0 10px;
}

.ai-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: flex-start;
}

.ai-sidebar {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-models {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-models .pill {
  border-radius: 999px;
  padding: 8px 12px;
}
.ai-models .pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.ai-preview {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.ai-card {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-card textarea,
.ai-card input {
  width: 100%;
}

.ai-template-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.ai-template-actions input {
  flex: 1;
}
.ai-template-actions .btn {
  white-space: nowrap;
}

.hidden-input {
  display: none;
}

.ai-sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.ai-sample-grid img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  aspect-ratio: 1;
}

.ai-image-preview {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.02);
}

.ai-image-preview img {
  max-width: 100%;
  border-radius: 10px;
}

.ai-image-edit-section {
  margin-top: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.ai-image-edit-section .field {
  margin-bottom: 12px;
}

.ai-image-edit-section textarea {
  width: 100%;
  resize: vertical;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  margin: 6px 0;
}

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

.contact-table th,
.contact-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.contact-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 700;
}
.contact-table .numeric-col {
  min-width: 140px;
  text-align: right;
}

.sales-header {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
}

.sort-buttons {
  display: inline-flex;
  gap: 4px;
}

.sort-buttons .btn {
  padding: 4px 6px;
  line-height: 1;
}
.sort-buttons .btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.date-cell {
  white-space: nowrap;
  color: var(--muted);
}

.contact-table .actions-col {
  text-align: right;
  width: 120px;
}

.actions-cell {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.bulk-send {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bulk-schedule {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.schedule-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.schedule-mode {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}
.schedule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.scheduled-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.schedule-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel-1);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.schedule-card .meta {
  color: var(--muted);
  font-size: 0.9rem;
}
.schedule-card .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

.select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.bulk-tag-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}

.bulk-tag-bar input {
  min-width: 220px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 20px 10px;
}

.contacts-card {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow: auto;
}

.contact-row {
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: border 0.15s ease, transform 0.15s ease;
}
.contact-row:hover { border-color: rgba(255,255,255,0.2); transform: translateY(-1px); }
.contact-name { margin: 0; font-weight: 600; }
.contact-phone { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }

.contact-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.contact-form .field { margin: 0; }
.contact-form button { grid-column: 1 / -1; }

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal.open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: none;
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  max-width: 95vw;
  max-height: 95vh;
}

.modal-content img {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  border-radius: 10px;
}

.modal-content.modal-wide {
  max-width: 85vw;
}

.modal-content.modal-medium {
  max-width: 480px;
}
.modal-content.modal-contact {
  width: 460px;
  max-width: 92vw;
}

.modal-close {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 1.2rem;
  line-height: 1;
  padding: 6px 10px;
}

.tiny { font-size: 0.8rem; margin: 0; }

.field-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .field-row.two-col {
    grid-template-columns: 1fr;
  }
}

#contact-modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#contact-modal .contacts-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
#contact-modal h3 {
  margin: 0 0 8px;
}

/* Templates refresh */
.templates-modern { display: flex; flex-direction: column; gap: 16px; }
.templates-hero { display: flex; align-items: center; gap: 14px; justify-content: space-between; border: 1px solid rgba(255,255,255,0.05); background: #0d131f; border-radius: 18px; padding: 16px 18px; box-shadow: 0 12px 32px rgba(0,0,0,0.35); }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, #10b981, #22d3ee, #38bdf8); display: inline-flex; align-items: center; justify-content: center; color: #0b0b0d; font-weight: 800; box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3); }
.templates-hero-left { display: flex; gap: 10px; align-items: center; }
.hero-title { margin: 0; font-size: 1.4rem; }
.templates-hero-actions { display: flex; gap: 8px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.pill .dot-live { background: #10b981; box-shadow: 0 0 0 4px rgba(16,185,129,0.2); }
.pill .icon-plus { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,0.1); display: inline-flex; align-items: center; justify-content: center; }
.md-show { display: none; }
.pill-count { float: right; font-size: 0.85em; color: var(--muted); padding-left: 8px; }
.templates-layout { display: flex; flex-direction: column; gap: 12px; }
.templates-topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border: 1px solid rgba(255,255,255,0.05); background: #0d131f; padding: 12px 14px; border-radius: 16px; width: 100%; }
.templates-body { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.templates-filters { border: 1px solid rgba(255,255,255,0.05); background: #0c111c; border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 26px rgba(0,0,0,0.35); width: 100%; }
.filters-section { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.filters-section:last-child { border-bottom: none; }
.filters-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }
.filters-list { display: flex; flex-direction: column; gap: 6px; }
.pill-btn { text-align: left; padding: 10px 12px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.06); background: #0f1625; color: var(--text); }
.pill-btn.active { border-color: #1dd1a1; color: #1dd1a1; box-shadow: 0 6px 18px rgba(29,209,161,0.25); }
.pill-btn.ghost { background: transparent; }
.pill-btn .pill-count { float: right; color: var(--muted); font-size: 0.8em; }
.filters-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.filters-tags .tag { padding: 8px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.06); background: #0f1625; font-size: 0.82rem; color: #8ea4c0; }
.filters-tags .tag.active { color: #e6f5ff; border-color: #1dd1a1; box-shadow: 0 4px 12px rgba(29,209,161,0.25); }
.filters-checks { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 0.88rem; }
.templates-main { border: 1px solid rgba(255,255,255,0.05); background: #0a0f19; border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 14px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.02), 0 12px 32px rgba(0,0,0,0.35); flex: 1 1 auto; min-width: 0; }
.templates-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.templates-toolbar .search, .templates-topbar .search { display: flex; align-items: center; gap: 6px; border: 1px solid #1f2a3d; border-radius: 16px; padding: 12px 14px; min-width: 260px; flex: 1; background: #0c111c; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04); }
.templates-toolbar .search input { flex: 1; background: transparent; border: none; color: var(--text); }
.templates-toolbar .sort, .templates-topbar .sort { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.templates-toolbar .sort select, .templates-topbar .sort select { background: #0c111c; border: 1px solid #1f2a3d; color: var(--text); border-radius: 14px; padding: 10px 12px; }
.layout-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 4px; gap: 4px; }
.layout-toggle .toggle { padding: 6px 10px; border-radius: 999px; border: none; background: transparent; color: var(--muted); }
.layout-toggle .toggle.active { background: var(--panel-2); color: var(--text); }
.templates-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.templates-chips.inline { flex: 1 1 100%; }
.chip.pill { border-radius: 999px; border: 1px solid #1f2a3d; background: #0c111c; padding: 10px 14px; color: #8ea4c0; }
.chip.pill.primary { background: linear-gradient(135deg, #12b886, #0fb5a5); color: #021019; border-color: transparent; box-shadow: 0 10px 30px rgba(18,184,134,0.35); }
.templates-list.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  width: 100%;
}
.templates-main { width: 100%; }
.templates-list.list,
.templates-list.list-mode {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
  align-items: stretch;
}
.templates-list.list > * { width: 100%; }
.templates-list.list-mode > * { width: 100%; }
.template-list-header {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, 1.5fr) minmax(0, 1.3fr);
  gap: 14px;
  padding: 12px 18px;
  width: 100%;
  border: 1px solid #1f2a3d;
  border-radius: 12px;
  background: #0c111c;
  color: #8ea4c0;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.template-card { border: 1px solid #1f2a3d; background: #0f1421; border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 14px 40px rgba(0,0,0,0.45); width: 100%; }
.template-card.list {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, 1.5fr) minmax(0, 1.3fr);
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  min-height: 120px;
  border-radius: 12px;
  width: 100%;
}
.template-thumb { height: 160px; background: linear-gradient(135deg, #1b794f, #1d385f, #5e3f6c); display: flex; align-items: center; justify-content: center; position: relative; padding: 14px; }
.template-card.list .template-thumb { width: 220px; min-height: 140px; height: auto; }
.template-thumb .badge { position: absolute; top: 10px; right: 10px; background: rgba(12,17,28,0.9); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 5px 10px; font-size: 0.82rem; color: #a1c5ff; }
.template-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.template-body h4 { margin: 0; font-size: 1rem; }
.template-body p { margin: 0; color: #9bb0cb; }
.template-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.template-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.template-tags .tag { border: 1px solid #1f2a3d; border-radius: 999px; padding: 6px 9px; font-size: 0.8rem; background: #0c111c; color: #8ea4c0; }
.template-card .actions { border-top: 1px solid #1f2a3d; padding: 12px; display: flex; align-items: center; justify-content: space-between; background: rgba(10,15,25,0.9); }
.template-card.list .actions { border: none; background: transparent; justify-content: flex-end; }
.template-card .actions .btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.template-card.list .list-col { display: flex; flex-direction: column; gap: 6px; }
.template-card.list .list-col.type { align-items: flex-start; }
.template-card.list .badge { background: rgba(12,17,28,0.9); border: 1px solid rgba(255,255,255,0.08); border-radius: 999px; padding: 6px 10px; font-size: 0.8rem; color: #a1c5ff; position: static; }
.template-card.list .list-col.actions-col { align-items: flex-end; }
.template-card.list .muted.small { font-size: 0.85rem; }
.pill-tag { border: 1px solid #1f2a3d; background: #0c111c; color: #8ea4c0; border-radius: 999px; padding: 6px 10px; font-size: 0.85rem; }
.template-row.list {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, 1.5fr) minmax(0, 1.3fr);
  gap: 14px;
  align-items: center;
  width: 100%;
  border: 1px solid #1f2a3d;
  background: #0f1421;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.template-row.list .list-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.template-row.list .title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.template-row.list h4 {
  margin: 0;
  font-size: 1.02rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-row.list .muted.small {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
}

.template-row.list .list-col.actions-col { align-items: flex-end; }
.template-row.list .actions .btn-row { flex-wrap: wrap; justify-content: flex-end; }
.templates-pagination { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }

.logs-view { width: 100%; display: flex; }
.logs-frame { flex: 1 1 auto; width: 100%; min-height: 90vh; min-width: 0; border: 1px solid var(--border); background: var(--panel-2); border-radius: 18px; overflow: hidden; display: flex; box-shadow: 0 12px 30px rgba(0,0,0,0.12); }
.logs-frame iframe { flex: 1 1 auto; width: 100%; min-height: 90vh; border: 0; }
.logs-layout { max-width: none; width: 100%; padding: 0 22px 24px; display: flex; flex-direction: column; }
.logs-layout .logs-view { flex: 1 1 auto; }

/* Light theme component overrides */
body.theme-light .topbar,
body.theme-light .sidebar,
body.theme-light .chat,
body.theme-light .card,
body.theme-light .contacts-panel,
body.theme-light .contacts-list-card,
body.theme-light .contacts-form-card,
body.theme-light .contact-table,
body.theme-light .templates-main,
body.theme-light .templates-filters,
body.theme-light .templates-topbar,
body.theme-light .template-card,
body.theme-light .template-row.list,
body.theme-light .template-list-header {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
}

body.theme-light .pill,
body.theme-light .chip.pill,
body.theme-light .pill-btn,
body.theme-light .tag,
body.theme-light .filters-tags .tag {
  background: #edf2fb;
  border-color: var(--border);
  color: var(--muted);
}
body.theme-light .templates-new-list,
body.theme-light .templates-new-preview,
body.theme-light .template-list-head,
body.theme-light .template-row {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}
body.theme-light .templates-new-actions input[type="search"],
body.theme-light .templates-new-actions select {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--border);
}
body.theme-light .template-row .badge {
  background: #e9eef9;
  color: #0f172a;
  border-color: var(--border);
}
body.theme-light .template-row .tag {
  background: #f5f7fb;
  color: #0f172a;
  border-color: var(--border);
}

/* Pill toggles for conversation filters */
.pill-toggle {
  display: inline-flex;
  align-items: center;
}
.pill-toggle input {
  appearance: none;
  margin: 0;
}
.pill-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.pill-toggle input:checked + span {
  background: #10b981;
  color: #0b1727;
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.25);
}
.pill-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.field.small-gap {
  gap: 8px;
}

body.theme-light .templates-topbar,
body.theme-light .templates-filters { border: 1px solid var(--border); }

body.theme-light .template-card .actions { background: rgba(0,0,0,0.03); }

body.theme-light .pill-btn.active { background: #e0f5ed; color: #0f172a; box-shadow: 0 6px 18px rgba(16, 185, 129, 0.18); }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { min-height: 0; }
  .composer { grid-template-columns: 1fr; }
  .bubble { max-width: 85%; }
}

@media (max-width: 1100px) {
  .templates-body { grid-template-columns: 1fr; }
  .templates-filters { width: 100%; }
  .templates-main { width: 100%; }
  .templates-list.grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .template-card.list { grid-template-columns: 2fr 1fr auto; }
}

@media (max-width: 720px) {
  .templates-body { grid-template-columns: 1fr; }
  .templates-list.grid { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .template-card.list { grid-template-columns: 1fr; }
  .template-card.list .list-col.actions-col { align-items: flex-start; }
}

/* New Templates Page Styles */
.templates-view {
  max-width: 1400px;
  width: 100%;
  padding: 0 22px 24px;
  display: flex;
  flex-direction: column;
}

.templates-new-page {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 18px 38px rgba(0,0,0,0.35);
  width: 100%;
  flex: 1 1 auto;
}

.templates-new-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.templates-new-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.templates-new-actions {
  display: flex;
  gap: 12px;
}

.templates-new-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.templates-new-search {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.templates-new-search input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 0.875rem;
}

.templates-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
}

.templates-new-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.templates-new-sort select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 0.75rem;
}

.templates-view-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.templates-view-btn {
  padding: 6px 12px;
  border-radius: 999px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.templates-view-btn.active {
  background: var(--ink);
  color: var(--background);
}

.templates-new-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.templates-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

.templates-card:hover {
  border-color: rgba(117, 240, 199, 0.4);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}

.templates-card-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.3);
  margin-bottom: 12px;
}

.templates-card-name {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.templates-card-snippet {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.templates-card-actions {
  display: flex;
  gap: 8px;
}

.templates-new-list {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.templates-list-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 16px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.templates-list-dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
}

.templates-list-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: background 0.2s;
}

.templates-list-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.templates-list-row:last-child {
  border-bottom: none;
}

.templates-list-row-name {
  font-weight: 600;
  font-size: 0.875rem;
}

.templates-list-row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-templates {
  width: 80vw;
  max-width: 1200px;
  max-height: 90vh;
  overflow-y: auto;
}

.templates-editor-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
}

.templates-media-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.templates-media-filename {
  font-size: 0.875rem;
  color: var(--muted);
  flex: 1;
  min-width: 200px;
}

.templates-media-preview {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.templates-media-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 6px;
  display: block;
}

.templates-media-preview.hidden {
  display: none;
}

.templates-card-media {
  margin-top: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  overflow: hidden;
}

.templates-card-media img {
  width: 100%;
  height: auto;
  display: block;
}

.templates-list-media-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--accent);
}

/* Light theme overrides for new templates */
body.theme-light .templates-new-page {
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
}

body.theme-light .templates-new-toolbar {
  background: rgba(248, 250, 252, 1);
}

body.theme-light .templates-new-search input,
body.theme-light .templates-new-sort select {
  background: #ffffff;
  border-color: #e2e8f0;
}

body.theme-light .templates-view-toggle {
  background: #e2e8f0;
}

body.theme-light .templates-card {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.theme-light .templates-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

body.theme-light .templates-new-list {
  background: #ffffff;
}

body.theme-light .templates-list-header {
  background: #f8fafc;
}

body.theme-light .templates-list-row:hover {
  background: #f8fafc;
}

@media (max-width: 768px) {
  .templates-new-grid {
    grid-template-columns: 1fr;
  }
  
  .templates-list-header {
    display: none;
  }
  
  .templates-list-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .templates-list-row-actions {
    justify-content: flex-start;
  }
}

/* Home Dashboard Styles */
.home-view {
  display: block;
}

.home-view.hidden {
  display: none;
}

.home-dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.home-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.home-header h2 {
  margin: 0;
  font-size: 1.75rem;
}

.home-filters {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.period-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.period-btn {
  padding: 8px 16px;
  font-size: 0.875rem;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.period-btn.active {
  background: var(--accent);
  color: var(--bg);
}

.custom-date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-date-range input[type="date"] {
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 0.875rem;
}

.home-period-label {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.875rem;
}

.stats-section {
  margin-bottom: 32px;
}

.stats-section h3 {
  margin: 0 0 16px;
  font-size: 1.25rem;
  color: var(--fg);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.stat-icon {
  font-size: 2rem;
  line-height: 1;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 4px;
}

.daily-chart {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 200px;
}

.chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
  color: var(--muted);
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  padding-bottom: 30px;
  position: relative;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 40px;
}

.chart-bar-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  height: 120px;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  max-width: 30px;
  border-radius: 4px 4px 0 0;
  transition: height 0.3s;
}

.chart-bar.sms-sent { background: var(--accent); }
.chart-bar.sms-received { background: rgba(117, 240, 199, 0.5); }
.chart-bar.email-sent { background: #6366f1; }
.chart-bar.email-received { background: rgba(99, 102, 241, 0.5); }

.chart-bar-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-color.sms-sent { background: var(--accent); }
.legend-color.sms-received { background: rgba(117, 240, 199, 0.5); }
.legend-color.email-sent { background: #6366f1; }
.legend-color.email-received { background: rgba(99, 102, 241, 0.5); }

/* Light theme overrides for home dashboard */
body.theme-light .stat-card,
body.theme-light .daily-chart {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.theme-light .custom-date-range input[type="date"] {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--border);
}

@media (max-width: 768px) {
  .home-header {
    flex-direction: column;
    align-items: stretch;
  }

  .home-filters {
    align-items: stretch;
  }

  .period-buttons {
    justify-content: center;
  }

  .custom-date-range {
    flex-wrap: wrap;
    justify-content: center;
  }

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

  .stat-card {
    padding: 16px;
  }

  .stat-icon {
    font-size: 1.5rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }
}
