/* ── Landscape UI ─────────────────────────────────────── */
:root {
  /* SavvyOtter brand — steel blue + warm charcoal. Light theme (default). */
  --bg: #e9edf3;               /* tinted (not white) so white cards pop */
  --surface: #ffffff;
  --border: #dbe0e7;
  --text: #272320;
  --muted: #6f6a62;
  --ink: #3a352f;              /* logo charcoal — headings */
  --green: #2e8b4f;
  --yellow: #b7791f;
  --red: #c0392b;
  --blue: #1f6fb0;             /* steel blue — primary + links (a touch richer) */
  --blue-strong: #195a90;
  --blue-soft: #dceaf6;        /* tinted blue surface for accents */
  --radius: 9px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.08);

  /* Branded top bar (deep charcoal with a blue lean) */
  --nav-bg: #2b2f3a;
  --nav-fg: #f3f1ee;
  --nav-fg-muted: #b7bdc9;
  --nav-active: rgba(255,255,255,.14);

  --danger-bg: #fdeceb;  --danger-fg: #b42318;  --danger-border: #f3c5c0;
  --success-bg: #e9f6ec; --success-fg: #1e7a34; --success-border: #c0e3c9;
  --warn-bg: #fdf3e2;    --warn-fg: #8a5a00;    --warn-border: #f0dcae;
  --info-bg: #e9f1f8;    --info-fg: #275d85;    --info-border: #c4dcef;
}

html[data-theme="dark"] {
  /* Brand dark — warm charcoal surfaces (not cool navy) + lighter steel blue. */
  --bg: #1b1916;
  --surface: #252220;
  --border: #38332d;
  --text: #ece7df;
  --muted: #a39a8c;
  --ink: #ece7df;
  --green: #5cc16d;
  --yellow: #e0b34d;
  --red: #e06b5c;
  --blue: #5fa0d4;
  --blue-strong: #7bb4e0;
  --blue-soft: #1d3447;
  --shadow: 0 1px 2px rgba(0,0,0,.30), 0 4px 14px rgba(0,0,0,.40);

  --nav-bg: #161922;
  --nav-fg: #ece7df;
  --nav-fg-muted: #9aa1ae;
  --nav-active: rgba(255,255,255,.10);

  --danger-bg: #3a1d1a;  --danger-fg: #f0a79b;  --danger-border: #5a2a25;
  --success-bg: #15301d; --success-fg: #8fd6a0; --success-border: #234e30;
  --warn-bg: #33280f;    --warn-fg: #e6c578;    --warn-border: #4d3c18;
  --info-bg: #16293a;    --info-fg: #9cc4e6;    --info-border: #28455f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }

.top-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 110px;
  background: var(--nav-bg); border-bottom: 1px solid rgba(0,0,0,.2);
  position: sticky; top: 0; z-index: 100;
}
.nav-brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 1.05rem; font-weight: 700; color: var(--nav-fg); text-decoration: none;
  white-space: nowrap; letter-spacing: .2px;
}
.nav-brand:hover { color: var(--nav-fg); }
.nav-links { display: flex; align-items: center; gap: 0.25rem; }
.nav-links .nav-link {
  font-size: 0.82rem; color: var(--nav-fg-muted); padding: 0.4rem 0.7rem;
  border-radius: var(--radius); text-decoration: none; transition: background .15s, color .15s;
}
.nav-links .nav-link:hover, .nav-links .nav-link.active { background: var(--nav-active); color: var(--nav-fg); }
.nav-signout { color: var(--nav-fg-muted) !important; }

/* ── In-module tab navigation (e.g. Current: Clients · Board · Billing) ── */
.module-nav {
  display: flex; align-items: center; gap: 0.25rem;
  padding: 0 2rem; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.module-tab {
  padding: 0.8rem 1rem; font-size: 0.86rem; font-weight: 500;
  color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.module-tab:hover { color: var(--text); }
.module-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Current: nested hierarchy (Client › Project › Card) ── */
.cur-client-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 0.6rem; margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--blue);
}
.cur-client-title { font-size: 1.12rem; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 0.5rem; }
.cur-client-title .ic { color: var(--blue); font-size: 1rem; }

.cur-project {
  margin: 0.5rem 0 0.5rem 0.5rem; padding: 0.5rem 0 0.5rem 1rem;
  border-left: 3px solid var(--blue-soft);
}
.cur-project-head { display: flex; align-items: center; justify-content: space-between; }
.cur-project-title { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 0.45rem; }
.cur-project-title .ic { color: var(--blue); }

