:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-soft: #f5f2ec;
  --ink: #121212;
  --ink-muted: #5c5852;
  --border: #e8e2d9;
  --gold: #c5a059;
  --gold-dark: #a5823e;
  --ok: #1f6b4b;
  --ok-bg: #eef7f2;
  --warn: #9a5b13;
  --warn-bg: #fdf5ea;
  --danger: #a63a3a;
  --danger-bg: #fbeeee;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 18, 18, 0.04), 0 8px 24px rgba(18, 18, 18, 0.04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-title, .topbar-brand {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.kpi-value, .bar-val, .event-time { font-variant-numeric: tabular-nums; }

/* LOGIN */
.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}
.brand-lockup { text-align: center; margin-bottom: 28px; }
.brand-kicker {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--gold-dark);
  margin-bottom: 6px;
}
.brand-title { font-size: 34px; margin: 0 0 6px; color: var(--ink); }
.brand-sub { margin: 0; font-size: 13px; color: var(--ink-muted); }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-foot { margin: 22px 0 0; text-align: center; font-size: 12px; color: var(--ink-muted); }

/* INPUTS & BUTTONS */
.field-label { font-size: 12px; font-weight: 600; color: var(--ink); }
.field-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field-input:focus { outline: none; border-color: var(--gold); background: var(--surface); }
.field-compact { max-width: 210px; min-height: 36px; padding: 6px 12px; font-size: 13px; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  min-height: 40px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--ink);
  color: #ffffff;
  border: 1px solid var(--ink);
}
.btn-primary:hover { background: #262626; }

.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--gold); }

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { color: var(--ink); background: var(--surface-soft); }

.btn-danger-soft {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f0d0d0;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
}
.btn-ok-soft {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid #cbe4d7;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
}

.form-error { margin: 4px 0 0; font-size: 12px; color: var(--danger); font-weight: 500; }

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 249, 246, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold-dark);
}
.topbar-brand { font-size: 24px; line-height: 1.1; color: var(--ink); }
.topbar-divider { color: var(--gold); margin: 0 4px; }
.topbar-section { font-family: "Plus Jakarta Sans", sans-serif; font-size: 14px; font-weight: 500; color: var(--ink-muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sync-stamp { font-size: 12px; color: var(--ink-muted); }
.zero-ai-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid #cbe4d7;
  padding: 5px 10px;
  border-radius: 999px;
}

/* LAYOUT */
.container { max-width: 1240px; margin: 0 auto; padding: 24px 24px 64px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); }
.kpi-value { font-family: "Cormorant Garamond", Georgia, serif; font-size: 34px; line-height: 1.05; color: var(--ink); }
.kpi-meta { font-size: 12px; color: var(--ink-muted); }

/* TABS */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  overflow-x: auto;
}
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--ink-muted);
  padding: 10px 16px;
  white-space: nowrap;
}
.tab.is-active { color: var(--ink); border-bottom-color: var(--gold); }
.tab-badge {
  display: inline-block;
  margin-left: 6px;
  background: var(--gold);
  color: #ffffff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
}

.section-head { margin-bottom: 16px; }
.section-head-inline { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-title { font-size: 24px; margin: 0 0 2px; }
.section-desc { margin: 0; font-size: 13px; color: var(--ink-muted); }

/* AGENTS GRID */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow);
}
.agent-card.is-paused { border-color: #ecd1d1; background: #fffdfb; }
.agent-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.agent-layer { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-dark); }
.agent-name { font-size: 22px; margin: 2px 0 4px; }
.agent-desc { font-size: 12.5px; color: var(--ink-muted); margin: 0; }
.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill.active { background: var(--ok-bg); color: var(--ok); }
.status-pill.paused { background: var(--danger-bg); color: var(--danger); }
.agent-meta {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.agent-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* TWO-COL & CARDS */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.bars-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.bar-row { display: flex; flex-direction: column; gap: 4px; }
.bar-head { display: flex; justify-content: space-between; font-size: 12.5px; }
.bar-track { height: 8px; background: var(--surface-soft); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--gold); border-radius: 999px; }

.inline-form { display: flex; gap: 8px; margin: 14px 0 16px; }
.stack-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; max-height: 520px; overflow-y: auto; }
.item-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-tag { font-size: 11px; font-weight: 700; color: var(--gold-dark); letter-spacing: 0.04em; }
.item-time { font-size: 11px; color: var(--ink-muted); }
.item-body { margin: 0; font-size: 13px; color: var(--ink); word-break: break-word; }
.item-actions { display: flex; gap: 8px; margin-top: 4px; }

.events-table { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.event-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 12.5px;
}
.event-type { font-weight: 700; color: var(--ink); word-break: break-word; }
.event-detail { color: var(--ink-muted); word-break: break-word; }
.empty-state { font-size: 13px; color: var(--ink-muted); padding: 18px 0; text-align: center; }

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--ink);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  z-index: 50;
}

@media (max-width: 1080px) {
  .agents-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .topbar { padding: 12px 16px; }
  .container { padding: 16px 14px 48px; }
  .agents-grid, .two-col { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; }
  .event-row { grid-template-columns: 1fr; gap: 4px; }
}
