:root {
  /* surfaces — four levels of depth instead of one flat panel */
  --bg:        #07090b;
  --surface:   #0e1114;
  --surface-2: #141920;
  --surface-3: #1b222b;
  --line:      #1e252e;
  --line-soft: #161c23;

  /* type */
  --text:  #e8ecf0;
  --dim:   #8e9aa6;
  --faint: #5d6874;

  /* brand */
  --green:      #2cc76e;
  --green-dim:  #1d9d54;
  --green-glow: rgba(44, 199, 110, 0.13);
  --blue:       #4a9eff;
  --violet:     #9d7bff;
  --amber:      #f0b429;
  --red:        #f0554d;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); }
::selection { background: var(--green-glow); }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 36px 32px; box-shadow: var(--shadow);
}
.login-card .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(140deg, var(--green), var(--green-dim));
  display: grid; place-items: center; font-weight: 900; color: #04170c;
  margin-bottom: 18px; font-size: 17px;
}
.login-card h1 { font-size: 21px; font-weight: 800; letter-spacing: -.3px; }
.login-card p.sub { color: var(--dim); font-size: 13px; margin-bottom: 26px; }

/* ---------- shell ---------- */

.shell { display: flex; min-height: 100vh; }

.side {
  width: 236px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 20px; font-weight: 800; font-size: 15px; letter-spacing: -.2px;
}
.brand .mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(140deg, var(--green), var(--green-dim));
  display: grid; place-items: center; color: #04170c; font-size: 13px; font-weight: 900;
}
.nav-group { margin-bottom: 16px; }
.nav-group h4 {
  font-size: 10px; text-transform: uppercase; letter-spacing: .13em;
  color: var(--faint); font-weight: 700; padding: 0 10px 7px;
}
.nav-btn {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 0; text-align: left; width: 100%;
  padding: 8px 10px; border-radius: 9px; color: var(--dim); cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.on { background: var(--surface-3); color: var(--text); font-weight: 600; }
.nav-btn.on .ico { color: var(--green); }
.nav-btn .ico { width: 15px; text-align: center; opacity: .9; font-size: 13px; }

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.side-foot .who {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px 12px;
}
.side-foot .av {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-3); display: grid; place-items: center;
  font-weight: 700; font-size: 12px; color: var(--green);
}
.side-foot .who b { display: block; font-size: 13px; line-height: 1.3; }
.side-foot .who span { font-size: 11px; color: var(--faint); }
.side-foot .acts { display: flex; gap: 6px; padding: 0 4px; }
.side-foot .acts .btn { flex: 1; }

.main { flex: 1; padding: 26px 30px 60px; max-width: 1180px; min-width: 0; }

.page-head { margin-bottom: 20px; }
.page-head .titles { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h2 { font-size: 21px; font-weight: 800; letter-spacing: -.35px; }
.page-head .hint { color: var(--dim); font-size: 13px; margin-top: 3px; }
.page-head .tools { margin-left: auto; display: flex; gap: 8px; }

/* ---------- surfaces ---------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.card + .card, .card + .stack, .stack + .card { margin-top: 14px; }
.card > h3 {
  font-size: 13px; font-weight: 700; margin-bottom: 14px;
  display: flex; align-items: center; gap: 9px;
}
.card > h3 .count {
  font-size: 11px; color: var(--faint); font-weight: 600;
}

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px; position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--line);
}
.stat.accent::after { background: var(--green); }
.stat .k {
  font-size: 10px; text-transform: uppercase; letter-spacing: .11em;
  color: var(--faint); font-weight: 700;
}
.stat .v { font-size: 25px; font-weight: 800; margin-top: 3px; letter-spacing: -.5px; }
.stat .v.green { color: var(--green); }
.stat .sub { font-size: 11px; color: var(--faint); margin-top: 2px; }

/* ---------- tables ---------- */

.tbl-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10px; text-transform: uppercase;
  letter-spacing: .09em; color: var(--faint); font-weight: 700;
  padding: 0 10px 9px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.014); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--dim); }
