/* AgentOS Console — "Clearance" design. Light, warm, governance-forward. */

:root {
  --bg: #f7f6f3;
  --surface: #fcfbf9;
  --surface-2: #f3f1ec;
  --ink: #23211c;
  --ink-2: #55524a;
  --muted: #6f6b61;
  --line: rgba(24, 22, 16, 0.08);
  --line-strong: rgba(24, 22, 16, 0.14);
  --accent: #2456a6;
  --accent-soft: rgba(36, 86, 166, 0.08);
  --accent-ink: #183c78;
  --good: #006300;
  --good-dot: #0ca30c;
  --warn: #7a5a10;
  --warn-bg: #fbf3df;
  --warn-line: #ecdcb4;
  --danger: #a12e2e;
  --danger-bg: #faeeea;
  --idle-dot: #b5b1a6;
  --radius: 10px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Instrument Sans', -apple-system, 'Helvetica Neue', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }
button { font-family: inherit; cursor: pointer; }

.hidden { display: none !important; }

/* ---- Auth screen ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 380px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 12px 40px rgba(24, 22, 16, 0.06);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.auth-logo {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.auth-title { font-family: 'Instrument Serif', Georgia, serif; font-size: 26px; margin: 14px 0 2px; }
.auth-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input {
  height: 40px; padding: 0 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: #fff; font-size: 14px; color: var(--ink);
}
.field input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn {
  height: 40px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-danger { color: var(--danger); border-color: #dfa3a3; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 12.5px; }
.btn-block { width: 100%; }
.auth-toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--ink-2); }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---- App shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: var(--surface); border-right: 1px solid var(--line);
  padding: 16px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.org { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 8px; }
.org-logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.org-name { flex: 1; font-weight: 600; }
.nav-group { font-size: 10.5px; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; margin: 14px 10px 2px; }
.nav-item {
  height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 13.5px; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .icon { width: 15px; height: 15px; flex: none; }
.nav-badge { min-width: 18px; height: 18px; border-radius: 9px; background: #b3760a; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; padding: 0 5px; margin-left: auto; }
.nav-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #e8e4da; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--ink-2); }

.main { flex: 1; min-width: 0; padding: 28px 36px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-title { font-family: 'Instrument Serif', Georgia, serif; font-size: 32px; line-height: 1.1; }
.page-sub { font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }
.head-actions { display: flex; gap: 10px; }

/* ---- Cards, tables, stats ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 15px; font-weight: 600; }
.card-hint { font-size: 11.5px; color: var(--muted); }
.card-pad { padding: 16px 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 12.5px; color: var(--ink-2); }
.stat-value { font-size: 27px; font-weight: 600; }
.stat-foot { font-size: 12px; color: var(--muted); }
.stat-foot.good { color: var(--good); }
.stat-foot.danger { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.col { display: flex; flex-direction: column; gap: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; letter-spacing: 0.6px; color: var(--muted); font-weight: 600;
  padding: 12px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface);
}
tbody td { padding: 0 18px; height: 50px; border-bottom: 1px solid rgba(24,22,16,0.06); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
td .name { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }
.table-scroll { overflow: auto; max-height: calc(100vh - 280px); }
.row-warn { background: var(--warn-bg); }
.row-danger { background: var(--danger-bg); }

.status { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.good { background: var(--good-dot); }
.dot.idle { background: var(--idle-dot); }
.status.good { color: var(--good); }
.status.muted { color: var(--ink-2); }
.status.warn { color: var(--warn); }
.status.danger { color: var(--danger); }
.pill { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 4px 10px; border: 1px solid var(--line-strong); color: var(--ink-2); }
.pill.warn { color: var(--warn); border-color: #d9bf7c; }
.pill.danger { color: var(--danger); border-color: #dfa3a3; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 12px 16px; }
.banner-main { display: flex; align-items: center; gap: 12px; }
.banner-title { font-size: 13.5px; font-weight: 600; color: #4a3a0e; }
.banner-sub { font-size: 12px; color: var(--warn); }

.mono { font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace; }
.code { font-family: ui-monospace, 'SF Mono', monospace; font-size: 11.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 6px; padding: 8px 10px; }

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.select, .search {
  height: 38px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 12.5px; color: var(--ink-2); font-family: inherit;
}
.search { min-width: 260px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 34px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-size: 12.5px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.empty { padding: 40px 18px; text-align: center; color: var(--muted); font-size: 13px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 18px; border-bottom: 1px solid rgba(24,22,16,0.06); }
.list-row:last-child { border-bottom: none; }
.list-row.selectable { cursor: pointer; }
.list-row.selectable:hover { background: var(--surface-2); }
.list-row.selected { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.list-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-title { font-size: 13px; font-weight: 600; }
.list-sub { font-size: 11.5px; color: var(--muted); }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); opacity: 0; transform: translateY(8px); transition: all .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.modal-back { position: fixed; inset: 0; background: rgba(24,22,16,0.35); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 24px; }
.modal { background: var(--surface); border-radius: 14px; width: 520px; max-width: 100%; max-height: 90vh; overflow: auto; padding: 24px; }
.modal h3 { margin: 0 0 16px; font-family: 'Instrument Serif', Georgia, serif; font-size: 24px; font-weight: 400; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
textarea { width: 100%; min-height: 120px; font-family: ui-monospace, monospace; font-size: 12px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px; resize: vertical; }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--good); }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-2-even { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .main { padding: 20px; }
}
