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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d0d0d;
  color: #e0e0e0;
  font-size: 14px;
}

/* ── Nav ── */
nav {
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 48px;
  border-bottom: 1px solid #222;
}
nav .brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; letter-spacing: 0.02em; }
.nav-logo { width: 18px; height: 18px; opacity: 0.75; }
nav a { color: #888; text-decoration: none; margin-left: 20px; font-size: 13px; }
nav a:hover { color: #fff; }
nav a.active { color: #fff; font-weight: 600; }
nav form { margin-left: 20px; }
nav button.logout {
  background: none; border: 1px solid #333; color: #888;
  padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 13px;
}
nav button.logout:hover { border-color: #666; color: #fff; }

/* ── Layout ── */
.page { max-width: 900px; margin: 32px auto; padding: 0 16px; }
h1 { font-size: 20px; font-weight: 600; margin-bottom: 24px; color: #f0f0f0; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: #e0e0e0; }

/* ── Card ── */
.card {
  background: #161616;
  border: 1px solid #272727;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
  overflow: hidden;
}
details.card { padding: 0; }

/* ── Collapsable sections ── */
details.card > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  cursor: pointer;
  user-select: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { margin-bottom: 0; }
details.card > summary::after {
  content: "▾";
  font-size: 22px;
  color: #666;
  line-height: 1;
  transition: transform 0.2s;
  flex-shrink: 0;
}
details.card:not([open]) > summary::after { transform: rotate(-90deg); }
details.card > summary + * { border-top: 1px solid #222; }
.card-body { padding: 16px 24px 20px; }

/* ── Add Form ── */
.add-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.add-form input {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  flex: 1;
  min-width: 120px;
  color: #e0e0e0;
}
.add-form input::placeholder { color: #555; }
.add-form input:focus { border-color: #555; }
.add-form input[name="slug"] { max-width: 180px; flex: none; }
.add-form input[name="tweet_id"] { max-width: 210px; flex: none; }
.add-form button {
  background: #e0e0e0; color: #111; border: none;
  border-radius: 5px; padding: 6px 16px; cursor: pointer; font-size: 13px;
  font-weight: 600; white-space: nowrap;
}
.add-form button:hover { background: #fff; }
.add-form button:disabled { background: #333; color: #666; cursor: default; }

/* ── List Items ── */
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #222;
}
.item:last-child { border-bottom: none; }
.item-label { font-weight: 500; flex: 1; color: #d0d0d0; }
.item-meta { color: #555; font-size: 12px; font-family: monospace; }
.item-url { color: #555; font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.item-new {
  animation: item-flash 3s forwards;
}
@keyframes item-flash {
  0%   { background: #14532d44; }
  60%  { background: #14532d44; }
  100% { background: transparent; }
}

.btn-remove {
  background: none; border: 1px solid #2e2e2e; color: #555;
  border-radius: 4px; padding: 3px 10px; cursor: pointer; font-size: 12px;
  flex-shrink: 0;
}
.btn-remove:hover { border-color: #7f1d1d; color: #f87171; }

.empty { color: #555; font-size: 13px; padding: 6px 0; }
.form-error { color: #f87171; font-size: 13px; padding: 4px 0 8px; }
.settings-hint { font-size: 12px; color: #555; margin-bottom: 4px; }
.settings-hint code { background: #222; border-radius: 3px; padding: 1px 5px; color: #aaa; font-size: 11px; }

/* ── Brevo list toggles ── */
.brevo-save-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.btn-save {
  background: #2a2a2a; color: #555; border: none;
  border-radius: 5px; padding: 7px 20px; font-size: 13px; font-weight: 600;
  cursor: not-allowed; transition: background 0.15s;
}
.btn-save.active { background: #16a34a; color: #fff; cursor: pointer; }
.btn-save.active:hover { background: #15803d; }
.btn-spinner {
  display: inline-block; width: 11px; height: 11px;
  border: 2px solid rgba(255,255,255,0.2); border-top-color: #fff;
  border-radius: 50%; animation: btn-spin 0.6s linear infinite;
  vertical-align: middle; margin-right: 4px;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.save-confirm { font-size: 12px; color: #4ade80; font-weight: 500; }

.list-toggles { display: flex; flex-direction: column; }
.list-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid #222;
}
.list-toggle-row:last-child { border-bottom: none; }
.list-toggle-info { flex: 1; }
.list-toggle-name { font-weight: 500; font-size: 13px; color: #d0d0d0; }
.list-toggle-count { font-size: 12px; color: #555; margin-left: 8px; }

.btn-eye {
  background: none; border: 1px solid #2e2e2e; border-radius: 6px;
  padding: 5px 7px; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-eye svg { width: 16px; height: 16px; display: block; }
.btn-eye.included { color: #3b82f6; border-color: #1d4ed8; background: #1e3a5f22; }
.btn-eye.excluded { color: #444; border-color: #2a2a2a; background: #1a1a1a; }
.btn-eye.included .eye-closed { display: none; }
.btn-eye.excluded .eye-open { display: none; }
.btn-eye:hover.included { background: #1e3a5f55; }
.btn-eye:hover.excluded { background: #222; }

/* ── Divider ── */
hr.section { border: none; border-top: 1px solid #222; margin: 0 0 16px; }

/* ── Refresh bar ── */
.refresh-bar {
  display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 20px;
}
.refresh-bar button {
  background: #e0e0e0; color: #111; border: none;
  border-radius: 5px; padding: 7px 18px; cursor: pointer; font-size: 13px;
  font-weight: 600;
}
.refresh-bar button:hover { background: #fff; }
.refresh-bar button:disabled { background: #2a2a2a; color: #555; cursor: default; }
#refresh-status { font-size: 13px; color: #666; }

/* ── Top row (KPI grid + wallet card side by side) ── */
.dashboard-top {
  display: flex;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 20px;
}
.dashboard-top .kpi-grid { margin-bottom: 0; flex: 1; }

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

/* ── Wallet card ── */
.wallet-card {
  background: #161616;
  border: 1px solid #272727;
  border-radius: 8px;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 150px;
}
.wallet-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: #f0f0f0;
}
.wallet-label {
  font-size: 12px;
  color: #555;
  margin-top: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kpi-card {
  background: #161616;
  border: 1px solid #272727;
  border-radius: 8px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  aspect-ratio: 1;
}
.kpi-value {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  color: #f0f0f0;
}
.kpi-label {
  font-size: 12px;
  color: #555;
  margin-top: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kpi-card.kpi-placeholder .kpi-value { color: #333; }
.kpi-card.kpi-placeholder .kpi-label { color: #3a3a3a; }
.kpi-card.kpi-card-clickable {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.kpi-card.kpi-card-clickable:hover,
.kpi-card.kpi-card-clickable.active { border-color: #B791E6; background: #1c1622; }
.kpi-card.kpi-card-clickable.active { border-color: #555; }

/* ── Follower chart card ── */
.follower-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.follower-chart-header h2 { margin-bottom: 0; }
.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
}

/* ── Stats (legacy, kept for compat) ── */
.stat-row { display: flex; gap: 24px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: #555; margin-top: 3px; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
th { text-align: left; font-weight: 600; color: #555; border-bottom: 2px solid #272727; padding: 6px 8px; }
td { padding: 7px 8px; border-bottom: 1px solid #1e1e1e; vertical-align: top; color: #ccc; }
tr:last-child td { border-bottom: none; }
td.cell-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: #e0e0e0; }
a.link-out {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 24px;
  background: #1e1e1e; border: 1px solid #303030; border-radius: 4px;
  color: #555; text-decoration: none; font-size: 12px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
a.link-out:hover { background: #2a2a2a; border-color: #555; color: #e0e0e0; }
a.btn-stats {
  display: inline-block;
  background: #1e1e1e; color: #aaa; text-decoration: none;
  border: 1px solid #2e2e2e; border-radius: 5px;
  padding: 3px 10px; font-size: 11px; font-weight: 500;
  white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
a.btn-stats:hover { background: #2a2a2a; border-color: #444; color: #e0e0e0; }

tfoot tr.total-row td { border-top: 2px solid #272727; font-weight: 600; background: #111; color: #e0e0e0; }
td.cell-date { font-size: 12px; color: #555; white-space: nowrap; }
td.cell-muted { font-size: 12px; color: #555; }

h3 { font-size: 13px; font-weight: 600; color: #666; margin-bottom: 6px; }
.last-refresh { font-size: 12px; color: #444; }
.no-data { padding: 40px 0; text-align: center; color: #555; }

/* ── Fathom Analytics ── */
.fathom-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.fathom-toggle {
  display: flex;
  border: 1px solid #2e2e2e;
  border-radius: 6px;
  overflow: hidden;
}
.fathom-btn {
  background: #1a1a1a;
  border: none;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.fathom-btn + .fathom-btn { border-left: 1px solid #2e2e2e; }
.fathom-btn.active { background: #e0e0e0; color: #111; }
.fathom-btn:hover:not(.active) { background: #222; color: #ccc; }
.fathom-range {
  font-size: 12px;
  color: #555;
}
.fathom-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.fathom-stat {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.fathom-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: #f0f0f0;
}
.fathom-label {
  font-size: 11px;
  color: #555;
  margin-top: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Login page ── */
body.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 320px;
}
.login-logo {
  margin-bottom: 16px;
  opacity: 0.9;
}
.login-brand {
  font-size: 15px;
  font-weight: 600;
  color: #888;
  letter-spacing: 0.02em;
  margin-bottom: 28px;
}
.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-form input {
  background: #1a1a1a;
  border: 1px solid #2e2e2e;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  color: #e0e0e0;
  outline: none;
  width: 100%;
}
.login-form input::placeholder { color: #444; }
.login-form input:focus { border-color: #555; }
.login-form button {
  margin-top: 4px;
  background: #e0e0e0;
  color: #111;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.login-form button:hover { background: #fff; }

/* ── Per-section refresh panel ── */
.refresh-panel {
  background: #161616;
  border: 1px solid #272727;
  border-radius: 8px;
  padding: 4px 20px;
  margin-bottom: 20px;
}
.refresh-section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #1e1e1e;
}
.refresh-section-row:last-child { border-bottom: none; }
.rs-name {
  font-size: 13px;
  color: #666;
}
.refresh-section-row.rs-done .rs-name { color: #888; }
.rs-check { color: #4ade80; font-size: 13px; font-weight: 700; }
.rs-err   { color: #f87171; font-size: 13px; font-weight: 700; }

/* ── Loading bars (Sr / Jr style) ── */
.loading-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 4px;
  height: 18px;
}
.loading-bars span {
  width: 4px;
  border-radius: 2px;
  background: #555;
  transform-origin: bottom;
}
.loading-bars span:nth-child(1) {
  height: 14px;
  animation: bar-sr 1.8s ease-in-out infinite;
}
.loading-bars span:nth-child(2) {
  height: 14px;
  animation: bar-jr 1.8s ease-in-out infinite;
}
@keyframes bar-sr {
  0%, 100% { transform: scaleY(0.22); }
  50%       { transform: scaleY(1); }
}
@keyframes bar-jr {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(0.22); }
}