.cur-cards { margin: 0.4rem 0 0 0.4rem; padding-left: 1rem; border-left: 1px dashed var(--border); display: flex; flex-direction: column; gap: 0.1rem; }
.cur-card-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; padding: 0.18rem 0; }
.cur-card-row .dot { color: var(--blue); font-size: 0.7rem; line-height: 1; }
.cur-subhead { color: var(--muted); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Category color coding (work type) */
.cat-project  { background: var(--info-bg);    color: var(--info-fg); }
.cat-billable { background: var(--success-bg); color: var(--success-fg); }
.cat-warranty { background: var(--warn-bg);    color: var(--warn-fg); }
.cat-internal { background: var(--border);     color: var(--muted); }

/* User avatars (photo or colored initials) */
.avatar { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; overflow: hidden; object-fit: cover; flex-shrink: 0; vertical-align: middle; line-height: 1; }

/* ── Nav dropdowns ── */
.nav-dropdown { position: relative; display: flex; align-items: center; }
.nav-dropdown-trigger { cursor: pointer; user-select: none; }
.nav-dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); min-width: 140px; z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,.25); padding: 0.25rem 0;
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-item {
  display: block; padding: 0.45rem 0.85rem;
  font-size: 0.82rem; color: var(--muted); text-decoration: none;
  transition: background .12s, color .12s; white-space: nowrap;
}
.nav-dropdown-item:hover, .nav-dropdown-item.active {
  background: var(--border); color: var(--text);
}
.app-main { flex: 1; min-height: 0; }

.dash-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 2rem; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.dash-header h2 { font-size: 1.25rem; font-weight: 600; }
.last-updated { font-size: 0.75rem; color: var(--muted); margin-top: 2px; display: block; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }

.btn-primary, .btn-secondary, .btn-outline, .btn-sm {
  padding: 0.45rem 1rem; border-radius: var(--radius); border: none;
  cursor: pointer; font-size: 0.85rem; font-weight: 500; transition: opacity .15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-strong); opacity: 1; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.75rem; }
.btn-warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-border); }
.btn-danger { background: var(--red); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.875rem; }
.alert-error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-fg); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success-fg); }

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1rem; padding: 1.5rem 2rem;
}

