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

:root {
  /* Sidebar */
  --sidebar-w:        212px;
  --sidebar-bg:       #1a1f35;
  --sidebar-border:   rgba(255,255,255,0.06);
  --sidebar-text:     #8b9ab5;
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --sidebar-active-bg:#3b82f6;
  --sidebar-active:   #ffffff;
  --logo-accent:      #3b82f6;

  /* Layout */
  --topbar-h:         60px;
  --main-bg:          #f1f5f9;
  --content-pad:      32px;

  /* Cards */
  --card-bg:          #ffffff;
  --card-border:      #e2e8f0;
  --card-radius:      14px;
  --card-shadow:      0 8px 24px rgba(15,23,42,0.05);

  /* Typography */
  --text-primary:     #1e293b;
  --text-secondary:   #64748b;
  --text-muted:       #94a3b8;

  /* Accents */
  --accent:           #3b82f6;
  --accent-dark:      #2563eb;
  --accent-green:     #10b981;
  --accent-red:       #ef4444;
  --accent-yellow:    #f59e0b;
  --accent-purple:    #8b5cf6;

  /* Forms */
  --input-bg:         #ffffff;
  --input-border:     #d1d5db;
  --input-focus:      #3b82f6;
  --input-radius:     6px;

  /* Font */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--main-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); }

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1f35 0%, #1e2d4a 100%);
  padding: 20px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 8px;
}


.login-subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 14px;
  line-height: 1.6;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--accent-red);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

.login-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 20px;
}

.auth-switch {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 16px;
}
.auth-switch a {
  color: var(--accent);
  text-decoration: none;
}
.auth-switch a:hover { text-decoration: underline; }

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

.automation-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 16px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: #fff;
}

.automation-event-list {
  display: grid;
  gap: 12px;
}

.automation-event-card,
.automation-rule-card {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px;
}

.automation-event-head,
.automation-rule-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.automation-event-kind {
  font-weight: 600;
  color: var(--text-primary);
}

.automation-event-summary {
  color: var(--text-primary);
  margin-bottom: 6px;
}

.automation-event-meta {
  color: var(--text-secondary);
  font-size: 12.5px;
}

.automation-status-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* ── App Shell ──────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
  position: relative;
  z-index: 100;
}

.sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 72px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo .logo-icon { width: 24px; height: 24px; color: var(--logo-accent); }
.sidebar-logo .brand-mark { width: 24px; height: 24px; object-fit: cover; border-radius: 7px; }
.sidebar-logo .logo-text { transition: opacity 0.15s; }
.sidebar.collapsed .logo-text { opacity: 0; width: 0; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 20px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s, transform 0.2s;
}

.sidebar-toggle:hover { color: #fff; background: var(--sidebar-hover-bg); }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
  scrollbar-width: none;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 0;
  transition: color 0.15s, background 0.15s;
  position: relative;
}

.nav-item:hover {
  color: #fff;
  background: var(--sidebar-hover-bg);
  text-decoration: none;
}

.nav-item.active {
  color: #fff;
  background: var(--sidebar-active-bg);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #fff;
  border-radius: 0 2px 2px 0;
}

.nav-icon, .download-icon {
  width: 18px;
  height: 18px;
  text-align: center;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg, .download-icon svg, .page-icon svg, .section-icon svg, .status-icon svg, .info-icon svg, .button-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-icon, .section-icon, .info-icon, .button-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-label { transition: opacity 0.15s; }
.sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 8px 16px;
}

