/* ViralSpot Growth Data — admin dashboard. Dark, dense, readable. */
:root {
  --bg: #0a0c11;
  --side: #0d1016;
  --panel: #131722;
  --panel2: #171c28;
  --mut: #828b9e;
  --mut2: #5a6478;
  --line: #1e2430;
  --acc: #5b8cff;
  --grn: #45d483;
  --red: #f76b6b;
  --ylw: #f5b840;
  --pur: #9d7bff;
  --txt: #e8ebf0;
}
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  letter-spacing: .1px;
}
.mono { font-family: 'SFMono-Regular', Consolas, Menlo, monospace; font-variant-numeric: tabular-nums; }
a { color: inherit; }

/* ---- login page ---- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 32px;
  border-radius: 14px;
  width: 320px;
  box-shadow: 0 8px 40px #0008;
}
.login-title { font-size: 17px; margin: 0 0 4px; font-weight: 700; }
.login-sub { font-size: 12.5px; color: var(--mut); margin: 0 0 18px; }
.login-card input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px;
  margin: 7px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
}
.login-card button {
  width: 100%;
  padding: 11px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--acc);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.login-card button:hover { filter: brightness(1.08); }
.login-card .err { color: var(--red); font-size: 13px; margin: 4px 0; }

/* ---- shell ---- */
body.dash { display: flex; }
.sidebar {
  width: 224px;
  background: var(--side);
  border-right: 1px solid var(--line);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  padding-top: 18px;
  z-index: 10;
  overflow-y: auto;
}
.brand {
  padding: 2px 22px 20px;
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  gap: 10px;
  align-items: center;
}
.brand .logo {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--acc), var(--pur));
  flex: 0 0 auto;
}
.nav { display: flex; flex-direction: column; }
.nav button {
  all: unset;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 22px;
  color: var(--mut);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 2px solid transparent;
  cursor: pointer;
  user-select: none;
}
.nav button:hover { color: var(--txt); background: #11151e; }
.nav button.active { color: #fff; background: #141925; border-left-color: var(--acc); }
.nav .badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
}
.foot {
  margin-top: auto;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--mut2);
}
.foot a { display: block; margin-top: 8px; text-decoration: none; color: var(--mut); }
.foot a:hover { color: var(--txt); }
.foot label { display: flex; align-items: center; gap: 6px; margin-top: 8px; cursor: pointer; }

.main { margin-left: 224px; flex: 1; min-height: 100vh; width: calc(100% - 224px); }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 20px 30px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(10, 12, 17, .88);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 600; }
.topbar .r { color: var(--mut); font-size: 12.5px; }
.content { padding: 22px 30px 60px; max-width: 1320px; }
section { display: none; }
section.active { display: block; }

/* ---- cards / panels ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--acc); opacity: .55;
}
.card.g::before { background: var(--grn); }
.card.r::before { background: var(--red); }
.card.y::before { background: var(--ylw); }
.card.p::before { background: var(--pur); }
.card .k { color: var(--mut); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.card .v { font-size: 25px; font-weight: 600; margin-top: 6px; font-family: 'SFMono-Regular', Consolas, monospace; }
.card .s { color: var(--mut); font-size: 11.5px; margin-top: 6px; }
.card.alert .v { color: var(--red); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1040px) { .grid2 { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.panel h2 {
  font-size: 11.5px; margin: 0 0 12px; color: var(--mut);
  text-transform: uppercase; letter-spacing: .07em; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}
.panel h2 .sub { color: var(--mut2); font-weight: 500; text-transform: none; letter-spacing: 0; }

table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--mut2); font-weight: 600; font-size: 10.3px; text-transform: uppercase; letter-spacing: .05em; }
td.num { font-family: 'SFMono-Regular', Consolas, monospace; }
tbody tr:hover { background: #161b26; cursor: default; }
tbody tr.clickable:hover { cursor: pointer; }
.scroll { max-height: 480px; overflow: auto; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 10.8px; font-weight: 600; }
.ok { background: rgba(69, 212, 131, .14); color: var(--grn); }
.bad { background: rgba(247, 107, 107, .14); color: var(--red); }
.warn { background: rgba(245, 184, 64, .14); color: var(--ylw); }
.neu { background: #1c2230; color: var(--mut); }
.dim { color: var(--mut); }
.empty { text-align: center; padding: 30px 16px; color: var(--mut); }

/* ---- lane cards ---- */
.lanes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.lane-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.lane-card.unhealthy { border-color: rgba(247, 107, 107, .4); }
.lane-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.lane-head .id { font-weight: 600; font-size: 13px; }
.lane-meta { color: var(--mut); font-size: 11.5px; margin-bottom: 10px; line-height: 1.6; }
.pips { display: flex; gap: 3px; margin: 8px 0; }
.pip { width: 12px; height: 14px; border-radius: 3px; background: var(--line); }
.pip.used { background: var(--acc); }
.pip.full { background: var(--red); }
.lane-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 11.5px; margin-top: 8px; }
.lane-stats .n { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 14px; font-weight: 600; }
.lane-stats .l { color: var(--mut2); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.countdown { font-family: 'SFMono-Regular', Consolas, monospace; }
.lane-err { margin-top: 8px; font-size: 11px; color: var(--red); word-break: break-word; }

/* ---- jobs ---- */
.job-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.job-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 8px; }
.job-bar { height: 8px; border-radius: 5px; background: var(--line); overflow: hidden; }
.job-bar > div { height: 100%; background: var(--acc); }

