/* ═══════════════════════════════════════════
   RESET & TOKENS
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
img  { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }

:root {
  --ink:     #0d1117;
  --ink2:    #3d4a5c;
  --ink3:    #8391a6;
  --paper:   #f8f7f4;
  --white:   #ffffff;
  --red:     #c8281e;
  --red-h:   #e03228;
  --red-lt:  #fdf1f0;
  --grn:     #15774f;
  --grn-lt:  #edf7f2;
  --amb:     #b45c0f;
  --amb-lt:  #fef3e2;
  --blue:    #1a56db;
  --blue-lt: #ebf2ff;
  --bdr:     #e4e1da;
  --bdr2:    #ccc8be;
  --serif:   'Playfair Display', Georgia, serif;
  --sans:    'Instrument Sans', system-ui, sans-serif;
  --rad:     10px;
  --rad-lg:  16px;
  --sh:      0 2px 8px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --sh-lg:   0 12px 40px rgba(0,0,0,.10), 0 3px 12px rgba(0,0,0,.06);
  --nav-h:   56px;
  --sidebar: 220px;
}

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── UTILITIES ── */
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-muted { color: var(--ink3); }

/* ═══════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════ */
@keyframes fadeUp  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes blink   { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes spin    { to { transform: rotate(360deg); } }

.fade-up { animation: fadeUp .3s ease both; }
.fade-in { animation: fadeIn .25s ease both; }

/* ═══════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════ */
.page-login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--paper);
}

.login-wrap {
  width: 100%; max-width: 400px; padding: 24px;
  animation: fadeUp .35s ease both;
}

.login-card {
  background: var(--white); border: 1px solid var(--bdr);
  border-radius: var(--rad-lg); box-shadow: var(--sh-lg);
  padding: 40px 36px; text-align: center;
}

.login-logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--serif); font-size: 22px; font-weight: 700;
  color: var(--ink); margin-bottom: 24px;
}

.login-logo-tag,
.nav-logo-tag {
  font-family: var(--sans); font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink3); background: var(--paper);
  border: 1px solid var(--bdr); border-radius: 4px;
  padding: 2px 6px; margin-left: 2px;
}

.login-title {
  font-family: var(--serif); font-size: 26px; letter-spacing: -.02em;
  color: var(--ink); margin-bottom: 8px;
}

.login-sub {
  font-size: 13px; color: var(--ink2); line-height: 1.6;
  margin-bottom: 28px; max-width: 280px; margin-left: auto; margin-right: auto;
}

.login-btn-wrap {
  display: flex; justify-content: center; margin-bottom: 14px;
}

.login-err {
  margin-top: 12px; padding: 10px 14px;
  background: var(--red-lt); border: 1px solid rgba(200,40,30,.2);
  border-radius: var(--rad); font-size: 13px; color: var(--red);
  line-height: 1.5;
}

.logo-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); flex-shrink: 0;
  animation: blink 2s ease infinite;
}

/* ═══════════════════════════════════════════
   TOP NAV
═══════════════════════════════════════════ */
#admin-nav-host { position: sticky; top: 0; z-index: 500; }

.admin-nav {
  height: var(--nav-h);
  background: rgba(248,247,244,.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bdr);
  display: flex; align-items: center;
  padding: 0 24px; gap: 24px;
}

.admin-nav-logo {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--serif); font-size: 18px; font-weight: 700;
  color: var(--ink); cursor: pointer; flex-shrink: 0;
  text-decoration: none; white-space: nowrap;
}

.admin-nav-links {
  display: flex; align-items: center; gap: 2px; flex: 1;
}

.admin-nav-link {
  padding: 5px 14px; border-radius: 100px;
  font-size: 13px; font-weight: 600; color: var(--ink3);
  text-decoration: none; transition: all .15s; white-space: nowrap;
}
.admin-nav-link:hover  { background: var(--red-lt); color: var(--red); }
.admin-nav-link.active { background: var(--red); color: #fff; }

.admin-nav-user {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0; margin-left: auto;
}

.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--bdr); flex-shrink: 0;
}

