/* ─────────────────────────────────────────────────────────────────────────
   TLX SMS Framework Dashboard — Design System
   Dark glassmorphism · Purple/Cyan/Green accent palette · Inter typeface
   ───────────────────────────────────────────────────────────────────────── */

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

:root {
  /* Palette */
  --bg-base:       #080c1a;
  --bg-surface:    #0d1228;
  --bg-elevated:   #111835;
  --bg-hover:      #171f40;

  --accent-purple: #7c3aed;
  --accent-blue:   #2563eb;
  --accent-cyan:   #06b6d4;
  --accent-green:  #10b981;
  --accent-red:    #ef4444;
  --accent-yellow: #f59e0b;

  --text-primary:   #f0f4ff;
  --text-secondary: #8892b0;
  --text-muted:     #4a5270;
  --text-code:      #10f5c8;

  --border:        rgba(255,255,255,0.06);
  --border-active: rgba(124,58,237,0.5);

  --glass-bg:      rgba(13,18,40,0.75);
  --glass-border:  rgba(255,255,255,0.07);
  --glass-blur:    blur(16px);

  --sidebar-w:     240px;
  --topbar-h:      60px;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --shadow-sm:   0 2px 8px rgba(0,0,0,.4);
  --shadow-md:   0 8px 24px rgba(0,0,0,.5);
  --shadow-glow: 0 0 20px rgba(124,58,237,.25);

  --transition: 0.18s cubic-bezier(.4,0,.2,1);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 60% 50% at 10% 0%, rgba(124,58,237,.18) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 90% 100%, rgba(37,99,235,.12) 0%, transparent 60%);
}

.hidden { display: none !important; }

/* ── Glass utility ───────────────────────────────────────────────────────── */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.login-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: float 8s ease-in-out infinite;
}
.orb-1 { width: 600px; height: 600px; background: rgba(124,58,237,.25); top: -200px; left: -200px; }
.orb-2 { width: 500px; height: 500px; background: rgba(6,182,212,.15); bottom: -150px; right: -150px; animation-delay: -3s; }
.orb-3 { width: 400px; height: 400px; background: rgba(37,99,235,.2); top: 40%; left: 40%; animation-delay: -5s; }

@keyframes float {
  0%, 100% { transform: translate(0,0) scale(1); }
  33%       { transform: translate(20px,-30px) scale(1.05); }
  66%       { transform: translate(-15px,20px) scale(.97); }
}

.login-card {
  position: relative; z-index: 1;
  width: 420px;
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-md), var(--shadow-glow);
  animation: slideUp .5s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo { display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem; }
.logo-icon svg { width: 48px; height: 48px; }
.login-title { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.login-subtitle { font-size: .8rem; color: var(--text-secondary); margin-top: 2px; }

.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-error {
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.4);
  border-radius: var(--radius-sm);
  padding: .65rem 1rem;
  font-size: .85rem;
  color: #fca5a5;
}
.login-hint { margin-top: 1.5rem; font-size: .75rem; color: var(--text-muted); line-height: 1.5; }
.login-hint code { font-family: 'JetBrains Mono', monospace; color: var(--text-code); background: rgba(16,245,200,.1); padding: 1px 5px; border-radius: 4px; }