.server-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  border-left: 3px solid var(--border);
}
.server-card.healthy { border-left-color: var(--green); }
.server-card.warning { border-left-color: var(--yellow); }
.server-card.critical { border-left-color: var(--red); }
.server-card.unknown { border-left-color: var(--muted); }
.server-card.paused { border-left-color: #6366f1; opacity: 0.75; }
.paused-msg { font-size: 0.8rem; color: #93c5fd; margin: 0.5rem 0; font-style: italic; }

.card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.healthy { background: var(--green); }
.status-dot.warning { background: var(--yellow); }
.status-dot.critical { background: var(--red); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.ip { font-size: 0.75rem; color: var(--muted); }

.metrics { display: flex; flex-direction: column; gap: 0.5rem; }
.metric { display: grid; grid-template-columns: 36px 1fr 90px; align-items: center; gap: 0.5rem; }
.metric-label { font-size: 0.75rem; color: var(--muted); }
.metric-val { font-size: 0.75rem; color: var(--muted); text-align: right; }
.bar-wrap { background: var(--bg); border-radius: 4px; height: 6px; overflow: hidden; }
.bar { height: 100%; border-radius: 4px; transition: width .5s; min-width: 2px; }
.bar-ok { background: var(--green); }
.bar-warn { background: var(--yellow); }
.bar-critical { background: var(--red); }

.info-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.25rem; font-size: 0.75rem; color: var(--muted); }
.card-footer { font-size: 0.7rem; color: var(--muted); margin-top: 0.75rem; border-top: 1px solid var(--border); padding-top: 0.5rem; }
.error-msg { font-size: 0.8rem; color: var(--red); margin: 0.5rem 0; }

.badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 4px; font-weight: 500; }
.badge { background: var(--info-bg); color: var(--info-fg); }
/* Category colors must win over the base .badge background when both classes are present
   (board work-type chips + card category badges). Without this the later .badge rule above
   overrides .cat-* at equal specificity and every category collapses to the info color. */
.badge.cat-project  { background: var(--info-bg);    color: var(--info-fg); }
.badge.cat-billable { background: var(--success-bg); color: var(--success-fg); }
.badge.cat-warranty { background: var(--warn-bg);    color: var(--warn-fg); }
.badge.cat-internal { background: var(--border);     color: var(--muted); }
.badge-error { background: var(--danger-bg); color: var(--danger-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }
.badge-ok { background: var(--success-bg); color: var(--success-fg); }
.badge-off { background: var(--border); color: var(--muted); }
.badge-windows { background: var(--info-bg); color: var(--info-fg); }
.badge-paused { background: var(--info-bg); color: var(--info-fg); }
.pause-toggle { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--muted); cursor: pointer; }
.pause-toggle input { cursor: pointer; }

.empty-state { text-align: center; padding: 4rem 2rem; color: var(--muted); }
.empty-state p { margin-bottom: 1rem; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 360px; }
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.logo-icon { font-size: 2rem; }
.login-logo h1 { font-size: 1.5rem; margin-top: 0.25rem; }
.login-logo p { color: var(--muted); font-size: 0.85rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field label { font-size: 0.8rem; color: var(--muted); }
.field input { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 0.5rem 0.75rem; border-radius: var(--radius); font-size: 0.9rem; width: 100%; }
.field input:focus { outline: none; border-color: var(--blue); }
.login-card .btn-primary { width: 100%; padding: 0.6rem; }

.section-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 1.5rem 2rem; padding: 1.5rem; box-shadow: var(--shadow); }
.section-card h3 { margin-bottom: 1rem; font-size: 1rem; }

/* Card detail two-column layout: scope on the left, money & time on the right */
.card-cols { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.card-col-left  { flex: 1 1 520px; min-width: 0; }
.card-col-right { flex: 1 1 460px; min-width: 0; }
.card-cols .section-card { margin: 0 0 1.25rem 0; }
/* Compact, fluid tables inside card-detail forms (e.g. the estimate line editor) */
.card-cols .server-table.compact { table-layout: fixed; }
.card-cols .server-table.compact th,
.card-cols .server-table.compact td { padding: 0.45rem 0.4rem; }
.card-cols .server-table.compact .form-input { width: 100%; min-width: 0; box-sizing: border-box; }

/* Drag-and-drop file zone (a transparent <input type=file> overlays the styled zone) */
.dropzone { position: relative; border: 1.5px dashed var(--border); border-radius: 8px; padding: 1.1rem; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.dragging { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 7%, transparent); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-label { pointer-events: none; font-size: 0.85rem; line-height: 1.5; }
.dropzone-label span { font-size: 0.74rem; opacity: 0.8; }

/* Modal overlay + card (used by card close-out popup) */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 1rem; z-index: 1000; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 520px; padding: 1.5rem; max-height: 88vh; overflow-y: auto; }
.modal-card .modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-card .modal-head h3 { margin: 0; }
.modal-close { background: none; border: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--muted); }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.form-row .field { flex: 1; min-width: 160px; }
.form-row .field-sm { flex: 0 0 100px; }
.form-row .field-check { display: flex; align-items: flex-end; padding-bottom: 0.5rem; }
.pubkey-notice { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; margin: 0.75rem 0; font-size: 0.8rem; color: var(--muted); }
.pubkey-notice pre { margin-top: 0.5rem; word-break: break-all; white-space: pre-wrap; font-size: 0.72rem; }
.server-table { width: 100%; border-collapse: collapse; }
.server-table th, .server-table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.server-table th { color: var(--muted); font-weight: 500; }
.server-table td:last-child { display: flex; gap: 0.4rem; }
.empty-msg { color: var(--muted); }

.recommendation-box { margin-top: 1.25rem; padding: 1rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.recommendation-title { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.75rem; }
.recommendation-item { font-size: 0.85rem; color: var(--text); margin-bottom: 0.4rem; }
.recommendation-item em { color: var(--muted); }
.nav-brand-img-wrap {
  width: 78px; height: 78px; border-radius: 50%; background: #fff;
  overflow: hidden; flex-shrink: 0; box-shadow: 0 0 0 3px #fff;
}
.nav-brand-img-wrap img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  transform: scale(2.1) translateY(6%); transform-origin: center;
}
.recommendation-warn { color: var(--yellow); }
.recommendation-cmd { margin: 0.4rem 0 0.75rem 0; }

.patrol-status { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; min-width: 220px; }
.patrol-label { font-size: 0.72rem; color: var(--muted); }
.patrol-timer { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1; }
.patrol-countdown { display: flex; flex-direction: column; align-items: center; }
.patrol-progress { display: flex; flex-direction: column; align-items: stretch; gap: 0.35rem; width: 100%; }
.patrol-bar-wrap { background: var(--bg); border-radius: 4px; height: 6px; overflow: hidden; }
.patrol-bar { height: 100%; background: var(--blue); border-radius: 4px; transition: width .4s; }

.org-section { margin-bottom: 0.5rem; }
.org-header { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 2rem 0.25rem; border-bottom: 1px solid var(--border); }
.org-name { font-size: 0.95rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.org-status-pills { display: flex; gap: 0.4rem; }
.org-pill { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 4px; font-weight: 500; background: var(--border); color: var(--muted); text-transform: capitalize; }
.org-pill.healthy { background: var(--success-bg); color: var(--success-fg); }
.org-pill.warning { background: var(--warn-bg); color: var(--warn-fg); }
.org-pill.critical { background: var(--danger-bg); color: var(--danger-fg); }
.org-section .server-grid { padding-top: 1rem; padding-bottom: 1rem; }

.chart-section-row { display: flex; gap: 1rem; margin: 1.5rem 2rem; }
.chart-section-panel { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.chart-panel-title { font-size: 0.9rem; margin-bottom: 0.5rem; }
.chart-range-label { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.utilization-chart { width: 100%; height: auto; display: block; }
.chart-time-labels { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--muted); margin-top: 0.25rem; }

/* ── ALEXANDRIA page ──────────────────────────────────── */
.alex-page { display: flex; flex-direction: column; height: calc(100vh - 110px); }
.alex-tab-bar { display: flex; border-bottom: 1px solid var(--border); background: var(--surface); padding: 0 1.5rem; flex-shrink: 0; }
.alex-tab-btn { padding: 0.65rem 1.25rem; font-size: 0.85rem; color: var(--muted); background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; transition: color .15s; }
.alex-tab-btn:hover { color: var(--text); }
.alex-tab-btn.active { color: var(--text); border-bottom-color: var(--blue); }

/* ── Project Briefs layout ──────────────────────────────── */
.briefs-layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.briefs-sidebar { width: 220px; border-right: 1px solid var(--border); overflow-y: auto; padding: 0.75rem 0; flex-shrink: 0; background: var(--surface); }
.brief-sidebar-msg { padding: 0.75rem 1rem; font-size: 0.8rem; color: var(--muted); }
.brief-client-header { padding: 0.6rem 1rem 0.2rem; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 0.25rem; }
.brief-client-header:first-child { margin-top: 0; }
.brief-item { display: block; width: 100%; text-align: left; padding: 0.4rem 1rem 0.4rem 1.5rem; font-size: 0.83rem; color: var(--muted); background: none; border: none; cursor: pointer; transition: background .1s, color .1s; }
.brief-item:hover { background: var(--border); color: var(--text); }
.brief-item.active { background: var(--border); color: var(--text); font-weight: 500; }
.brief-content-panel { flex: 1; overflow-y: auto; padding: 2rem 2.5rem; }
.brief-content-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--muted); text-align: center; }

/* ── Rendered markdown content ──────────────────────────── */
.brief-content h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
.brief-content h2 { font-size: 1.15rem; font-weight: 600; margin-top: 1.75rem; margin-bottom: 0.5rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border); }
.brief-content h3 { font-size: 1rem; font-weight: 600; margin-top: 1.25rem; margin-bottom: 0.35rem; }
.brief-content p { margin-bottom: 0.75rem; line-height: 1.65; }
.brief-content ul, .brief-content ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
.brief-content li { margin-bottom: 0.25rem; line-height: 1.55; }
.brief-content code { background: var(--bg); border: 1px solid var(--border); padding: 0.1rem 0.3rem; border-radius: 3px; font-family: monospace; font-size: 0.82em; }
.brief-content pre { background: var(--bg); border: 1px solid var(--border); padding: 0.85rem 1rem; border-radius: var(--radius); overflow-x: auto; margin-bottom: 0.85rem; }
.brief-content pre code { background: none; border: none; padding: 0; font-size: 0.82rem; }
.brief-content table { width: 100%; border-collapse: collapse; margin-bottom: 0.85rem; font-size: 0.83rem; }
.brief-content th, .brief-content td { padding: 0.4rem 0.75rem; border: 1px solid var(--border); }
.brief-content th { background: var(--bg); font-weight: 600; color: var(--muted); }
.brief-content a { color: var(--blue); }
.brief-content blockquote { border-left: 3px solid var(--border); padding: 0.25rem 1rem; color: var(--muted); margin-bottom: 0.75rem; }
.brief-content hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.brief-content input[type="checkbox"] { margin-right: 0.4rem; }

