/* /agents — fleet performance-review pages. Grayscale / dark, professional. */
/* Design tokens echo memory/wilder-design-tokens.json (screen theme, graphite #1B1D21). */

:root {
  --bg: #1B1D21;          /* graphite — deliberately not pure black */
  --bg-raise: #222428;    /* card background */
  --bg-inner: #2A2C31;    /* inner tag / nested surface */
  --border: #3A3C40;
  --text: #FFFFFF;        /* textPrimary */
  --text-2: #AAAAAA;      /* textSecondary */
  --text-3: #7C7E84;      /* between muted (#555) and secondary */
  --text-4: #555555;      /* textMuted */
  --accent: #00B4D8;      /* eyebrow accent — used sparingly */
  --ok: #3FB950;          /* green, success/fresh */
  --warn: #C9883A;        /* caution */
  --bad: #E8431A;         /* risk/incident */
  --mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }

/* --- header --- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.6rem 0 1.2rem;
}
.site-header .eyebrow {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 0.4rem;
}
.site-header h1 {
  font-size: 1.9rem; margin: 0 0 0.3rem; letter-spacing: -0.01em; font-weight: 700;
}
.site-header .sub { margin: 0; color: var(--text-2); }
.site-nav {
  display: flex; gap: 1.4rem; margin-top: 0.9rem;
  font-size: 0.85rem; color: var(--text-3);
}
.site-nav a.active { color: var(--text); font-weight: 600; }

/* --- fleet summary strip --- */
.fleet-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.stat-card {
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.85rem 1rem;
}
.stat-card .k { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-4); margin-bottom: 0.25rem; }
.stat-card .v { font-size: 1.25rem; font-weight: 700; }
.stat-card .v small { font-size: 0.75rem; font-weight: 400; color: var(--text-3); }
.stat-card .note { font-size: 0.72rem; color: var(--text-4); margin-top: 0.2rem; }

/* --- master agent grid --- */
.section-title {
  font-size: 0.85rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-3); margin: 2rem 0 0.9rem;
}
.agent-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.85rem;
}
.agent-card {
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.85rem 0.9rem; transition: border-color .15s ease, transform .15s ease;
}
.agent-card:hover { border-color: var(--text-3); transform: translateY(-1px); text-decoration: none; }
.avatar {
  width: 46px; aspect-ratio: 3 / 4; border-radius: 8px; flex: 0 0 auto;
  background: #F5F2EB; object-fit: contain; border: 1px solid var(--border);
}
.agent-card .meta { min-width: 0; }
.agent-card .name { font-weight: 700; font-size: 0.98rem; }
.agent-card .role-line { font-size: 0.78rem; color: var(--text-3); margin-top: 0.1rem; }
.agent-card .desc { font-size: 0.78rem; color: var(--text-2); margin-top: 0.35rem; line-height: 1.4; }

/* --- detail page --- */
.detail-head {
  display: flex; gap: 1.1rem; align-items: center; margin: 1.5rem 0 0.5rem;
}
.detail-head .avatar { width: 72px; aspect-ratio: 3 / 4; border-radius: 12px; }
.detail-head h2 { margin: 0; font-size: 1.6rem; }
.detail-head .role-line { color: var(--text-2); margin-top: 0.15rem; }
.back-link { display: inline-block; margin-top: 1rem; color: var(--text-3); font-size: 0.85rem; }

/* --- per-agent two-column layout (above-the-fold orientation) --- */
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
  margin: 1.2rem 0;
}
.detail-main { min-width: 0; }
.detail-errors {
  min-width: 0;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}

/* independently-scrolling errors column (own scroll, not the page's) */
.detail-errors .panel {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.errors-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.3rem;
  max-height: calc(100vh - 9rem);
  min-height: 4rem;
}

/* collapsible panels */
.panel.collapsible .panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.panel.collapsible .panel-head h3 { margin: 0; }
.expand-btn {
  font: inherit; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent); background: var(--bg-inner);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.18rem 0.55rem;
  cursor: pointer; white-space: nowrap;
}
.expand-btn:hover { border-color: var(--accent); }
.panel-summary { color: var(--text-2); margin: 0; font-size: 0.9rem; }
.panel-body { margin-top: 0.6rem; }
.panel-body[hidden] { display: none; }

