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

:root {
  --black: #000000;
  --near-black: #080808;
  --surface-1: #0d0d0d;
  --surface-2: #111111;
  --surface-3: #161616;
  --surface-4: #1c1c1c;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.14);
  --white: #ffffff;
  --grey-1: #d4d4d4;
  --grey-2: #9a9a9a;
  --grey-3: #5a5a5a;
  --grey-4: #2a2a2a;
  --accent: #ff6a3d;
  --accent-dim: rgba(255,106,61,0.12);
  --st-new: #6a6a6a;
  --st-noanswer: #8a8a8a;
  --st-voicemail: #d9a441;
  --st-interested: #ff6a3d;
  --st-notinterested: #8a5257;
  --st-booked: #3ecf8e;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

html { font-size: 16px; }

body {
  background: var(--black);
  color: var(--grey-1);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, select, input, textarea { font-family: inherit; }
button { cursor: pointer; }

/* progress rail (dashboard) */
#progress-rail { position: fixed; top: 0; left: 0; height: 2px; background: var(--accent); z-index: 200; transition: width 0.5s ease; }

/* ============================================================
   TOPBAR (shared: dashboard + admin)
============================================================ */
#topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
  padding: 1.1rem 2rem;
  background: rgba(0,0,0,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.logo-img { height: 28px; width: auto; object-fit: contain; }
.topbar-title { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--grey-2); border-left: 1px solid var(--border-strong); padding-left: 1rem; }
.topbar-right { display: flex; align-items: center; gap: 1.25rem; }
.topbar-date { font-size: 0.85rem; color: var(--grey-3); }
.topbar-stat { font-size: 0.85rem; color: var(--grey-1); font-weight: 500; }
.topbar-stat strong { color: var(--white); font-weight: 700; }
.topbar-user { font-size: 0.8rem; color: var(--grey-3); }
.topbar-user strong { color: var(--grey-1); font-weight: 600; }
.reset-btn, .text-link-btn { font-size: 0.78rem; color: var(--grey-3); border: 1px solid var(--grey-4); border-radius: var(--radius-sm); padding: 0.4rem 0.85rem; background: none; transition: border-color var(--transition), color var(--transition); }
.reset-btn:hover, .text-link-btn:hover { color: var(--grey-1); border-color: var(--grey-2); }

.container { max-width: 1180px; margin: 0 auto; padding: 0 2rem; }

/* ============================================================
   LOGIN SCREEN
============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.25rem;
  text-align: center;
}
.login-logo { height: 34px; width: auto; margin: 0 auto 1.75rem; }
.login-card h1 { font-size: 1.15rem; font-weight: 700; color: var(--white); margin-bottom: 0.4rem; }
.login-card .login-sub { font-size: 0.85rem; color: var(--grey-3); margin-bottom: 2rem; }
.form-field { text-align: left; margin-bottom: 1.1rem; }
.form-field label { display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--grey-3); margin-bottom: 0.5rem; }
.form-field input[type="text"],
.form-field input[type="password"] {
  width: 100%; background: var(--surface-1); border: 1px solid var(--border-strong); color: var(--white);
  border-radius: var(--radius-sm); padding: 0.75rem 1rem; font-size: 0.92rem; transition: border-color var(--transition);
}
.form-field input:focus { outline: none; border-color: var(--grey-2); }
.form-error {
  display: none;
  background: rgba(138,82,87,0.15); border: 1px solid rgba(138,82,87,0.4); color: #e79aa0;
  font-size: 0.8rem; border-radius: var(--radius-sm); padding: 0.65rem 0.9rem; margin-bottom: 1.1rem; text-align: left;
}
.btn-block {
  width: 100%; display: inline-flex; align-items: center; justify-content: center;
  padding: 0.85rem 1rem; background: var(--white); color: var(--black);
  font-size: 0.9rem; font-weight: 700; border-radius: var(--radius-sm); border: none;
  transition: background var(--transition), color var(--transition), transform 0.2s ease;
}
.btn-block:hover { background: var(--accent); color: var(--white); transform: translateY(-1px); }
.login-hint { margin-top: 1.75rem; font-size: 0.74rem; color: var(--grey-4); line-height: 1.6; }

/* ============================================================
   SUMMARY / FILTER BAR (dashboard)
============================================================ */
.summary-bar { display: flex; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; margin: 2rem 0 1.75rem; }
.summary-cell { flex: 1; background: var(--surface-2); padding: 1.25rem 1.5rem; }
.summary-num { font-size: 1.9rem; font-weight: 800; color: var(--white); letter-spacing: -0.03em; line-height: 1; }
.summary-num.accent { color: var(--accent); }
.summary-num.booked { color: var(--st-booked); }
.summary-label { font-size: 0.72rem; color: var(--grey-3); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 0.5rem; font-weight: 500; }

.filter-bar { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.5rem; }
.filter-search { flex: 1; min-width: 200px; position: relative; }
.filter-search input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--white);
  border-radius: var(--radius-sm); padding: 0.7rem 1rem; font-size: 0.9rem; transition: border-color var(--transition);
}
.filter-search input:focus { outline: none; border-color: var(--grey-2); }
.filter-search input::placeholder { color: var(--grey-3); }
.filter-select {
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--grey-1);
  border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; font-size: 0.85rem; cursor: pointer; transition: border-color var(--transition);
}
.filter-select:focus { outline: none; border-color: var(--grey-2); }

