/* Lead Gen AI — operator dashboard stylesheet.
 *
 * Single CSS file, no JS dependency. Color tokens at top so a designer can
 * re-skin everything by editing the :root block. Strict CSP friendly:
 * no inline <style> blocks anywhere in the templates; everything routes
 * through this file via /dashboard/static/app.css.
 */
:root {
  --bg:           #f4f5f8;
  --bg-soft:      #eef0f5;
  --panel:        #ffffff;
  --panel-alt:    #fafbfd;
  --ink:          #14171f;
  --ink-soft:     #5b6271;
  --ink-faint:    #8a92a3;
  --line:         #e3e6ec;
  --line-soft:    #eef0f5;
  --accent:       #2451c9;
  --accent-soft:  #e6edff;
  --accent-deep:  #1a3da3;
  --ok:           #138a59;
  --ok-soft:      #d8efe3;
  --warn:         #a85e00;
  --warn-soft:    #fff0d2;
  --bad:          #b8302d;
  --bad-soft:     #fbdedd;
  --cat-A:        #6938a0;
  --cat-A-soft:   #ece2f6;
  --cat-B:        #1f4dbf;
  --cat-B-soft:   #dde6fb;
  --cat-C:        #a85e00;
  --cat-C-soft:   #fbe5c5;
  --cat-D:        #138a59;
  --cat-D-soft:   #d8efe3;
  --cat-E:        #4f5765;
  --cat-E-soft:   #e6e8ed;
  --shadow-sm:    0 1px 2px rgba(20, 23, 31, 0.04), 0 0 0 1px rgba(20, 23, 31, 0.04);
  --shadow-md:    0 4px 12px rgba(20, 23, 31, 0.06), 0 0 0 1px rgba(20, 23, 31, 0.04);
  --radius:       8px;
  --radius-sm:    5px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, #1c1f28 0%, #161922 100%);
  color: #d7d9e0;
  padding: 20px 0 40px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  padding: 0 20px 16px;
  border-bottom: 1px solid #2a2e3a;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.sidebar .brand small {
  display: block;
  font-weight: 400;
  color: #8a90a0;
  font-size: 11px;
  margin-top: 3px;
  letter-spacing: 0;
}
.sidebar .phase-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6a7081;
  padding: 16px 20px 4px;
  font-weight: 600;
}
.sidebar a.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 20px;
  color: #d7d9e0;
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.sidebar a.nav:hover {
  background: #232732;
  text-decoration: none;
  color: #ffffff;
}
.sidebar a.nav.active {
  background: #232732;
  border-left-color: var(--accent);
  color: #ffffff;
  font-weight: 500;
}
.sidebar a.nav .pill {
  font-size: 10px;
  background: #353a47;
  color: #b6bccc;
  padding: 1px 7px;
  border-radius: 8px;
  font-weight: 600;
}
.sidebar a.nav.active .pill {
  background: var(--accent);
  color: #ffffff;
}

