/* ============================================================
   Armstrong Family & Divorce Law — Internal Dashboard (demo)
   Premium dark theme, plum + gold accents. Playfair + Lato.
   ============================================================ */

:root {
  --plum:        #b85a8a;          /* lighter plum for text on dark */
  --plum-mid:    #9b4470;
  --plum-deep:   #7B2D52;          /* brand primary */
  --plum-dark:   #5A1F3B;
  --plum-soft:   rgba(184,90,138,0.14);
  --plum-line:   rgba(184,90,138,0.32);

  --gold:        #C9A037;
  --gold-light:  #D4B870;
  --gold-soft:   rgba(201,160,55,0.14);

  --bg:          #150a10;
  --bg-2:        #1c0f17;
  --bg-card:     #23141e;
  --bg-card-2:   #2c1927;
  --bg-hover:    #331c2c;

  --line:        rgba(255,255,255,0.06);
  --line-2:      rgba(255,255,255,0.10);

  --text:        rgba(255,255,255,0.95);
  --text-soft:   rgba(255,255,255,0.72);
  --text-dim:    rgba(255,255,255,0.50);
  --text-faint:  rgba(255,255,255,0.30);

  --success:     #4ade80;  --success-bg: rgba(74,222,128,0.14);
  --warn:        #fbbf24;   --warn-bg:    rgba(251,191,36,0.14);
  --rose:        #fb7185;   --rose-bg:    rgba(251,113,133,0.14);
  --info:        #60a5fa;   --info-bg:    rgba(96,165,250,0.14);
  --purple:      #c084fc;   --purple-bg:  rgba(192,132,252,0.14);
  --teal:        #2dd4bf;   --teal-bg:    rgba(45,212,191,0.14);

  --radius:      12px;
  --radius-sm:   7px;
  --radius-lg:   16px;
  --shadow-lg:   0 24px 60px rgba(0,0,0,0.5);

  --sidebar-w:   240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--text-faint); }
a { color: var(--gold-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================== Login ===================== */
#login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 25% 18%, rgba(184,90,138,0.16), transparent 55%),
    radial-gradient(circle at 78% 88%, rgba(123,45,82,0.40), transparent 65%),
    var(--bg);
  padding: 24px;
}
.login-card {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-top: 3px solid var(--plum-deep);
  border-radius: var(--radius-lg);
  padding: 44px 38px 30px;
  width: 430px; max-width: 92vw;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-mark {
  width: 56px; height: 56px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--plum-deep), var(--plum-dark));
  color: #fff; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', serif; font-weight: 800; font-size: 26px;
  box-shadow: 0 6px 18px rgba(123,45,82,0.45);
}
.login-brand {
  font-family: 'Playfair Display', serif;
  font-size: 22px; color: var(--text);
  margin-bottom: 2px; letter-spacing: -0.3px;
}
.login-brand b { color: var(--gold); font-weight: 700; }
.login-card h1 { font-family: 'Playfair Display', serif; font-size: 19px; font-weight: 700; color: var(--text-soft); margin: 10px 0 4px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 24px; }
.login-card input {
  width: 100%; padding: 13px 15px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: inherit;
  margin-bottom: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input::placeholder { color: var(--text-faint); }
.login-card input:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px rgba(184,90,138,0.18); }
.login-card button {
  width: 100%; padding: 13px;
  background: var(--plum-deep); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px; letter-spacing: 0.3px;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.login-card button:hover { background: var(--plum-mid); }
.error { color: var(--rose); font-size: 13px; margin-top: 6px; }
.login-demo {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text-dim); line-height: 1.7;
}
.login-demo code {
  background: rgba(255,255,255,0.06); color: var(--gold-light);
  padding: 2px 7px; border-radius: 5px; font-size: 11.5px;
  font-family: 'SF Mono', Menlo, monospace; cursor: pointer;
}
.login-demo code:hover { background: rgba(255,255,255,0.12); }

/* ===================== App layout ===================== */
#app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
header {
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, #2a1320 0%, #1c0d15 100%);
  border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
}
.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 6px 18px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.brand-mark {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--plum-deep), var(--plum-dark)); color: #fff;
  font-family: 'Playfair Display', serif; font-weight: 800; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(123,45,82,0.4);
}
.brand-row h1 { font-family: 'Playfair Display', serif; font-size: 17px; font-weight: 700; margin: 0; line-height: 1.05; }
.brand-sub { font-size: 9.5px; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 1.4px; margin: 4px 0 0; }