.queue-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.queue-heading h1 { font-size: 1.05rem; font-weight: 700; color: var(--white); letter-spacing: -0.01em; }
.queue-heading span { font-size: 0.8rem; color: var(--grey-3); }

/* ============================================================
   LEAD LIST (dashboard)
============================================================ */
.lead-list { display: flex; flex-direction: column; gap: 0.65rem; padding-bottom: 4rem; }

.lead-card {
  position: relative;
  display: grid;
  grid-template-columns: 3px 1.6fr 1fr 1.3fr auto;
  align-items: center;
  gap: 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.4rem 1.1rem 0;
  transition: border-color var(--transition), background var(--transition);
}
.lead-card:hover { border-color: var(--border-strong); background: var(--surface-3); }
.lead-card.is-done { opacity: 0.55; }

.heat-bar { align-self: stretch; border-radius: 3px; background: var(--grey-4); }
.heat-bar.heat-hot { background: var(--accent); }
.heat-bar.heat-warm { background: var(--grey-2); }
.heat-bar.heat-cold { background: var(--grey-4); }

.lead-main { min-width: 0; }
.lead-name-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
.lead-name { font-size: 1rem; font-weight: 600; color: var(--white); }
.industry-tag { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--grey-3); background: var(--surface-4); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0.2rem 0.5rem; }
.lead-flags { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.flag-pill { font-size: 0.72rem; color: var(--grey-2); background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 20px; padding: 0.18rem 0.65rem; }
.flag-pill.flag-warn { color: var(--accent); border-color: rgba(255,106,61,0.3); background: var(--accent-dim); }

.lead-contact { font-size: 0.85rem; color: var(--grey-2); }
.lead-phone { display: block; font-size: 0.98rem; font-weight: 600; color: var(--white); margin-bottom: 0.2rem; transition: color var(--transition); }
.lead-phone:hover { color: var(--accent); }
.lead-city { font-size: 0.8rem; color: var(--grey-3); }

.lead-controls { display: flex; flex-direction: column; gap: 0.5rem; }
.status-select {
  appearance: none;
  font-size: 0.8rem; font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0.5rem 2rem 0.5rem 0.8rem;
  border: 1px solid var(--border-strong);
  background-color: var(--surface-4);
  color: var(--grey-1);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a5a5a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}
.status-select:focus { outline: none; border-color: var(--grey-2); }
.notes-toggle { font-size: 0.72rem; color: var(--grey-3); text-align: left; background: none; border: none; transition: color var(--transition); }
.notes-toggle:hover { color: var(--grey-1); }

.lead-actions { display: flex; align-items: center; }
.call-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.65rem 1.1rem; background: var(--white); color: var(--black);
  font-size: 0.82rem; font-weight: 700; border-radius: var(--radius-sm);
  transition: background var(--transition), transform 0.2s ease;
  white-space: nowrap;
}
.call-btn:hover { background: var(--accent); color: var(--white); transform: translateY(-2px); }

.notes-panel { grid-column: 1 / -1; display: none; padding: 0.9rem 1.4rem 0.2rem 1.4rem; margin-left: 3px; }
.notes-panel.open { display: block; }
.notes-panel textarea {
  width: 100%; min-height: 64px; resize: vertical;
  background: var(--surface-1); border: 1px solid var(--border-strong); color: var(--grey-1);
  border-radius: var(--radius-sm); padding: 0.65rem 0.85rem; font-size: 0.85rem; line-height: 1.5;
}
.notes-panel textarea:focus { outline: none; border-color: var(--grey-2); }
.notes-panel .notes-saved { font-size: 0.7rem; color: var(--grey-3); margin-top: 0.35rem; }