/* ── App shell ────────────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.page { display: block; }
.page.hidden { display: none !important; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

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

.sidebar-logo { display: flex; align-items: center; gap: .65rem; }
.sidebar-logo-icon svg { width: 30px; height: 30px; }
.sidebar-logo-text { font-size: 1rem; font-weight: 700; letter-spacing: -.02em; }

.sidebar-toggle { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: .3rem; border-radius: var(--radius-sm); transition: color var(--transition); }
.sidebar-toggle:hover { color: var(--text-primary); }

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 1rem 1rem .25rem;
}

.sidebar-nav { list-style: none; padding: 0 .5rem; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active {
  background: linear-gradient(135deg, rgba(124,58,237,.3), rgba(37,99,235,.2));
  color: var(--text-primary);
  border: 1px solid var(--border-active);
}
.nav-link.active::before {
  content: '';
  position: absolute; left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: linear-gradient(to bottom, var(--accent-purple), var(--accent-blue));
  border-radius: 3px;
}

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

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
}
.user-chip { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: .8rem; font-weight: 600; truncate: clip; }
.user-role { font-size: .65rem; color: var(--accent-cyan); text-transform: uppercase; letter-spacing: .05em; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(8,12,26,.7);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: .75rem; }
.page-title { font-size: 1.1rem; font-weight: 600; }
.db-badge {
  font-size: .65rem; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; text-transform: uppercase; letter-spacing: .06em;
}
.db-badge.sqlite     { background: rgba(16,185,129,.15); color: #10b981; border: 1px solid rgba(16,185,129,.3); }
.db-badge.postgresql { background: rgba(37,99,235,.15);  color: #60a5fa; border: 1px solid rgba(37,99,235,.3); }
.db-badge.mysql      { background: rgba(245,158,11,.15); color: #fbbf24; border: 1px solid rgba(245,158,11,.3); }

.topbar-right { display: flex; align-items: center; gap: .75rem; }
.topbar-time { font-size: .75rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

/* ── Page content ─────────────────────────────────────────────────────────── */
.page-content {
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.page-content.active { display: flex; }
.page-content.hidden  { display: none; }

/* ── Stat grid ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card {
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex; align-items: flex-start; gap: 1rem;
  position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md), var(--shadow-glow); }
.stat-card::after {
  content: '';
  position: absolute; top: -40%; right: -20%;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--glow-color, rgba(124,58,237,.15));
  filter: blur(30px);
  pointer-events: none;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.purple { background: rgba(124,58,237,.2); color: #a78bfa; }
.stat-icon.green  { background: rgba(16,185,129,.2); color: #34d399; }
.stat-icon.red    { background: rgba(239,68,68,.2);  color: #f87171; }
.stat-icon.cyan   { background: rgba(6,182,212,.2);  color: #22d3ee; }
.stat-icon.yellow { background: rgba(245,158,11,.2); color: #fbbf24; }
.stat-icon.blue   { background: rgba(37,99,235,.2);  color: #60a5fa; }

.stat-body { flex: 1; }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }
.stat-label { font-size: .75rem; color: var(--text-secondary); margin-top: 2px; }
.stat-sub   { font-size: .7rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Charts ───────────────────────────────────────────────────────────────── */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
}
.chart-card {
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.chart-card-sm { }
.chart-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.chart-header h3 { font-size: .9rem; font-weight: 600; }
.chart-legend { display: flex; align-items: center; gap: .75rem; font-size: .75rem; color: var(--text-secondary); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-dot.purple { background: var(--accent-purple); }
.legend-dot.cyan   { background: var(--accent-cyan); }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-card { border-radius: var(--radius-lg); padding: 1.25rem; }
.table-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.table-header h3 { font-size: .9rem; font-weight: 600; }
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}
.data-table th {
  padding: .6rem .75rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: .7rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-hover); color: var(--text-primary); }
