:root {
  --navy: #0d1b2a;
  --navy-mid: #162538;
  --navy-light: #1e3450;
  --gold: #c9a84c;
  --gold-light: #e8c97a;
  --white: #f5f2ec;
  --white-dim: rgba(245,242,236,0.6);
  --white-faint: rgba(245,242,236,0.08);
  --red: #e05252;
  --yellow: #e0b252;
  --green: #52b788;
  --orange: #e07d3c;
  --border: rgba(201,168,76,0.2);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--navy);
  color: var(--white);
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  position: relative;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(201,168,76,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 90%, rgba(30,52,80,0.8) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#login-page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: var(--navy-mid);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(201,168,76,0.05);
  animation: fadeUp 0.6s ease forwards;
}

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

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.login-logo .shield { font-size: 1.8rem; line-height: 1; }

.login-logo .wordmark {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--white);
  letter-spacing: 0.05em;
}

.login-logo .wordmark span { color: var(--gold); }

.login-headline {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--white);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.login-sub {
  font-size: 0.85rem;
  color: var(--white-dim);
  margin-bottom: 2rem;
  line-height: 1.5;
}

.tab-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--white-dim);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.5rem 1.25rem 0.75rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--white-dim);
  margin-bottom: 0.5rem;
}

.form-group input {
  width: 100%;
  background: var(--white-faint);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.75rem 1rem;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--gold);
  background: rgba(201,168,76,0.05);
}

.form-group input::placeholder { color: rgba(245,242,236,0.25); }

.btn-primary {
  width: 100%;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 3px;
  padding: 0.85rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: var(--gold-light); }
.btn-primary:active { transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.login-msg {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 3px;
  font-size: 0.85rem;
  display: none;
}

.login-msg.success {
  background: rgba(82,183,136,0.15);
  border: 1px solid rgba(82,183,136,0.3);
  color: var(--green);
  display: block;
}

.login-msg.error {
  background: rgba(224,82,82,0.15);
  border: 1px solid rgba(224,82,82,0.3);
  color: var(--red);
  display: block;
}

#dashboard-page {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.dash-header {
  background: var(--navy-mid);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ── Fixed Dashboard Logo Styles ── */
.dash-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--white);
}
.dash-logo span, .dash-logo .wordmark {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
}
.dash-logo > span:not(.wordmark):not(.shield) {
  color: var(--gold);
}
.dash-logo .wordmark {
  color: var(--white);
}
.dash-logo .wordmark span {
  color: var(--gold);
}
.dash-logo .shield {
  color: initial;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.dash-greeting { font-size: 0.85rem; color: var(--white-dim); }

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--white-dim);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.4rem 1rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover { border-color: var(--gold); color: var(--gold); }

.dash-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

.dash-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ── Modernized Cards ── */
.card {
  background: var(--navy-mid);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.card:not(.calls-section) {
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}

.card-body { padding: 1.5rem; }

/* ── Device Status Banner ── */
.device-status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 0.6rem;
  border: none !important;
  min-height: 48px;
  transition: all 0.3s;
}

.device-status-banner.online { background: rgba(82, 183, 136, 0.15); }
.device-status-banner.offline { background: rgba(224, 125, 60, 0.1); }
.device-status-banner.unknown { background: var(--white-faint); }

.device-status-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.device-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.device-status-banner.online .device-status-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}

.device-status-banner.offline .device-status-dot {
  background: var(--orange);
  box-shadow: 0 0 6px var(--orange);
}

.device-status-banner.unknown .device-status-dot {
  background: var(--white-dim);
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green); }
  50% { opacity: 0.6; box-shadow: 0 0 14px var(--green); }
}

.device-status-label {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.device-status-banner.online .device-status-label { color: var(--green); }
.device-status-banner.offline .device-status-label { color: var(--orange); }
.device-status-banner.unknown .device-status-label { color: var(--white-dim); }

.device-status-since {
  font-size: 0.72rem;
  color: var(--white-dim);
  letter-spacing: 0.03em;
}

/* ── Protection Active Banner ── */
.protection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  border: none !important;
  min-height: 48px;
  transition: all 0.3s;
}

.protection-banner.active { background: rgba(82, 183, 136, 0.12); }
.protection-banner.inactive { background: rgba(224, 82, 82, 0.12); }

.protection-banner-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.protection-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.protection-banner.active .protection-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}

