/* ────────────────────────────────────────────────────────────────────────────
   SB Corp Elite Access — Theme
   Palette: midnight navy + champagne gold + deep glass
   ──────────────────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg-base:       #07090F;
  --bg-elevated:   #0E1322;
  --bg-card:       rgba(20, 26, 44, 0.72);
  --bg-card-solid: #131A2C;
  --bg-input:      #0B1120;
  --bg-hover:      rgba(200, 168, 90, 0.06);

  /* Borders / dividers */
  --border:        rgba(200, 168, 90, 0.14);
  --border-strong: rgba(200, 168, 90, 0.28);
  --divider:       rgba(255, 255, 255, 0.06);

  /* Brand gold */
  --gold:          #C8A85A;
  --gold-bright:   #E5C56F;
  --gold-deep:     #8E7634;
  --gold-glow:     rgba(200, 168, 90, 0.35);

  /* Text */
  --text:          #ECEFF7;
  --text-muted:    #8A93A8;
  --text-faded:    #5B6377;

  /* Status */
  --ok:            #4ADE80;
  --warn:          #F4C77B;
  --err:           #F87171;
  --info:          #7DB3FF;

  /* Layout */
  --sidebar-w:     264px;
  --topbar-h:      62px;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow-glow:   0 0 0 1px var(--border), 0 12px 40px rgba(0,0,0,.45);

  --serif:         'Cormorant Garamond', 'Garamond', 'Times New Roman', serif;
  --sans:          'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono:          'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

/* ── Reset + base ─────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-base);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  /* subtle radial vignette + gold dust */
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(200,168,90,.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(125,179,255,.05), transparent 60%);
  pointer-events: none; z-index: 0;
}

a { color: var(--gold-bright); text-decoration: none; }
a:hover { color: var(--gold); }

h1, h2, h3, h4 { color: var(--text); margin: 0 0 .6rem; font-weight: 600; letter-spacing: .2px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 .8rem; color: var(--text); }

code, pre {
  font-family: var(--mono);
  font-size: .85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}
pre { padding: 12px; overflow: auto; }

::selection { background: var(--gold-glow); color: var(--text); }

/* ── Layout shell ─────────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  background: linear-gradient(180deg, #0A0F1C 0%, #060912 100%);
  border-right: 1px solid var(--border);
  padding: 18px 14px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 14px;
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold-deep));
  display: grid; place-items: center;
  color: #0A0F1C; font-family: var(--serif); font-weight: 700; font-size: 22px;
  box-shadow: 0 4px 14px rgba(200,168,90,.35), inset 0 0 0 1px rgba(255,255,255,.18);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--serif); font-size: 1.15rem; color: var(--gold-bright); letter-spacing: .5px; }
.brand-sub  { font-size: .68rem; color: var(--text-faded); letter-spacing: 2px; text-transform: uppercase; }

.nav-section-label {
  font-size: .65rem; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-faded);
  padding: 16px 12px 6px;
}

.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 2px;
  transition: background .15s, color .15s, transform .15s;
}
.nav a:hover { background: var(--bg-hover); color: var(--text); }
.nav a.active {
  background: linear-gradient(90deg, rgba(200,168,90,.16), rgba(200,168,90,.04));
  color: var(--gold-bright);
  box-shadow: inset 2px 0 0 var(--gold);
}
.nav .icon { width: 18px; text-align: center; opacity: .85; }
.nav .badge {
  margin-left: auto;
  font-size: .7rem;
  background: var(--gold-glow);
  color: var(--gold-bright);
  border-radius: 4px;
  padding: 1px 6px;
}

.main {
  display: flex; flex-direction: column;
  min-width: 0; /* prevents grid blowout */
}

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 9, 15, 0.7);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.topbar .breadcrumb { color: var(--text-faded); font-size: .85rem; }
.topbar .topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .85rem;
  color: var(--text-muted);
}
.topbar .user-chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 8px var(--ok);
}

.content {
  padding: 26px 28px 60px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
}

