* { box-sizing: border-box; }

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c2430;
  --dim: #6b7684;
  --border: #dde2e9;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --purple: #7c3aed;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

main { padding: 16px 20px 60px; max-width: 1500px; margin: 0 auto; }

/* ---- nav ---- */
.topnav {
  display: flex; align-items: center; gap: 4px;
  background: #101827; color: #fff; padding: 0 20px;
}
.topnav .brand { font-weight: 700; margin-right: 20px; padding: 12px 0; }
.topnav a {
  color: #c3cad6; text-decoration: none; padding: 12px 14px;
}
.topnav a:hover { color: #fff; }
.topnav a.active { color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }
.nav-user { margin-left: auto; color: #c3cad6; font-size: 13px; padding: 12px 4px; }
.nav-user a { display: inline; padding: 0; color: #9db4e0; }
.nav-badge {
  display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 2px;
  border-radius: 9px; background: #e5484d; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 16px; text-align: center;
}

/* show/hide password toggle */
.pw-wrap { position: relative; display: inline-block; }
.pw-wrap input { padding-right: 30px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; padding: 0; margin: 0;
  font-size: 15px; line-height: 1; opacity: 0.75;
}
.pw-eye:hover { opacity: 1; }
.login-form .pw-wrap { display: block; }
.login-form .pw-wrap input { width: 100%; }

/* ---- users & access ---- */
.user-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 12px; }
.user-card .u-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-card .u-name { font-weight: 700; font-size: 15px; }
.u-meta { color: var(--dim); font-size: 12px; }
.u-actions { margin-left: auto; display: flex; gap: 6px; }
.u-actions form { display: inline; }
.u-usage { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid var(--border); }
.qbar { display: inline-block; width: 110px; height: 8px; border-radius: 5px;
  background: #eef1f5; overflow: hidden; vertical-align: middle; margin-left: 4px; }
.qbar > span { display: block; height: 100%; background: var(--accent); }
.chip { display: inline-block; background: #e3ecfd; color: var(--accent-dark);
  border-radius: 10px; padding: 2px 9px; font-size: 12px; margin: 2px 3px 0 0; }
details.u-edit { margin-top: 10px; }
details.u-edit > summary { cursor: pointer; color: var(--accent); font-size: 13px;
  list-style: none; display: inline-block; border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 11px; background: #fff; font-weight: 600; }
details.u-edit > summary:hover { background: #f0f3f7; }
details.u-edit[open] > summary { background: #e3ecfd; border-color: var(--accent); }
details.u-edit > summary::-webkit-details-marker { display: none; }
.u-edit-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  margin-top: 8px; padding: 12px; background: #f7f9fc; border-radius: 8px; }
details.add-user { margin-top: 12px; }
details.add-user > summary { list-style: none; }
details.add-user > summary::-webkit-details-marker { display: none; }

/* ---- help ---- */
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px; margin-top: 14px; }
.help-item { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px;
  background: #fbfcfe; }
.help-item h3 { margin: 0 0 6px; font-size: 14px; }
.help-item p { margin: 0; font-size: 13px; color: var(--text); line-height: 1.5; }

.login-wrap { display: flex; min-height: 90vh; align-items: center; justify-content: center; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px 36px; width: 340px; box-shadow: 0 8px 30px rgba(0,0,0,0.08); }
.login-card h1 { margin: 0 0 2px; font-size: 20px; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); }
.login-form input { padding: 9px 11px; }
.login-form button { margin-top: 6px; padding: 10px; }

/* ---- generic ---- */
h2 { margin: 0 0 12px; font-size: 16px; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.warn { color: var(--amber); font-size: 13px; }
.empty { color: var(--dim); padding: 40px; text-align: center; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; }

button, .button, select, input {
  font: inherit; color: inherit;
  border: 1px solid var(--border); border-radius: 6px;
  background: #fff; padding: 6px 10px;
}
a.button { text-decoration: none; display: inline-block; }
button:hover, .button:hover { background: #f0f3f7; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-dark); }
button.primary:disabled { background: #9db4e0; border-color: #9db4e0; cursor: not-allowed; }
button.danger { color: var(--red); }
button.danger:hover { background: #fdeaea; }

.badge { border-radius: 10px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.badge-hot { background: #fdeaea; color: var(--red); }
.badge-ok { background: #e5f6ec; color: var(--green); }

/* ---- toolbar / pull ---- */
.toolbar {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 14px;
}
.campaign-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.campaign-select select { font-weight: 600; color: var(--accent-dark); }
tr.active-campaign { background: #e3ecfd; }
.campaign-edit { gap: 5px !important; }
.campaign-edit input { font-size: 12px; padding: 3px 6px; }
.campaign-edit select { font-size: 12px; padding: 3px 4px; }
.pull-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#pull-industry { min-width: 170px; }
.add-industry-form { display: inline-flex; gap: 4px; align-items: center; margin-left: auto; }
.add-industry-form input { width: 150px; }
.add-industry-form button { padding: 6px 10px; }
.ind-checks {
  display: flex; gap: 2px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 4px;
  max-height: 96px; overflow-y: auto; max-width: 640px; align-content: flex-start;
}
.chk {
  display: inline-flex; gap: 5px; align-items: center;
  padding: 4px 9px; border-radius: 5px; cursor: pointer; user-select: none;
}
.chk:hover { background: #f0f3f7; }
.chk:has(input:checked) { background: #e3ecfd; color: var(--accent-dark); font-weight: 600; }
.chk input { accent-color: var(--accent); margin: 0; }
.chk-row { flex-direction: row !important; align-items: center; gap: 8px !important; }
.contact-line { color: var(--green); margin-top: 2px; }
.links { margin-top: 2px; display: flex; gap: 10px; }
.links a { color: var(--accent); }
.button.primary-outline { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.phone-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .03em;
  padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: middle; }
.phone-tag.ok { background: #e5f6ec; color: var(--green); }
.phone-tag.bad { background: #fdeaea; color: var(--red); font-weight: 700; }

.query-edit { display: inline-flex; gap: 4px; align-items: center; }
.query-edit input { font-size: 12px; padding: 3px 7px; width: 260px;
  font-family: ui-monospace, monospace; }
.query-edit button { font-size: 12px; padding: 3px 8px; }
#pull-target { width: 80px; }
.pull-controls .geo { width: 120px; }
/* :not([hidden]) so the `hidden` attribute (display:none) actually wins */
.pull-progress { margin-top: 10px; gap: 10px; align-items: center; color: var(--dim); }
.pull-progress:not([hidden]) { display: flex; }
[hidden] { display: none !important; }
.pull-result { margin-top: 10px; font-weight: 600; }
.pull-result.ok { color: var(--green); }
.pull-result.err { color: var(--red); }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- filters / stats ---- */
.filters {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form label { display: flex; gap: 6px; align-items: center; color: var(--dim); }
.current-pull { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  width: 100%; margin-bottom: 4px; }
.current-pull .pill { background: var(--accent); color: #fff; border-radius: 10px;
  padding: 2px 10px; font-size: 12px; font-weight: 600; }
.current-pull a { margin-left: auto; }
.stats { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stat { color: var(--dim); font-size: 13px; }
.stat strong { color: var(--text); }

/* ---- leads table ---- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
table.leads { width: 100%; border-collapse: collapse; }
table.leads th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--dim); padding: 10px 12px; border-bottom: 2px solid var(--border);
  position: sticky; top: 0; background: var(--card);
}
table.leads td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.leads tbody tr:hover { background: #f7f9fc; }
.hook { max-width: 340px; color: var(--dim); }
.score { font-weight: 700; }
.notes { width: 160px; font-size: 12px; }
.notes.saved { border-color: var(--green); }

tr.status-called td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.status-interested td:first-child { box-shadow: inset 3px 0 0 var(--green); }
tr.status-not_interested td:first-child { box-shadow: inset 3px 0 0 var(--red); }
tr.status-not_interested { opacity: 0.55; }
tr.status-callback td:first-child { box-shadow: inset 3px 0 0 var(--purple); }
tr.status-appointment td:first-child { box-shadow: inset 3px 0 0 #0891b2; }
tr.status-dnc { opacity: 0.4; }
tr.status-dnc td:first-child { box-shadow: inset 3px 0 0 #444; }
tr.status-dnc strong { text-decoration: line-through; }

.import-summary { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.import-summary ul { margin: 8px 0; padding-left: 20px; line-height: 1.7; }
.code-block { background: #f4f6f9; border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 12px; overflow-x: auto; white-space: pre; }

.status-buttons { display: flex; gap: 3px; }
.sbtn { padding: 3px 7px; font-size: 12px; border-radius: 5px; }
.sbtn.on { color: #fff; font-weight: 600; }
.sbtn-called.on { background: var(--accent); border-color: var(--accent); }
.sbtn-interested.on { background: var(--green); border-color: var(--green); }
.sbtn-not_interested.on { background: var(--red); border-color: var(--red); }
.sbtn-callback.on { background: var(--purple); border-color: var(--purple); }
.sbtn-appointment.on { background: #0891b2; border-color: #0891b2; }

/* ---- settings ---- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
}
.card.wide { grid-column: 1 / -1; }
.stack-form { display: flex; flex-direction: column; gap: 10px; max-width: 320px; margin-bottom: 14px; }
.stack-form label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); }
table.mini { width: 100%; border-collapse: collapse; margin-top: 12px; }
table.mini td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.actions { display: inline-flex; gap: 6px; }
.actions form { display: inline; }
.disabled-row { opacity: 0.5; }

.industry { border-top: 1px solid var(--border); padding: 12px 0; }
.industry-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; gap: 5px; align-items: center;
  background: #eef1f5; border-radius: 12px; padding: 3px 4px 3px 10px; font-size: 12px;
}
.chip button {
  border: none; background: none; padding: 0 5px; color: var(--dim); font-size: 14px; line-height: 1;
}
.chip button:hover { color: var(--red); background: none; }
.chip-add input { border: 1px dashed var(--border); font-size: 12px; padding: 3px 8px; width: 170px; }
.chip-add button { padding: 3px 8px; font-size: 12px; }
.api-status { border-top: 1px solid var(--border); padding-top: 12px; }

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

/* Clients / Campaigns pages */
table.data { width: 100%; border-collapse: collapse; margin-top: 12px; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
table.data th { color: var(--dim); font-weight: 600; }
table.data tr.dim td { opacity: 0.55; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.row-form input { padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; }
.stack-form { display: flex; flex-direction: column; gap: 10px; max-width: 460px; margin-top: 12px; }
.stack-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); }
.stack-form input, .stack-form select { padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: inherit; }
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
details.new-campaign { margin: 8px 0 4px; }
details.new-campaign > summary { display: inline-block; cursor: pointer; list-style: none; }
details.new-campaign > summary::-webkit-details-marker { display: none; }