.protection-banner.inactive .protection-dot {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

.protection-banner-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  font-weight: 500;
}

.protection-banner.active .protection-banner-label { color: var(--green); }
.protection-banner.inactive .protection-banner-label { color: var(--red); }

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--white-faint);
  font-size: 0.85rem;
  gap: 1rem;
}

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

.info-label {
  color: var(--white-dim);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.info-value {
  color: var(--white);
  text-align: right;
  word-break: break-word;
}

.contact-card-body { padding: 1.5rem; }

.contact-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--white-faint);
}

.contact-item:last-child { border-bottom: none; }

.contact-icon {
  font-size: 1rem;
  width: 28px;
  flex-shrink: 0;
  text-align: center;
  margin-top: 1px;
}

.contact-detail { flex: 1; }

.contact-detail-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white-dim);
  margin-bottom: 0.2rem;
}

.contact-detail-value { font-size: 0.88rem; color: var(--white); }
.contact-detail-value a { color: var(--gold); text-decoration: none; }
.contact-detail-value a:hover { text-decoration: underline; }

/* ── Calls Table ── */
.calls-section { margin-top: 1.5rem; }

.calls-table-wrap {
  width: 100%;
  overflow-x: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead th {
  font-size: 0.63rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
  padding: 0.75rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--white-faint);
  transition: background 0.15s;
}

tbody tr:hover { background: var(--white-faint); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 0.75rem 0.5rem;
  color: var(--white-dim);
  vertical-align: middle;
}

tbody td.td-main { color: var(--white); }

/* Column sizing */
thead th:nth-child(1), tbody td:nth-child(1) { width: 90px; min-width: 90px; }
thead th:nth-child(2), tbody td:nth-child(2) { width: 48px; min-width: 48px; white-space: nowrap; }
thead th:nth-child(3), tbody td:nth-child(3) { min-width: 120px; }
thead th:nth-child(4), tbody td:nth-child(4) { width: 48px; min-width: 48px; white-space: nowrap; }
thead th:nth-child(5), tbody td:nth-child(5) { width: 76px; min-width: 76px; }
thead th:nth-child(6), tbody td:nth-child(6) { width: 52px; min-width: 52px; }

td.td-audio { width: 36px; min-width: 36px; text-align: center; white-space: nowrap; }
td.td-audio:has(.audio-player) { width: auto; min-width: 180px; }
thead th:last-child { width: 36px; text-align: center; }

.dir-out { font-size: 0.75rem; color: var(--gold); letter-spacing: 0.02em; white-space: nowrap; }
.dir-in { font-size: 0.75rem; color: var(--green); letter-spacing: 0.02em; white-space: nowrap; }

.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.35rem;
  border-radius: 2px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-green { background: rgba(82,183,136,0.15); color: var(--green); border: 1px solid rgba(82,183,136,0.3); }
.badge-yellow { background: rgba(224,178,82,0.15); color: var(--yellow); border: 1px solid rgba(224,178,82,0.3); }
.badge-red { background: rgba(224,82,82,0.15); color: var(--red); border: 1px solid rgba(224,82,82,0.3); }

.warning-badge {
  display: inline-block;
  padding: 0.2rem 0.35rem;
  border-radius: 2px;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.warning-yes { background: rgba(224,82,82,0.15); color: var(--red); border: 1px solid rgba(224,82,82,0.25); }
.warning-no { background: var(--white-faint); color: var(--white-dim); border: 1px solid rgba(245,242,236,0.1); }

.play-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--gold);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.play-btn:hover { background: var(--gold); color: var(--navy); border-color: var(--gold); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--white-dim);
}

