/* ══════════════════════════════════════════════════
   LumenaPhone — Portal CSS
   ══════════════════════════════════════════════════ */

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

:root {
  /* Every size in this file is in rem, so this one value scales the whole
     interface. ui-scale.js writes it; the fallback keeps the page correct if
     that script is blocked. */
  --ui-scale: 1;
  --ui-base: 16px;

  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --accent-light: #e0e7ff;
  --purple: #8b5cf6;
  --bg: #0f0f13;
  --surface: #18181f;
  --surface2: #1e1e28;
  --surface3: #252533;
  --border: #2a2a3a;
  --text: #f1f1f5;
  --text-muted: #7b7b9a;
  --text-dim: #4a4a6a;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --sidebar-w: 220px;
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: calc(var(--ui-base) * var(--ui-scale));
  line-height: 1.5;
  overflow: hidden;
}

/* ════════════════════════════════════════
   AUTH SCREEN
════════════════════════════════════════ */

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.12) 0%, transparent 60%),
              var(--bg);
  overflow-y: auto;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
  justify-content: center;
}

.auth-logo svg { width: 36px; height: 36px; }

.auth-logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

.auth-logo-text .accent { color: var(--accent); }

.auth-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 0.3rem;
  text-align: center;
}

.auth-sub {
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

.auth-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

/* ── Field groups ── */
.field-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.field-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.field-group label .optional {
  font-weight: 400;
  color: var(--text-dim);
}

.field-group input,
.field-group select,
.field-group textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.875rem;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
}

.field-group input::placeholder,
.field-group textarea::placeholder { color: var(--text-dim); }

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.field-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%237b7b9a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ── Auth button ── */
.btn-auth {
  width: 100%;
  padding: 0.8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.btn-auth:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
}

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

/* ── Auth links ── */
.auth-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.auth-divider { color: var(--text-dim); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  font-family: 'Inter', sans-serif;
  transition: color 0.2s;
}

.link-btn:hover { color: #818cf8; }
.link-btn.small { font-size: 0.8rem; }

.auth-terms {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 1.25rem;
  line-height: 1.6;
}

.auth-terms a { color: var(--text-muted); }
.auth-terms a:hover { color: var(--text); }

/* ── Radio group ── */
.radio-group {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.15rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
}

.radio-label input[type="radio"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ════════════════════════════════════════
   PORTAL APP LAYOUT
════════════════════════════════════════ */

#portal-app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-top {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.sidebar-logo svg { width: 28px; height: 28px; flex-shrink: 0; }
.sidebar-logo .accent { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.575rem 0.75rem;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
  position: relative;
}

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

.nav-item.active {
  background: rgba(99,102,241,0.15);
  color: var(--accent-light);
  font-weight: 600;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 100px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
  min-width: 0;
}

.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.account-info { min-width: 0; }

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

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

.logout-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.logout-btn:hover {
  color: var(--red);
  background: rgba(239,68,68,0.1);
}

/* ── MAIN CONTENT ── */
#portal-main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  position: relative;
}

.portal-section {
  display: none;
  padding: 2rem 2.25rem;
  min-height: 100%;
  animation: sectionFade 0.2s ease;
}

.portal-section.active { display: block; }

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

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
}

.section-header .header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-sub {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 0.2rem;
}

.section-subheader {
  margin: 2rem 0 1rem;
}

.section-subheader h2 {
  font-size: 1rem;
  font-weight: 700;
}

/* ════════════════════════════════════════
   BUTTONS
════════════════════════════════════════ */

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  border: none;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(99,102,241,0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.25);
}

.btn-danger:hover {
  background: rgba(239,68,68,0.22);
  border-color: rgba(239,68,68,0.5);
}

.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--surface3);
  color: var(--text);
}

.select-sm {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%237b7b9a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  transition: border-color 0.15s;
}

.select-sm:focus { border-color: var(--accent); }

/* ════════════════════════════════════════
   DASHBOARD STAT CARDS
════════════════════════════════════════ */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color 0.2s;
}

.stat-card:hover { border-color: rgba(99,102,241,0.3); }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon-indigo {
  background: rgba(99,102,241,0.15);
  color: var(--accent);
}