.panel {
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.1rem 1.2rem; margin: 1.1rem 0;
}
.panel h3 {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-3); margin: 0 0 0.6rem;
}
.panel p { margin: 0.4rem 0; color: var(--text-2); }
.panel .src { font-size: 0.72rem; color: var(--text-4); margin-top: 0.5rem; font-family: var(--mono); word-break: break-all; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 0.35rem 1rem; font-size: 0.9rem; }
.kv .k { color: var(--text-4); }
.kv .v { color: var(--text); }

.badge { display: inline-block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 0.12rem 0.5rem; border-radius: 20px; border: 1px solid var(--border); }
.badge.ok { color: var(--ok); border-color: rgba(63,185,80,.4); }
.badge.warn { color: var(--warn); border-color: rgba(201,136,58,.4); }
.badge.bad { color: var(--bad); border-color: rgba(232,67,26,.4); }
.badge.neutral { color: var(--text-2); }

/* activity / error lists */
.entry { display: flex; gap: 0.8rem; padding: 0.5rem 0; border-bottom: 1px solid var(--bg-inner); font-size: 0.83rem; }
.entry:last-child { border-bottom: 0; }
.entry .t { color: var(--text-4); font-family: var(--mono); font-size: 0.74rem; flex: 0 0 auto; padding-top: 0.1rem; min-width: 118px; }
.entry .b { min-width: 0; }
.entry .a { font-weight: 600; color: var(--text-2); }
.entry .d { color: var(--text-3); margin-top: 0.1rem; word-break: break-word; }
.res { font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.res.success { color: var(--ok); }
.res.failure { color: var(--bad); }
.res.partial { color: var(--warn); }

.empty { color: var(--text-4); font-size: 0.85rem; }

/* lessons */
.lesson { border: 1px solid var(--border); border-radius: 8px; padding: 0.9rem 1rem; margin-bottom: 0.7rem; background: var(--bg-inner); }
.lesson .title { font-weight: 700; }
.lesson .body { color: var(--text-2); font-size: 0.87rem; margin-top: 0.3rem; }
.lesson .closure { margin-top: 0.55rem; font-size: 0.8rem; color: var(--text-3); border-left: 2px solid var(--accent); padding-left: 0.6rem; }
.lesson .closure .lab { font-weight: 700; color: var(--text); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* spend */
.spend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }
.spend-cell { background: var(--bg-inner); border-radius: 8px; padding: 0.7rem 0.8rem; }
.spend-cell .k { font-size: 0.68rem; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.08em; }
.spend-cell .v { font-size: 1.05rem; font-weight: 700; margin-top: 0.15rem; }
.spend-cell .v small { color: var(--text-3); font-weight: 400; font-size: 0.7rem; }

/* cron schedule table */
.cron-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.cron-table th { text-align: left; color: var(--text-4); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
.cron-table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--bg-inner); vertical-align: top; }
.cron-table tr:last-child td { border-bottom: 0; }
.cron-table .cad { white-space: nowrap; }
.cron-table .owner { color: var(--text-3); }
.cron-table code { font-family: var(--mono); font-size: 0.78rem; color: var(--text-2); }

.cadence-tag { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.1rem 0.45rem; border-radius: 4px; background: var(--bg-inner); border: 1px solid var(--border); color: var(--text-3); display: inline-block; }
.cadence-tag.daily { color: var(--ok); border-color: rgba(63,185,80,.35); }
.cadence-tag.weekly { color: var(--accent); border-color: rgba(0,180,216,.35); }
.cadence-tag.monthly { color: var(--warn); border-color: rgba(201,136,58,.35); }

.footer {
  border-top: 1px solid var(--border); margin-top: 3rem; padding: 1.4rem 0 3rem;
  color: var(--text-4); font-size: 0.78rem;
}
.footer a { color: var(--text-3); }

.hint { font-size: 0.78rem; color: var(--text-4); margin-top: 0.4rem; }
.mono { font-family: var(--mono); }

@media (max-width: 860px) {
  .detail-layout { grid-template-columns: 1fr; }
  .detail-errors { position: static; max-height: none; }
  .errors-scroll { max-height: 22rem; }
}

@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr; gap: 0.1rem; }
  .detail-head { flex-direction: column; align-items: flex-start; }
  .cron-table { font-size: 0.76rem; }
  .cron-table .expr { display: block; }
}