.user-name {
  font-size: 13px; font-weight: 500; color: var(--ink2); white-space: nowrap;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}

.signout-btn {
  padding: 5px 12px; border-radius: var(--rad);
  border: 1px solid var(--bdr2); background: var(--white);
  font-size: 12px; font-weight: 600; color: var(--ink2);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.signout-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-lt); }

/* ═══════════════════════════════════════════
   PAGE LAYOUT
═══════════════════════════════════════════ */
.page-wrap {
  max-width: 1100px; margin: 0 auto; padding: 32px 24px 80px;
}

.page-header { margin-bottom: 28px; }

.page-title {
  font-family: var(--serif); font-size: 28px; letter-spacing: -.02em;
  color: var(--ink); margin-bottom: 4px;
}

.page-sub {
  font-size: 13px; color: var(--ink2); line-height: 1.5;
}

/* ═══════════════════════════════════════════
   KPI CARDS
═══════════════════════════════════════════ */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 32px;
}

.kpi-card {
  background: var(--white); border: 1px solid var(--bdr);
  border-radius: var(--rad-lg); padding: 20px 22px;
  box-shadow: var(--sh);
}

.kpi-val {
  font-family: var(--serif); font-size: 36px; font-weight: 700;
  color: var(--ink); line-height: 1; margin-bottom: 6px;
}

.kpi-lbl {
  font-size: 11px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink3);
}

.kpi-delta {
  font-size: 11px; color: var(--grn); margin-top: 4px; font-weight: 600;
}

/* ═══════════════════════════════════════════
   TABS
═══════════════════════════════════════════ */
.tab-bar {
  display: flex; gap: 0; border-bottom: 1px solid var(--bdr);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 18px; border: none; border-bottom: 2px solid transparent;
  background: none; font-family: var(--sans); font-size: 13px; font-weight: 600;
  color: var(--ink3); cursor: pointer; transition: all .15s;
  margin-bottom: -1px;
}
.tab-btn:hover      { color: var(--ink2); }
.tab-btn.active     { color: var(--red); border-bottom-color: var(--red); }

.tab-panel          { display: none; }
.tab-panel.active   { display: block; animation: fadeIn .2s ease; }

/* ═══════════════════════════════════════════
   CARD / PANEL
═══════════════════════════════════════════ */
.panel {
  background: var(--white); border: 1px solid var(--bdr);
  border-radius: var(--rad-lg); overflow: hidden;
  box-shadow: var(--sh);
}

.panel-header {
  padding: 16px 20px; border-bottom: 1px solid var(--bdr);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.panel-title {
  font-size: 14px; font-weight: 700; color: var(--ink);
}

.panel-hint {
  font-size: 12px; color: var(--ink3);
}

/* ═══════════════════════════════════════════
   TABLES
═══════════════════════════════════════════ */
.tbl-scroll  { overflow-x: auto; }

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

th {
  padding: 10px 16px; text-align: left;
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink3);
  background: var(--paper); border-bottom: 1px solid var(--bdr);
  white-space: nowrap;
}