.stat-icon-purple {
  background: rgba(139,92,246,0.15);
  color: var(--purple);
}

.stat-icon-green {
  background: rgba(34,197,94,0.12);
  color: var(--green);
}

.stat-icon-amber {
  background: rgba(245,158,11,0.12);
  color: var(--amber);
}

.stat-body {}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Dashboard grid ── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.dash-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

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

.panel-header h3 {
  font-size: 0.9rem;
  font-weight: 700;
}

/* ════════════════════════════════════════
   NUMBERS SECTION
════════════════════════════════════════ */

.number-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
  transition: border-color 0.2s;
  cursor: default;
}

.number-card:hover { border-color: rgba(99,102,241,0.3); }

.number-card-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.number-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(99,102,241,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.number-icon svg { width: 18px; height: 18px; }

.number-display {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.number-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.number-card-actions {
  display: flex;
  gap: 0.5rem;
}

/* Search result items */
.number-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.number-result-num {
  font-size: 0.9rem;
  font-weight: 600;
  font-family: monospace;
}

.number-result-loc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ── Dial pad ── */
.dialpad-section { margin-top: 1.5rem; }

.dialpad-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dialpad-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
}

.dialpad-display input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.875rem;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  outline: none;
  font-family: 'Inter', sans-serif;
}

.dialpad-clear {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.15s;
}

.dialpad-clear:hover {
  background: var(--surface2);
  color: var(--text);
}

.dialpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.875rem;
}

.dialpad-key {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  transition: all 0.1s;
  user-select: none;
}

.dialpad-key span {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.dialpad-key:hover {
  background: var(--surface3);
  border-color: var(--accent);
}

.dialpad-key:active { transform: scale(0.95); }

.dialpad-call-btn {
  width: 100%;
  padding: 0.8rem;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.dialpad-call-btn:hover {
  background: #16a34a;
  box-shadow: 0 4px 16px rgba(34,197,94,0.35);
}

/* ════════════════════════════════════════
   MESSAGES SECTION
════════════════════════════════════════ */

.messages-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  height: calc(100vh - 180px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.thread-list {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.thread-search {
  padding: 0.875rem;
  border-bottom: 1px solid var(--border);
}

.thread-search input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}

.thread-search input:focus { border-color: var(--accent); }
.thread-search input::placeholder { color: var(--text-dim); }

#thread-list-items {
  flex: 1;
  overflow-y: auto;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  position: relative;
}

.thread-item:hover { background: var(--surface2); }
.thread-item.active { background: rgba(99,102,241,0.1); }

.thread-item-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface3);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

.thread-item-avatar.unread {
  background: rgba(99,102,241,0.2);
  color: var(--accent);
}

.thread-item-body { flex: 1; min-width: 0; }

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

.thread-item-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.thread-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  flex-shrink: 0;
}