.empty-state { text-align: center; padding: 5rem 1rem; color: var(--grey-3); }
.empty-state h3 { color: var(--grey-1); font-size: 1.1rem; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.88rem; }

.page-footer { border-top: 1px solid var(--border); padding: 1.75rem 0 3rem; text-align: center; }
.page-footer p { font-size: 0.78rem; color: var(--grey-4); }

/* ============================================================
   ADMIN PANEL
============================================================ */
.admin-grid { display: grid; grid-template-columns: 380px 1fr; gap: 1.5rem; align-items: start; margin: 2rem 0 4rem; }

.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.75rem; }
.panel h2 { font-size: 0.95rem; font-weight: 700; color: var(--white); margin-bottom: 1.4rem; }

.check-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.25rem; }
.check-pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.78rem; color: var(--grey-2);
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 0.4rem 0.8rem 0.4rem 0.6rem; cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.check-pill:has(input:checked) { color: var(--white); border-color: var(--accent); }
.check-pill input { accent-color: var(--accent); }

.lead-checklist { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.35rem; padding-right: 0.25rem; }
.check-row { display: flex; align-items: center; gap: 0.6rem; font-size: 0.82rem; color: var(--grey-2); padding: 0.4rem 0.5rem; border-radius: var(--radius-sm); transition: background var(--transition); }
.check-row:hover { background: var(--surface-3); }
.check-row input { accent-color: var(--accent); flex-shrink: 0; }
.check-row em { font-style: normal; color: var(--grey-4); margin-left: 0.3rem; }

.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.btn-primary-inline {
  flex: 1; display: inline-flex; align-items: center; justify-content: center;
  padding: 0.75rem 1rem; background: var(--white); color: var(--black);
  font-size: 0.85rem; font-weight: 700; border-radius: var(--radius-sm); border: none;
  transition: background var(--transition), color var(--transition);
}
.btn-primary-inline:hover { background: var(--accent); color: var(--white); }
.btn-secondary-inline {
  display: none;
  padding: 0.75rem 1rem; background: none; color: var(--grey-3);
  font-size: 0.85rem; font-weight: 600; border-radius: var(--radius-sm); border: 1px solid var(--grey-4);
  transition: border-color var(--transition), color var(--transition);
}
.btn-secondary-inline:hover { color: var(--grey-1); border-color: var(--grey-2); }

.caller-list { display: flex; flex-direction: column; gap: 0.85rem; }
.caller-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem 1.5rem; }
.caller-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.85rem; }
.caller-name { font-size: 0.98rem; font-weight: 700; color: var(--white); }
.caller-pass { font-size: 0.78rem; color: var(--grey-3); margin-top: 0.25rem; }
.caller-pass code { color: var(--grey-1); background: var(--surface-3); border-radius: 4px; padding: 0.1rem 0.4rem; }
.caller-card-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.mini-btn { font-size: 0.74rem; font-weight: 600; color: var(--grey-2); background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0.4rem 0.75rem; transition: border-color var(--transition), color var(--transition); }
.mini-btn:hover { color: var(--white); border-color: var(--grey-2); }
.mini-btn.danger:hover { color: #e79aa0; border-color: #8a5257; }
.caller-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.empty-note { font-size: 0.85rem; color: var(--grey-3); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 980px) {
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .lead-card { grid-template-columns: 3px 1fr; grid-template-areas: "bar main" "bar contact" "bar controls" "bar actions"; row-gap: 0.75rem; padding: 1.1rem; }
  .heat-bar { grid-area: bar; }
  .lead-main { grid-area: main; }
  .lead-contact { grid-area: contact; }
  .lead-controls { grid-area: controls; flex-direction: row; align-items: center; justify-content: space-between; }
  .lead-actions { grid-area: actions; }
  .call-btn { width: 100%; justify-content: center; }
  .notes-panel { margin-left: 0; padding: 0 1.1rem 1.1rem; }
}

@media (max-width: 640px) {
  #topbar { padding: 1rem 1.25rem; }
  .topbar-title { display: none; }
  .container { padding: 0 1.25rem; }
  .summary-bar { flex-wrap: wrap; }
  .summary-cell { flex: 1 1 50%; }
  .caller-card-head { flex-direction: column; }
}