/* ── Cards / panels ──────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-glow);
}
.card + .card { margin-top: 18px; }
.card-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--gold-bright);
  margin-bottom: 14px;
  letter-spacing: .5px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-sub { color: var(--text-muted); font-size: .85rem; margin-top: -8px; margin-bottom: 14px; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
}

/* ── Stat tiles ──────────────────────────────────────────────────────────── */

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute; top: 0; right: 0;
  width: 60px; height: 60px;
  background: radial-gradient(circle at top right, var(--gold-glow), transparent 70%);
  pointer-events: none;
}
.stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-faded); }
.stat-value { font-family: var(--serif); font-size: 1.8rem; color: var(--gold-bright); margin-top: 6px; }
.stat-delta { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.stat-delta.up { color: var(--ok); }
.stat-delta.down { color: var(--err); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: .88rem; font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  font-family: inherit;
}
.btn:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  border: none;
  color: #0A0F1C;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(200,168,90,.35);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 22px rgba(200,168,90,.45);
}
.btn-danger { border-color: rgba(248,113,113,.4); color: var(--err); }
.btn-danger:hover { background: rgba(248,113,113,.08); }
.btn-ghost  { border: 1px dashed var(--border-strong); color: var(--text-muted); }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: 6px; letter-spacing: .3px; }
input, select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
textarea { min-height: 100px; resize: vertical; }

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data {
  width: 100%; border-collapse: collapse;
  font-size: .87rem;
}
table.data th {
  text-align: left;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider);
  color: var(--text);
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--bg-hover); }

/* ── Pills / badges ──────────────────────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: .3px;
}
.pill-gold { background: var(--gold-glow); color: var(--gold-bright); }
.pill-ok   { background: rgba(74,222,128,.12); color: var(--ok); }
.pill-warn { background: rgba(244,199,123,.12); color: var(--warn); }
.pill-err  { background: rgba(248,113,113,.12); color: var(--err); }
.pill-mute { background: rgba(255,255,255,.04); color: var(--text-muted); }

/* ── Auth (login) page ──────────────────────────────────────────────────── */

.auth-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 30px;
  position: relative; z-index: 1;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.auth-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 22px;
}
.auth-title {
  font-family: var(--serif);
  font-size: 1.6rem; color: var(--gold-bright);
  margin-bottom: 4px;
}
.auth-sub {
  font-size: .8rem; color: var(--text-faded);
  letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 22px;
}
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 12px; }

/* ── Flashes / toasts ────────────────────────────────────────────────────── */

.flash {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  border: 1px solid var(--border);
  font-size: .88rem;
}
.flash.error   { border-color: rgba(248,113,113,.3); color: var(--err); background: rgba(248,113,113,.06); }
.flash.success { border-color: rgba(74,222,128,.3);  color: var(--ok);  background: rgba(74,222,128,.06); }
.flash.info    { border-color: rgba(125,179,255,.3); color: var(--info); background: rgba(125,179,255,.06); }

/* ── Footer ──────────────────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--divider);
  padding: 18px 28px;
  font-size: .75rem;
  color: var(--text-faded);
  display: flex; justify-content: space-between;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty .empty-icon { font-size: 2.4rem; opacity: .35; margin-bottom: 8px; }
.empty .empty-msg  { font-family: var(--serif); font-size: 1.1rem; }

/* ── Tabs (used in P1 panel etc) ────────────────────────────────────────── */

.tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  padding: 0 4px;
}
.tabs button, .tabs a {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: .85rem;
  font-weight: 500;
  letter-spacing: .5px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  text-decoration: none;
  transition: all .15s;
}
.tabs button:hover, .tabs a:hover { color: var(--text); }
.tabs button.active, .tabs a.active {
  color: var(--gold-bright);
  border-bottom-color: var(--gold);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Dialer keypad (used in /call/ and /p1/ dial tab) ────────────────────── */

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 320px;
  margin: 0 auto;
}
.keypad .key {
  aspect-ratio: 1.4 / 1;
  display: grid; place-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--gold-bright);
  user-select: none;
  transition: all .1s ease;
}
.keypad .key small {
  font-family: var(--sans); font-size: .55rem; letter-spacing: 2px;
  color: var(--text-faded); display: block; margin-top: 2px;
}
.keypad .key:hover  { border-color: var(--gold); background: var(--bg-hover); }
.keypad .key:active,
.keypad .key.pressed { transform: scale(.96); background: var(--gold-glow); }

/* In-call control buttons grid */
.ctl-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.ctl-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
}
.ctl-btn:hover { border-color: var(--gold); background: var(--bg-hover); }
.ctl-btn.active, .ctl-btn.muted, .ctl-btn.held {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--gold-bright);
}
.ctl-btn .ctl-icon  { font-size: 1.3rem; margin-bottom: 4px; display: block; }
.ctl-btn .ctl-label { font-size: .65rem; letter-spacing: 1.5px; color: var(--text-muted); }
.ctl-btn.active .ctl-label,
.ctl-btn.muted  .ctl-label,
.ctl-btn.held   .ctl-label { color: var(--gold-bright); }

