/* FCConnect design system. Tokens first; components below use only tokens. */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/static/fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e4e8ee;
  --border-soft: #eef1f5;
  --input-border: #dde2ea;

  --text: #101828;
  --text-2: #344054;
  --muted: #5b6576;
  --faint: #98a2b3;

  --accent: #1f5fa8;
  --accent-hover: #174a85;
  --accent-soft: #e8eef7;
  --accent-ink: #1f3b63;

  --success: #1d6b3d;  --success-bg: #e6f4ec;
  --warn: #8a5300;     --warn-bg: #fff3dc;
  --danger: #b42318;   --danger-bg: #fdecea;
  --purple: #6b21a8;   --purple-bg: #f3e8fd;
  --teal: #0f5f58;     --teal-bg: #e0f2f1;

  --side-bg: #0f1d33;
  --side-text: #c9d3e1;
  --side-muted: #93a3ba;
  --side-label: #8494ab;
  --side-line: #22324d;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
code { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 5px; padding: 1px 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); font-weight: 600; }
.text-warn { color: var(--warn); font-weight: 600; }
.text-success { color: var(--success); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; width: 248px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 22px; padding: 20px 14px;
  background: var(--side-bg); color: var(--side-text); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px; color: #fff; }
.brand:hover { color: #fff; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff;
}
.brand-name { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name strong { font-size: 16px; }
.brand-name span { font-size: 12px; color: var(--side-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--side-label); padding: 16px 12px 6px; }
.nav-label:first-child { padding-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  color: var(--side-text); font-weight: 500;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, 0.10); color: #fff; font-weight: 600; }
.nav-item.soon { color: var(--side-muted); cursor: default; }
.nav-item.soon:hover { background: none; color: var(--side-muted); }
.nav-item svg { flex-shrink: 0; }
.nav-count { margin-left: auto; font-size: 12px; color: var(--side-muted); }
.nav-badge { margin-left: auto; font-size: 11px; font-weight: 700; color: #fff; background: #c2410c; border-radius: 999px; padding: 1px 7px; }
.nav-soon { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: #b8c4d6; border: 1px solid #3a4b66; border-radius: 999px; padding: 1px 7px; }

.side-foot { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--side-line); padding-top: 16px; }
.sync-status { display: flex; align-items: center; gap: 8px; padding: 0 10px; font-size: 12px; color: #b8c4d6; }
.dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; background: var(--faint); }
.dot.ok { background: #34d399; }
.dot.busy { background: #fbbf24; }
.dot.bad { background: #f87171; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: rgba(255, 255, 255, 0.06); }
.user-menu .who { display: flex; flex-direction: column; line-height: 1.3; }
.user-menu .who strong { color: #fff; font-size: 13px; }
.user-menu .who span { font-size: 12px; color: var(--side-muted); }
.user-menu .menu { position: absolute; bottom: 52px; left: 6px; right: 6px; background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; }
.menu-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 7px; background: none; border: 0; font: inherit; color: var(--text-2); cursor: pointer; }
.menu-item:hover { background: var(--surface-2); color: var(--text); }

.main-col { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; height: 64px; flex-shrink: 0;
  display: flex; align-items: center; gap: 16px; padding: 0 32px;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border);
}
.topbar .search { width: 440px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 26px 32px 40px; display: flex; flex-direction: column; gap: 20px; width: 100%; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head .titles { display: flex; flex-direction: column; gap: 4px; }
.subtitle { color: var(--muted); }
.breadcrumb { display: flex; gap: 8px; font-size: 13px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* ---------- layout grids ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-end { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.spacer { margin-left: auto; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border-soft); }
.card-head h2 .count { color: var(--muted); font-weight: 600; margin-left: 4px; }
.card-body { padding: 16px 20px; }
.card-body.tight { padding: 12px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border-soft); color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid #f1f3f7; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-row .title { font-weight: 600; }
.list-row .sub { font-size: 13px; color: var(--muted); }
.list-row.done .title { color: var(--muted); text-decoration: line-through; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text-2); margin-bottom: 4px; }

.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.kpi .value small { font-size: 18px; color: var(--muted); font-weight: 600; }
.kpi .hint { font-size: 13px; color: var(--muted); }
.meter { height: 6px; border-radius: 999px; background: var(--border-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }

.stat { border: 1px solid var(--border-soft); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat .value { font-weight: 600; }

.mini { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; }
.mini strong { font-size: 20px; }
.mini span { font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--input-border); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #f3c3be; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.icon-btn { width: 40px; height: 40px; padding: 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-weight: 600; }
.link-btn:hover { color: var(--accent-hover); }
.link-btn.danger { color: var(--danger); }
.link-btn.muted { color: var(--muted); }

/* ---------- pills, chips, badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-neutral { background: var(--border-soft); color: var(--text-2); }
.pill-purple { background: var(--purple-bg); color: var(--purple); }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); background: #f1f4f9; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.chip .swatch { width: 7px; height: 7px; border-radius: 999px; background: var(--accent); }
.chip.lg { font-size: 13px; padding: 4px 11px; }
.chip.off { color: var(--faint); background: #f6f7f9; text-decoration: line-through; }
.chip.off .swatch { background: var(--faint); }
a.chip:hover { background: var(--accent-soft); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.src { font-size: 12px; font-weight: 700; }
.src-auto { color: var(--success); }
.src-manual { color: var(--warn); }
.src-exclude { color: var(--danger); }

/* role toggles */
.toggle-pill {
  font: inherit; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 5px 11px; cursor: pointer;
  background: var(--surface); color: var(--muted); border: 1px dashed #c5ccd8;
}
.toggle-pill:hover { color: var(--text-2); border-color: var(--faint); }
.toggle-pill.on { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.toggle-pill.on:hover { background: var(--accent-hover); }
.toggle-pill.stake.on { background: var(--purple-bg); color: var(--purple); border: 1px solid #e3cffa; }
.toggle-pill.htmx-request { opacity: 0.6; }

/* ---------- avatars ---------- */
.avatar { width: 28px; height: 28px; border-radius: 999px; display: inline-grid; place-items: center; flex-shrink: 0; font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.md { width: 34px; height: 34px; font-size: 12px; }
.avatar.side { width: 32px; height: 32px; font-size: 13px; background: #2b3e5c; color: #fff; }
.avatar.gray { background: var(--border-soft); color: var(--text-2); }
.logo-sq { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; font-size: 13px; font-weight: 700; }
.logo-sq.lg { width: 60px; height: 60px; border-radius: 14px; font-size: 22px; font-weight: 800; }
.tone-0 { background: #e8eef7; color: #1f3b63; }
.tone-1 { background: #e6f4ec; color: #1d6b3d; }
.tone-2 { background: #fff3dc; color: #8a5300; }
.tone-3 { background: #f3e8fd; color: #6b21a8; }
.tone-4 { background: #e0f2f1; color: #0f5f58; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--input-border); border-radius: var(--radius-sm); padding: 0 12px; height: 38px; min-width: 0;
}
.textarea { padding: 10px 12px; height: auto; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid rgba(31, 95, 168, 0.25); border-color: var(--accent); }
.field.grow { flex-grow: 1; }
.input[type=color] { width: 48px; padding: 3px; }
.select.bare { border: 0; background: transparent; padding: 0; height: auto; font-weight: 600; }
.search {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted);
}
.search input { border: 0; outline: none; background: transparent; font: inherit; font-size: 14px; color: var(--text); flex-grow: 1; min-width: 0; }
.search.sm { height: 38px; background: var(--surface); }
.kbd { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--input-border); border-radius: 5px; padding: 0 6px; }
.filter-select { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-2); }
.filter-select select { border: 0; font: inherit; font-weight: 500; background: transparent; color: var(--text); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.form-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3c3be; border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 600; }
.composer { border: 1px solid var(--input-border); border-radius: 12px; padding: 12px 14px; background: #fbfcfd; display: flex; flex-direction: column; gap: 10px; }
.composer textarea { border: 0; outline: none; resize: vertical; font: inherit; background: transparent; color: var(--text); min-height: 48px; }

/* inline "+ Add" disclosure */
.add-panel > summary { list-style: none; cursor: pointer; font-weight: 600; color: var(--accent); font-size: 13px; }
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel[open] > summary { color: var(--muted); }
.add-form { margin: 0 20px 16px; padding: 14px; border: 1px solid var(--border-soft); border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }

/* segmented control */
.segmented { display: inline-flex; background: #e9edf2; border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented a { font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 8px; color: var(--muted); }
.segmented a:hover { color: var(--text); }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.10); }
.segmented .n { opacity: 0.7; margin-left: 4px; }

/* tabs */
.tabs { display: flex; gap: 4px; margin: 0 -24px; padding: 0 20px; border-top: 1px solid var(--border-soft); }
.tab { padding: 14px 12px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; color: var(--muted); text-transform: uppercase; background: var(--surface-2); padding: 11px 16px; border-bottom: 1px solid var(--border-soft); }
.table td { padding: 12px 16px; border-bottom: 1px solid #f1f3f7; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: #fafbfd; }
.table tr.inactive td { color: var(--faint); }
.cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-main .names { display: flex; flex-direction: column; min-width: 0; }
.cell-main .names strong { font-weight: 600; color: var(--text); }
.cell-main .names span { font-size: 12px; color: var(--muted); }
a.row-link { color: inherit; }
a.row-link:hover strong { color: var(--accent); }

/* ---------- dates ---------- */
.datebox { width: 44px; flex-shrink: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); display: flex; flex-direction: column; align-items: center; padding: 3px 0; line-height: 1.15; background: var(--surface); }
.datebox .m { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: var(--danger); }
.datebox .d { font-size: 17px; font-weight: 700; }

/* follow-up checkbox button */
.check-btn { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid #c5ccd8; background: var(--surface); cursor: pointer; flex-shrink: 0; padding: 0; display: grid; place-items: center; color: #fff; }
.check-btn:hover { border-color: var(--success); }
.check-btn.checked { background: var(--success); border-color: var(--success); }

/* ---------- notes ---------- */
.note { border-top: 1px solid var(--border-soft); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.note.pinned { border: 1px solid #f3e3b5; background: #fffaeb; border-radius: 12px; padding: 12px 14px; }
.note .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note.pinned .meta { color: #6b5a24; }
.note .body { white-space: pre-wrap; line-height: 1.55; }
.note details > summary { list-style: none; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.note details > summary::-webkit-details-marker { display: none; }

/* ---------- timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; width: 30px; flex-shrink: 0; }
.tl-icon { width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.tl-line { width: 2px; flex-grow: 1; min-height: 18px; background: var(--border-soft); }
.tl-item:last-child .tl-line { display: none; }
.tl-body { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 16px; }
.tl-body .meta { font-size: 12px; color: var(--muted); }
.tl-tag { background: #e8eef7; color: #1f3b63; }
.tl-note { background: #fff3dc; color: #8a5300; }
.tl-follow_up { background: #e6f4ec; color: #1d6b3d; }
.tl-key_date { background: #f3e8fd; color: #6b21a8; }
.tl-contact { background: #eef1f5; color: #344054; }
.tl-company { background: #e0f2f1; color: #0f5f58; }
.tl-other { background: #eef1f5; color: #344054; }
.feed-dot { width: 8px; height: 8px; border-radius: 999px; margin-top: 7px; flex-shrink: 0; }
.feed-dot.tl-tag { background: #6b8fd6; }
.feed-dot.tl-note { background: #c9a227; }
.feed-dot.tl-follow_up { background: #3c9a64; }
.feed-dot.tl-key_date { background: #a45bc4; }
.feed-dot.tl-contact, .feed-dot.tl-other { background: var(--faint); }
.feed-dot.tl-company { background: #0d9488; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }
.toast { background: #101828; color: #fff; border-radius: var(--radius-sm); padding: 11px 16px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 13px; animation: toast-in 0.18s ease-out; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- login ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: var(--side-bg); padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px; padding: 32px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 20px; }
.auth-card .brand { color: var(--text); padding: 0; }
.auth-card .brand-name span { color: var(--muted); }

/* ---------- misc ---------- */
.grid-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.link-card { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; color: var(--text); }
.link-card:hover { border-color: var(--accent); color: var(--text); }
.link-card span { color: var(--muted); font-size: 13px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.kv span:last-child { color: var(--muted); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .topbar .search { width: auto; flex-grow: 1; }
}
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { position: static; width: auto; height: auto; }
  .content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .grid-4, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* Wide and ultrawide screens: use the space rather than stopping at a fixed width. */
@media (min-width: 2200px) {
  .content { padding: 32px 48px 48px; }
  .topbar { padding: 0 48px; }
  .grid-links { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

/* ---------- banners, previews, pickers ---------- */
.banner { border-radius: var(--radius-sm); padding: 11px 16px; border: 1px solid; font-size: 14px; }
.banner-info { background: var(--accent-soft); color: var(--accent-ink); border-color: #cfdcf0; }
.banner-ok { background: var(--success-bg); color: var(--success); border-color: #bfe3cc; }
.banner-warn { background: var(--warn-bg); color: var(--warn); border-color: #f3dca8; }
.banner-danger { background: var(--danger-bg); color: var(--danger); border-color: #f3c3be; }
.email-preview { display: block; width: 100%; height: 640px; border: 0; border-top: 1px solid var(--border-soft); border-radius: 0 0 var(--radius) var(--radius); background: #f4f6f9; }
.pre { white-space: pre-wrap; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0; }
.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; border: 1px solid var(--input-border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); font-weight: 500; }
.tl-incident { background: #fdecea; color: #b42318; }
.tl-email { background: #e8eef7; color: #1f3b63; }
.feed-dot.tl-incident { background: #b42318; }
.feed-dot.tl-email { background: #6b8fd6; }

/* sortable table headers (buttons injected by app.js) */
.sort-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.sort-btn:hover { color: var(--text); }
.sort-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sort-btn::after { content: "↕"; font-size: 11px; opacity: 0.35; }
th[aria-sort="ascending"] .sort-btn::after { content: "▲"; opacity: 1; font-size: 9px; }
th[aria-sort="descending"] .sort-btn::after { content: "▼"; opacity: 1; font-size: 9px; }
th[aria-sort] { color: var(--text); }
th.num .sort-btn { justify-content: flex-end; }
.kd-edit > summary { list-style: none; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); padding-left: 56px; }
.kd-edit > summary::-webkit-details-marker { display: none; }
.kd-edit > summary:hover { color: var(--accent); }

/* ---------- catalog multi-tag editor ---------- */
.select-col { width: 36px; }
.catalog-table tr.dirty td { background: #fffbeb; }
.catalog-table tr.dirty td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.tag-picker { position: relative; }
.tag-picker > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 3px 8px; border: 1px solid transparent; border-radius: 8px; }
.tag-picker > summary::-webkit-details-marker { display: none; }
.tag-picker > summary:hover, .tag-picker[open] > summary { border-color: var(--input-border); background: var(--surface); }
.picker-chips { display: flex; flex-wrap: wrap; gap: 6px; flex-grow: 1; }
.picker-caret { color: var(--faint); font-size: 12px; }
.picker-menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 240px; max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.picker-menu .check { padding: 4px 6px; border-radius: 6px; }
.picker-menu .check:hover { background: var(--surface-2); }
.tag-picker.up .picker-menu { top: auto; bottom: calc(100% + 6px); }
.bulk-bar { position: sticky; bottom: 16px; z-index: 30; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: #101828; color: #fff; border-radius: 14px; padding: 10px 16px; box-shadow: var(--shadow-lg); }
.bulk-bar[hidden] { display: none; }
.bulk-section { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bulk-section[hidden] { display: none; }
.bulk-bar .link-btn.muted { color: #b8c4d6; }
.bulk-bar .tag-picker > summary { background: #fff; color: var(--text); border-color: transparent; }
.pill-table { border-collapse: collapse; width: 100%; }
.pill-table td { padding: 0; border: 0; }
.pill-table .row { flex-direction: column; align-items: stretch !important; }

/* ---------- global search suggestions ---------- */
.global-search { position: relative; }
.suggest-host:empty { display: none; }
.suggest-host { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; }
.suggest-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; max-height: 70vh; overflow-y: auto; }
.suggest-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; padding: 8px 10px 4px; }
.suggest-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 13px; line-height: 1.35; }
.suggest-item:hover, .suggest-item:focus { background: var(--surface-2); color: var(--text); outline: none; }
.suggest-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.suggest-all { display: block; padding: 8px 10px; margin-top: 4px; border-top: 1px solid var(--border-soft); font-size: 13px; font-weight: 600; }
/* server-sorted headers */
.sort-link { color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.sort-link span { font-size: 10px; opacity: 0.35; }
.sort-link.active { color: var(--text); }
.sort-link.active span { opacity: 1; }
a.card.kpi { color: inherit; transition: border-color 0.12s, box-shadow 0.12s; }
a.card.kpi:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(16, 24, 40, 0.08); }

/* Newsletter AI suggestions */
.ai-suggestion { border: 1px dashed var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; }
.ai-suggestion .ai-label { font-size: 12px; font-weight: 600; color: var(--accent-ink); }
.ai-suggestion .ai-text { white-space: pre-wrap; font-size: 14px; }
.ai-topic { display: grid; gap: 2px; padding: 8px 0; border-top: 1px solid var(--border-soft); font-size: 13px; }
.ai-topic:first-child { border-top: 0; }
.ai-topic .link-btn { justify-self: start; margin-top: 2px; }

/* Newsletter formatting toolbar */
.md-toolbar { display: flex; gap: 2px; padding: 4px; border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0; background: #f8fafc; }
.md-toolbar button { height: 28px; min-width: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text, #101828); font-size: 13px; cursor: pointer; }
.md-toolbar button:hover, .md-toolbar button:focus-visible { background: var(--accent-soft); color: var(--accent-ink); }
.md-toolbar + .md-input { border-top-left-radius: 0; border-top-right-radius: 0; }

/* Auto-growing text boxes: JS sets the height; no manual drag handle needed. */
textarea[data-autogrow] { resize: vertical; overflow-y: hidden; min-height: 96px; }

/* Card layout: collapse + drag */
.card-head.has-tools { justify-content: flex-start; }
.card-head.has-tools > h2 { flex: 0 1 auto; margin-right: auto; }
.card-toggle, .card-grip { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex: 0 0 auto; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.card-toggle:hover, .card-grip:hover, .card-toggle:focus-visible, .card-grip:focus-visible { background: var(--surface-2, #f4f6f9); color: var(--text, #101828); }
.card-grip { cursor: grab; margin-left: -8px; margin-right: -4px; }
.card-toggle svg { transition: transform .15s ease; }
.card.card-collapsed .card-toggle svg { transform: rotate(-90deg); }
.card.card-collapsed > :not(.card-head):not(details) { display: none !important; }
.card.card-collapsed > details > :not(summary) { display: none !important; }
.card.card-collapsed .card-head { border-bottom: 0; }
.card.dragging { opacity: .45; outline: 2px dashed var(--accent); }
.layout-reset { display: block; margin: 24px auto 8px; font-size: 12px; color: var(--muted); }

/* Campaign audience sections */
.audience-part { border: 1px solid var(--border-soft); border-radius: 8px; padding: 8px 12px; }
.audience-part > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.count-pill { display: inline-block; min-width: 20px; padding: 0 7px; border-radius: 999px; background: var(--surface-2, #f4f6f9); color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }

/* Collapsible price-change list on the company Agreements tab */
.price-changes > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* "+ New" quick actions (top bar) */
.quick-menu { position: relative; }
.quick-menu > summary { list-style: none; cursor: pointer; }
.quick-menu > summary::-webkit-details-marker { display: none; }
.quick-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 220px;
  background: var(--surface, #fff); border: 1px solid var(--border-soft); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12); padding: 6px; display: grid; gap: 2px; }
.quick-menu-list a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px;
  color: inherit; text-decoration: none; font-weight: 500; }
.quick-menu-list a:hover, .quick-menu-list a:focus { background: var(--surface-2, #f4f6f9); outline: none; }
.quick-menu-label { padding: 4px 10px; font-size: 12px; color: var(--muted); }
.list-row:target { box-shadow: inset 3px 0 0 var(--accent, #1f5fa8); background: var(--surface-2, #f4f6f9); }

/* Dev copy marker + release in the sidebar footer */
.dev-strip { background: #b45309; color: #fff; font-size: 12px; font-weight: 600; padding: 4px 16px; text-align: center; }
.app-version { font-size: 11px; color: rgba(255, 255, 255, .45); padding: 2px 4px 6px; }
.divider { border: 0; border-top: 1px solid var(--border-soft); margin: 2px 0; width: 100%; }
.todo-edit > summary { list-style: none; display: inline-block; cursor: pointer; margin-top: 2px; }
.todo-edit > summary::-webkit-details-marker { display: none; }
.todo-edit[open] > summary { color: var(--text-2); }