.main {
  padding: 28px 36px 60px;
  max-width: 1280px;
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h2 {
  margin: 26px 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
h3 {
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.subtitle {
  color: var(--ink-soft);
  margin: 0 0 22px;
  font-size: 13px;
}

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 14px;
}
.panel h2:first-child { margin-top: 0; }

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
}
.kpi .value {
  font-size: 28px;
  font-weight: 600;
  margin-top: 2px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .sub {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 2px;
}
.kpi.accent-A { box-shadow: var(--shadow-sm), inset 4px 0 0 var(--cat-A); }
.kpi.accent-B { box-shadow: var(--shadow-sm), inset 4px 0 0 var(--cat-B); }
.kpi.accent-C { box-shadow: var(--shadow-sm), inset 4px 0 0 var(--cat-C); }
.kpi.accent-D { box-shadow: var(--shadow-sm), inset 4px 0 0 var(--cat-D); }
.kpi.accent-E { box-shadow: var(--shadow-sm), inset 4px 0 0 var(--cat-E); }
.kpi.accent-ok   { box-shadow: var(--shadow-sm), inset 4px 0 0 var(--ok); }
.kpi.accent-warn { box-shadow: var(--shadow-sm), inset 4px 0 0 var(--warn); }
.kpi.accent-bad  { box-shadow: var(--shadow-sm), inset 4px 0 0 var(--bad); }

/* CSS-only horizontal bar gauge inside a KPI */
.gauge {
  margin-top: 8px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-soft);
  overflow: hidden;
}
.gauge > span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.gauge.gauge-A > span { background: var(--cat-A); }
.gauge.gauge-B > span { background: var(--cat-B); }
.gauge.gauge-C > span { background: var(--cat-C); }
.gauge.gauge-D > span { background: var(--cat-D); }
.gauge.gauge-E > span { background: var(--cat-E); }

/* ---------- tables ---------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
th, td {
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
th {
  background: var(--panel-alt);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  position: sticky; top: 0;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafc; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.truncate {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--line-soft);
  color: var(--ink);
  line-height: 1.45;
  letter-spacing: 0.01em;
  vertical-align: baseline;
}
.badge.cat-A { background: var(--cat-A-soft); color: var(--cat-A); }
.badge.cat-B { background: var(--cat-B-soft); color: var(--cat-B); }
.badge.cat-C { background: var(--cat-C-soft); color: var(--cat-C); }
.badge.cat-D { background: var(--cat-D-soft); color: var(--cat-D); }
.badge.cat-E { background: var(--cat-E-soft); color: var(--cat-E); }
.badge.discard,
.badge.status-discarded,
.badge.status-rejected,
.badge.status-failed { background: var(--bad-soft); color: var(--bad); }
.badge.status-new,
.badge.status-cancelled { background: var(--line-soft); color: var(--ink-soft); }
.badge.status-matched,
.badge.status-approved,
.badge.status-active,
.badge.status-sent,
.badge.status-success { background: var(--ok-soft); color: var(--ok); }
.badge.status-pending_approval,
.badge.status-escalated,
.badge.status-partial { background: var(--warn-soft); color: var(--warn); }
.badge.status-scheduled { background: var(--accent-soft); color: var(--accent-deep); }
.badge.dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 5px;
  vertical-align: middle;
}

/* ---------- chips (removable tags, e.g. excluded categories) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 11px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bad-soft);
  color: var(--bad);
  line-height: 1.5;
}
.chip.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip.chip-ok .chip-x { color: var(--ok); }
.chip form { margin: 0; line-height: 0; }
.chip-x {
  border: none;
  background: transparent;
  color: var(--bad);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 5px;
  border-radius: 50%;
  opacity: 0.7;
}
.chip-x:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.3;
  transition: background 0.1s, border-color 0.1s;
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #ffffff; text-decoration: none; }
.btn.secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}
.btn.secondary:hover {
  background: var(--panel-alt);
  border-color: #c8cdd8;
  color: var(--ink);
}
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: #8c2422; border-color: #8c2422; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.ok:hover { background: #0f6e47; border-color: #0f6e47; }
.btn.large { padding: 11px 22px; font-size: 14px; }

/* ---------- empty states ---------- */
.empty {
  padding: 36px 24px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px dashed var(--line);
}
.empty .hint { font-size: 12px; margin-top: 6px; color: var(--ink-faint); }

/* ---------- filter bar ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.filter-bar select,
.filter-bar input[type=text],
.filter-bar input[type=number] {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--panel);
  color: var(--ink);
}
.filter-bar label {
  font-size: 12px;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- pagination ---------- */
.pagination {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.pagination .page-info {
  color: var(--ink-soft);
  font-size: 12px;
  margin-right: auto;
}

/* ---------- touch / form blocks ---------- */
.touch-block {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.touch-block .touch-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-deep);
  font-weight: 700;
}
.touch-block .day-label {
  font-size: 11px;
  color: var(--ink-faint);
  margin-left: 8px;
}
.touch-block input[type=text],
.touch-block textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  margin-top: 6px;
  color: var(--ink);
  background: var(--panel);
}
.touch-block input[type=text]:focus,
.touch-block textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.touch-block textarea { min-height: 130px; resize: vertical; }
.touch-block .field-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-top: 10px;
  display: block;
  font-weight: 600;
}

