/* ---------- design tokens ---------- */
:root {
  --bg-page: #f5f5f3;
  --bg-card: #ffffff;
  --bg-sidebar: #f0efed;
  --bg-hover: #ebe9e4;
  --bg-active: #e1dfd9;

  --text-1: #1a1a18;
  --text-2: #6b6b67;
  --text-3: #9c9a92;

  --border: #e5e4e0;
  --border-strong: #d6d4cd;

  --accent: #185FA5;
  --accent-hover: #144d85;
  --accent-soft: #e6efF8;

  --status-done:    #639922;
  --status-attn:    #BA7517;
  --status-urgent:  #E24B4A;
  --status-idle:    #888780;

  --tag-review-bg: #FAEEDA;
  --tag-review-fg: #633806;
  --tag-urgent-bg: #FCE3E3;
  --tag-urgent-fg: #8a2624;
  --tag-working-bg: #EEEDFE;
  --tag-working-fg: #3C3489;
  --tag-done-bg: #EAF3DE;
  --tag-done-fg: #27500A;
  --tag-idle-bg: #ecebe7;
  --tag-idle-fg: #4f4e4a;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.18);

  --sidebar-w: 200px;
}

/* ---------- dark mode ---------- */
html[data-theme="dark"] {
  --bg-page: #16140f;
  --bg-card: #1f1d18;
  --bg-sidebar: #131210;
  --bg-hover: #2a2722;
  --bg-active: #353027;

  --text-1: #ebe9e2;
  --text-2: #9e9b91;
  --text-3: #6b6862;

  --border: #2c2a25;
  --border-strong: #403d36;

  --accent: #4892d8;
  --accent-hover: #65a4e3;
  --accent-soft: #1a3354;

  --status-done:    #88be3a;
  --status-attn:    #d68f2a;
  --status-urgent:  #ec5e5d;
  --status-idle:    #888780;

  --tag-review-bg: #3e2e10;
  --tag-review-fg: #f0d49b;
  --tag-urgent-bg: #401818;
  --tag-urgent-fg: #f4a8a7;
  --tag-working-bg: #1f1c4d;
  --tag-working-fg: #b9b4f5;
  --tag-done-bg: #1f3008;
  --tag-done-fg: #c8e08a;
  --tag-idle-bg: #2a2722;
  --tag-idle-fg: #b3b0a7;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow:    0 4px 12px rgba(0,0,0,0.45);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.6);

  color-scheme: dark;
}

html[data-theme="dark"] .draft,
html[data-theme="dark"] pre.draft {
  background: #0e0d0a;
  color: #d8d6cf;
  border-color: var(--border);
}