td {
  padding: 13px 16px; font-size: 13px; color: var(--ink2);
  border-bottom: 1px solid var(--bdr); vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td      { background: rgba(248,247,244,.6); }

.td-primary   { font-weight: 600; color: var(--ink); }
.td-mono      { font-family: 'Courier New', monospace; font-size: 12px; }
.td-actions   { display: flex; gap: 8px; align-items: center; }

/* ═══════════════════════════════════════════
   STATUS BADGE + SELECT
═══════════════════════════════════════════ */
.status-select {
  appearance: none; border: 1.5px solid var(--bdr); border-radius: 100px;
  background: var(--paper); padding: 4px 24px 4px 10px; font-size: 11px;
  font-weight: 700; cursor: pointer; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6' viewBox='0 0 8 6'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%238391a6' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  transition: border-color .15s;
}
.status-select:focus { border-color: var(--red); }

.status-select.s-new        { color: var(--blue); background-color: var(--blue-lt); border-color: #c3d9ff; }
.status-select.s-contacted  { color: var(--amb);  background-color: var(--amb-lt);  border-color: #f5d9b8; }
.status-select.s-matched    { color: var(--grn);  background-color: var(--grn-lt);  border-color: #b8e4d0; }
.status-select.s-converted  { color: var(--grn);  background-color: var(--grn-lt);  border-color: #b8e4d0; font-weight: 800; }
.status-select.s-no_answer  { color: var(--ink3); background-color: var(--paper);   border-color: var(--bdr); }
.status-select.s-cancelled  { color: var(--ink3); background-color: var(--paper);   border-color: var(--bdr); }

.bdg {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: 100px; font-size: 10px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}
.bdg-grn  { background: var(--grn-lt); color: var(--grn); }
.bdg-amb  { background: var(--amb-lt); color: var(--amb); }
.bdg-red  { background: var(--red-lt); color: var(--red); }
.bdg-blue { background: var(--blue-lt); color: var(--blue); }
.bdg-gray { background: var(--paper); color: var(--ink3); border: 1px solid var(--bdr); }

/* outcome badge mapping */
.outcome-interested    { background: var(--grn-lt);  color: var(--grn); }
.outcome-not_interested{ background: var(--red-lt);  color: var(--red); }
.outcome-voicemail     { background: var(--amb-lt);  color: var(--amb); }
.outcome-no_answer     { background: var(--paper);   color: var(--ink3); border: 1px solid var(--bdr); }

/* ═══════════════════════════════════════════
   FORMS (shared)
═══════════════════════════════════════════ */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; margin-bottom: 16px;
}

.form-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

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

.fg   { display: flex; flex-direction: column; gap: 5px; }
.fl   { font-size: 11px; font-weight: 700; color: var(--ink2); letter-spacing: .04em; }
.fl-req { color: var(--red); }

.fi {
  height: 42px; background: var(--paper);
  border: 1.5px solid var(--bdr); border-radius: var(--rad);
  padding: 0 12px; font-family: var(--sans); font-size: 13px; color: var(--ink);
  outline: none; width: 100%; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.fi::placeholder { color: var(--ink3); }
.fi:focus        { border-color: var(--red); box-shadow: 0 0 0 3px rgba(200,40,30,.08); background: var(--white); }
.fi.err          { border-color: var(--red); background: var(--red-lt); }

textarea.fi { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }

select.fi {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238391a6' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
select.fi option { background: #fff; }

.f-err { font-size: 11px; color: var(--red); display: none; }
.fg.has-err .f-err { display: block; }
.fg.has-err .fi    { border-color: var(--red); background: var(--red-lt); }

/* ═══════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--rad); border: none;
  font-family: var(--sans); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all .15s; white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--red); color: #fff;
  box-shadow: 0 3px 12px rgba(200,40,30,.28);
}
.btn-primary:hover:not(:disabled) { background: var(--red-h); transform: translateY(-1px); }

.btn-secondary {
  background: var(--white); color: var(--ink2);
  border: 1px solid var(--bdr2);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--ink2); color: var(--ink); }

.btn-ghost {
  background: none; color: var(--ink3); border: none; padding: 6px 10px;
  font-size: 12px;
}
.btn-ghost:hover { color: var(--red); }

.btn-danger {
  background: var(--white); color: var(--red);
  border: 1px solid rgba(200,40,30,.25);
  font-size: 12px; padding: 6px 12px;
}
.btn-danger:hover:not(:disabled) { background: var(--red-lt); border-color: var(--red); }

/* ═══════════════════════════════════════════
   LOG FORM PANEL
═══════════════════════════════════════════ */
.log-form-panel {
  background: var(--white); border: 1px solid var(--bdr);
  border-radius: var(--rad-lg); padding: 24px 28px;
  margin-bottom: 24px; box-shadow: var(--sh);
}

.log-form-title {
  font-size: 15px; font-weight: 700; color: var(--ink);
  margin-bottom: 18px;
}

.log-form-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px;
}

/* ═══════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════ */
.empty-state {
  padding: 52px 24px; text-align: center;
}

.empty-icon  { font-size: 36px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty-sub   { font-size: 13px; color: var(--ink3); line-height: 1.6; max-width: 340px; margin: 0 auto; }

/* ═══════════════════════════════════════════
   ALERT / TOAST
═══════════════════════════════════════════ */
.alert {
  padding: 12px 16px; border-radius: var(--rad);
  font-size: 13px; line-height: 1.5; margin-bottom: 20px;
}
.alert-err  { background: var(--red-lt); color: var(--red); border: 1px solid rgba(200,40,30,.2); }
.alert-info { background: var(--blue-lt); color: var(--blue); border: 1px solid #c3d9ff; }
.alert-warn { background: var(--amb-lt); color: var(--amb); border: 1px solid #f5d9b8; }

/* ═══════════════════════════════════════════
   REPORT PAGE
═══════════════════════════════════════════ */
.report-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px;
}

.report-entry {
  background: var(--white); border: 1px solid var(--bdr);
  border-radius: var(--rad-lg); padding: 20px 22px;
  box-shadow: var(--sh);
}

.report-entry-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}

.report-dentist-name {
  font-size: 15px; font-weight: 700; color: var(--ink);
}

.report-dentist-practice {
  font-size: 12px; color: var(--ink3); margin-top: 2px;
}

.report-field { margin-bottom: 8px; }
.report-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink3); margin-bottom: 2px; }
.report-value { font-size: 13px; color: var(--ink2); line-height: 1.5; }

/* ═══════════════════════════════════════════
   LOADING SPINNER
═══════════════════════════════════════════ */
.spinner-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 48px 24px; gap: 10px; color: var(--ink3); font-size: 13px;
}

.spinner {
  width: 18px; height: 18px; border: 2px solid var(--bdr);
  border-top-color: var(--red); border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   MODAL (edit cold call)
═══════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(13,17,23,.45);
  z-index: 900; display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fadeIn .2s ease;
}

.modal-card {
  background: var(--white); border-radius: var(--rad-lg);
  box-shadow: var(--sh-lg); width: 100%; max-width: 500px;
  animation: fadeUp .25s ease;
}

.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--bdr);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 15px; font-weight: 700; color: var(--ink); }

.modal-close {
  background: none; border: none; cursor: pointer; color: var(--ink3);
  font-size: 20px; line-height: 1; padding: 0; transition: color .15s;
}
.modal-close:hover { color: var(--ink); }

.modal-body    { padding: 20px 24px; }
.modal-footer  { padding: 16px 24px; border-top: 1px solid var(--bdr); display: flex; justify-content: flex-end; gap: 10px; }

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 900px) {
  .kpi-grid    { grid-template-columns: repeat(2, 1fr); }
  .report-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .admin-nav         { padding: 0 16px; gap: 12px; }
  .admin-nav-links   { display: none; }
  .user-name         { display: none; }
  .page-wrap         { padding: 20px 16px 60px; }
  .kpi-grid          { grid-template-columns: 1fr 1fr; }
  .form-grid         { grid-template-columns: 1fr; }
  .form-grid-3       { grid-template-columns: 1fr; }
  .log-form-panel    { padding: 18px; }
}

@media (max-width: 480px) {
  .login-card        { padding: 28px 22px; }
  .kpi-grid          { grid-template-columns: 1fr 1fr; }
  .modal-card        { max-width: 100%; }
}