.faint { color: var(--faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- forms ---------- */

input, select, textarea {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; width: 100%; outline: none;
  transition: border-color .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--green-dim); }
input:disabled, select:disabled { opacity: .45; }
textarea { resize: vertical; min-height: 82px; }
label { display: block; font-size: 12px; color: var(--dim); margin: 13px 0 5px; font-weight: 500; }
label:first-child { margin-top: 0; }
label .tip { color: var(--faint); font-weight: 400; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }
.actions { margin-top: 16px; display: flex; gap: 9px; }

/* ---------- buttons ---------- */

.btn {
  background: var(--green); border: 0; color: #04170c;
  font-weight: 700; padding: 9px 16px; border-radius: 9px;
  cursor: pointer; width: auto; white-space: nowrap; transition: filter .12s, opacity .12s;
}
.btn:hover:not(:disabled) { filter: brightness(1.09); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost {
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); font-weight: 600;
}
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); filter: none; }
.btn.danger { background: transparent; border: 1px solid #3d2220; color: var(--red); font-weight: 600; }
.btn.danger:hover:not(:disabled) { background: rgba(240,85,77,.08); filter: none; }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn.icon { padding: 5px 9px; font-size: 12px; border-radius: 7px; }

/* ---------- pills & flags ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--line); color: var(--dim); white-space: nowrap;
}
.pill.green  { color: var(--green);  border-color: rgba(44,199,110,.28);  background: var(--green-glow); }
.pill.blue   { color: var(--blue);   border-color: rgba(74,158,255,.28);  background: rgba(74,158,255,.08); }
.pill.violet { color: var(--violet); border-color: rgba(157,123,255,.28); background: rgba(157,123,255,.08); }
.pill.amber  { color: var(--amber);  border-color: rgba(240,180,41,.28);  background: rgba(240,180,41,.08); }
.pill.red    { color: var(--red);    border-color: rgba(240,85,77,.28);   background: rgba(240,85,77,.08); }
.pill.off    { color: var(--faint); }
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.msg { padding: 10px 13px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }
.msg.err { background: rgba(240,85,77,.09); border: 1px solid rgba(240,85,77,.25); color: #f5938d; }
.msg.ok  { background: var(--green-glow); border: 1px solid rgba(44,199,110,.25); color: var(--green); }
.msg.info{ background: rgba(74,158,255,.07); border: 1px solid rgba(74,158,255,.2); color: #9cc8ff; }

.empty { color: var(--faint); font-size: 13px; padding: 26px 0; text-align: center; }

/* ---------- meters ---------- */

.meter { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 70px; }
.meter i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.meter i.warn { background: var(--amber); }
.meter i.hot  { background: var(--red); }

/* ---------- chat ---------- */

.chat-log {
  height: 48vh; min-height: 280px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 13px;
  padding-right: 6px; margin-bottom: 14px;
}
.chat-msg .meta { font-size: 11px; color: var(--faint); margin-bottom: 3px; display: flex; gap: 7px; align-items: center; }
.chat-msg .meta b { color: var(--dim); font-weight: 600; }
.chat-msg .body { white-space: pre-wrap; word-break: break-word; }
.chat-send { display: flex; gap: 10px; align-items: flex-end; }
.chat-send textarea { min-height: 44px; }

/* ---------- hook generator stepper ---------- */

.steps { display: flex; flex-direction: column; gap: 14px; }
.step-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; }
.step-card.done { opacity: .78; }
.step-card .step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 21px; height: 21px; border-radius: 50%; background: var(--surface-3);
  font-size: 11px; font-weight: 800; color: var(--dim); margin-right: 9px;
}
.step-card.active .step-n { background: var(--green); color: #04170c; }
.step-card h3 { font-size: 13px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; }

.choices { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  flex: 1; min-width: 130px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.choice:hover:not(:disabled) { border-color: var(--green-dim); background: var(--surface-3); }
.choice.on { border-color: var(--green); background: var(--green-glow); }
.choice:disabled { opacity: .38; cursor: not-allowed; }
.choice .t { font-weight: 700; font-size: 14px; }
.choice .s { font-size: 11px; color: var(--faint); margin-top: 2px; }

.hook-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 0; overflow: hidden;
}
.hook-card + .hook-card { margin-top: 10px; }
.hook-card .hd {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.hook-card .rank {
  font-size: 12px; font-weight: 800; color: var(--green);
  background: var(--green-glow); border-radius: 6px; padding: 2px 8px;
}
.hook-card .bd { padding: 14px 16px; display: flex; flex-direction: column; gap: 11px; }
.slide { display: flex; gap: 12px; align-items: flex-start; }
.slide .n {
  flex-shrink: 0; font-size: 10px; font-weight: 700; letter-spacing: .08em;
  color: var(--faint); text-transform: uppercase; width: 52px; padding-top: 3px;
}
.slide .txt { flex: 1; font-size: 15px; line-height: 1.45; word-break: break-word; }

.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.16); border-top-color: var(--green);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .side {
    width: auto; flex-direction: row; align-items: center; gap: 4px;
    overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px;
  }
  .brand { padding: 0 10px 0 2px; }
  .nav-group { margin-bottom: 0; display: flex; gap: 4px; }
  .nav-group h4 { display: none; }
  .nav-btn { white-space: nowrap; }
  .side-foot { margin-top: 0; padding-top: 0; border-top: 0; display: flex; align-items: center; margin-left: auto; }
  .side-foot .who { padding: 0 10px 0 0; }
  .main { padding: 18px 14px 50px; }
  .tbl-wrap { margin: 0 -14px; padding: 0 14px; }
}

/* ---------- charts ---------- */

.chart {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 16px 18px;
}
.chart-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.chart-head h3 { font-size: 13px; font-weight: 700; }
.chart-head button { margin-left: auto; }
.chart-total { font-size: 21px; font-weight: 800; letter-spacing: -.4px; margin-top: 2px; }
.chart-total .faint { font-size: 11px; font-weight: 600; letter-spacing: 0; }
.chart-body { position: relative; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot .grid { stroke: var(--line); stroke-width: 1; }
.plot .tick { fill: var(--faint); font-size: 10px; font-family: inherit; }
.plot .endlabel { fill: var(--dim); font-size: 11px; font-weight: 700; font-family: inherit; }
.plot .cross { stroke: var(--line-soft); stroke-width: 1; }
.plot .hit { cursor: crosshair; }
.chart .tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; white-space: nowrap;
  box-shadow: var(--shadow); min-width: 92px;
}
.chart .tip b { display: block; color: var(--dim); font-size: 10px; font-weight: 600; margin-bottom: 1px; }
.chart-table { margin-top: 8px; max-height: 220px; overflow-y: auto; }

.trackurl {
  background: var(--bg); border: 1px solid var(--line-soft);
  border-radius: 9px; padding: 9px 11px; word-break: break-all; font-size: 12.5px;
}
