/* ============== TEND V4 DESIGN SYSTEM ============== */
:root {
  --bg: #F5F2EC; --bg-elev: #FFFFFF; --bg-soft: #FAF8F3; --bg-dark: #0E0D0C;
  --border: #E8E4DB; --border-strong: #D6D1C5;
  --text: #15130F; --text-2: #56524C; --muted: #9C9891; --muted-2: #B8B4AC; --muted-3: #C4C0B8;
  --green: #1F6B40; --green-bg: #E6F2EC;
  --red: #B83018; --red-bg: #FCEBE7;
  --blue: #2A4D8C; --blue-bg: #E8EEF5;
  --amber: #B85A0F; --amber-bg: #FCEFD9;
  --purple: #6B3D8C; --purple-bg: #F0E9F5;
  --shadow-sm: 0 1px 2px rgba(14,13,12,0.04);
  --shadow-md: 0 1px 3px rgba(14,13,12,0.05), 0 4px 12px rgba(14,13,12,0.04);
  --radius: 14px; --radius-lg: 16px; --radius-pill: 999px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); }
body { font-family: 'Inter', system-ui, sans-serif; font-size: 14px; color: var(--text); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* dot-matrix chart colors */
circle.d-l { fill: #C4C0B8; }
circle.d-d { fill: #15130F; }

/* ============== TOPBAR ============== */
.topbar { padding: 18px 32px; display: flex; align-items: center; justify-content: space-between; background: var(--bg); }
.topbar-l { display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.brand-mark { width: 22px; height: 22px; background: var(--text); border-radius: 5px; }
.scope { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.16em; font-weight: 600; }
.topbar-r { display: flex; align-items: center; gap: 18px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; }
.dot-live { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 6px; }
.user-pill { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--bg-elev); color: var(--text-2); font-family: 'Inter'; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--text); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; font-family: 'Inter'; }

/* ============== NAV ============== */
.nav { padding: 0 32px; display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); }
.nav-item { padding: 14px 16px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; transition: color .12s; display: inline-flex; align-items: center; gap: 8px; }
.nav-item:hover { color: var(--text-2); }
.nav-item.active { color: var(--text); border-bottom-color: var(--text); }
.nav-count { background: var(--red-bg); color: var(--red); font-size: 9.5px; padding: 1px 7px; border-radius: var(--radius-pill); font-weight: 700; letter-spacing: 0.08em; }
.nav-r { margin-left: auto; display: flex; gap: 4px; }
.nav-btn { padding: 8px 14px; border: 1px solid var(--border); background: var(--bg-elev); border-radius: var(--radius-pill); font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
.nav-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* ============== LAYOUT ============== */
.main { max-width: 1280px; margin: 0 auto; padding: 32px; }
.main-narrow { max-width: 1080px; margin: 0 auto; padding: 32px; }
.row { display: grid; gap: 20px; }
.row-2 { grid-template-columns: 2fr 1fr; }
.row-2-eq { grid-template-columns: 1fr 1fr; }

/* ============== TYPE PRIMITIVES ============== */
.eyebrow { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.18em; font-weight: 700; }
.h-page { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin-top: 8px; }
.h-section { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.sub { font-size: 14px; color: var(--text-2); line-height: 1.55; margin-top: 8px; max-width: 720px; }
.mono-meta { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; }

/* page header (eyebrow + h + sub) */
.page-head { padding-bottom: 28px; }

/* ============== CARD ============== */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-lg { border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.card-pad { padding: 22px 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 22px 26px 14px; }
.section-body { padding: 0 26px 26px; }
.section-head-tight { padding: 18px 22px 12px; }
.section-body-tight { padding: 0 22px 22px; }

/* ============== BUTTONS ============== */
.btn-primary { padding: 12px 18px; background: var(--text); color: #fff; border: 0; border-radius: var(--radius-pill); font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; }
.btn-primary:hover { background: #2a2723; }
.btn-secondary { padding: 12px 18px; background: var(--bg-elev); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; }
.btn-secondary:hover { border-color: var(--text); }
.btn-ghost { padding: 8px 14px; background: transparent; color: var(--text-2); border: 0; font-family: 'JetBrains Mono', monospace; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
.btn-ghost:hover { color: var(--text); }

/* ============== KPI CARDS ============== */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-top { padding: 18px 20px 14px; }
.kpi-label { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.16em; font-weight: 600; }
.kpi-stat { font-family: 'JetBrains Mono', monospace; font-size: 28px; font-weight: 500; letter-spacing: -0.01em; line-height: 1; margin-top: 8px; color: var(--text); }
.kpi-stat .unit { font-size: 14px; color: var(--text-2); margin-left: 1px; }
.kpi-stat.warn { color: var(--red); }
.kpi-delta { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; font-weight: 600; margin-top: 8px; color: var(--green); }
.kpi-delta.bad { color: var(--red); }
.kpi-chart { padding: 4px 16px 14px; }
.kpi-chart svg { width: 100%; display: block; }

/* ============== AGENT TILES ============== */
.agent-glyph { width: 36px; height: 36px; border-radius: 8px; background: var(--text); color: #fff; display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.agent-glyph.scout { background: var(--green); }
.agent-glyph.chase { background: var(--blue); }
.agent-glyph.milo  { background: var(--purple); }
.agent-glyph.vera  { background: var(--amber); }
.agent-glyph.tally { background: #4A6B6B; }
.agent-glyph-lg { width: 48px; height: 48px; border-radius: 10px; font-size: 14px; }

/* compact agent row (used on workspace home + agents page list) */
.agent { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft); transition: border-color .12s; }
.agent:hover { border-color: var(--border-strong); background: var(--bg-elev); }
.agent-name { font-size: 14px; font-weight: 600; }
.agent-role { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; margin-top: 2px; }
.agent-spark { width: 92px; }
.agent-spark svg { width: 100%; height: 28px; display: block; }
.agent-stat { text-align: right; min-width: 72px; }
.agent-stat-v { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 600; }
.agent-stat-l { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; margin-top: 2px; }

/* ============== STATUS DOTS / BADGES ============== */
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-dot.green { background: var(--green); animation: pulse 2.4s infinite; }
.status-dot.red   { background: var(--red); animation: pulse 1.4s infinite; }
.status-dot.amber { background: var(--amber); }
.status-dot.muted { background: var(--muted-2); }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.85); } }
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: var(--radius-pill); font-family: 'JetBrains Mono', monospace; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red   { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue  { background: var(--blue-bg); color: var(--blue); }
.badge.muted { background: #EFEBE2; color: var(--text-2); }

/* ============== FEED ============== */
.feed-row { display: grid; grid-template-columns: 64px auto 1fr; align-items: start; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.feed-row:first-child { border-top: 0; }
.feed-time { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; padding-top: 2px; }
.feed-ic { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.feed-ic.ok { background: var(--green-bg); color: var(--green); }
.feed-ic.info { background: var(--blue-bg); color: var(--blue); }
.feed-ic.warn { background: var(--amber-bg); color: var(--amber); }
.feed-ic.bad { background: var(--red-bg); color: var(--red); }
.feed-text { font-size: 13px; line-height: 1.55; color: var(--text-2); }
.feed-text strong { color: var(--text); font-weight: 600; }

/* ============== LIST ROWS (rooms, items, etc) ============== */
.list-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px; padding: 18px 22px; border-top: 1px solid var(--border); transition: background .12s; }
.list-row:first-of-type { border-top: 0; }
.list-row:hover { background: var(--bg-soft); }
.list-id { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; min-width: 56px; }
.list-title { font-size: 14px; font-weight: 600; }
.list-meta { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; margin-top: 4px; }
.list-arrow { font-family: 'JetBrains Mono', monospace; color: var(--muted); font-size: 16px; }

/* ============== VERSION FLAG ============== */
.flag { position: fixed; bottom: 18px; right: 18px; padding: 8px 14px; background: var(--text); color: #fff; border-radius: var(--radius-pill); font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: 0.16em; font-weight: 700; display: flex; gap: 12px; align-items: center; z-index: 99; }
.flag a { color: var(--muted-3); }
.flag a:hover { color: #fff; }

/* ============== RESPONSIVE ============== */
@media (max-width: 1080px) {
  .row-2, .row-2-eq { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .main, .main-narrow { padding: 20px; }
  .h-page { font-size: 26px; }
  .topbar, .nav { padding-left: 20px; padding-right: 20px; }
  .topbar-r > span:not(.user-pill) { display: none; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr; }
}