/* Call display strip */
.call-display {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 1.4rem;
  color: var(--gold-bright);
  text-align: center;
  letter-spacing: 2px;
  min-height: 56px;
  display: flex; align-items: center; justify-content: center;
}
.call-display.placeholder { color: var(--text-faded); letter-spacing: 4px; }

.call-status {
  text-align: center;
  font-size: .7rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 8px 0;
  font-family: var(--mono);
}
.call-status.live    { color: var(--ok); }
.call-status.ringing { color: var(--warn); }
.call-status.ended   { color: var(--err); }

/* Big call/end buttons */
.btn-call, .btn-end {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  letter-spacing: 2px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: var(--serif);
  transition: all .15s;
}
.btn-call {
  background: linear-gradient(135deg, var(--ok), #2db14d);
  color: #04200a;
  box-shadow: 0 4px 14px rgba(74,222,128,.35);
}
.btn-call:disabled { opacity: .4; cursor: not-allowed; }
.btn-call:not(:disabled):hover { filter: brightness(1.1); }
.btn-end {
  background: linear-gradient(135deg, var(--err), #cc4949);
  color: #fff;
  box-shadow: 0 4px 14px rgba(248,113,113,.35);
}
.btn-end:hover { filter: brightness(1.1); }

/* ── Mobile: collapsible sidebar ─────────────────────────────────────────── */

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--gold-bright);
  font-size: 1.1rem;
  width: 38px; height: 38px;
  cursor: pointer;
  align-items: center; justify-content: center;
}
.menu-toggle:hover { border-color: var(--gold); }
.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 19;
  backdrop-filter: blur(4px);
}

/* ── Mobile bottom-nav (hidden on desktop, fixed on mobile) ─────────────── */
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(7, 9, 15, 0.96);
    border-top: 1px solid var(--border-strong);
    backdrop-filter: blur(20px);
    z-index: 18;
    padding: 4px env(safe-area-inset-right) calc(4px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
    box-shadow: 0 -4px 18px rgba(0,0,0,.5);
  }
  .bn-item {
    background: transparent;
    border: none;
    color: var(--text-faded);
    text-decoration: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 8px 4px;
    font-family: inherit;
    cursor: pointer;
    border-radius: 8px;
    min-height: 56px;
    position: relative;
    transition: color .15s, background .15s;
  }
  .bn-item:hover, .bn-item:focus { background: var(--bg-hover); }
  .bn-item.active {
    color: var(--gold-bright);
    background: linear-gradient(180deg, rgba(200,168,90,.16), rgba(200,168,90,.04));
  }
  .bn-item.active::before {
    content: "";
    position: absolute; top: 0; left: 30%; right: 30%;
    height: 2px; background: var(--gold-bright);
    border-radius: 0 0 2px 2px;
  }
  .bn-icon { font-size: 1.15rem; line-height: 1; margin-bottom: 4px; }
  .bn-lbl  { font-size: .65rem; letter-spacing: 1px; text-transform: uppercase; }

  /* Reserve space for the fixed bottom-nav so content doesn't get hidden */
  .content { padding-bottom: 84px; }
  .footer  { display: none; }

  /* Hide the topbar hamburger — bottom-nav has its own More button */
  .menu-toggle { display: none !important; }
  .topbar { padding: 0 14px; }
}

@media (max-width: 380px) {
  .bn-lbl { font-size: .6rem; }
  .bn-icon { font-size: 1rem; }
  .bn-item { min-height: 48px; padding: 6px 2px; }
}

@media (max-width: 900px) {
  body { overflow-x: hidden; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 280px;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .scrim.show  { display: block; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 60px; }
  .ctl-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .ctl-btn { padding: 10px 4px; }
  .keypad { gap: 8px; max-width: 100%; }
  .keypad .key { font-size: 1.4rem; }
  .topbar h1, .topbar .breadcrumb { font-size: .85rem; }
  .topbar-right { gap: 6px; }
  .topbar-right .pill { font-size: .65rem; }
  .topbar-right .user-chip { font-size: .75rem; padding: 4px 8px; }
}

/* Smaller phone tweaks */
@media (max-width: 480px) {
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.05rem; }
  .stat-value { font-size: 1.4rem; }
  .card { padding: 14px; }
  .field-row { flex-direction: column; gap: 0; }
  .ctl-grid { grid-template-columns: repeat(2, 1fr); }
  table.data th, table.data td { padding: 8px 10px; font-size: .8rem; }
}
