/* =============================================================================
   Contrak — Design System
   -----------------------------------------------------------------------------
   Self-contained. No Bootstrap/jQuery/Select2 — everything below (grid,
   forms, multi-select, tabs, modal, kanban) is written from scratch so the
   codebase has zero third-party runtime dependencies to vendor or update.
   System font stack is used deliberately (no webfont files to manage on an
   internal Bitnami box with no outbound access).
   ========================================================================== */

:root {
  /* Palette */
  --ink: #16202B;
  --ink-soft: #57667A;
  --ink-faint: #8A96A3;
  --paper: #F5F6F8;
  --surface: #FFFFFF;
  --line: #E1E5EA;
  --line-strong: #C7CDD6;
  --accent: #1F3A5F;
  --accent-hover: #16293F;
  --accent-soft: #EAF0F7;
  --good: #2F7D5D;
  --good-soft: #E7F3EE;
  --warn: #B8860B;
  --warn-soft: #FBF3DF;
  --bad: #B3452C;
  --bad-soft: #FBEAE5;
  --neutral-soft: #EEF0F3;

  /* Type scale */
  --font-ui: Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 0.81rem;
  --fs-sm: 0.878rem;
  --fs-base: 0.945rem;
  --fs-md: 1.08rem;
  --fs-lg: 1.35rem;
  --fs-xl: 1.62rem;

  /* Spacing / shape */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(22,32,43,0.06);
  --shadow-md: 0 4px 16px rgba(22,32,43,0.10);
  --sidebar-w: 200px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 0.5rem; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.text-muted { color: var(--ink-soft); }
.text-faint { color: var(--ink-faint); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* =============================================================================
   App shell
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  color: #C9D3DE;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  transition: width 0.15s ease;
}
.sidebar-brand {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand-top { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.sidebar-brand img { height: 28px; width: auto; border-radius: 4px; padding: 2px; flex-shrink: 0; }
.sidebar-brand span { font-weight: 700; color: #fff; font-size: var(--fs-md); }
.sidebar-collapse-btn {
  background: none; border: none; color: #8A96A3; cursor: pointer;
  padding: 0.3rem; border-radius: var(--radius-sm); display: flex; flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-collapse-btn svg { transition: transform 0.15s ease; }
.sidebar-nav { padding: 0.75rem 0.5rem; overflow-y: auto; flex: 1; }
.sidebar-section-label {
  font-size: 0.7425rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #6B7A8C; padding: 0.9rem 0.75rem 0.35rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: #C9D3DE; font-size: var(--fs-sm); font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.sidebar-link.active { background: var(--accent); color: #fff; }
.sidebar-link svg { flex-shrink: 0; opacity: 0.9; }
.sidebar-link-disabled { color: #5C6879; cursor: default; justify-content: space-between; }
.sidebar-link-disabled:hover { background: none; }
.sidebar-link-disabled svg { opacity: 0.45; }
.soon-pill { font-size: 0.675rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: rgba(255,255,255,0.08); color: #8A96A3; border-radius: 999px; padding: 0.1rem 0.45rem; margin-left: auto; }
.sidebar-foot { padding: 0.85rem 1.1rem; border-top: 1px solid rgba(255,255,255,0.08); font-size: var(--fs-xs); color: #6B7A8C; }

/* Collapsed state — toggled by JS adding "sidebar-collapsed" to <html>, so
   the app-shell's --sidebar-w override cascades correctly to both .sidebar
   and .main (siblings, so the variable has to come from a shared ancestor).
   The class lives on <html> rather than .app-shell itself so an inline
   script in <head> (see includes/layout_top.php) can apply it before first
   paint, avoiding an expanded-then-collapsed flash on every page load.
   Scoped to min-width:901px so it never fights with the mobile slide-out
   sidebar below — a phone always gets the full labelled sidebar when opened
   via the hamburger button, regardless of any collapse preference saved from
   a desktop session on the same browser. */
@media (min-width: 901px) {
  html.sidebar-collapsed .app-shell { --sidebar-w: 64px; }
  html.sidebar-collapsed .sidebar-brand { padding-left: 0.4rem; padding-right: 0.4rem; }
  html.sidebar-collapsed .sidebar-brand-top { flex-direction: column; align-items: center; gap: 0.5rem; }
  html.sidebar-collapsed .sidebar-brand img { width: 100%; height: auto; max-width: 100%; padding: 0; }
  html.sidebar-collapsed .sidebar-brand span,
  html.sidebar-collapsed .sidebar-link span,
  html.sidebar-collapsed .sidebar-section-label,
  html.sidebar-collapsed .sidebar-foot { display: none; }
  html.sidebar-collapsed .sidebar-link { justify-content: center; }
  html.sidebar-collapsed .sidebar-link-disabled { justify-content: center; }
  html.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.15s ease;
}
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky; top: 0; z-index: 20;
  gap: 0.75rem;
}
.topbar-left { display: flex; align-items: center; gap: 0.75rem; min-width: 0; flex: 1; }
.sidebar-toggle { flex-shrink: 0; }
.topbar-title { font-weight: 600; font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar-user { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.user-chip {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: var(--fs-sm); color: var(--ink-soft);
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-xs); flex-shrink: 0;
}
.content { padding: 1.25rem; flex: 1; }
.content-narrow { max-width: 640px; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; z-index: 40; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex !important; }
}

/* Phone-width refinements. The desktop auto-wrapping Kanban grid and the
   persistent full-name display both make more sense on a wide screen than on
   a tall, narrow one, so both get a lighter-weight treatment here — a single
   horizontally-scrolling row (still in exact array order) gives each column
   more usable height on a phone than several stacked, wrapped rows would. */
@media (max-width: 640px) {
  .topbar { padding: 0 0.85rem; }
  .content { padding: 0.9rem; }
  .user-name-text { display: none; }
  .kanban-board {
    display: flex;
    grid-template-rows: none;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .kanban-col { flex: 0 0 260px; width: 260px; max-height: calc(100vh - 230px); }
}

/* =============================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font-family: inherit; font-size: var(--fs-sm); font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--neutral-soft); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--neutral-soft); color: var(--ink); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: var(--fs-xs); }
.btn-icon { padding: 0.4rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; }

/* =============================================================================
   Cards / panels
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  flex-wrap: wrap;
}
.card-body { padding: 1.1rem; }
.card-footer { padding: 0.8rem 1.1rem; border-top: 1px solid var(--line); }

.tiles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1.1rem; border-left: 4px solid var(--accent);
}
.tile .tile-count { font-size: 1.728rem; font-weight: 700; }
.tile .tile-label { font-size: var(--fs-xs); color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }

/* =============================================================================
   Forms — multi-column layout support
   ========================================================================== */
.form-grid { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 0.9rem 1.25rem; }
.form-grid.cols-1 { --cols: 1; }
.form-grid.cols-3 { --cols: 3; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr !important; } }

.form-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.form-field.span-2 { grid-column: span 2; }
.form-field.span-3 { grid-column: span 3; }
.form-field.span-full { grid-column: 1 / -1; }
.form-grid > .span-2 { grid-column: span 2; }
.form-grid > .span-3 { grid-column: span 3; }
.form-grid > .span-full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-field.span-2, .form-field.span-3, .form-field.span-full, .form-grid > .span-2, .form-grid > .span-3, .form-grid > .span-full { grid-column: auto; } }

label, .form-label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.form-hint { font-size: var(--fs-xs); color: var(--ink-soft); }
.form-error { font-size: var(--fs-xs); color: var(--bad); }
.required-mark { color: var(--bad); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=url], input[type=search],
select, textarea {
  font-family: inherit; font-size: var(--fs-base); color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  width: 100%;
}
textarea { resize: vertical; min-height: 5rem; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input.field-invalid, select.field-invalid, textarea.field-invalid { border-color: var(--bad); }
input:disabled, select:disabled, textarea:disabled { background: var(--neutral-soft); color: var(--ink-soft); cursor: not-allowed; }
.input-prefix-group { display: flex; }
.input-prefix-group .prefix {
  display: flex; align-items: center; padding: 0 0.6rem;
  background: var(--neutral-soft); border: 1px solid var(--line-strong); border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-size: var(--fs-sm); color: var(--ink-soft); font-weight: 600;
}
.input-prefix-group input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-row input[type=checkbox] { width: 16px; height: 16px; }
fieldset { border: none; padding: 0; margin: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 0.5rem; }
.form-section-title { font-size: var(--fs-md); font-weight: 700; margin: 1.5rem 0 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.form-section-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.form-actions { display: flex; gap: 0.6rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* Custom multi-select (see assets/js/multiselect.js) */
.msel { position: relative; }
/* Belt-and-suspenders: once a <select> is moved inside .msel by the JS
   enhancer, it must never be visible - guaranteed here at the CSS layer
   rather than relying solely on an inline style set by JS, so there is
   never a chance of the native select's own border/box showing alongside
   the enhanced control. */
.msel select { display: none !important; }
.msel-control {
  display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem; min-height: 2.3rem; cursor: text; background: var(--surface);
}
.msel-control:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.msel-tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 0.15rem 0.5rem; font-size: var(--fs-xs); font-weight: 600;
}
.msel-tag button { background: none; border: none; cursor: pointer; color: var(--accent); font-size: 0.972rem; line-height: 1; padding: 0; }
.msel-input { flex: 1; min-width: 80px; border: none; outline: none; font-size: var(--fs-sm); padding: 0.15rem; }
.msel-input.msel-input-collapsed { flex: 0 0 2px; min-width: 2px; width: 2px; padding: 0.15rem 0; }
.msel-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); max-height: 220px; overflow-y: auto; display: none;
}
.msel-dropdown.open { display: block; }
.msel-option { padding: 0.5rem 0.7rem; font-size: var(--fs-sm); cursor: pointer; }
.msel-option:hover, .msel-option.highlighted { background: var(--accent-soft); }
.msel-option.selected { color: var(--ink-faint); }
.msel-empty { padding: 0.5rem 0.7rem; font-size: var(--fs-xs); color: var(--ink-faint); }

/* =============================================================================
   Tables / listings
   ========================================================================== */
.table-toolbar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; justify-content: space-between; }
.table-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.table-filters input, .table-filters select { width: auto; min-width: 140px; }

/* Wider variant for filter bars that should use the full available row width
   on desktop and stack to full-width on mobile — currently used by the Deal
   Contacts and Partner Contacts listings. */
.table-filters-wide { flex: 1; min-width: 0; }
.table-filters-wide input[type="search"],
.table-filters-wide input[type="text"],
.table-filters-wide select,
.table-filters-wide .msel { flex: 1 1 220px; min-width: 200px; }
@media (max-width: 700px) {
  .table-filters-wide { flex-direction: column; align-items: stretch; }
  .table-filters-wide > * { width: 100%; flex: none; }
}
.data-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data-table th {
  text-align: left; padding: 0.6rem 0.9rem; background: var(--paper);
  border-bottom: 1px solid var(--line); color: var(--ink-soft); font-weight: 600; font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}
table.data-table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--paper); }
th.sortable a { color: inherit; display: inline-flex; align-items: center; gap: 0.25rem; }
th.sortable a:hover { text-decoration: none; color: var(--ink); }
.row-actions { display: flex; gap: 0.4rem; }

.pagination { display: flex; align-items: center; gap: 0.4rem; justify-content: flex-end; margin-top: 1rem; font-size: var(--fs-sm); }
.pagination a, .pagination span {
  padding: 0.35rem 0.65rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
  color: var(--ink); min-width: 2rem; text-align: center;
}
.pagination a:hover { background: var(--neutral-soft); text-decoration: none; }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* =============================================================================
   Badges / status pills — the vocabulary reused across lists, detail, kanban
   ========================================================================== */
.pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: var(--fs-xs); font-weight: 700; padding: 0.2rem 0.55rem;
  border-radius: 999px; background: var(--neutral-soft); color: var(--ink-soft);
  white-space: nowrap;
}
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* =============================================================================
   Tabs
   ========================================================================== */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.1rem; }
.tab-link {
  padding: 0.6rem 0.9rem; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-link:hover { color: var(--ink); text-decoration: none; }
.tab-link.active { color: var(--accent); border-bottom-color: var(--accent); }

/* =============================================================================
   Kanban board (Deals) — the app's signature view
   -----------------------------------------------------------------------------
   Row-flow grid with auto-fill: fills left-to-right in exact array order
   (matching KANBAN_STATUS_COLUMNS in config.php), wrapping to additional rows
   as needed based on available width, rather than one long horizontally-
   scrolling row. (A column-flow variant was tried here previously, but
   filling top-to-bottom per column-pair before moving right meant scanning
   just the visible top row skipped every other status — wrong reading order
   even though the underlying array order was always correct.)
   ========================================================================== */
.kanban-scroll { overflow-x: auto; padding-bottom: 0.5rem; }
.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, 270px);
  gap: 0.9rem;
  align-items: start;
}
.kanban-col {
  width: 270px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column;
  max-height: calc(100vh - 260px);
}
.kanban-col-head {
  padding: 0.7rem 0.85rem; font-weight: 700; font-size: var(--fs-sm);
  border-bottom: 3px solid var(--accent); border-radius: var(--radius) var(--radius) 0 0;
  display: flex; justify-content: space-between; align-items: center; background: var(--surface);
}
.kanban-col-head .count { font-weight: 600; color: var(--ink-soft); background: var(--neutral-soft); border-radius: 999px; padding: 0.1rem 0.5rem; font-size: var(--fs-xs); }
.kanban-col-body { padding: 0.6rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 0.6rem; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem; box-shadow: var(--shadow-sm); cursor: grab;
}
.kanban-card:hover { border-color: var(--line-strong); }
.kanban-card.dragging { opacity: 0.5; }
.kanban-card .kc-title { font-weight: 700; font-size: var(--fs-sm); margin-bottom: 0.15rem; }
.kanban-card .kc-sub { font-size: var(--fs-xs); margin-bottom: 0.3rem; }
.kanban-card .kc-meta { font-size: var(--fs-xs); color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.kanban-card .kc-meta a { color: inherit; display: inline-flex; align-items: center; }
.kanban-col.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* =============================================================================
   Toasts / flash messages
   ========================================================================== */
.flash-stack { position: fixed; top: 1rem; right: 1rem; z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; max-width: 360px; }
.flash {
  padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); font-size: var(--fs-sm);
  box-shadow: var(--shadow-md); border: 1px solid transparent; background: var(--surface);
  display: flex; justify-content: space-between; gap: 0.6rem; align-items: flex-start;
}
.flash-success { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.flash-error { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.flash-info { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.flash-warning { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.flash button { background: none; border: none; cursor: pointer; color: inherit; font-size: 1.08rem; line-height: 1; }

/* =============================================================================
   Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(22,32,43,0.45); z-index: 60;
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-header { padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.2rem; }
.modal-footer { padding: 1rem 1.2rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 0.6rem; }

/* =============================================================================
   Empty states / misc
   ========================================================================== */
.empty-state { padding: 2.5rem 1.5rem; text-align: center; color: var(--ink-soft); }
.empty-state svg { margin-bottom: 0.75rem; opacity: 0.5; }
.divider { height: 1px; background: var(--line); border: none; margin: 1.25rem 0; }
.sidebar-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--ink); }

/* =============================================================================
   Login page
   ========================================================================== */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--paper); padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 2rem; }
.login-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.25rem 0; color: var(--ink-faint); font-size: var(--fs-xs); }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* =============================================================================
   Notes stream (deal notes)
   ========================================================================== */