html[data-theme="dark"] .data-table thead th { background: #1a1814; }
html[data-theme="dark"] .row-clickable:hover td { background: #25221d; }
html[data-theme="dark"] .list-detail { background: #1a1814; }
html[data-theme="dark"] .list-row:hover { background: #1f1d18; }
html[data-theme="dark"] .nav-item.active { background: #2a2722; }
html[data-theme="dark"] .tag-thread { background: #1f2a3e; color: #a8c0e3; }
html[data-theme="dark"] .toast { background: #2a2722; color: var(--text-1); }
html[data-theme="dark"] .iframe-host { background: var(--bg-page); }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-1);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-1);
  transition: background 80ms ease, border-color 80ms ease;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { background: var(--bg-active); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-1); }
.btn-block { width: 100%; }

/* ---------- form fields ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  outline: none;
  transition: border-color 80ms ease, box-shadow 80ms ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- tags ---------- */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--tag-idle-bg);
  color: var(--tag-idle-fg);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tag-urgent  { background: var(--tag-urgent-bg);  color: var(--tag-urgent-fg);  }
.tag-review  { background: var(--tag-review-bg);  color: var(--tag-review-fg);  }
.tag-working { background: var(--tag-working-bg); color: var(--tag-working-fg); }
.tag-done    { background: var(--tag-done-bg);    color: var(--tag-done-fg);    }

/* provider badges */
.tag-prov-anthropic { background: #EEEDFE; color: #3C3489; }
.tag-prov-openai    { background: #EAF3DE; color: #27500A; }
.tag-prov-xai       { background: #FAEEDA; color: #633806; }

/* ---------- card ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

/* ---------- login page ---------- */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px 20px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: 13px;
  border-radius: var(--radius-sm); letter-spacing: 0.02em;
}
.login-title { font-weight: 600; font-size: 15px; }
.login-subtitle { font-size: 12px; color: var(--text-2); }
.login-error { margin: 10px 0 0; font-size: 12px; color: var(--status-urgent); }
.login-foot { margin: 18px 0 0; font-size: 11px; color: var(--text-3); text-align: center; }

/* ---------- app shell ---------- */
.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: 11px;
  border-radius: var(--radius-sm);
}
.brand-title { font-weight: 600; font-size: 13px; }
.brand-subtitle { font-size: 11px; color: var(--text-2); }

.sidebar-nav { display: flex; flex-direction: column; gap: 1px; padding: 10px 8px; overflow-y: auto; flex: 1; }
.nav-header {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; font-size: 13px; color: var(--text-1);
  border-radius: var(--radius-sm); cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--bg-card); border: 1px solid var(--border); font-weight: 500; }
.nav-count {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 999px;
}
.nav-count[hidden] { display: none; }

.sidebar-foot { padding: 10px 12px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text-1); }

/* ---------- main area ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  position: sticky; top: 0; z-index: 1;
}
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar-meta { font-size: 12px; color: var(--text-2); }

.content { padding: 20px; display: grid; gap: 12px; max-width: 1400px; }

/* Iframe-hosted section (e.g. Quote Builder) — fills the entire main pane,
   no padding, no max-width, no scrollbars from the wrapper. */
.iframe-host {
  position: fixed;
  top: 56px;        /* below the topbar */
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  background: var(--bg-card);
}
.iframe-embed { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 720px) {
  .iframe-host { left: 0; }
}

/* ---------- section head ---------- */
/* Sections live as children of `.content` (a CSS grid). `display: contents`
   lets each section's *children* become grid items so cards line up across
   sections. We need a more specific selector to ensure [hidden] still hides. */
.section { display: contents; }
.section[hidden] { display: none; }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; margin-bottom: 4px;
}
.section-head p { margin: 0; font-size: 13px; }
.section-actions { display: flex; gap: 6px; }

/* ---------- list (inbox / approvals / proposals) ---------- */
.list { display: grid; gap: 8px; }
.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.list-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px;
  cursor: pointer;
}
.list-row:hover { background: #fafaf8; }
.list-main { flex: 1; min-width: 0; }
.list-line1 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list-name { font-weight: 500; }
.list-line2 { color: var(--text-1); margin-top: 2px; }
.list-line2.muted { color: var(--text-2); }
.list-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.list-actions { display: flex; gap: 6px; margin-top: 6px; }

.list-detail {
  border-top: 1px solid var(--border);
  padding: 12px;
  background: #fbfbf9;
}
.detail-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.detail-block h4 { font-size: 12px; color: var(--text-2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.detail-block p { margin: 0; }
.detail-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; margin-right: 4px; }

/* Threaded conversations in inbox */
.tag-thread { background: #e8eef7; color: #1a3a64; }
.thread { display: grid; gap: 10px; }
.thread-msg {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.thread-msg-last { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.thread-msg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.thread-msg-subject { font-weight: 500; margin-bottom: 4px; }
.thread-msg-body { font-size: 13px; color: var(--text-1); margin-bottom: 6px; white-space: pre-wrap; }
.thread-msg-notes { margin-bottom: 6px; }
.thread-msg-draft { margin-top: 8px; }
.thread-msg-toolbar { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.thread-msg-full { margin: 6px 0; max-height: 480px; overflow: auto; }
.thread-msg-full pre { max-height: none; }

.thread-msg-attachments { margin: 8px 0; display: grid; gap: 6px; }
.attachment-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.attachment-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.attachment-info > span:nth-child(2) { font-weight: 500; word-break: break-all; }
.attachment-actions { display: flex; gap: 6px; align-items: center; }
.attachment-parse-result { grid-column: 1 / -1; margin-top: 6px; }

.parse-card {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}
.parse-card-head { display: flex; gap: 8px; align-items: center; }
.parse-summary { font-size: 13px; }
.parse-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
  margin-top: 4px;
}
.parse-field { display: flex; flex-direction: column; gap: 2px; }
.parse-field > span:last-child { font-size: 13px; word-break: break-word; }

.apply-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px; margin-top: 6px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--accent);
}
html[data-theme="dark"] .apply-row {
  background: rgba(72, 146, 216, 0.08);
}

/* Fade out resolved threads as they leave the inbox. */
.thread-resolved {
  transition: opacity 0.35s ease, transform 0.35s ease;
  opacity: 0;
  transform: translateX(-16px);
  pointer-events: none;
}
.inline-field select {
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 12px;
}

.draft {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  margin: 0;
}

.list-item.expanded { box-shadow: var(--shadow-sm); }

@media (max-width: 880px) {
  .detail-grid { grid-template-columns: 1fr; }
  .list-meta { flex-direction: row; align-items: center; flex-wrap: wrap; }
}

/* ---------- kanban ---------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
  overflow-x: auto;
}
.kanban-col {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  min-width: 180px;
}
.kanban-col-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.kanban-col-name { font-weight: 600; font-size: 13px; }
.kanban-col-count {
  font-size: 11px; color: var(--text-2);
  background: var(--bg-card);
  padding: 1px 8px; border-radius: 999px;
}
.kanban-col-body { padding: 8px; display: grid; gap: 6px; min-height: 60px; }
.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
.kanban-card-name { font-weight: 500; }
.kanban-card-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.kanban-card-foot { margin-top: 6px; font-size: 12px; }
.kanban-value { color: var(--accent); font-weight: 600; }
.kanban-empty { padding: 8px; text-align: center; }

/* ---------- detail view (lead/opp overview) ---------- */
.kanban-card { transition: transform 60ms ease, box-shadow 60ms ease; }
.kanban-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--accent); }

.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 4px 0 6px;
}
.detail-title { font-size: 18px; font-weight: 600; }