/* ---------- flash ---------- */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.flash.ok   { background: var(--ok-soft);   color: var(--ok); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.flash.bad  { background: var(--bad-soft);  color: var(--bad); }

/* ---------- detail-grid ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: 170px 1fr;
  row-gap: 9px;
  column-gap: 18px;
}
.detail-grid .k {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
}
.detail-grid .v { font-size: 13px; }

/* ---------- unbuilt notice ---------- */
.unbuilt-notice {
  background: var(--warn-soft);
  color: var(--warn);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.unbuilt-notice strong { font-weight: 700; }

/* ---------- pipeline form ---------- */
.pipeline-form {
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
}
.pipeline-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
}
.pipeline-form input[type=number],
.pipeline-form select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--panel);
  color: var(--ink);
  min-width: 100px;
}

pre.code {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--ink);
}

/* ---------- approval form standalone layout ---------- */
.standalone {
  max-width: 780px;
  margin: 40px auto;
  padding: 0 20px;
}
.standalone .topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.standalone .topbar h1 { font-size: 20px; margin: 0 0 4px; }
.standalone .topbar .badge { font-size: 12px; }

/* ---------- table-wrapping helpers ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.table-wrap > table { box-shadow: none; }

/* ---------- category-mix bar (home page) ---------- */
.cat-mix {
  display: flex;
  height: 28px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--bg-soft);
}
.cat-mix > div {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  min-width: 30px;
  transition: filter 0.1s;
}
.cat-mix > div:hover { filter: brightness(1.08); }
.cat-mix .seg-A { background: var(--cat-A); }
.cat-mix .seg-B { background: var(--cat-B); }
.cat-mix .seg-C { background: var(--cat-C); }
.cat-mix .seg-D { background: var(--cat-D); }
.cat-mix .seg-E { background: var(--cat-E); }
.cat-mix .seg-disc { background: var(--bad); }
.cat-mix .seg-empty {
  color: var(--ink-faint);
  background: var(--bg-soft);
  flex: 1;
  font-weight: 500;
  font-style: italic;
}

/* ---------- source row (today's panel) ---------- */
.source-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  padding: 8px 0;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.source-row:last-child { border-bottom: none; }
.source-row .src-name {
  font-weight: 500;
}
.source-row .src-url {
  font-size: 11px;
  color: var(--ink-faint);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.source-row .src-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.source-row .src-num .lbl {
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

/* ============ LOGIN PAGE ============ */
body.login-body {
  background:
    radial-gradient(900px 600px at 70% -10%, #2b3550 0%, transparent 60%),
    radial-gradient(700px 500px at 0% 100%, #1a3da3 0%, transparent 55%),
    #14171f;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-wrap {
  width: 100%;
  max-width: 420px;
}
.login-card {
  background: var(--panel);
  border-radius: 14px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.15);
  padding: 36px 38px 30px;
}
.login-brand {
  text-align: center;
  margin-bottom: 22px;
}
.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
  box-shadow: 0 6px 16px rgba(36, 81, 201, 0.35);
}
.login-brand h1 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.login-tagline {
  margin: 0;
  font-size: 12px;
  color: var(--ink-faint);
}
.login-field {
  display: block;
  margin-bottom: 14px;
}
.login-field > span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 5px;
}
.login-field > input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--ink);
  background: var(--panel);
  font-family: inherit;
}
.login-field > input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-btn {
  width: 100%;
  margin-top: 6px;
}
.login-footer {
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--ink-faint);
  text-align: center;
  line-height: 1.5;
}
.login-fineprint {
  margin: 18px 0 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 11px;
}
.login-fineprint a {
  color: rgba(255, 255, 255, 0.65);
}

/* ============ SIDEBAR USER PANEL ============ */
.sidebar-user {
  position: sticky;
  bottom: 0;
  margin-top: 18px;
  padding: 14px 18px;
  background: linear-gradient(180deg, transparent 0%, #14171f 25%);
  border-top: 1px solid #2a2e3a;
}
.sidebar-user .who {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.sidebar-user .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.sidebar-user .name {
  font-size: 13px;
  font-weight: 500;
  color: #d7d9e0;
  line-height: 1.2;
}
.sidebar-user .role {
  font-size: 10px;
  color: #6a7081;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1px;
}
.sidebar-user form { margin: 0; }
.sidebar-user .logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  color: #b6bccc;
  border: 1px solid #2a2e3a;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}
.sidebar-user .logout-btn:hover {
  background: #232732;
  color: #ffffff;
  border-color: #353a47;
}