.empty-row { text-align: center; color: var(--text-muted); padding: 2rem !important; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px; font-size: .68rem; font-weight: 600;
}
.status-badge::before { content: '●'; font-size: .55rem; }
.status-delivered     { background: rgba(16,185,129,.15); color: #34d399; }
.status-delivery_failed { background: rgba(239,68,68,.15); color: #f87171; }
.status-sent          { background: rgba(37,99,235,.15);   color: #60a5fa; }
.status-queued        { background: rgba(124,58,237,.15);  color: #a78bfa; }
.status-sending       { background: rgba(245,158,11,.15);  color: #fbbf24; }
.status-received      { background: rgba(6,182,212,.15);   color: #22d3ee; }

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panel { border-radius: var(--radius-lg); padding: 1.25rem; }
.panel-title { font-size: .9rem; font-weight: 600; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.two-col { display: grid; grid-template-columns: 380px 1fr; gap: 1.25rem; align-items: start; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: .4rem; }
.field-label { font-size: .78rem; font-weight: 500; color: var(--text-secondary); }
.field-hint  { font-size: .72rem; color: var(--text-muted); }
.char-count  { font-size: .7rem; color: var(--text-muted); text-align: right; }
.filter-row  { display: flex; align-items: center; gap: .75rem; }

.field-wrap { position: relative; }
.field-icon {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.field-icon svg { width: 15px; height: 15px; }
.field-wrap .field-input { padding-left: 2.5rem; }

.field-input {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .6rem .85rem;
  color: var(--text-primary);
  font-size: .875rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.field-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(124,58,237,.2);
}
.field-input::placeholder { color: var(--text-muted); }
.field-textarea { resize: vertical; min-height: 80px; }
.field-select { cursor: pointer; }
option { background: var(--bg-elevated); }

.toggle-label { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--text-secondary); cursor: pointer; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-md);
  border: none; cursor: pointer;
  font-size: .875rem; font-weight: 500; font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color: #fff;
  box-shadow: 0 4px 12px rgba(124,58,237,.3);
}
.btn-primary:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn-ghost {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(239,68,68,.2); border: 1px solid rgba(239,68,68,.3); color: #f87171; }
.btn-danger:hover { background: rgba(239,68,68,.35); }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: .35rem; border-radius: var(--radius-sm);
  transition: color var(--transition);
  display: flex; align-items: center;
}
.btn-icon:hover { color: var(--text-primary); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Campaigns grid ──────────────────────────────────────────────────────── */
.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.campaign-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  background: var(--bg-elevated);
  padding: 1.25rem;
  transition: transform var(--transition);
}
.campaign-card:hover { transform: translateY(-2px); }
.campaign-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.campaign-id { font-family: 'JetBrains Mono', monospace; font-size: .75rem; color: var(--text-code); }
.campaign-status { padding: 2px 8px; border-radius: 99px; font-size: .68rem; font-weight: 600; }
.campaign-status.ACTIVE    { background: rgba(16,185,129,.15); color: #34d399; }
.campaign-status.SUSPENDED { background: rgba(239,68,68,.15);  color: #f87171; }
.campaign-status.INACTIVE  { background: rgba(255,255,255,.05); color: var(--text-muted); }
.campaign-usecase { font-size: .8rem; font-weight: 600; margin-bottom: .25rem; }
.campaign-desc  { font-size: .75rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 1rem; }
.campaign-numbers { display: flex; flex-wrap: wrap; gap: .35rem; }
.number-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: .68rem;
  padding: 2px 6px;
  background: rgba(6,182,212,.1);
  color: var(--accent-cyan);
  border-radius: 4px;
  border: 1px solid rgba(6,182,212,.2);
}

/* ── Send result ─────────────────────────────────────────────────────────── */
.send-result {
  margin-top: 1rem;
  border-radius: var(--radius-md);
  padding: .75rem 1rem;
  font-size: .8rem;
  line-height: 1.6;
}
.send-result.ok  { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.send-result.err { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: .4rem; padding: .75rem 0 0; }
.page-btn {
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: var(--radius-sm);
  padding: .3rem .6rem; font-size: .75rem; cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-btn.active { background: var(--accent-purple); color: #fff; border-color: var(--accent-purple); }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%; max-width: 460px;
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  animation: slideUp .2s ease;
  display: flex; flex-direction: column; gap: 1rem;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; margin-top: .5rem; }

.key-reveal { border-radius: var(--radius-md); background: rgba(16,245,200,.06); border: 1px solid rgba(16,245,200,.2); padding: 1rem; }
.key-reveal-warning { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: #fbbf24; margin-bottom: .75rem; }
.key-reveal-warning svg { width: 15px; height: 15px; }
.key-box { display: flex; align-items: center; gap: .5rem; }
.key-box code {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  color: var(--text-code);
  background: rgba(0,0,0,.3);
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  word-break: break-all;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 300;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .75rem 1rem;
  font-size: .8rem;
  display: flex; align-items: center; gap: .5rem;
  box-shadow: var(--shadow-md);
  animation: slideLeft .2s ease;
  min-width: 260px;
}
@keyframes slideLeft { from { opacity: 0; transform: translateX(20px); } }
.toast svg { width: 15px; height: 15px; flex-shrink: 0; }
.toast.ok   { border-color: rgba(16,185,129,.4); color: #6ee7b7; }
.toast.err  { border-color: rgba(239,68,68,.4);  color: #fca5a5; }
.toast.info { border-color: rgba(37,99,235,.4);  color: #93c5fd; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .chart-row   { grid-template-columns: 1fr; }
  .two-col     { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .login-card { margin: 1rem; width: auto; }
}

/* ── Message Log ────────────────────────────────────────────────────────────── */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem;
}
.msg-body {
  max-width: 280px;
  max-height: 3.6em;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .8rem;
  line-height: 1.4;
  color: var(--text-secondary);
}
.num-cell  { font-family: 'JetBrains Mono', monospace; font-size: .78rem; white-space: nowrap; }
.date-cell { font-size: .78rem; white-space: nowrap; color: var(--text-muted); }
.cost-cell { font-size: .78rem; white-space: nowrap; font-family: 'JetBrains Mono', monospace; }
.dim-cell  { font-size: .78rem; color: var(--text-muted); }
.body-cell { max-width: 300px; }

/* MMS media thumbnails */
.media-thumbs {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
  margin-top: .25rem;
}
.media-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .15s;
}
.media-thumb:hover { transform: scale(1.1); }
.more-media {
  font-size: .7rem;
  color: var(--text-muted);
  align-self: center;
  padding: 0 .2rem;
}

/* Message detail modal */
.modal-wide { max-width: 680px !important; width: 95vw; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; }
.detail-grid .field-group { margin-bottom: 0; }
.msg-detail-text {
  background: rgba(0,0,0,.25);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .85rem;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.media-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .25rem;
}
.media-thumb-lg {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .15s;
}
.media-thumb-lg:hover { transform: scale(1.05); }

/* pagination reuse */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 0 0;
}

/* ── Settings page ───────────────────────────────────────────────────────── */
.settings-card {
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
}
.settings-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue));
  opacity: .6;
}

.settings-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.settings-card-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.settings-card-icon svg { width: 22px; height: 22px; }
.telnyx-icon {
  background: linear-gradient(135deg, rgba(16,185,129,.25), rgba(6,182,212,.2));
  color: #34d399;
  border: 1px solid rgba(16,185,129,.2);
}
.telegram-icon {
  background: linear-gradient(135deg, rgba(37,99,235,.25), rgba(6,182,212,.2));
  color: #60a5fa;
  border: 1px solid rgba(37,99,235,.2);
}
.settings-card-title { font-size: 1rem; font-weight: 600; }
.settings-card-desc  { font-size: .78rem; color: var(--text-secondary); margin-top: .2rem; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 768px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .field-group[style*="grid-column"] { grid-column: auto !important; }
}

/* Secret field with inline eye toggle */
.secret-field-wrap {
  position: relative;
}
.secret-field-wrap .field-input {
  padding-right: 2.75rem;
}
.secret-toggle {
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  opacity: .6;
  transition: opacity var(--transition), color var(--transition);
}
.secret-toggle:hover {
  opacity: 1;
  color: var(--accent-purple);
}

/* Toggle switches */
.settings-toggles {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.settings-toggle-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  cursor: pointer;
  padding: .5rem .25rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.settings-toggle-item:hover {
  background: rgba(255,255,255,.03);
}
.settings-toggle-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.settings-toggle-switch {
  width: 44px;
  height: 24px;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--border);
  border-radius: 99px;
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
.settings-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.settings-toggle-item input:checked + .settings-toggle-switch {
  background: rgba(124,58,237,.25);
  border-color: rgba(124,58,237,.5);
}
.settings-toggle-item input:checked + .settings-toggle-switch::after {
  transform: translateX(20px);
  background: var(--accent-purple);
  box-shadow: 0 0 8px rgba(124,58,237,.4);
}
.settings-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.settings-toggle-label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-primary);
}
.settings-toggle-hint {
  font-size: .72rem;
  color: var(--text-muted);
}

.settings-card-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}

/* ── Inline user chip (API Keys table owner column) ──────────────────────── */
.user-chip-inline {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  color: var(--text-secondary);
}
.user-avatar-xs {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .6rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

/* ── Mono utility ─────────────────────────────────────────────────────────── */
.mono { font-family: 'JetBrains Mono', monospace; }