.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state p { font-size: 0.85rem; }

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.refresh-btn {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  width: 28px;
  height: 28px;
  transition: transform 0.3s;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.refresh-btn svg { display: block; }
.refresh-btn:hover { color: var(--gold-light); background: var(--white-faint); }
.refresh-btn.spinning { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-row td { text-align: center; padding: 2rem; }

.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(201,168,76,0.1);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.sidebar { display: flex; flex-direction: column; gap: 1.5rem; }

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  color: var(--white);
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  z-index: 999;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ── Mobile Responsive (Fully Refined Flex Cards) ── */
.calls-section {
  overflow: hidden;
  min-width: 0;
}

@media (max-width: 768px) {
  .dash-grid { grid-template-columns: 1fr; gap: 1rem; }
  .dash-main { padding: 1.5rem 1rem; }
  .sidebar { gap: 1rem; }
}

@media (max-width: 640px) {
  /* Glassmorphism Sticky Header */
  .dash-header {
    background: rgba(22, 37, 56, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1.25rem;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .dash-greeting { display: none; }
  .dash-logo { font-size: 1.1rem; }
  .dash-main { padding: 1rem 0.75rem; }
  .card-body, .contact-card-body { padding: 1rem; }
  .card-header { padding: 0.875rem 1rem; }
  .toast { left: 1rem; right: 1rem; bottom: 1rem; text-align: center; }

  /* Clean Typography for Account Details */
  .info-row { 
    flex-direction: column; 
    gap: 0.3rem; 
    align-items: flex-start; 
    padding: 0.85rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  }
  .info-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--white-dim);
  }
  .info-value {
    font-size: 1.05rem;
    color: var(--white);
    text-align: left;
  }

  /* Transform Call History Table into Modern Cards (Flex Layout) */
  .calls-table-wrap { overflow: hidden; }
  .calls-table-wrap thead { display: none; }
  
  .calls-table-wrap table, 
  .calls-table-wrap tbody {
    display: block;
    width: 100%;
  }

  .calls-table-wrap tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.6rem; 
    width: 100%;
  }
  
  .calls-table-wrap tbody tr:last-child {
    margin-bottom: 0;
  }

  .calls-table-wrap tbody td {
    display: block;
    padding: 0;
    border: none;
    line-height: 1.3;
    min-width: 0 !important;
    width: auto !important;
    white-space: normal;
  }

  /* Direction Icon */
  .calls-table-wrap tbody td:nth-child(2) {
    order: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
  }
  
  .dir-in, .dir-out { 
    font-size: 1.1rem; 
    letter-spacing: -10px; 
    color: transparent; 
    white-space: nowrap; 
    overflow: hidden; 
    display: inline-block; 
    width: 12px; 
  }
  .dir-in::first-letter { color: var(--green); }
  .dir-out::first-letter { color: var(--gold); }

  /* Caller ID */
  .calls-table-wrap tbody td:nth-child(3) {
    order: 2;
    flex: 1;
    overflow: hidden;
  }
  .calls-table-wrap tbody td:nth-child(3) .caller-wrap {
    white-space: normal;
    max-width: 100%;
  }
  .caller-nickname { font-size: 1rem; font-weight: 500; }
  .caller-number { font-size: 0.85rem; }

  /* Duration */
  .calls-table-wrap tbody td:nth-child(4) {
    order: 3;
    font-size: 0.75rem;
    color: var(--white-dim);
    flex-shrink: 0;
    margin-left: auto;
    display: block !important;
  }

  /* Date & Time */
  .calls-table-wrap tbody td:nth-child(1) {
    order: 4;
    width: 100% !important;
    font-size: 0.75rem !important;
    color: var(--white-dim) !important;
    opacity: 0.7;
    padding-left: calc(36px + 0.6rem); /* Perfectly indents text under Caller ID */
    margin-bottom: 0.2rem;
  }

  /* Risk Score */
  .calls-table-wrap tbody td:nth-child(5) {
    order: 5;
    margin-left: calc(36px + 0.6rem); /* Perfectly indents badge under Date/Time */
    display: block !important;
  }

  /* Warning */
  .calls-table-wrap tbody td:nth-child(6) {
    order: 6;
    display: block !important;
  }

  /* Audio Button */
  .calls-table-wrap tbody td.td-audio {
    order: 7;
    margin-left: auto;
    text-align: right;
    display: block !important;
  }
  
  .play-btn { width: 34px; height: 34px; font-size: 0.8rem; }

  /* Expanded Audio Player State */
  .calls-table-wrap td.td-audio:has(.audio-player) {
    order: 8;
    margin-top: 0.5rem !important;
    padding-top: 0.75rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    width: 100% !important;
    text-align: left;
    margin-left: 0;
  }

  .calls-table-wrap td.td-audio:has(.audio-player) .audio-player {
    width: 100%;
  }
  .ap-time { display: none; }

  /* Hide badges & audio for Outgoing Calls only (they just show as empty dashes anyway) */
  .row-out td:nth-child(5),
  .row-out td:nth-child(6),
  .row-out td.td-audio {
    display: none !important;
  }

  /* Fix for Loading & Empty states in mobile flexbox */
  .calls-table-wrap tbody tr.loading-row,
  .calls-table-wrap tbody tr:has(.empty-state) {
    display: block;
    background: transparent;
    border: none;
    padding: 0;
  }
  
  .calls-table-wrap tbody td[colspan="7"] {
    width: 100% !important;
    opacity: 1 !important;
    font-size: 0.85rem !important;
    color: var(--white-dim) !important;
    padding-left: 0; /* Reset indentation */
  }

  .nickname-tip {
    left: 1rem;
    right: 1rem;
    bottom: 4.5rem;
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 1.75rem 1.25rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  #login-page { padding: 0; align-items: stretch; }
  .cancel-modal { padding: 1.5rem 1.25rem; }
  .cancel-modal-actions { flex-direction: column-reverse; }
  .cancel-modal-btn-keep,
  .cancel-modal-btn-request { flex: none; width: 100%; }
}

@media (max-width: 400px) {
  .device-status-banner,
  .protection-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    min-height: unset;
    padding: 0.75rem 1rem;
  }
}

/* ── Portal Footer ── */
.portal-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--white-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin-top: 2rem;
}
.portal-footer a {
  color: var(--white-dim);
  text-decoration: none;
}
.portal-footer a:hover {
  color: var(--gold);
}

