/* ==========================================================================
   twitterfolls — dashboard theme
   Dark, quiet, data-first. Geist + Geist Mono.
   ========================================================================== */

:root {
  --canvas:        #131517;
  --surface:       #1a1d1f;
  --surface-alt:   #17191b;
  --panel:         #1f2225;
  --field:         #252a2d;
  --field-hi:      #2c3134;
  --ink:           #f2f4f2;
  --ink-dim:       #c7cccb;
  --muted:         #8d9494;
  --faint:         #616867;
  --line:          #ffffff14;
  --line-strong:   #ffffff26;

  --green:         #47bb64;
  --green-hi:      #69d27f;
  --green-ink:     #08210f;
  --yellow:        #e6cc52;
  --red:           #ef6b62;
  --blue:          #6aa9f5;

  --radius:        16px;
  --radius-sm:     10px;
  --radius-pill:   999px;
  --shadow:        0 24px 70px #00000059;
  --shadow-sm:     0 6px 20px #00000033;

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open { overflow: hidden; }

/* .modal / .run-row / .sk set `display`, which beats the [hidden] UA rule —
   without this the settings overlay is painted on top of the page at load. */
[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--green-hi); }

code, .mono { font-family: var(--mono); font-size: .92em; }

.bg-glow {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 620px;
  background:
    radial-gradient(45% 55% at 22% 30%, #47bb6426, transparent 70%),
    radial-gradient(40% 50% at 78% 10%, #6aa9f51c, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ------------------------------------------------------------- topbar --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: #131517e6;
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--green) 0%, #2f8d47 100%);
  color: var(--green-ink);
  box-shadow: 0 6px 22px #47bb6438;
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; font-weight: 560; letter-spacing: -.03em; }
.brand-text em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--faint);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 12px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.chip.ok .dot { background: var(--green); box-shadow: 0 0 0 3px #47bb6430; }
.chip.warn .dot { background: var(--yellow); box-shadow: 0 0 0 3px #e6cc5230; }
.chip.bad .dot { background: var(--red); box-shadow: 0 0 0 3px #ef6b6230; }

/* -------------------------------------------------------------- buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}
.btn:hover { background: var(--field-hi); transform: scale(1.02); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }

.btn.primary {
  background: var(--green);
  border-color: #47bb6400;
  color: var(--green-ink);
  font-weight: 600;
}
.btn.primary:hover { background: var(--green-hi); }

.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--field); }

.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.big { width: 100%; padding: 13px 18px; font-size: 14px; border-radius: 14px; }

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.icon-btn:hover { color: var(--ink); background: var(--field); }

/* --------------------------------------------------------------- layout --- */

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding: 22px 26px 40px;
  max-width: 1560px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls { padding: 20px; position: sticky; top: 84px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}
.section-head .hint { color: var(--faint); text-transform: none; letter-spacing: .02em; font-size: 11px; }

.divider { height: 1px; background: var(--line); margin: 20px 0; }

/* --------------------------------------------------------------- fields --- */

.field { display: block; margin-bottom: 14px; }
.field .label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-dim);
}
.field .sub { display: block; margin-top: 6px; font-size: 11px; color: var(--faint); line-height: 1.45; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .16s ease, background .16s ease;
}
.input-wrap:focus-within { border-color: #47bb6466; background: var(--field-hi); }
.input-wrap .prefix { font-family: var(--mono); color: var(--faint); }
.input-wrap svg { width: 15px; height: 15px; color: var(--faint); flex: none; }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  outline: none;
}
input::placeholder { color: var(--faint); }

select {
  padding: 10px 12px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d9494' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  padding-right: 34px;
}
select:focus { border-color: #47bb6466; }

input[type="number"] {
  padding: 10px 12px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { opacity: .35; }

/* ------------------------------------------------------------- controls --- */

.cost-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}
.credits-total { color: var(--muted); }

.watchlist { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }

.wchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 12px;
  color: var(--ink-dim);
  cursor: pointer;
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.wchip:hover { border-color: var(--line-strong); color: var(--ink); background: var(--field); }
.wchip.active { border-color: #47bb6466; color: var(--green-hi); background: #47bb641a; }
.wchip .x {
  display: grid; place-items: center;
  width: 17px; height: 17px;
  border-radius: 50%;
  color: var(--faint);
  font-size: 11px;
  line-height: 1;
}
.wchip .x:hover { background: #ef6b6229; color: var(--red); }

.empty-inline { font-size: 12px; color: var(--faint); }

.accounts { display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px; max-height: 240px; overflow: auto; }

.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
}
.account-row:hover { background: var(--field); border-color: var(--line); }
.account-row.active { background: #47bb641a; border-color: #47bb6459; }
.account-row img { width: 24px; height: 24px; border-radius: 50%; background: var(--field); object-fit: cover; }
.account-row .ar-badge {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--field);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.account-row .ar-main { min-width: 0; flex: 1; }
.account-row .ar-handle { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row .ar-sub { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.account-row .ar-new { font-family: var(--mono); font-size: 10.5px; color: var(--green-hi); }

.note {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}
.note strong { color: var(--ink-dim); font-weight: 560; }

/* ---------------------------------------------------------------- main --- */

.main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.profile-card {
  display: flex;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(140deg, #202426 0%, #1a1d1f 60%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.pf-avatar { width: 66px; height: 66px; border-radius: 18px; object-fit: cover; background: var(--field); flex: none; }
.pf-body { min-width: 0; flex: 1; }
.pf-name { display: flex; align-items: center; gap: 7px; font-size: 18px; font-weight: 560; letter-spacing: -.02em; }
.pf-verified { width: 17px; height: 17px; color: var(--green); flex: none; }
.pf-handle { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.pf-bio { margin: 8px 0 10px; font-size: 12.5px; color: var(--ink-dim); max-width: 70ch; }
.pf-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.pf-meta b { color: var(--ink); font-weight: 560; }

/* --------------------------------------------------------------- stats --- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.stat {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.stat .k {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--faint);
  margin-bottom: 6px;
}
.stat .v { font-size: 22px; font-weight: 560; letter-spacing: -.03em; }
.stat .v.accent { color: var(--green-hi); }
.stat .s { font-size: 11px; color: var(--faint); margin-top: 2px; }

/* ------------------------------------------------------------ results --- */

.results-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  padding: 9px 14px 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .16s ease, border-color .16s ease;
}
.tab:hover { color: var(--ink-dim); }
.tab.active { color: var(--ink); border-bottom-color: var(--green); }
.tab .count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--field);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}
.tab.active .count { background: #47bb6429; color: var(--green-hi); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  flex-wrap: wrap;
}
.toolbar .search { flex: 1; min-width: 200px; max-width: 420px; }
.toolbar .search input { padding: 8px 0; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.result-count { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.export { display: flex; gap: 6px; }

.table-scroll { overflow-x: auto; max-height: 660px; overflow-y: auto; }

table.followers { width: 100%; border-collapse: collapse; font-size: 13px; }

table.followers thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 12px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--faint);
  font-weight: 500;
  white-space: nowrap;
}
table.followers th.num, table.followers td.num { text-align: right; }

table.followers tbody tr { border-bottom: 1px solid var(--line); }
table.followers tbody tr:hover { background: #ffffff08; }
table.followers tbody tr.is-new { background: #47bb6412; }
table.followers tbody tr.is-new:hover { background: #47bb641f; }

table.followers td { padding: 9px 12px; vertical-align: middle; }

.col-idx { width: 44px; }
.col-act { width: 46px; }
td.col-idx { font-family: var(--mono); font-size: 11px; color: var(--faint); }

.who { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.who img {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--field);
  flex: none;
}
.who .who-text { min-width: 0; }
.who .who-name {
  display: flex; align-items: center; gap: 5px;
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 320px;
}
.who .who-name svg { width: 13px; height: 13px; color: var(--green); flex: none; }
.who .who-handle { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.who .who-bio {
  font-size: 11.5px;
  color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 380px;
}

.badge-new {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--green);
  color: var(--green-ink);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  vertical-align: middle;
}
.badge-type {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

td .dim { color: var(--muted); }
td .mono-sm { font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim); }
td .ago { color: var(--faint); font-size: 11px; margin-left: 6px; }

.row-link {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}
.row-link:hover { color: var(--green-hi); border-color: #47bb6466; background: #47bb6414; }
.row-link svg { width: 14px; height: 14px; }

/* --------------------------------------------------------------- empty --- */

.empty { padding: 56px 24px 64px; text-align: center; }
.empty-mark {
  display: grid; place-items: center;
  width: 54px; height: 54px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--field);
  color: var(--faint);
}
.empty-mark svg { width: 26px; height: 26px; }
.empty h2 { margin: 0 0 6px; font-size: 17px; font-weight: 560; letter-spacing: -.02em; }
.empty p { margin: 0 auto; max-width: 46ch; font-size: 12.5px; color: var(--muted); }

/* -------------------------------------------------------------- table rows for runs --- */

.run-row td { padding: 11px 12px; }
.run-when { font-weight: 500; }
.run-new { color: var(--green-hi); font-family: var(--mono); font-size: 12px; }

/* ------------------------------------------------------------- skeleton --- */

.sk { position: relative; overflow: hidden; background: var(--field); border-radius: 6px; }
.sk::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, #ffffff0f, transparent);
  animation: sk 1.3s infinite;
}
@keyframes sk { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.spin { width: 15px; height: 15px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- footer --- */

.footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 18px 26px 30px;
  max-width: 1560px;
  margin: 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}
.footer .sep { opacity: .5; }

/* ---------------------------------------------------------------- modal --- */

.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: #0a0c0dcc; backdrop-filter: blur(4px); }
.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 560; letter-spacing: -.02em; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.save-state { margin-right: auto; font-size: 11.5px; color: var(--faint); }

.info-box {
  margin-top: 6px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  display: flex; flex-direction: column; gap: 7px;
  font-size: 11.5px;
}
.info-box > div { display: flex; gap: 10px; align-items: baseline; }
.info-box span { width: 82px; flex: none; color: var(--faint); }
.info-box code { color: var(--ink-dim); word-break: break-all; }

/* --------------------------------------------------------------- toasts --- */

.toast-wrap {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 120;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  min-width: 220px;
  max-width: 380px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  color: var(--ink-dim);
  animation: slide .2s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.info { border-left-color: var(--blue); }
@keyframes slide { from { opacity: 0; transform: translateX(14px); } }

/* ------------------------------------------------------------- responsive --- */

@media (max-width: 1160px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .controls { position: static; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  .topbar { padding: 12px 16px; }
  .layout { padding: 16px 16px 32px; gap: 16px; }
  .footer { padding: 14px 16px 26px; }
  .brand-text em { display: none; }
  .hide-sm { display: none; }
  .toolbar .search { max-width: none; }
  .profile-card { flex-direction: column; gap: 12px; }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .chip { font-size: 11px; padding: 5px 10px; }
  .who .who-bio { display: none; }
  .export { flex-wrap: wrap; }
}
