/* Agency — operations floor for Lakeside Games' standing agents.
   Own design system, small on purpose:
   - graphite ground, panels separated by 1px hairlines, minimal radius
   - text carries hierarchy; color is reserved for state and per-agent accents
   - data (timestamps, ids, numbers, tool names) is always mono */

:root {
  --bg: #0b0c0e;
  --panel: #111214;
  --panel-2: #16181b;
  --line: rgba(235, 238, 242, 0.09);
  --line-2: rgba(235, 238, 242, 0.18);
  --text: #edeff2;
  --text-2: rgba(237, 239, 242, 0.62);
  --text-3: rgba(237, 239, 242, 0.38);
  --accent: #4cc2ff;
  --ok: #3ecf8e;
  --err: #ff5d5d;
  --warn: #f5a524;
  --font: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --r: 6px;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 420px at 50% -160px, rgba(76, 194, 255, 0.08), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
::selection { background: rgba(76, 194, 255, 0.28); }

/* ── Top bar ── */

.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  height: 52px; padding: 0 20px;
  background: rgba(11, 12, 14, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: baseline; gap: 9px;
  font: 600 13px/1 var(--mono); letter-spacing: 0.14em;
  text-decoration: none; white-space: nowrap;
}
.brand-block { width: 9px; height: 9px; background: var(--accent); align-self: center; }
.brand-sub { font: 400 11px/1 var(--font); letter-spacing: 0.02em; color: var(--text-3); }
.nav { display: flex; gap: 4px; margin-right: auto; }
.nav-item {
  padding: 6px 10px; border-radius: var(--r);
  color: var(--text-2); text-decoration: none; font-size: 13px;
}
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.on { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.bar-right { display: flex; align-items: center; gap: 14px; }
.clock { font: 12px var(--mono); color: var(--text-3); }

/* ── Shell ── */

.shell { max-width: 1240px; margin: 0 auto; padding: 26px 20px 80px; }
.shell.bare { max-width: none; padding: 0; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 24px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -0.015em; }
.eyebrow {
  display: block; margin-bottom: 4px;
  font: 600 10.5px var(--mono); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-3);
}

/* ── Panels ── */

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font: 600 11px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2); }
.panel-body { padding: 14px; }
.panel-link { font-size: 12px; color: var(--text-3); text-decoration: none; }
.panel-link:hover { color: var(--text); }

/* ── Stat strip ── */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.stat { background: var(--panel); padding: 13px 16px; }
.stat b { display: block; font: 600 22px var(--mono); letter-spacing: -0.02em; }
.stat b.zero { color: var(--text-3); }
.stat span { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.09em; }

/* ── Agent grid ── */

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
@media (max-width: 1080px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px) { .grid { grid-template-columns: 1fr; } }
.agent {
  position: relative; display: flex; flex-direction: column; gap: 9px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  border-left: 2px solid var(--ag, var(--line-2));
  padding: 13px 14px; text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.agent:hover { background: var(--panel-2); border-color: var(--line-2); border-left-color: var(--ag); }
.agent.off { opacity: 0.5; }
.agent-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.agent-id { font: 650 13px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ag, var(--text)); }
.agent-role { font-size: 12.5px; color: var(--text-3); margin-top: -4px; }
.agent-sum {
  margin: 2px 0 0; font-size: 13.5px; color: var(--text-2); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 4em;
}
.agent-meta { display: flex; gap: 10px; align-items: center; font: 10.5px var(--mono); color: var(--text-3); flex-wrap: wrap; letter-spacing: 0.03em; }
.agent-state { text-transform: uppercase; letter-spacing: 0.08em; }
.agent-state.s-running { color: var(--accent); }
.agent-state.s-error { color: var(--err); }

/* ── State ── */

.st { display: inline-flex; align-items: center; gap: 6px; font: 11px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; }
.st i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.st.ok i { background: var(--ok); }
.st.ok { color: var(--ok); }
.st.error i, .st.timeout i, .st.lost i { background: var(--err); }
.st.error, .st.timeout, .st.lost { color: var(--err); }
.st.running i { background: var(--accent); animation: pulse 1.3s ease-in-out infinite; }
.st.running { color: var(--accent); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(76, 194, 255, 0.18); } }

.tag {
  font: 10.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-2); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 3px; padding: 2px 7px; white-space: nowrap;
}

/* ── Columns ── */

.cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; align-items: start; margin-bottom: 18px; }
@media (max-width: 920px) { .cols { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ── Feed ── */

.feed { max-height: 460px; overflow-y: auto; font-size: 13px; }
.feed-row {
  display: grid; grid-template-columns: 52px 82px minmax(0, 1fr); gap: 12px;
  padding: 8px 14px; border-bottom: 1px solid var(--line); align-items: baseline;
}
.feed-row:last-child { border-bottom: 0; }
.feed-row.fresh { animation: enter 240ms ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(3px); } }
.feed-t { font: 10.5px var(--mono); color: var(--text-3); white-space: nowrap; }
.feed-a { font: 600 11px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ag, var(--accent)); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-x { color: var(--text-2); overflow-wrap: anywhere; }
.feed-x code, .code code, .prose code { font: 12px var(--mono); }
.feed-x code { color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
.t-err { color: var(--err); }
.live { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.3s ease-in-out infinite; }

/* ── Table ── */

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 9px 14px;
  font: 600 10.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3);
  border-bottom: 1px solid var(--line-2);
}
.tbl td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--panel-2); }
.tbl a { text-decoration: none; font-weight: 550; }
.tbl a:hover { color: var(--accent); }
.mono { font: 12px var(--mono); color: var(--text-2); }
.dim { color: var(--text-3); font-size: 12px; }
.sum-cell { color: var(--text-2); }

/* ── Profile ── */

.profile { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.profile-block { width: 44px; height: 44px; border-radius: var(--r); background: color-mix(in srgb, var(--ag) 16%, transparent); border: 1px solid color-mix(in srgb, var(--ag) 40%, transparent); display: grid; place-items: center; font: 700 13px var(--mono); color: var(--ag); letter-spacing: 0.05em; }
.profile-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.profile-main h1 { margin: 0; font-size: 23px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 12px; }
.profile-role { margin: 0; font-size: 13.5px; color: var(--text-2); }
.profile-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.actions { display: flex; gap: 8px; }

/* ── Buttons, forms ── */

.btn {
  font: 550 13px var(--font); color: #0b0c0e;
  background: var(--text); border: 1px solid var(--text);
  border-radius: var(--r); padding: 7px 14px; cursor: pointer;
}
.btn:hover { background: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: transparent; color: var(--text-2); border-color: var(--line-2); }
.btn.ghost:hover { color: var(--text); border-color: var(--text-3); background: var(--panel-2); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

.form { display: flex; flex-direction: column; gap: 10px; }
.in {
  font: 13px var(--font); color: var(--text);
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 8px 10px; width: 100%;
}
.in:focus { outline: none; border-color: var(--accent); }
.form .btn { align-self: flex-start; }

/* ── Mail ── */

.mail { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.mail:last-child { border-bottom: 0; }
.mail.unread { box-shadow: inset 2px 0 0 var(--accent); }
.mail-head { display: flex; justify-content: space-between; gap: 12px; font: 11px var(--mono); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.mail-subject { font-weight: 600; font-size: 13.5px; margin: 4px 0 2px; }
.mail-body { font-size: 13px; color: var(--text-2); }
.mail-body p { margin: 0 0 8px; }
.mail .btn { margin-top: 8px; }

/* ── Prose (reports, charters, memory) ── */

.prose { font-size: 13.5px; line-height: 1.65; color: var(--text-2); overflow-wrap: anywhere; }
.prose h3, .prose h4, .prose h5 { color: var(--text); margin: 18px 0 8px; font-size: 13px; font-weight: 650; }
.prose h3 { font-size: 14.5px; }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0 0 10px; padding-left: 20px; }
.prose li { margin-bottom: 4px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.prose code { color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
.prose a { color: var(--accent); }
.code, .prose pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; overflow-x: auto; margin: 0 0 10px;
}
.ag-code { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; overflow-x: auto; margin: 0 0 10px; }
.ag-code code { font: 12px var(--mono); }

.fold > summary {
  cursor: pointer; padding: 11px 14px; list-style: none;
  font: 600 11px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:hover { color: var(--text); }
.fold[open] > summary { border-bottom: 1px solid var(--line); }
.fold .panel-body { padding-top: 12px; }

.empty { color: var(--text-3); font-size: 13px; padding: 18px 14px; margin: 0; }

/* ── KPIs ── */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 18px; }
.kpi { background: var(--panel); padding: 11px 14px; }
.kpi b { display: block; font: 600 18px var(--mono); }
.kpi span { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; }

/* ── Login ── */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login {
  width: 100%; max-width: 360px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 28px;
}
.login .brand { margin-bottom: 6px; }
.login h1 { font-size: 16px; margin: 14px 0 2px; }
.login .sub { color: var(--text-3); font-size: 13px; margin: 0 0 18px; }
.login label { display: block; font: 600 10.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); margin: 12px 0 5px; }
.login .btn { width: 100%; margin-top: 16px; }
.form-error { color: var(--err); font-size: 13px; margin: 12px 0 0; }

/* ── Toast ── */

.toast { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast-item {
  background: var(--panel-2); border: 1px solid var(--line-2); border-left: 2px solid var(--accent);
  border-radius: var(--r); padding: 9px 13px; font-size: 13px;
  animation: enter 200ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .st.running i, .live { animation: none; }
  .feed-row.fresh, .toast-item { animation: none; }
}
