:root {
  --brand: #22c55e;
  --brand-bright: #35d07f;
  --brand-dim: #15361f;
  --brand-glow: rgba(34, 197, 94, .28);
  --bg: #0b1017;
  --panel: #141b24;
  --panel-2: #1a222d;
  --line: #253040;
  --text: #e6edf3;
  --muted: #8896a8;
  --danger: #f0616d;
  --amber: #e9b949;
  --sidebar: #0a0e14;
  --sidebar-ink: #c7d3e2;
  --sidebar-ink-2: #7e8ca0;
  --sidebar-active: #16202c;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif; }

/* ---------- auth page ---------- */
.authpage { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(900px 400px at 50% -10%, rgba(34,197,94,.12), transparent 60%), var(--bg); }
.authcard { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 34px; width: 340px; text-align: center; }
.authlogo { display: inline-flex; filter: drop-shadow(0 4px 14px var(--brand-glow)); margin-bottom: 12px; }
.authlogo svg { border-radius: 12px; }
.authtitle { margin: 0 0 4px; font-size: 20px; font-weight: 500; }
.authtitle b { font-weight: 750; }
.authsub { color: var(--muted); font-size: 13.5px; margin: 4px 0 18px; }
.authcard input { width: 100%; box-sizing: border-box; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 11px 13px; margin: 7px 0; font: inherit; outline: none; }
.authcard input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.autherr { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0; }
.authok { color: var(--brand-bright); font-size: 13px; margin: 4px 0; }
.authswap { color: var(--muted); font-size: 13px; margin-top: 14px; }
.authswap a { color: var(--brand-bright); text-decoration: none; }
.authnote { color: var(--muted); font-size: 12px; margin-top: 10px; opacity: .8; }
.authfoot { position: fixed; bottom: 16px; width: 100%; text-align: center; color: var(--muted); font-size: 12px; opacity: .6; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--sidebar); display: flex; flex-direction: column; padding: 18px 14px; gap: 4px; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-size: 17px; font-weight: 500; color: #fff; }
.brand svg { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 8px; }
.brand b { font-weight: 750; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; border: 0; background: transparent; color: var(--sidebar-ink-2); font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: left; width: 100%; transition: background .12s, color .12s; }
.nav-item svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav-item:hover { color: var(--sidebar-ink); background: rgba(255,255,255,.04); }
.nav-item.active { color: #fff; background: var(--sidebar-active); }
.nav-item.active svg { color: var(--brand-bright); }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #04220f; display: grid; place-items: center; font-weight: 700; }
.su-name { font-size: 13px; font-weight: 600; color: #fff; }
.su-plan { font-size: 11.5px; color: var(--sidebar-ink-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { padding: 20px 28px 14px; border-bottom: 1px solid var(--line); background: rgba(9,13,19,.4); }
.topbar-title { font-size: 18px; font-weight: 650; }
.topbar-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.content { padding: 24px 28px 60px; max-width: 1240px; width: 100%; }

/* ---------- panels / form ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.panel.narrow { max-width: 460px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: span 2; }
.field.small { max-width: 150px; }
.field span { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; }
input:not([type="checkbox"]), .select { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 10px 12px; font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
input:not([type="checkbox"]):focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
/* searchable cascading dropdowns */
.combo { position: relative; }
.combo-input { width: 100%; }
.combo-input:disabled { opacity: .55; cursor: not-allowed; }
.combo-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: 260px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 12px 30px rgba(0,0,0,.4); padding: 4px; }
.combo-opt { padding: 9px 11px; border-radius: 7px; cursor: pointer; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt:hover, .combo-opt.hl { background: var(--brand-dim); color: var(--brand-bright); }
.combo-opt.all { color: var(--brand-bright); font-weight: 600; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 2px; }
.combo-empty { padding: 10px 11px; color: var(--muted); font-size: 13px; }

.opts { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 18px; }
.spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); cursor: pointer; user-select: none; font-size: 13px; }
.check input { accent-color: var(--brand); width: 15px; height: 15px; }
button, .btnlink { font: inherit; border-radius: 9px; padding: 10px 18px; cursor: pointer; border: 1px solid transparent; text-decoration: none; display: inline-block; transition: filter .15s, border-color .15s; }
.primary { background: var(--brand); color: #04220f; font-weight: 650; box-shadow: 0 4px 14px var(--brand-glow); }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.primary.wide { width: 100%; margin-top: 8px; }
.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.ghost:hover { border-color: var(--muted); }
.link { background: none; border: none; color: var(--muted); padding: 0; font-size: 12px; text-decoration: underline; cursor: pointer; }
.link.del { color: var(--danger); }

/* ---------- status + stepper ---------- */
.statusrow { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding: 15px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 23px; font-weight: 700; color: var(--brand-bright); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.statusmsg { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-left: auto; }
.dotpulse { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); animation: pulse 1.4s infinite; }
.dotpulse.done { animation: none; } .dotpulse.err { background: var(--danger); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--brand-glow); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.processing { padding: 8px 20px 16px; }
.procgrid { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding: 13px 0; position: relative; }
.step:not(:last-child)::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: -1px; width: 2px; background: var(--line); }
.step.done:not(:last-child)::before { background: var(--brand-dim); }
.step .icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--line); background: var(--panel-2); color: var(--muted); font-size: 15px; z-index: 1; transition: all .25s; }
.step .body { padding-top: 4px; min-width: 0; }
.step .title { font-weight: 550; color: var(--muted); transition: color .25s; }
.step .detail { color: var(--muted); font-size: 12.5px; margin-top: 2px; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step.pending .icon { opacity: .5; } .step.pending .title { opacity: .6; }
.step.active .icon { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px var(--brand-glow); }
.step.active .title { color: var(--text); }
.step.active .spinner { width: 15px; height: 15px; border: 2px solid var(--brand-dim); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.step.done .icon { border-color: var(--brand); background: var(--brand); color: #04220f; }
.step.done .title { color: var(--text); }
.step.error .icon { border-color: var(--danger); color: var(--danger); } .step.error .title, .step.error .detail { color: var(--danger); }
.step.skipped .icon { border-style: dashed; } .step.skipped .title { text-decoration: line-through; opacity: .5; } .step.skipped .detail { opacity: .5; }
@keyframes spin { to { transform: rotate(360deg); } }
.pbar { height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; margin-top: 9px; max-width: 340px; }
.pbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-dim), var(--brand)); border-radius: 3px; transition: width .3s ease; }
.showlog { display: inline-block; margin: 6px 0 2px 48px; }
pre#logBox { margin: 10px 0 4px 48px; max-height: 190px; overflow: auto; font: 12px/1.7 ui-monospace, Consolas, monospace; color: #9fb0c3; white-space: pre-wrap; }

/* ---------- tables ---------- */
.tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tools input, .tools .select { min-width: 160px; }
.tools input#filterText, .tools input#savedFilter { flex: 1; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 11px 12px; position: sticky; top: 0; }
td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #172029; }
td.num { color: var(--muted); width: 40px; }
td a { color: #6fb2ff; text-decoration: none; } td a:hover { text-decoration: underline; }
.cat { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.email { color: var(--brand-bright); }
.vbadge { display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px; margin-left: 4px; text-transform: uppercase; letter-spacing: .03em; vertical-align: middle; cursor: help; }
.v-valid { background: var(--brand-dim); color: var(--brand-bright); }
.v-risky { background: rgba(233,185,73,.16); color: var(--amber); }
.v-invalid { background: rgba(240,97,109,.14); color: var(--danger); }
.v-unknown { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.savebtn { background: var(--brand-dim); color: var(--brand-bright); border: 1px solid transparent; border-radius: 7px; padding: 6px 12px; font-size: 12px; }
.savebtn:hover { filter: brightness(1.15); }
.savebtn.saved { background: transparent; color: var(--muted); border-color: var(--line); cursor: default; }
.noteInp { width: 100%; min-width: 130px; padding: 7px 9px !important; font-size: 12.5px; }
.statusSel { padding: 6px 8px; font-size: 12.5px; }
.status-new { color: var(--muted); } .status-contacted { color: var(--amber); }
.status-replied { color: #6fb2ff; } .status-won { color: var(--brand-bright); } .status-not_interested { color: var(--danger); }

/* ---------- history / admin / account ---------- */
.logtitle { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.historylist { display: flex; flex-direction: column; gap: 8px; }
.histitem { display: flex; align-items: center; gap: 14px; padding: 11px 13px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; transition: border-color .15s; }
.histitem:hover { border-color: var(--brand-dim); }
.histitem .q { flex: 1; } .histitem .meta { color: var(--muted); font-size: 12px; }
.err { color: var(--danger); }
.userform { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.userform input { flex: 1; min-width: 150px; }
.badge { font-size: 10.5px; padding: 3px 9px; border-radius: 20px; text-transform: capitalize; }
.b-active { background: var(--brand-dim); color: var(--brand-bright); }
.b-pending { background: rgba(233,185,73,.16); color: var(--amber); }
.b-disabled { background: rgba(240,97,109,.14); color: var(--danger); }
.acts { display: flex; gap: 10px; white-space: nowrap; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; } .kv span { color: var(--muted); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: 4px 8px; } .nav { flex-direction: row; flex-wrap: wrap; margin: 0; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; gap: 8px; align-items: center; }
  .field.wide { grid-column: span 1; }
}