/* ── Support / Chat page ─────────────────────────────── */
.support-page {
  display: flex; overflow: hidden;
  height: calc(100vh - 110px);
}
.alex-page .support-page { height: auto; flex: 1; min-height: 0; }

.chat-column {
  display: flex; flex-direction: column; flex: 1; min-width: 0;
  border-right: 1px solid var(--border);
}
.chat-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.chat-col-title { font-size: 1rem; font-weight: 600; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem 1.25rem;
  display: flex; flex-direction: column; gap: 0.75rem; min-height: 0;
}
.chat-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; text-align: center;
  color: var(--muted); padding: 2rem;
}
.chat-empty p { margin-bottom: 0.35rem; }

.message { display: flex; }
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }
.bubble {
  max-width: 72%; padding: 0.6rem 0.9rem; border-radius: var(--radius);
  font-size: 0.88rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.message.user .bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 2px; }
.message.assistant .bubble {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-bottom-left-radius: 2px;
}

.bubble.typing { display: flex; align-items: center; gap: 5px; padding: 0.75rem 1rem; }
.bubble.typing span {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); animation: typingDot 1.2s infinite;
}
.bubble.typing span:nth-child(2) { animation-delay: .2s; }
.bubble.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: .3; transform: scale(1); }
  30%           { opacity: 1;  transform: scale(1.2); }
}