/* ── Nickname Editing ── */
.caller-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
}

.caller-stack {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: hidden;
}

.caller-nickname {
  font-size: 0.83rem;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.caller-number {
  font-size: 0.7rem;
  white-space: nowrap;
}

.nickname-edit-btn {
  background: none;
  border: none;
  color: var(--white-dim);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 5px;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

tbody tr:hover .nickname-edit-btn {
  opacity: 1;
}

.nickname-edit-btn:hover {
  color: var(--gold);
  background: rgba(201,168,76,0.12);
}

.nickname-input {
  background: var(--navy-light);
  border: 1px solid var(--gold);
  border-radius: 2px;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  padding: 0.2rem 0.5rem;
  outline: none;
  width: 110px;
  flex-shrink: 0;
}

.nickname-input::placeholder {
  color: rgba(245,242,236,0.3);
}

.nickname-save-btn {
  background: var(--gold);
  border: none;
  border-radius: 2px;
  color: var(--navy);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  flex-shrink: 0;
  transition: background 0.15s;
}

.nickname-save-btn:hover {
  background: var(--gold-light);
}

/* ── Nickname Tip ── */
.nickname-tip {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  font-size: 0.8rem;
  color: var(--white-dim);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 998;
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  white-space: nowrap;
}

.nickname-tip.visible {
  opacity: 1;
  transform: translateY(0);
}

.nickname-tip-close {
  position: absolute;
  top: 50%;
  right: 0.6rem;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--white-dim);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0.2rem 0.3rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.nickname-tip-close:hover { opacity: 1; }

/* ── Payment Warning Banner (past_due) ── */
.payment-warning-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(224,178,82,0.1);
  border-bottom: 1px solid rgba(224,178,82,0.3);
  padding: 0.9rem 2rem;
  flex-wrap: wrap;
}

.payment-warning-left {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 1;
}

.payment-warning-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--yellow);
}

.payment-warning-text {
  font-size: 0.85rem;
  color: var(--white-dim);
  line-height: 1.55;
}

.payment-warning-text strong {
  color: var(--yellow);
  font-weight: 500;
}

.payment-warning-btn {
  background: var(--yellow);
  color: var(--navy);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.45rem 1rem;
  border-radius: 3px;
  white-space: nowrap;
  transition: background 0.2s;
  flex-shrink: 0;
  align-self: center;
}

.payment-warning-btn:hover {
  background: var(--gold-light);
}

@media (max-width: 640px) {
  .payment-warning-banner {
    padding: 0.75rem 1rem;
  }
  .payment-warning-btn {
    width: 100%;
    text-align: center;
  }
}

/* ── Cancelled Screen ── */
#cancelled-screen {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.cancelled-inner {
  max-width: 520px;
  width: 100%;
  text-align: center;
}

.cancelled-icon {
  font-size: 3rem;
  margin-bottom: 1.5rem;
  opacity: 0.4;
}

.cancelled-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--white);
  margin-bottom: 0.75rem;
  line-height: 1.25;
}

.cancelled-sub {
  font-size: 0.9rem;
  color: var(--white-dim);
  line-height: 1.6;
  margin-bottom: 2rem;
}