.tabs { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.tab {
  display: flex; align-items: center; gap: 11px;
  background: transparent; color: var(--text-soft);
  border: none; padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  cursor: pointer; text-align: left;
  transition: all 0.15s; border-left: 3px solid transparent; margin-left: -3px;
}
.tab::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.45; flex-shrink: 0; }
.tab:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.tab.active { background: var(--plum-soft); color: #e6a9c6; border-left-color: var(--plum-deep); }
.tab.active::before { opacity: 1; }
.tab-admin { display: none; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.user-chip {
  display: block; padding: 10px 12px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text-soft);
  font-size: 12px; margin-bottom: 8px; word-break: break-word;
}
.foot-actions { display: flex; gap: 8px; }
.btn-icon {
  background: rgba(255,255,255,0.04); color: var(--text);
  border: 1px solid var(--line); padding: 9px;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  font-family: inherit; cursor: pointer; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.btn-icon:hover { background: var(--plum-soft); border-color: var(--plum-line); color: var(--plum); }
.btn-ghost {
  flex: 1; background: transparent; color: var(--text-dim);
  border: 1px solid var(--line); padding: 9px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); border-color: var(--line-2); }

/* ===================== Panes ===================== */
.tab-pane { display: none; padding: 26px 32px 48px; }
.tab-pane.active { display: block; }

/* ===================== Stats ===================== */
.stats-bar { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; margin-bottom: 24px; }
.stat-box {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; position: relative; overflow: hidden;
  transition: border-color 0.18s, transform 0.18s;
}
.stat-box::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: 0; transition: opacity 0.2s; }
.stat-box:hover { border-color: var(--plum-line); transform: translateY(-1px); }
.stat-box:hover::before { opacity: 1; }
.stat-value { font-family: 'Playfair Display', serif; font-size: 28px; font-weight: 800; color: var(--gold); line-height: 1; letter-spacing: -0.5px; }
.stat-label { color: var(--text-dim); font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; margin-top: 7px; font-weight: 700; }
@media (max-width: 1400px) { .stats-bar { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 760px) { .stats-bar { grid-template-columns: repeat(2, 1fr); } }

/* ===================== Filters ===================== */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filters input, .filters select {
  background: var(--bg-card); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 10px 14px; font-size: 13.5px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filters input { flex: 1; min-width: 240px; }
.filters select { min-width: 150px; cursor: pointer; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px rgba(184,90,138,0.16); }

/* ===================== Tables ===================== */
.table-wrap { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--bg-card-2); color: var(--text-soft); text-align: left;
  padding: 14px 18px; font-weight: 700;
  font-size: 10.5px; letter-spacing: 1.3px; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
tbody td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--text-soft); }
tbody tr { transition: background 0.12s; }
tbody tr:last-child td { border-bottom: none; }
#leads-table tbody tr, #calls-table tbody tr { cursor: default; }
#leads-table tbody tr { cursor: pointer; }
#leads-table tbody tr:hover { background: var(--bg-hover); }
td a { color: var(--gold-light); }

/* ===================== Badges ===================== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 99px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; white-space: nowrap; }
.badge-form     { background: var(--teal-bg);    color: var(--teal); }
.badge-chat     { background: var(--gold-soft);  color: var(--gold-light); }
.badge-voice    { background: var(--purple-bg);  color: var(--purple); }
.badge-meta     { background: var(--info-bg);    color: var(--info); }
.badge-ppc      { background: var(--warn-bg);    color: var(--warn); }
.badge-tools    { background: var(--plum-soft);  color: var(--plum); }
.badge-en       { background: rgba(255,255,255,0.07); color: var(--text-soft); }
.badge-es       { background: var(--warn-bg);    color: var(--warn); }
.badge-new      { background: var(--info-bg);    color: var(--info); }
.badge-contacted{ background: var(--warn-bg);    color: var(--warn); }
.badge-qualified{ background: var(--gold-soft);  color: var(--gold-light); }
.badge-retained { background: var(--success-bg); color: var(--success); }
.badge-lost     { background: var(--rose-bg);    color: var(--rose); }

.status-select, .assign-select {
  background: rgba(255,255,255,0.04); border: 1px solid var(--line-2); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: 12px; font-family: inherit;
  cursor: pointer; transition: border-color 0.15s;
}
.status-select:hover, .assign-select:hover { border-color: var(--plum); }
.assign-select { min-width: 130px; }

#no-leads, #loading, #calls-loading, #no-calls { padding: 56px 20px; text-align: center; color: var(--text-dim); font-size: 13.5px; }

/* ===================== Detail drawer ===================== */
#modal-overlay { position: fixed; inset: 0; background: rgba(8,4,7,0.66); backdrop-filter: blur(4px); z-index: 100; display: flex; justify-content: flex-end; animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; } }
#modal {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-2) 100%);
  border-left: 1px solid var(--line); width: 640px; max-width: 100%;
  height: 100vh; overflow-y: auto; position: relative; padding: 32px 36px;
  box-shadow: -16px 0 50px rgba(0,0,0,0.5); animation: slideIn 0.22s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