.chat-input-row {
  display: flex; gap: 0.5rem; padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.chat-textarea {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 0.5rem 0.75rem; border-radius: var(--radius);
  font-size: 0.88rem; resize: none; font-family: inherit; line-height: 1.4;
}
.chat-textarea:focus { outline: none; border-color: var(--blue); }
.chat-textarea:disabled { opacity: .5; }

.chat-info-panel {
  width: 260px; flex-shrink: 0; overflow-y: auto; padding: 1.25rem;
  border-left: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; gap: 1.25rem;
}
.info-section { display: flex; flex-direction: column; gap: 0.4rem; }
.info-section-title {
  font-size: 0.7rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.1rem;
}
.info-list { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; color: var(--muted); }
.info-list li { line-height: 1.45; }
.example-query {
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
  padding: 0.4rem 0.65rem; border-radius: var(--radius); font-size: 0.78rem;
  text-align: left; cursor: pointer; transition: border-color .15s, color .15s; width: 100%;
}
.example-query:hover { border-color: var(--blue); color: var(--text); }
.info-link { display: block; font-size: 0.82rem; color: var(--blue); padding: 0.2rem 0; }
.info-link:hover { text-decoration: underline; }

/* ── PILLAR Page ── */
.pillar-page {
  display: flex; flex-direction: column; height: calc(100vh - 110px); overflow: hidden;
}
.pillar-section-title {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.75rem;
  display: flex; align-items: center;
}

/* Requests layout */
.pillar-requests-layout {
  display: grid; grid-template-columns: 400px 1fr; gap: 0;
  flex: 1; overflow: hidden; border-top: 1px solid var(--border);
}
.pillar-new-request {
  border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; overflow: hidden;
}
.pillar-request-list {
  padding: 1.5rem; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.pillar-empty { color: var(--muted); font-size: 0.88rem; }
.pillar-request-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.85rem 1rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.pillar-request-card.pillar-request-resolved { opacity: 0.6; }
.pillar-request-card.pillar-request-highlight { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,.25); }
/* ── Portal home / lander ─────────────────────────────── */
.portal-home { max-width: 1060px; margin: 0 auto; padding: 2.4rem 2rem 3rem; }

.portal-hero { text-align: center; padding: 0.5rem 0 2rem; }
.portal-logo-full { width: 100%; max-width: 340px; height: auto; }
.portal-hero h1 {
  font-size: 1.5rem; color: var(--ink); margin-top: 1rem;
  font-weight: 700; letter-spacing: -0.01em;
}
.portal-subtitle { color: var(--muted); font-size: 0.98rem; margin-top: 0.35rem; }

.portal-section-label {
  font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin: 0 0 0.8rem 0.15rem;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.05rem;
}

.portal-card {
  display: flex; align-items: flex-start; gap: 0.9rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.15rem;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
  position: relative;
}
.portal-card:hover {
  transform: translateY(-3px);
  border-color: var(--blue);
  box-shadow: 0 8px 22px rgba(16,24,40,0.12), 0 2px 6px rgba(16,24,40,0.08);
}
.portal-card-icon {
  flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; line-height: 1;
  background: var(--blue-soft);
}
.portal-card-body { min-width: 0; }
.portal-card-title { font-weight: 700; color: var(--ink); font-size: 1.02rem; }
.portal-card-desc { color: var(--muted); font-size: 0.86rem; line-height: 1.45; margin-top: 0.25rem; }
.portal-card::after {
  content: "→"; position: absolute; top: 1.05rem; right: 1.1rem;
  color: var(--blue); font-weight: 700;
  opacity: 0; transform: translateX(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.portal-card:hover::after { opacity: 1; transform: translateX(0); }

@media (max-width: 560px) {
  .portal-logo-full { max-width: 240px; }
  .portal-grid { grid-template-columns: 1fr; }
}

.pillar-request-header {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.pillar-client-badge {
  background: var(--blue); color: #fff; font-size: 0.7rem; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 999px; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pillar-request-date { font-size: 0.75rem; color: var(--muted); }
.pillar-request-summary { font-size: 0.9rem; font-weight: 500; }
.pillar-request-details {
  font-size: 0.82rem; color: var(--muted); white-space: pre-wrap;
  border-left: 2px solid var(--border); padding-left: 0.65rem; margin-top: 0.15rem;
}
.pillar-request-actions { display: flex; gap: 0.5rem; margin-top: 0.25rem; flex-wrap: wrap; }
.diag-panel {
  margin-top: 0.75rem; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0;
}
.diag-messages {
  max-height: 420px; overflow-y: auto; padding: 0.75rem 0.25rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.diag-messages .bubble { font-size: 0.875rem; }
.diag-messages .bubble p { margin: 0 0 0.4rem; }
.diag-messages .bubble p:last-child { margin-bottom: 0; }
.diag-messages .bubble h1, .diag-messages .bubble h2, .diag-messages .bubble h3 {
  font-size: 0.9rem; font-weight: 600; margin: 0.6rem 0 0.2rem;
}
.diag-messages .bubble code { font-size: 0.8rem; }
.diag-messages .bubble pre { font-size: 0.8rem; overflow-x: auto; }
.diag-input-row { padding: 0.5rem 0 0; border-top: 1px solid var(--border); }
.diag-status-log { padding: 0.25rem 0.5rem; font-size: 0.75rem; color: var(--muted); font-family: monospace; }
.diag-status-entry::before { content: '› '; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 0.85rem; padding: 0.1rem 0.3rem; color: var(--muted); border-radius: 3px; margin-left: auto; transition: color .15s; }
.btn-icon:hover { color: var(--text); }
.brief-item-row { display: flex; align-items: center; }
.brief-item-row .brief-item { flex: 1; }
.brief-item-link { flex-shrink: 0; margin-right: 0.5rem; font-size: 0.72rem; padding: 0.15rem 0.4rem; }
.pillar-resolved-section {
  margin-top: 0.5rem; color: var(--muted); font-size: 0.82rem;
}
.pillar-resolved-section summary { cursor: pointer; user-select: none; font-weight: 500; margin-bottom: 0.5rem; }
.pillar-resolved-section summary:hover { color: var(--text); }

/* Missions layout */
.pillar-missions-layout {
  display: grid; grid-template-columns: 220px 1fr; flex: 1; overflow: hidden;
  border-top: 1px solid var(--border);
}
.pillar-missions-sidebar {
  border-right: 1px solid var(--border); overflow-y: auto;
  background: var(--surface); padding: 0.75rem 0;
}
.pillar-missions-content { display: flex; flex-direction: column; overflow: hidden; }
.pillar-missions-list-panel {
  display: grid; grid-template-columns: 260px 1fr; flex: 1; overflow: hidden;
}
.pillar-missions-list {
  border-right: 1px solid var(--border); overflow-y: auto;
  background: var(--surface); padding: 0.75rem 0;
}

/* ── TEMPO Page ── */
.tempo-page { display: flex; flex-direction: column; height: calc(100vh - 110px); overflow: hidden; }
.tempo-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 1.25rem; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0; flex-wrap: wrap; gap: 0.5rem;
}
.tempo-range-presets { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.tempo-preset-btn {
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
  padding: 0.3rem 0.7rem; border-radius: var(--radius); font-size: 0.8rem;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.tempo-preset-btn:hover { border-color: var(--blue); color: var(--text); }
.tempo-preset-btn.active { border-color: var(--blue); color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, transparent); }
.tempo-custom-range { display: flex; align-items: center; gap: 0.35rem; margin-left: 0.5rem; }
.form-input-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; height: 28px; }
.tempo-sync-area { display: flex; align-items: center; gap: 0.75rem; }
.tempo-sync-label { font-size: 0.78rem; color: var(--muted); }
.tempo-sync-ok    { font-size: 0.78rem; color: var(--green); }
.tempo-sync-error { font-size: 0.78rem; color: var(--red, #ef4444); }
.tempo-loading { padding: 3rem; text-align: center; color: var(--muted); }
.tempo-empty   { padding: 3rem; text-align: center; color: var(--muted); font-size: 0.9rem; }

.tempo-summary-bar {
  display: flex; gap: 2rem; padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.tempo-summary-stat { display: flex; flex-direction: column; align-items: center; }
.tempo-summary-value { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.tempo-summary-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.tempo-content { flex: 1; overflow-y: auto; padding: 1.25rem 1.5rem; }

.tempo-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.tempo-table th {
  text-align: left; padding: 0.5rem 0.75rem; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.tempo-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tempo-table tr:last-child td { border-bottom: none; }
.tempo-table .text-right { text-align: right; }
.tempo-row-group { cursor: pointer; }
.tempo-row-group:hover td { background: color-mix(in srgb, var(--blue) 5%, transparent); }
.tempo-row-group.expanded td { background: color-mix(in srgb, var(--blue) 6%, transparent); font-weight: 500; }
.tempo-row-detail { cursor: pointer; }
.tempo-row-detail td { background: var(--surface); color: var(--muted); font-size: 0.84rem; }
.tempo-row-detail:hover td { background: color-mix(in srgb, var(--surface) 80%, var(--border)); }
.tempo-row-detail.expanded td { background: color-mix(in srgb, var(--surface) 60%, var(--border)); font-weight: 500; }
.tempo-row-entry td { background: color-mix(in srgb, var(--surface) 50%, transparent); color: var(--muted); font-size: 0.81rem; }
.tempo-expand-icon { display: inline-block; width: 1em; color: var(--muted); }

.tempo-worktype-badge {
  font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.5rem;
  border-radius: 999px; display: inline-block;
}
.wt-warranty    { background: #fef3c7; color: #92400e; }
.wt-nonwarranty { background: #dbeafe; color: #1e40af; }
.wt-project     { background: #d1fae5; color: #065f46; }
.wt-operations  { background: #f3e8ff; color: #6b21a8; }
.wt-other       { background: #f3f4f6; color: #6b7280; }

/* ── Brief Builder ────────────────────────────────────── */
.bb-page { display: flex; flex-direction: column; height: calc(100vh - 110px); overflow: hidden; }

.bb-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 1.25rem; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0; gap: 1rem; flex-wrap: wrap;
}
.bb-meta-fields { display: flex; align-items: center; gap: 1rem; }
.bb-field { display: flex; align-items: center; gap: 0.5rem; }
.bb-field label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.bb-field input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 0.35rem 0.65rem; border-radius: var(--radius); font-size: 0.85rem;
  width: 220px; font-family: inherit;
}
.bb-field input:focus { outline: none; border-color: var(--blue); }
.bb-status { font-size: 0.8rem; padding: 0.25rem 0.65rem; border-radius: var(--radius); }
.bb-status-ok  { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.bb-status-err { color: var(--red);   background: color-mix(in srgb, var(--red)   12%, transparent); }

.bb-columns { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* Chat column */
.bb-chat-col {
  display: flex; flex-direction: column; flex: 0 0 42%; min-width: 0;
  border-right: 1px solid var(--border); overflow: hidden;
}
.bb-col-header {
  padding: 0.55rem 1.25rem; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.bb-messages {
  flex: 1; overflow-y: auto; padding: 1rem 1.25rem;
  display: flex; flex-direction: column; gap: 0.75rem; min-height: 0;
}
.bb-chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--muted); text-align: center; font-size: 0.88rem; }
.bb-msg-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: -0.4rem; padding: 0 0.25rem; }
.bb-msg-tags.user { justify-content: flex-end; }
.bb-tag { font-size: 0.72rem; background: var(--border); color: var(--muted); padding: 0.15rem 0.5rem; border-radius: 999px; }

/* Bubble markdown override */
.bubble-md { white-space: normal; }
.bubble-md p { margin: 0.2rem 0; }
.bubble-md p:last-child { margin-bottom: 0; }
.bubble-md ul, .bubble-md ol { margin: 0.25rem 0 0.25rem 1.1rem; }
.bubble-md li { margin-bottom: 0.1rem; }
.bubble-md strong { font-weight: 600; }
.bubble-md code { font-size: 0.78rem; background: rgba(0,0,0,0.25); padding: 0.1em 0.3em; border-radius: 3px; font-family: monospace; }
.bubble-md pre  { font-size: 0.78rem; overflow-x: auto; margin: 0.35rem 0; }
.bubble-md h1, .bubble-md h2, .bubble-md h3 { font-size: 0.88rem; font-weight: 600; margin: 0.5rem 0 0.2rem; }
.bubble-md table { font-size: 0.78rem; border-collapse: collapse; margin: 0.3rem 0; }
.bubble-md th, .bubble-md td { border: 1px solid rgba(255,255,255,0.15); padding: 0.2rem 0.45rem; }

/* Input area */
.bb-input-area {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 0.75rem 1rem; flex-shrink: 0;
}
.bb-pending-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.bb-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.75rem; background: var(--border); color: var(--text);
  padding: 0.2rem 0.55rem; border-radius: 999px;
}
.bb-chip-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.85rem; line-height: 1; padding: 0; }
.bb-chip-remove:hover { color: var(--text); }
.bb-input-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.bb-input-btns { display: flex; flex-direction: column; gap: 0.4rem; }
.bb-attach-btn { cursor: pointer; font-size: 1rem; padding: 0.35rem 0.55rem; line-height: 1; }
.alert-error-inline { margin: 0 1rem 0.4rem; font-size: 0.82rem; color: var(--red); padding: 0.4rem 0.65rem; background: color-mix(in srgb, var(--red) 10%, transparent); border-radius: var(--radius); }

/* Preview column */
.bb-preview-col { display: flex; flex-direction: column; flex: 1; min-width: 0; overflow: hidden; }
.bb-preview-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.bb-tab {
  padding: 0.6rem 1.1rem; font-size: 0.82rem; color: var(--muted);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.bb-tab:hover { color: var(--text); }
.bb-tab.active { color: var(--text); border-bottom-color: var(--blue); font-weight: 500; }
.bb-tab:disabled { opacity: 0.4; cursor: default; }
.bb-preview-actions {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.bb-preview-content { flex: 1; overflow-y: auto; padding: 1.5rem 2rem; }
.bb-preview-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 0.88rem; text-align: center; max-width: 320px; margin: 0 auto; }
.bb-preview-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 0.88rem; }
.sow-document h1 { color: var(--blue); }

/* ── Usage Page ──────────────────────────────────────── */
.usage-key-badge {
  font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.5rem;
  border-radius: 999px; display: inline-block; text-transform: lowercase;
  letter-spacing: 0.02em;
}
.usage-key-user   { background: color-mix(in srgb, var(--blue)  14%, transparent); color: var(--blue); }
.usage-key-server { background: color-mix(in srgb, var(--red,#ef4444) 14%, transparent); color: var(--red,#ef4444); }

.usage-sparkline { display: block; }
.usage-sparkbar  { fill: color-mix(in srgb, var(--blue) 22%, transparent); }
.usage-sparkline-line {
  fill: none; stroke: var(--blue); stroke-width: 1.2;
  stroke-linejoin: round; stroke-linecap: round;
}

/* Print — show only the SOW content */
@media print {
  .top-nav, .bb-topbar, .bb-chat-col, .bb-preview-tabs, .bb-preview-actions { display: none !important; }
  .bb-page, .bb-columns, .bb-preview-col { display: block !important; height: auto !important; overflow: visible !important; }
  .bb-preview-content { padding: 0 !important; height: auto !important; overflow: visible !important; }
}