.thread-item-time {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.thread-unread-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

/* ── Thread view ── */
.thread-view {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.thread-view-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.thread-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  flex-shrink: 0;
}

.thread-contact {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.thread-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.thread-contact-name {
  font-size: 0.9rem;
  font-weight: 700;
}

.thread-contact-number {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.thread-actions { display: flex; gap: 0.5rem; }

/* ── Message bubbles ── */
.message-bubbles {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.message-bubble {
  max-width: 72%;
  display: flex;
  flex-direction: column;
}

.message-bubble.outbound { align-self: flex-end; align-items: flex-end; }
.message-bubble.inbound  { align-self: flex-start; align-items: flex-start; }

.bubble-text {
  padding: 0.6rem 0.875rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-wrap: break-word;
}

.message-bubble.outbound .bubble-text {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-bubble.inbound .bubble-text {
  background: var(--surface3);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.bubble-time {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  padding: 0 0.25rem;
}

/* ── Composer ── */
.message-composer {
  border-top: 1px solid var(--border);
  padding: 0.875rem 1rem;
  background: var(--surface);
  flex-shrink: 0;
}

.composer-number-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.composer-number-select select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%237b7b9a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
}

.composer-input-row {
  display: flex;
  gap: 0.625rem;
  align-items: flex-end;
}

.composer-input-row textarea {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.875rem;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.composer-input-row textarea:focus { border-color: var(--accent); }
.composer-input-row textarea::placeholder { color: var(--text-dim); }

.send-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  transition: all 0.15s;
}

.send-btn:hover {
  background: var(--accent-dark);
  transform: scale(1.05);
}

.composer-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
}

/* ════════════════════════════════════════
   CALL LOG TABLE
════════════════════════════════════════ */

.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  overflow-x: auto;
}

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

.data-table thead {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 0.75rem 1.25rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.data-table td {
  padding: 0.875rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(42,42,58,0.5);
  white-space: nowrap;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover td {
  background: rgba(30,30,40,0.5);
  color: var(--text);
}

.data-table td.number-cell {
  color: var(--text);
  font-weight: 500;
  font-family: monospace;
  font-size: 0.88rem;
}

/* Direction badges */
.dir-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
}

.dir-badge.inbound {
  background: rgba(34,197,94,0.12);
  color: #86efac;
}

.dir-badge.outbound {
  background: rgba(99,102,241,0.12);
  color: #a5b4fc;
}

.dir-badge.missed {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
}

.status-badge.active {
  background: rgba(34,197,94,0.12);
  color: #86efac;
}

.status-badge.cancelled {
  background: rgba(239,68,68,0.1);
  color: #fca5a5;
}

.status-badge.pending {
  background: rgba(245,158,11,0.1);
  color: #fcd34d;
}

.status-badge.trialing {
  background: rgba(99,102,241,0.12);
  color: #a5b4fc;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

#calls-page-info {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ════════════════════════════════════════
   BILLING SECTION
════════════════════════════════════════ */

.billing-plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 2rem;
}

.plan-name {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.plan-price {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.plan-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.plan-renewal {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.plan-limits {
  display: flex;
  gap: 2rem;
}

.plan-limit-item { text-align: right; }

.plan-limit-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.plan-limit-value {
  font-size: 1rem;
  font-weight: 700;
}

.billing-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

/* ── Plan options in modal ── */
.plan-options { display: flex; flex-direction: column; gap: 0.75rem; }

.plan-option {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.plan-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(99,102,241,0.08);
}

.plan-option input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

.plan-option-name {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.plan-option-price {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.plan-option-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Invoice table */
#invoices-table { margin-top: 0; }

/* ════════════════════════════════════════
   SETTINGS SECTION
════════════════════════════════════════ */

.settings-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.settings-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border);
}

.settings-group {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.settings-group h4 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.875rem;
}

.form-msg {
  padding: 0.5rem 0.75rem;
  border-radius: 7px;
  font-size: 0.82rem;
  margin-bottom: 0.875rem;
}

.form-msg.success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  color: #86efac;
}

.form-msg.error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
}

/* ── Toggle switch ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(42,42,58,0.5);
}

.toggle-row:last-of-type { border-bottom: none; }

.toggle-label {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.1rem;
}

.toggle-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

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

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface3);
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-track::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

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

.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(18px);
  background: #fff;
}

/* ════════════════════════════════════════
   SIDE PANELS
════════════════════════════════════════ */

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,0.4);
  animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.side-panel-header h3 { font-size: 1rem; font-weight: 700; }

.close-panel {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}

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

.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ════════════════════════════════════════
   MODALS
════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeOverlay 0.15s ease;
}

@keyframes fadeOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  animation: scaleIn 0.2s ease;
}

.modal-card-sm { max-width: 380px; }

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

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

.modal-header h3 { font-size: 1rem; font-weight: 700; }

.close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}

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

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ════════════════════════════════════════
   ACTIVE CALL BAR
════════════════════════════════════════ */

#active-call-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  background: var(--surface2);
  border-top: 2px solid var(--green);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 400;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.call-bar-info {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.call-bar-status {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--green);
}

.call-bar-contact {
  font-size: 0.95rem;
  font-weight: 700;
}

.call-bar-duration {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
}

.call-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.call-bar-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.mute-btn {
  background: var(--surface3);
  color: var(--text-muted);
}

.mute-btn:hover { background: var(--border); color: var(--text); }
.mute-btn.active { background: var(--amber); color: #fff; }

.hold-btn {
  background: var(--surface3);
  color: var(--text-muted);
}

.hold-btn:hover { background: var(--border); color: var(--text); }
.hold-btn.active { background: var(--accent); color: #fff; }

.hangup-btn {
  background: var(--red);
  color: #fff;
}

.hangup-btn:hover { background: #dc2626; transform: scale(1.05); }

/* ════════════════════════════════════════
   INCOMING CALL MODAL
════════════════════════════════════════ */

#incoming-call-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.incoming-call-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7);
  animation: scaleIn 0.2s ease;
  min-width: 300px;
}

.incoming-pulse {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
}

.incoming-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(34,197,94,0.2);
  animation: ringPulse 1.5s ease-out infinite;
}

.incoming-ring.ring2 {
  animation-delay: 0.6s;
}

@keyframes ringPulse {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2); opacity: 0; }
}