#modal-close { position: absolute; top: 18px; right: 22px; background: transparent; border: none; color: var(--text-dim); font-size: 28px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); transition: all 0.15s; }
#modal-close:hover { background: var(--bg-hover); color: var(--plum); }
#modal h2 { font-family: 'Playfair Display', serif; font-size: 25px; font-weight: 700; margin: 0 0 6px; color: var(--text); padding-right: 50px; }
#modal .meta-row { color: var(--text-dim); font-size: 12px; margin: 0 0 22px; }
.detail-row { display: grid; grid-template-columns: 140px 1fr; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-faint); font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; padding-top: 2px; font-weight: 700; }
.detail-value { color: var(--text); }
.detail-value code { font-family: 'SF Mono', Menlo, monospace; font-size: 12px; color: var(--text-soft); word-break: break-all; }
.modal-section-title { margin: 24px 0 12px; font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.transcript-box, .audit-list { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.65; max-height: 280px; overflow-y: auto; }
.transcript-box { padding: 14px 16px; white-space: pre-wrap; color: var(--text-soft); }
.audit-row { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 12.5px; display: flex; justify-content: space-between; gap: 12px; color: var(--text-soft); }
.audit-row:last-child { border-bottom: none; }
.audit-time { color: var(--text-faint); font-size: 11px; white-space: nowrap; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.modal-actions select, .modal-actions textarea { background: var(--bg); border: 1px solid var(--line-2); color: var(--text); padding: 9px 13px; border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; }
.modal-actions textarea { flex: 1 1 100%; min-width: 220px; resize: vertical; min-height: 70px; }
.modal-actions button { background: var(--plum-deep); color: #fff; border: none; padding: 9px 22px; border-radius: var(--radius-sm); font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; transition: background 0.15s; }
.modal-actions button:hover { background: var(--plum-mid); }

/* ===================== Reports ===================== */
.reports-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.reports-toolbar h2 { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; color: var(--text); margin: 0; }
.reports-toolbar select, .reports-toolbar button { background: var(--bg-card); color: var(--text); border: 1px solid var(--line-2); padding: 9px 16px; border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; cursor: pointer; }
.reports-toolbar select:hover { border-color: var(--plum); }
.reports-toolbar button { background: var(--plum-deep); color: #fff; border-color: var(--plum-deep); font-weight: 700; }
.reports-toolbar button:hover { background: var(--plum-mid); }
.report-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
.kpi { background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-2) 100%); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; position: relative; overflow: hidden; transition: border-color 0.18s; }
.kpi:hover { border-color: var(--plum-line); }
.kpi .v { font-family: 'Playfair Display', serif; font-size: 30px; font-weight: 800; color: var(--gold); line-height: 1; letter-spacing: -0.5px; }
.kpi .l { color: var(--text-dim); font-size: 10.5px; letter-spacing: 1.3px; text-transform: uppercase; margin-top: 8px; font-weight: 700; }
.kpi .s { color: var(--text-faint); font-size: 12px; margin-top: 6px; }
@media (max-width: 1240px) { .report-grid { grid-template-columns: repeat(2, 1fr); } }
.report-panel { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.report-panel h3 { margin: 0; padding: 15px 22px; font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-soft); border-bottom: 1px solid var(--line); font-weight: 800; background: var(--bg-card-2); }
.report-panel .body { padding: 20px 22px; }
.report-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .report-cols { grid-template-columns: 1fr; } }
.bar-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; font-size: 13px; }
.bar-row .label { flex: 0 0 190px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.bar-row .bar { flex: 1; height: 8px; background: rgba(255,255,255,0.05); border-radius: 99px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: linear-gradient(90deg, var(--plum-deep), var(--plum)); border-radius: 99px; transition: width 0.4s ease; }
.bar-row .count { flex: 0 0 52px; text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; font-weight: 700; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 130px; margin: 0 4px 8px; }
.spark-col { flex: 1; background: linear-gradient(180deg, var(--gold) 0%, var(--plum-deep) 100%); border-radius: 3px 3px 0 0; min-height: 3px; position: relative; cursor: pointer; transition: opacity 0.15s; }
.spark-col:hover { opacity: 0.8; }
.spark-col::after { content: attr(data-tip); position: absolute; bottom: 108%; left: 50%; transform: translateX(-50%); background: var(--plum-dark); color: #fff; padding: 5px 10px; border-radius: 4px; font-size: 11px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.15s; z-index: 5; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.spark-col:hover::after { opacity: 1; }
.spark-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-faint); padding: 0 4px; }
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-step { display: flex; align-items: center; gap: 16px; padding: 12px 16px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color 0.15s; }
.funnel-step:hover { border-color: var(--plum-line); }
.funnel-step .n { font-family: 'Playfair Display', serif; font-size: 24px; color: var(--gold); font-weight: 800; min-width: 64px; letter-spacing: -0.5px; }
.funnel-step .name { flex: 1; color: var(--text); font-weight: 700; }
.funnel-step .pct { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ===================== Users ===================== */
#invite-result { color: var(--text-dim); font-size: 13px; margin-top: 18px; }
#invite-result code { background: rgba(255,255,255,0.06); padding: 3px 9px; border-radius: 4px; font-family: 'SF Mono', Menlo, monospace; font-size: 12px; color: var(--gold-light); }

/* ===================== Responsive ===================== */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }
  #app { grid-template-columns: 60px 1fr; }
  header { padding: 16px 6px; }
  .brand-row h1, .brand-sub, .user-chip, .btn-ghost { display: none; }
  .brand-row { justify-content: center; padding: 0 0 14px; }
  .tab { justify-content: center; padding: 12px 0; font-size: 0; }
  .tab::before { width: 9px; height: 9px; }
  .foot-actions { flex-direction: column; }
  .tab-pane { padding: 18px 16px 32px; }
}