.note-item { border-bottom: 1px solid var(--line); padding: 0.9rem 0; }
.note-item:last-child { border-bottom: none; }
.note-meta { font-size: var(--fs-xs); color: var(--ink-soft); margin-bottom: 0.3rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.note-content { font-size: var(--fs-sm); }
.note-content p:last-child, .note-content div:last-child { margin-bottom: 0; }
.note-content p, .note-content div { margin: 0 0 0.5rem; }
.note-content table { border-collapse: collapse; margin: 0.5rem 0; max-width: 100%; }
.note-content th, .note-content td { border: 1px solid var(--line-strong); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
.note-content th { background: var(--paper); font-weight: 600; }
.note-content img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 0.5rem 0; display: block; }

/* Rich text editor toolbar (deal notes) */
.rte-toolbar { display: flex; gap: 0.25rem; border: 1px solid var(--line-strong); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 0.35rem; background: var(--paper); flex-wrap: wrap; }
.rte-toolbar button { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; width: 28px; height: 28px; cursor: pointer; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.rte-toolbar button:hover { background: var(--neutral-soft); }
.rte-editable { border: 1px solid var(--line-strong); border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding: 0.6rem 0.75rem; min-height: 6rem; font-size: var(--fs-sm); overflow-x: auto; }
.rte-editable:empty:before { content: attr(data-placeholder); color: var(--ink-faint); pointer-events: none; }
.rte-editable:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rte-editable table { border-collapse: collapse; margin: 0.5rem 0; max-width: 100%; }
.rte-editable th, .rte-editable td { border: 1px solid var(--line-strong); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
.rte-editable th { background: var(--paper); font-weight: 600; }
.rte-editable img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 0.5rem 0; display: block; }

/* File manager (deal documents) */
.folder-list { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.folder-chip { display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-sm); font-weight: 600; }
.folder-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 1.5rem; text-align: center; color: var(--ink-soft); font-size: var(--fs-sm); }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