.detail-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}
.detail-card { display: flex; flex-direction: column; gap: 8px; }
.detail-card-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-2);
  margin: 0 0 2px;
}
.detail-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.detail-field { display: flex; flex-direction: column; gap: 1px; }
.detail-field > span:last-child { font-size: 13px; word-break: break-word; }

.detail-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.detail-list-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; padding: 6px 0; border-top: 1px solid var(--border);
}
.detail-list-row:first-child { border-top: 0; padding-top: 0; }
.detail-list-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }

.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.check-item { display: flex; gap: 8px; align-items: flex-start; }
.check-mark { width: 16px; flex-shrink: 0; font-weight: 700; color: var(--text-2); }
.check-done { color: var(--text-2); text-decoration: line-through; }
.check-done .check-mark { color: var(--status-done); }

/* ---------- table ---------- */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #fafaf8;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.row-clickable { cursor: pointer; }
.row-clickable:hover td { background: #fafaf8; }
.check.ok { color: var(--status-done); font-weight: 700; }
.check.bad { color: var(--status-urgent); font-weight: 700; }

/* ---------- agents grid ---------- */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.agent-card { display: flex; flex-direction: column; gap: 10px; }
.agent-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.agent-name { font-weight: 600; }
.agent-desc { margin-top: 2px; }
.agent-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.agent-output { font-size: 13px; }
.agent-output p { margin: 2px 0 0; }
.agent-actions { display: flex; gap: 6px; }

/* ---------- settings ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}
.settings-card { display: flex; flex-direction: column; gap: 10px; }
.settings-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.settings-name { font-weight: 600; }
.settings-row { display: flex; align-items: center; gap: 12px; }
.settings-label { width: 80px; font-size: 12px; color: var(--text-2); }
.settings-model { flex: 1; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-card); }
.settings-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); }

.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg-btn {
  padding: 5px 10px;
  border: none;
  background: var(--bg-card);
  color: var(--text-1);
  font-size: 12px;
  border-right: 1px solid var(--border-strong);
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--bg-hover); }
.seg-btn.on { background: var(--accent); color: #fff; }
.seg-count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  background: rgba(255,255,255,0.2);
  border-radius: 999px;
  font-size: 10px;
}
.seg-btn:not(.on) .seg-count { background: var(--bg-hover); color: var(--text-2); }

.toggle { position: relative; display: inline-block; width: 32px; height: 18px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border-strong);
  border-radius: 999px;
  transition: 120ms ease;
}
.toggle-slider::before {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff; border-radius: 50%;
  transition: 120ms ease;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(14px); }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(20, 20, 18, 0.42);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow: auto;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 14px; }
.modal-body { padding: 14px 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--border);
  margin: 14px -18px -14px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .field { grid-column: span 1; }

/* ---------- loading / errors ---------- */
.loading { padding: 16px; }
.error-card { border-color: var(--status-urgent); color: var(--tag-urgent-fg); background: var(--tag-urgent-bg); }
.toast-error { background: var(--status-urgent); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%);
  background: #1a1a18; color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  box-shadow: var(--shadow);
  z-index: 200;
}
.toast[hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-header { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}