.sidebar-footer {
  padding: 16px 18px 18px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-download-mac {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: rgba(99, 179, 255, 0.12);
  color: #63b3ff;
  border: 1px solid rgba(99, 179, 255, 0.25);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.btn-download-mac:hover {
  background: rgba(99, 179, 255, 0.22);
  border-color: rgba(99, 179, 255, 0.5);
  text-decoration: none;
}

.sidebar-version { color: var(--sidebar-text); font-size: 11px; }
.sidebar.collapsed .sidebar-footer { padding: 10px 8px; }
.sidebar.collapsed .btn-download-mac span { display: none; }
.sidebar.collapsed .btn-download-mac { justify-content: center; padding: 8px; }
.sidebar.collapsed .sidebar-version { display: none; }
.sidebar.collapsed .logout-btn { display: none; }

/* ── Top Bar ────────────────────────────────────────────────────────────────── */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 10;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle-mobile {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  padding: 4px;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 20px;
  background: var(--main-bg);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.user-name { font-size: 13px; font-weight: 500; }

/* ── Content Area ───────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--content-pad);
}

.page-loading {
  color: var(--text-muted);
  padding: 40px;
  text-align: center;
}

/* ── Page Header ────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 14px;
}

.page-header h2 {
  font-size: 23px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

.card-body { padding: 24px 26px; }

/* ── Stats Row ──────────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.stat-arrow {
  position: absolute;
  top: 16px;
  right: 16px;
  color: var(--text-muted);
  font-size: 16px;
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  width: 100%;
  text-align: center;
  padding: 12px 0 4px;
}

/* ── Filters Bar ────────────────────────────────────────────────────────────── */
.filters-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 18px 22px;
  margin-bottom: 22px;
}

.filters-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  line-height: 1.2;
  min-height: 14px;
}

.filter-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-input-row input {
  min-width: 0;
}

.filter-clear-btn {
  white-space: nowrap;
  height: 36px;
  padding: 0 10px;
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  background: var(--input-bg);
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 7px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
  cursor: pointer;
}

.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-danger {
  background: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
}
.btn-danger:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; }

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--card-border);
}
.btn-outline:hover:not(:disabled) { background: var(--main-bg); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-full { width: 100%; justify-content: center; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  padding: 0;
  font-family: var(--font);
}
.btn-link:hover { text-decoration: underline; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #16a34a; }
.badge-danger   { background: #fee2e2; color: #dc2626; }
.badge-warning  { background: #fef3c7; color: #d97706; }
.badge-info     { background: #dbeafe; color: #1d4ed8; }
.badge-default  { background: #f1f5f9; color: var(--text-secondary); }
.badge-purple   { background: #ede9fe; color: #7c3aed; }

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.table-scroll { overflow-x: auto; }

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

thead {
  background: #f8fafc;
  border-bottom: 2px solid var(--card-border);
}

thead th {
  padding: 13px 18px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--card-border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

td {
  padding: 14px 18px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-muted { color: var(--text-secondary); font-size: 12.5px; }

/* ── Progress Bar ───────────────────────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 100px;
}

.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-fill.green  { background: var(--accent-green); }
.progress-fill.yellow { background: var(--accent-yellow); }
.progress-fill.red    { background: var(--accent-red); }
.progress-label { font-size: 11.5px; color: var(--text-secondary); }

/* ── Toggle Switch ──────────────────────────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-label { font-size: 13.5px; color: var(--text-primary); }

.toggle {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle input:checked + .toggle-track { background: var(--accent); }

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--card-border);
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination-pages { display: flex; align-items: center; gap: 4px; }

.pg-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.pg-btn:hover:not(:disabled) { background: var(--main-bg); color: var(--text-primary); }
.pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pg-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Empty State ────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 10px;
}

.empty-state .empty-icon { font-size: 36px; }
.empty-state p { font-size: 14px; }

/* ── Conversations ─────────────────────────────────────────────────────────── */
.conversations-shell { min-height: 560px; }
.conversations-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
}
.conversation-list,
.conversation-thread {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}
.conversation-list {
  padding: 10px;
  max-height: 72vh;
  overflow: auto;
}
.conversation-row {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 6px;
}
.conversation-row:hover { background: #eef4ff; }
.conversation-row.active { background: #dbeafe; }
.conversation-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.conversation-phone { font-weight: 600; color: var(--text-primary); }
.conversation-time { font-size: 12px; color: var(--text-muted); }
.conversation-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation-thread {
  display: flex;
  flex-direction: column;
  min-height: 72vh;
}
.conversation-thread-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--card-border);
}
.conversation-thread-title { font-size: 16px; font-weight: 700; }
.conversation-thread-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.conversation-thread-body {
  padding: 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message-row {
  display: flex;
}
.message-row.inbound { justify-content: flex-start; }
.message-row.outbound { justify-content: flex-end; }
.message-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: min(72%, 640px);
}
.message-bubble {
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.message-bubble.inbound {
  background: #e5e7eb;
  color: #111827;
  border-bottom-left-radius: 8px;
}
.message-bubble.outbound {
  background: #3b82f6;
  color: white;
  border-bottom-right-radius: 8px;
}
.message-bubble.failed {
  border: 1px solid #fca5a5;
  box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.15);
}
.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
.message-meta.outbound { justify-content: flex-end; }
.message-meta.inbound { justify-content: flex-start; }
.message-failed-icon {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent-red);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.message-failed-label { color: var(--accent-red); font-weight: 600; }

@media (max-width: 1100px) {
  .conversations-layout { grid-template-columns: 1fr; }
  .conversation-list { max-height: 280px; }
  .conversation-thread { min-height: 52vh; }
  .message-bubble-wrap { max-width: 88%; }
}

.section-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
}

.form-label-lite {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.setup-value {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--surface-2, #f8fafc);
  color: var(--text-primary);
}

.toggle-row-wide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.ghl-refresh-btn {
  min-width: 142px;
  justify-content: center;
}

/* ── Section Heading ────────────────────────────────────────────────────────── */
.section-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--card-border);
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  margin-top: -10px;
}

/* ── Info Banner ────────────────────────────────────────────────────────────── */

.page-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.page-header-copy {
  max-width: 720px;
}

.page-description {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

.info-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 14px 16px;
  color: #1d4ed8;
  font-size: 13.5px;
  margin-bottom: 22px;
}

.overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.overview-title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overview-eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.overview-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 0;
  color: var(--text-primary);
}

.overview-subtitle {
  color: var(--text-secondary);
  font-size: 13.5px;
}

.device-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 0;
  border-top: 1px solid var(--card-border);
}

.device-row:first-child {
  border-top: none;
  padding-top: 0;
}

.device-meta-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}

.device-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.device-meta { font-size: 12.5px; color: var(--text-secondary); margin-top: 0; }

.device-status-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.status-card .status-icon, .about-logo {
  width: 28px;
  height: 28px;
  margin: 0 auto 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.about-logo {
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
}

.status-card .status-icon svg, .about-logo svg {
  width: 100%;
  height: 100%;
}

.field-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.table-action-note {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Connection Card ────────────────────────────────────────────────────────── */
.connection-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.connection-info { display: flex; align-items: center; gap: 14px; }
.connection-avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-purple) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
}

.connection-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.connection-sub  { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.connection-actions { display: flex; gap: 8px; }

/* ── Settings Sections ──────────────────────────────────────────────────────── */
.settings-section {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 26px;
  margin-bottom: 22px;
}

.settings-section h3 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--card-border);
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
}

.settings-row.full { grid-template-columns: 1fr; }

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

.setting-item:last-child { border-bottom: none; }
.setting-item-info { flex: 1; }
.setting-item-label { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }
.setting-item-desc  { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ── Secret Input ───────────────────────────────────────────────────────────── */
.secret-field {
  display: flex;
  gap: 8px;
  align-items: center;
}

.secret-field input { font-family: 'Courier New', monospace; letter-spacing: 0.08em; }

/* ── About Page ─────────────────────────────────────────────────────────────── */
.about-hero {
  text-align: center;
  padding: 40px 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 24px;
}

.about-logo { font-size: 48px; margin-bottom: 12px; }
.about-name { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.about-name strong { color: var(--accent); }
.about-version { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.about-tagline {
  margin-top: 14px;
  font-size: 15px;
  color: var(--text-secondary);
  font-style: italic;
}

.about-tagline strong { color: var(--accent-green); font-style: normal; }

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

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

.status-card .status-icon { font-size: 28px; margin-bottom: 8px; }
.status-card .status-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.status-card .status-value { font-size: 14px; font-weight: 700; margin-top: 4px; }

/* ── Platform Overview ───────────────────────────────────────────────────────── */
.overview-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 24px 26px;
}

.overview-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.device-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.device-name { font-size: 14px; font-weight: 600; color: var(--accent); }
.device-meta { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }

/* ── Location Table helpers ──────────────────────────────────────────────────── */
.iphone-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

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

.toast {
  background: var(--text-primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: toast-in 0.25s ease;
  max-width: 320px;
}

.toast.success { background: #16a34a; }
.toast.error   { background: #dc2626; }
.toast.info    { background: var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.modal {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.copy-field {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.copy-field input {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: var(--main-bg);
}

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.mt-4    { margin-top: 16px; }
.mt-6    { margin-top: 24px; }
.mb-4    { margin-bottom: 16px; }
.flex    { display: flex; }
.gap-2   { gap: 8px; }
.items-center { align-items: center; }
.text-sm { font-size: 12.5px; }
.text-muted { color: var(--text-muted); }
.font-mono { font-family: 'Courier New', monospace; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 200; transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-toggle { display: none; }
  .sidebar-toggle-mobile { display: flex; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .settings-row { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .status-grid { grid-template-columns: 1fr; }
}