.incoming-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  border-radius: 50%;
  z-index: 1;
}

.incoming-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green);
  margin-bottom: 0.4rem;
}

.incoming-number {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.incoming-to {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.incoming-actions {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
}

.incoming-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.incoming-btn.decline {
  background: var(--red);
  transform: rotate(135deg);
}

.incoming-btn.decline:hover { background: #dc2626; transform: rotate(135deg) scale(1.08); }

.incoming-btn.answer {
  background: var(--green);
}

.incoming-btn.answer:hover { background: #16a34a; transform: scale(1.08); }

.incoming-labels-row {
  display: flex;
  justify-content: center;
  gap: 4.5rem;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ════════════════════════════════════════
   EMPTY STATES
════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2.5rem 1rem;
  color: var(--text-dim);
  font-size: 0.88rem;
  text-align: center;
}

.empty-state svg { opacity: 0.35; }
.empty-state p { max-width: 220px; line-height: 1.5; }
.empty-state.large { padding: 4rem 1rem; }

/* ════════════════════════════════════════
   TOAST NOTIFICATIONS
════════════════════════════════════════ */

#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease;
  pointer-events: auto;
  max-width: 320px;
}

.toast.success { border-left: 3px solid var(--green); color: #86efac; }
.toast.error   { border-left: 3px solid var(--red); color: #fca5a5; }
.toast.info    { border-left: 3px solid var(--accent); color: #a5b4fc; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

/* ════════════════════════════════════════
   SCROLLBAR STYLES
════════════════════════════════════════ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */

/* was @media (max-width: 1100px) — now font-size aware */
html[data-lp-w~="le1100"] .stat-cards { grid-template-columns: repeat(2, 1fr); }
html[data-lp-w~="le1100"] .settings-layout { grid-template-columns: 1fr; }
html[data-lp-w~="le1100"] .dash-grid { grid-template-columns: 1fr; }


/* was @media (max-width: 820px) — now font-size aware */
html[data-lp-w~="le820"] { --sidebar-w: 60px; }
html[data-lp-w~="le820"] .sidebar-logo span:not(.accent) { display: none; }
html[data-lp-w~="le820"] .sidebar-logo .accent { display: none; }
html[data-lp-w~="le820"] .nav-item span:not(.nav-icon):not(.nav-badge) { display: none; }
html[data-lp-w~="le820"] .nav-item { justify-content: center; padding: 0.65rem; }
html[data-lp-w~="le820"] .nav-icon { width: 20px; height: 20px; margin: 0; }
html[data-lp-w~="le820"] .account-info { display: none; }
html[data-lp-w~="le820"] .sidebar-account { justify-content: center; }
html[data-lp-w~="le820"] .messages-layout { grid-template-columns: 220px 1fr; }
html[data-lp-w~="le820"] #active-call-bar { left: var(--sidebar-w); }


/* was @media (max-width: 640px) — now font-size aware */
html[data-lp-w~="le640"] .messages-layout { grid-template-columns: 1fr; }
html[data-lp-w~="le640"] .thread-list { display: none; }
html[data-lp-w~="le640"] .thread-list.show-on-mobile { display: flex; }
html[data-lp-w~="le640"] .field-row { grid-template-columns: 1fr; }
html[data-lp-w~="le640"] .billing-plan-card { flex-direction: column; }
html[data-lp-w~="le640"] .plan-limits { justify-content: flex-start; }