/* ---- events feed ---- */
.feed { max-height: 640px; overflow: auto; }
.feed .row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.8px; align-items: flex-start; }
.feed .t { color: var(--mut2); font-size: 11px; white-space: nowrap; width: 130px; font-family: 'SFMono-Regular', Consolas, monospace; padding-top: 1px; }
.dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; }

/* ---- bulk import ---- */
#bulk-form textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--txt);
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}
.bulk-row { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.bulk-row .dim { font-size: 11.5px; line-height: 1.5; flex: 1; }
.bulk-row code { background: #1c2230; border-radius: 4px; padding: 1px 5px; }
.bulk-row button {
  background: var(--acc); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 18px; font-weight: 600; cursor: pointer; font-size: 13px; flex: 0 0 auto;
}
.bulk-row button:hover { filter: brightness(1.08); }
#bulk-results-wrap { margin-top: 14px; max-height: 260px; }

/* ---- accounts form ---- */
.acct-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.acct-form input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  color: var(--txt); padding: 9px 11px; font-size: 13px; min-width: 160px; flex: 1;
}
.acct-form button {
  background: var(--acc); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 18px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.acct-form button:hover { filter: brightness(1.08); }
.row-actions { display: flex; gap: 6px; }
.row-actions button {
  background: var(--panel2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 9px; font-size: 11.5px; cursor: pointer;
}
.row-actions button:hover { background: #1c2230; }
.row-actions button.danger:hover { background: rgba(247, 107, 107, .16); border-color: var(--red); color: var(--red); }

/* ---- accounts: per-row worker state (from /admin/api/lanes) ---- */
.lane-mini { display: flex; flex-direction: column; gap: 3px; min-width: 160px; }
.lane-mini .pill { align-self: flex-start; }
.lane-mini .dim { font-size: 11px; }
.lane-mini .lane-err { font-size: 10.5px; }

/* ---- in-page danger confirm (no window.confirm — see app.js) ---- */
.row-actions button.danger.confirming {
  background: var(--red); border-color: var(--red); color: #fff;
}
.row-actions button:disabled { opacity: .55; cursor: default; }

/* ---- toasts (no window.alert — see app.js) ---- */
#toast-root {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--red);
  color: var(--txt); padding: 10px 14px; border-radius: 8px; font-size: 12.8px;
  max-width: 360px; box-shadow: 0 8px 30px #0008;
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { border-left-color: var(--grn); }

/* ---- drawer ---- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 20;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 92vw);
  background: var(--panel); border-left: 1px solid var(--line); z-index: 21;
  overflow-y: auto; padding: 20px 22px;
}
.drawer h2 { font-size: 15px; margin: 0 0 4px; }
.drawer .close { position: absolute; top: 16px; right: 18px; cursor: pointer; color: var(--mut); background: none; border: 0; font-size: 20px; }
.drawer dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 12.5px; margin: 14px 0; }
.drawer dt { color: var(--mut2); }
.drawer dd { margin: 0; font-family: 'SFMono-Regular', Consolas, monospace; word-break: break-word; }
.drawer pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; font-size: 11.5px; white-space: pre-wrap; word-break: break-word;
  max-height: 40vh; overflow: auto; margin: 6px 0 16px;
}
.drawer h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); margin: 14px 0 6px; }

/* ---- filters ---- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  color: var(--txt); padding: 7px 10px; font-size: 12.5px;
}

@media (max-width: 780px) {
  .sidebar { width: 60px; }
  .brand span:not(.logo), .nav button span.t, .foot span, .foot label span { display: none; }
  .main { margin-left: 60px; width: calc(100% - 60px); }
}
