/* mido fleet dashboard — dark, editorial, intentional. */
:root {
  --bg:        oklch(16% 0.02 265);
  --bg-2:      oklch(20% 0.025 265);
  --surface:   oklch(23% 0.03 265 / 0.72);
  --surface-2: oklch(27% 0.035 265 / 0.6);
  --border:    oklch(40% 0.04 265 / 0.45);
  --border-lit:oklch(55% 0.08 265 / 0.55);
  --text:      oklch(94% 0.01 265);
  --muted:     oklch(66% 0.02 265);
  --faint:     oklch(52% 0.02 265);
  --accent:    oklch(72% 0.17 250);
  --accent-2:  oklch(78% 0.16 200);
  --ok:        oklch(74% 0.17 150);
  --warn:      oklch(80% 0.16 85);
  --err:       oklch(67% 0.21 25);
  --run:       oklch(78% 0.16 200);

  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --r: 14px;
  --shadow: 0 1px 0 oklch(100% 0 0 / 0.04) inset, 0 12px 40px oklch(0% 0 0 / 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, oklch(30% 0.06 265 / 0.5), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, oklch(28% 0.07 285 / 0.4), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body > *:not(.grain) { position: relative; z-index: 1; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
  background: oklch(16% 0.02 265 / 0.7);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { color: var(--accent); font-size: 20px; transform: translateY(2px); }
.brand-name { font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.brand-sub { color: var(--faint); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.status { display: flex; align-items: center; gap: 10px; font-size: 13px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-ok   { background: var(--ok);  box-shadow: 0 0 0 4px oklch(74% 0.17 150 / 0.18); }
.dot-idle { background: var(--faint); }
.dot-err  { background: var(--err); box-shadow: 0 0 0 4px oklch(67% 0.21 25 / 0.18); }
.dot-run  { background: var(--run); box-shadow: 0 0 0 4px oklch(78% 0.16 200 / 0.2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 12px; }

.authbar {
  margin: 16px 28px 0; padding: 12px 16px; border-radius: 10px;
  background: oklch(67% 0.21 25 / 0.14); border: 1px solid oklch(67% 0.21 25 / 0.4);
  color: oklch(86% 0.08 30);
}
.authbar code { background: oklch(0% 0 0 / 0.3); padding: 2px 6px; border-radius: 5px; }
.hidden { display: none; }

/* ---- stats ---- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  padding: 24px 28px 6px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat:first-child .stat-num { color: var(--accent-2); }
.stat-label { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---- layout grid ---- */
.grid {
  display: grid; gap: 18px; padding: 18px 28px 40px;
  grid-template-columns: 1.4fr 1fr;
  grid-template-areas: "agents posts" "feed runs";
}
.panel-agents { grid-area: agents; }
.panel-posts  { grid-area: posts; }
.panel-feed   { grid-area: feed; }
.panel-runs   { grid-area: runs; }
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; grid-template-areas: "agents" "posts" "feed" "runs"; }
}

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow);
  min-height: 120px;
}
.panel-title {
  margin: 0 0 14px; font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.pill {
  font-family: var(--mono); font-size: 11px; color: var(--accent-2);
  background: oklch(78% 0.16 200 / 0.12); padding: 1px 8px; border-radius: 20px;
  letter-spacing: 0; text-transform: none;
}
.empty { color: var(--faint); font-size: 14px; padding: 12px 2px; }

/* ---- agent cards ---- */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.agent {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; transition: border-color .2s, transform .2s;
}
.agent:hover { border-color: var(--border-lit); transform: translateY(-2px); }
.agent.is-running { border-left: 3px solid var(--run); }
.agent.is-error   { border-left: 3px solid var(--err); }
.agent.is-done    { border-left: 3px solid var(--ok); }
.agent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.agent-acct { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.agent-state { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.agent-action { font-family: var(--mono); font-size: 13px; color: var(--accent-2); margin-bottom: 4px; }
.agent-goal { color: var(--text); font-size: 13.5px; opacity: 0.9; }
.agent-meta { display: flex; gap: 14px; margin-top: 12px; color: var(--faint); font-size: 12px; }
.agent-meta b { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.agent-task { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
  color: var(--faint); font-size: 12px; max-height: 3.2em; overflow: hidden; }

/* ---- posts ---- */
.posts-list { display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow-y: auto; }
.post {
  display: flex; flex-direction: column; gap: 6px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.post-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.post-acct { font-weight: 600; font-size: 13px; color: var(--accent); }
.post-text { font-size: 13.5px; color: var(--text); opacity: 0.92; word-break: break-word; }
.post-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.post-link {
  font-family: var(--mono); font-size: 12px; color: var(--accent-2); text-decoration: none;
  border: 1px solid var(--border-lit); padding: 3px 10px; border-radius: 20px; transition: background .2s;
  white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis;
}
.post-link:hover { background: oklch(78% 0.16 200 / 0.16); }
.post-target { color: var(--faint); font-size: 12px; }

/* ---- feed ---- */
.feed { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; }
.feed li { display: grid; grid-template-columns: 56px 90px 1fr auto; gap: 10px; align-items: baseline;
  padding: 6px 6px; border-radius: 7px; font-size: 13px; }
.feed li:nth-child(odd) { background: oklch(100% 0 0 / 0.018); }
.feed .f-acct { color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .f-action { font-family: var(--mono); font-size: 12px; color: var(--accent-2); }
.feed .f-goal { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .f-age { color: var(--faint); font-size: 11px; font-family: var(--mono); justify-self: end; }
.feed .f-finish .f-action { color: var(--ok); }

/* ---- runs ---- */
.runs-list { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.run { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; }
.run-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.run-task { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-badge { font-family: var(--mono); font-size: 11px; padding: 1px 8px; border-radius: 20px; white-space: nowrap; }
.b-ok { color: var(--ok); background: oklch(74% 0.17 150 / 0.14); }
.b-err { color: var(--err); background: oklch(67% 0.21 25 / 0.14); }
.b-other { color: var(--warn); background: oklch(80% 0.16 85 / 0.14); }
.run-meta { color: var(--faint); font-size: 12px; margin-top: 4px; font-family: var(--mono); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-lit); border-radius: 20px; }
::-webkit-scrollbar-track { background: transparent; }