.cancelled-box {
  background: var(--navy-mid);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  text-align: left;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--white-dim);
}

.cancelled-box strong {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.cancelled-contact {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.cancelled-contact a {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.88rem;
  transition: color 0.2s;
}

.cancelled-contact a:hover {
  color: var(--gold-light);
  text-decoration: underline;
}

.cancelled-reactivate {
  font-size: 0.82rem;
  color: var(--white-dim);
}

.cancelled-reactivate a {
  color: var(--gold);
  text-decoration: none;
}

.cancelled-reactivate a:hover {
  text-decoration: underline;
}

/* ── Account Menu Dropdown ── */
.account-menu-wrap {
  position: relative;
}

.account-menu-trigger {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-radius: 3px;
  transition: background 0.2s;
  color: var(--white-dim);
}

.account-menu-trigger:hover {
  background: var(--white-faint);
  color: var(--white);
}

.account-menu-trigger .dash-greeting {
  font-size: 0.85rem;
  color: inherit;
}

.account-menu-caret {
  color: var(--white-dim);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.account-menu-wrap.open .account-menu-caret {
  transform: rotate(180deg);
}

.account-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 200px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  z-index: 200;
  overflow: hidden;
  animation: dropdownFade 0.15s ease forwards;
}

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

.account-menu-wrap.open .account-dropdown {
  display: block;
}

.account-dropdown-name {
  padding: 0.75rem 1rem 0.6rem;
  font-size: 0.78rem;
  color: var(--white-dim);
  letter-spacing: 0.04em;
  font-style: italic;
}

.account-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.account-dropdown-item {
  width: 100%;
  background: none;
  border: none;
  color: var(--white-dim);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.83rem;
  padding: 0.7rem 1rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: background 0.15s, color 0.15s;
}

.account-dropdown-item:hover {
  background: var(--white-faint);
  color: var(--white);
}

.account-dropdown-cancel {
  color: rgba(224,82,82,0.7);
}

.account-dropdown-cancel:hover {
  background: rgba(224,82,82,0.08);
  color: var(--red);
}

.account-dropdown-icon {
  font-size: 0.75rem;
  width: 14px;
  flex-shrink: 0;
}

/* ── Cancellation Modal ── */
.cancel-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(2px);
  animation: overlayFade 0.2s ease forwards;
}

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

.cancel-modal {
  background: var(--navy-mid);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-top: 3px solid var(--yellow);
  border-radius: 12px;
  padding: 2rem 2.25rem;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 40px 80px rgba(0,0,0,0.6);
  animation: modalSlide 0.2s ease forwards;
}

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

.cancel-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.cancel-modal-icon {
  font-size: 1.3rem;
}

.cancel-modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--white);
  margin: 0;
}

.cancel-modal-intro {
  font-size: 0.85rem;
  color: var(--white-dim);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.cancel-modal-warnings {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.cancel-modal-warnings li {
  display: flex;
  gap: 0.75rem;
  font-size: 0.84rem;
  color: var(--white-dim);
  line-height: 1.55;
  background: var(--white-faint);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.cancel-modal-warnings li strong {
  color: var(--white);
}

.warn-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.cancel-modal-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.cancel-modal-btn-keep {
  flex: 1;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 4px;
  padding: 0.8rem 1.25rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.83rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.cancel-modal-btn-keep:hover {
  background: var(--gold-light);
}

.cancel-modal-btn-request {
  flex: 1;
  background: none;
  color: var(--white-dim);
  border: 1px solid rgba(245,242,236,0.15);
  border-radius: 4px;
  padding: 0.8rem 1.25rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.83rem;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
  display: block;
}

.cancel-modal-btn-request:hover {
  border-color: var(--red);
  color: var(--red);
}

.cancel-modal-note {
  font-size: 0.75rem;
  color: var(--white-dim);
  opacity: 0.6;
  line-height: 1.5;
  text-align: center;
}

/* ── Inline Audio Player ── */
.audio-player {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.ap-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--gold);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  padding: 0;
  line-height: 1;
}

.ap-btn:hover {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}

.ap-scrubber {
  flex: 1;
  min-width: 50px;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  accent-color: var(--gold);
}

.ap-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
}

.ap-time {
  font-size: 0.62rem;
  color: var(--white-dim);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .ap-scrubber { min-width: 36px; }
}