/* CRM (PHP) — design tokens carried over from the original app. */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f3f3f5;
  --line: #e7e7ec;
  --line-strong: #d7d7df;
  --fg: #141418;
  --muted: #6a6a76;
  --faint: #9b9ba6;
  --accent: #5a55de;
  --accent-soft: #eeedfc;
  --success: #1d9a66;
  --success-soft: #e5f6ed;
  --warning-soft: #fdf1df;
  --danger: #d4462f;
  --danger-soft: #fdebe8;
  --info: #2f77d1;
  --info-soft: #e8f1fd;
  --radius-control: 12px;
  --radius-card: 18px;
  --radius-dialog: 22px;
  --radius-tile: 10px;
  --shadow-card: 0 1px 2px rgb(20 20 24 / 0.04), 0 0 0 1px rgb(20 20 24 / 0.04);
  --shadow-pop: 0 0 0 1px rgb(20 20 24 / 0.06), 0 12px 40px -12px rgb(20 20 24 / 0.25);
  --shadow-dialog: 0 0 0 1px rgb(20 20 24 / 0.06), 0 30px 80px -20px rgb(20 20 24 / 0.35);
  --primary-bg: #141418;
  --primary-fg: #ffffff;
  --primary-bg-hover: #26262c;
  --table-head: rgb(245 245 247 / 0.6);
  --board-bg: rgb(245 245 247 / 0.7);
  --hover-hue: 250;
  --hover-bg: hsl(var(--hover-hue) 65% 95%);
  --topbar-bg: rgb(245 245 247 / 0.95);
  --text-soft: rgb(20 20 24 / 0.9);
  --flash-bg: var(--success-soft);
  --flash-fg: #14663f;
  --flash-line: #cfeadd;
  --success-text: #15774f;
  --warning-text: #96600f;
  --danger-text: #b23a26;
  --info-text: #2662ac;
  --accent-text: #4a45cf;
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #0f0f13;
  --surface: #17171c;
  --surface-2: #202028;
  --line: #2a2a33;
  --line-strong: #3a3a45;
  --fg: #f2f2f5;
  --muted: #a1a1af;
  --faint: #7d7d8f;
  --accent: #8f8af7;
  --accent-soft: #242246;
  --success: #46c894;
  --success-soft: #102c1f;
  --warning-soft: #332511;
  --danger: #f0775f;
  --danger-soft: #3a1a15;
  --info: #6aa8f0;
  --info-soft: #132437;
  --primary-bg: #f2f2f5;
  --primary-fg: #141418;
  --primary-bg-hover: #ffffff;
  --table-head: rgb(255 255 255 / 0.03);
  --board-bg: rgb(255 255 255 / 0.03);
  --hover-bg: hsl(var(--hover-hue) 20% 15%);
  --topbar-bg: rgb(15 15 19 / 0.94);
  --text-soft: rgb(242 242 245 / 0.9);
  --flash-bg: #102c1f;
  --flash-fg: #7fe0b3;
  --flash-line: #1d4a35;
  --success-text: #6fdcae;
  --warning-text: #f0c07a;
  --danger-text: #ff9b86;
  --info-text: #8dc0f7;
  --accent-text: #b3aef9;
  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.5), 0 0 0 1px rgb(255 255 255 / 0.05);
  --shadow-pop: 0 0 0 1px rgb(255 255 255 / 0.06), 0 12px 40px -12px rgb(0 0 0 / 0.7);
  --shadow-dialog: 0 0 0 1px rgb(255 255 255 / 0.06), 0 30px 80px -20px rgb(0 0 0 / 0.85);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; padding: 0; }
ul, ol { list-style: none; }
:focus-visible { outline: 2px solid rgb(90 85 222 / 0.55); outline-offset: 1px; }
::selection { background: rgb(90 85 222 / 0.18); }

.icon { width: 16px; height: 16px; flex: none; }

/* Layout */

.app { display: flex; height: 100vh; }

.sidebar {
  width: 236px;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 0;
}

.brand { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--primary-bg);
  color: var(--primary-fg);
  flex: none;
}
.brand-mark svg { width: 16px; height: 16px; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  margin-top: 12px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 1px 1px rgb(20 20 24 / 0.04);
}
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}
.search-box input::placeholder { color: var(--faint); }
.search-box:focus-within { border-color: rgb(90 85 222 / 0.5); box-shadow: 0 0 0 3px rgb(90 85 222 / 0.12); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 16px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--hover-bg); color: var(--fg); }
.nav-link.is-active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-card); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding: 8px 8px;
  border-radius: var(--radius-control);
  transition: background-color .15s ease;
}
.user-chip:hover { background: var(--hover-bg); }
.user-chip-text { min-width: 0; display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-mail { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; padding: 8px 8px 8px 0; }
.surface {
  height: 100%;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.topbar { display: none; }
.scrim { display: none; }

/* Page scaffolding */

.page { max-width: 1200px; margin: 0 auto; padding: 32px; }
.page--full { max-width: 1400px; }
.page--narrow { max-width: 840px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-head h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.022em; }
.page-sub { margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.flash {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 32px;
  background: var(--flash-bg);
  color: var(--flash-fg);
  font-size: 13px;
  border-bottom: 1px solid var(--flash-line);
}

/* Utilities */

.min-0 { min-width: 0; }
.flex-1 { flex: 1; }
.block { display: block; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.strong { font-weight: 500; }
.small { font-size: 12.5px; }
.tiny { font-size: 12px; }
.numeric { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-8 { margin-top: 32px; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link { font-size: 12.5px; color: var(--muted); }
.link:hover { color: var(--fg); }
.strong-link { font-weight: 500; }
.strong-link:hover { text-decoration: underline; }
.list-empty { padding: 24px 8px; text-align: center; font-size: 13px; color: var(--muted); }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--fg);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn .icon { width: 15px; height: 15px; }
.btn--primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); }
.btn--primary:hover { background: var(--primary-bg-hover); border-color: var(--primary-bg-hover); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--fg); border-color: transparent; }
.btn--danger { color: var(--danger); border-color: rgb(212 70 47 / 0.28); }
.btn--danger:hover { background: var(--danger-soft); border-color: rgb(212 70 47 / 0.4); }
.btn--icon { width: 36px; padding: 0; }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--radius-tile); }
.btn--sm.btn--icon { width: 30px; padding: 0; }
.btn--file { position: relative; overflow: hidden; }
.btn--file input[type='file'] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.is-disabled { opacity: .45; pointer-events: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}

/* Inputs */

.input, .select, .textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 13.5px;
  outline: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: rgb(90 85 222 / 0.6);
  box-shadow: 0 0 0 3px rgb(90 85 222 / 0.12);
}
.textarea { resize: vertical; line-height: 1.5; }
input[type="file"].input { padding: 7px 10px; color: var(--muted); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-body .field, .dialog-body .field-row { margin-bottom: 12px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 24px; }
.search-input { position: relative; flex: 1; min-width: 240px; max-width: 384px; }
.search-input .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search-input .input { padding-left: 34px; }

.inline-form { display: inline-flex; }
.inline-form-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; }

/* Cards and grids */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.card--pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 14px; font-weight: 600; }
.card-head .muted { font-size: 12.5px; color: var(--faint); }

.grid { display: grid; gap: 12px; margin-top: 12px; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid-span-2 { grid-column: span 2; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 24px; }
.kpi { display: flex; flex-direction: column; justify-content: space-between; height: 104px; padding: 16px; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-hint { display: flex; align-items: center; gap: 5px; margin-top: 2px; font-size: 12px; color: var(--faint); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 500; }
.delta .icon { width: 14px; height: 14px; }
.delta--up { color: var(--success); }
.delta--down { color: var(--danger); }

/* Overview lists */

.activity-mini li, .task-mini li { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity-mini li:last-child, .task-mini li:last-child { border-bottom: 0; }
.activity-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
}
.activity-icon .icon { width: 14px; height: 14px; }
.activity-mini .activity-icon { background: var(--surface-2); border-color: transparent; }
.activity-line { font-size: 13.5px; }
.activity-body { margin-top: 2px; font-size: 13px; color: var(--muted); }
.activity-time { flex: none; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.task-mini li { align-items: center; }
.task-mini .flex-1 p:first-child { font-size: 13.5px; }

.checkbox {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: #fff;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.checkbox:hover { border-color: var(--accent); }
.checkbox.is-checked { background: var(--accent); border-color: var(--accent); }
.checkbox svg { width: 12px; height: 12px; }

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { background: var(--success-soft); color: var(--success-text); }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); }
.badge--danger { background: var(--danger-soft); color: var(--danger-text); }
.badge--info { background: var(--info-soft); color: var(--info-text); }
.badge--accent { background: var(--accent-soft); color: var(--accent-text); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line-strong); }
.dot--lead { background: #c6c6d2; }
.dot--qualified { background: #9d99f0; }
.dot--proposal { background: var(--accent); }
.dot--negotiation { background: var(--info); }
.dot--won { background: var(--success); }
.dot--lost { background: var(--danger); }

/* Avatars */

.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; font-weight: 600; letter-spacing: 0; }
.round { border-radius: 50%; }
.company-mark { display: inline-grid; place-items: center; flex: none; border-radius: 12px; font-weight: 600; }

/* Tables */

.table-card { margin-top: 16px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13.5px; table-layout: fixed; }
.table thead tr { height: 40px; background: var(--table-head); border-bottom: 1px solid var(--line); }
.table th { padding: 0 16px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.table tbody tr { height: 56px; border-bottom: 1px solid var(--line); transition: background-color .15s ease; }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr[data-href]:hover { background: var(--hover-bg); }
.table td { padding: 0 16px; }
.cell-person { display: flex; align-items: center; gap: 12px; }
.stage-cell { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 13px; color: var(--muted); }
.pager-actions { display: flex; gap: 4px; }

/* Detail pages */

.back-link { display: inline-flex; align-items: center; gap: 6px; height: 32px; font-size: 13px; color: var(--muted); }
.back-link:hover { color: var(--fg); }
.back-link .icon { width: 14px; height: 14px; }

.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; margin-top: 16px; }
.detail-identity { display: flex; align-items: center; gap: 16px; }
.title-row { display: flex; align-items: center; gap: 12px; }
.title-row h1, .detail-identity h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.detail-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.detail-sub a { display: inline-flex; align-items: center; gap: 5px; }
.detail-sub a:hover { text-decoration: underline; }
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.meta-item .icon { width: 14px; height: 14px; color: var(--faint); }
.detail-actions { display: flex; align-items: center; gap: 8px; }

.avatar-form { margin: 0; }
.avatar-edit { position: relative; display: inline-flex; }
.photo-remove { position: absolute; right: -8px; bottom: -8px; display: flex; }
.photo-remove .btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-card);
}
.photo-remove .btn:hover { background: var(--surface); color: var(--danger); }
.avatar-upload { position: relative; display: inline-block; cursor: pointer; border-radius: 50%; }
.avatar-upload input[type='file'] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.avatar-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgb(20 20 24 / 0.5);
  color: #fff;
  opacity: 0;
  transition: opacity .15s ease;
}
.avatar-upload--square, .avatar-upload--square .avatar-overlay { border-radius: 12px; }
.avatar-upload:hover .avatar-overlay { opacity: 1; }
.avatar-overlay .icon { width: 20px; height: 20px; }

.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 32px; margin-top: 32px; align-items: start; }
.detail-aside { display: flex; flex-direction: column; gap: 32px; }
.detail-columns { align-items: start; margin-top: 32px; }
.section-title { margin-top: 24px; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.section-title .muted { font-weight: 400; font-size: 12.5px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 16px; }
.section-head .section-title { margin: 0; }

.detail-list { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; font-size: 13.5px; }
.detail-list > div { display: flex; align-items: center; gap: 12px; }
.detail-list dt { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 9px; background: var(--surface-2); color: var(--muted); }
.detail-list dt .icon { width: 14px; height: 14px; }
.detail-list dd { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-list dd a:hover { text-decoration: underline; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 24px; }
.stat { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-card); }
.stat p { font-size: 12.5px; color: var(--muted); }
.stat strong { display: block; margin-top: 4px; font-size: 20px; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }

/* Record lists */

.record-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.record-list li a, .record-list li.static {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  transition: background-color .15s ease, border-color .15s ease;
}
.record-list li a:hover { background: var(--hover-bg); border-color: var(--line-strong); }
.record-list--tall li a { min-height: 56px; }
.record-list .icon { color: var(--muted); }
.file-row { padding: 4px 8px !important; min-height: 44px !important; }
.files-panel { margin-top: 0; }
.files-panel .section-head { margin-top: 0; }

/* Company grid */

.company-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.company-card { display: flex; flex-direction: column; justify-content: space-between; height: 132px; padding: 16px; transition: border-color .15s ease, box-shadow .15s ease; }
.company-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-card); }
.company-card-head { display: flex; align-items: flex-start; gap: 12px; }
.company-card-head .strong { font-size: 14.5px; font-weight: 600; }
.company-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 12.5px; }
.company-stats dt { color: var(--faint); }
.company-stats dd { margin-top: 2px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* Deals board */

.segmented { display: grid; grid-auto-flow: column; gap: 2px; height: 36px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); }
.segmented a { display: grid; place-items: center; width: 32px; border-radius: 9px; color: var(--muted); }
.segmented a:hover { color: var(--fg); }
.segmented a.is-active { background: var(--surface-2); color: var(--fg); }

.board-scroll { overflow-x: auto; padding: 24px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.board { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; min-width: 1080px; }
.column { display: flex; flex-direction: column; min-height: 0; }
.column-head { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 4px; }
.column-head h2 { font-size: 13px; font-weight: 600; }
.column-count { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.column-total { margin-left: auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.column-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 160px;
  padding: 8px;
  border: 1px dashed transparent;
  border-radius: var(--radius-card);
  background: var(--board-bg);
  transition: background-color .15s ease, border-color .15s ease;
}
.column-body.drag-over { border-color: rgb(90 85 222 / 0.5); background: rgb(238 237 252 / 0.5); }
.column-add { display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--faint); font-size: 12.5px; cursor: pointer; }
.column-add:hover { background: var(--surface); color: var(--fg); }
.column-add .icon { width: 14px; height: 14px; }

.deal-card { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card); cursor: grab; user-select: none; -webkit-user-select: none; transition: border-color .15s ease, box-shadow .15s ease, opacity .15s ease; }
.deal-card:hover { border-color: var(--line-strong); }
.deal-card:active { cursor: grabbing; }
.deal-card.dragging { opacity: .35; }
.deal-title { font-size: 13.5px; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.deal-company { margin-top: 2px; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.deal-value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.deal-extra { display: flex; align-items: center; gap: 8px; }
.deal-date { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.deal-date .icon { width: 12px; height: 12px; }

/* Drawer */

.drawer-scrim { position: fixed; inset: 0; z-index: 40; background: rgb(20 20 24 / 0.16); }
.drawer-scrim a { display: block; width: 100%; height: 100%; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  width: min(480px, 100vw);
  overflow-y: auto;
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
}
.drawer-body { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.drawer-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-badges { display: flex; align-items: center; gap: 8px; }
.drawer-actions { display: flex; align-items: center; gap: 2px; }
.drawer-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.drawer-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; font-size: 13.5px; }
.drawer-meta a { display: inline-flex; align-items: center; gap: 8px; }
.drawer-meta a:hover { text-decoration: underline; }
.stage-switch { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 4px; border-radius: var(--radius-control); background: var(--bg); }
.stage-switch-btn { height: 32px; padding: 0 2px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-switch-btn:hover { color: var(--fg); }
.stage-switch-btn.is-active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-card); }

/* Tasks */

.task-groups { display: flex; flex-direction: column; gap: 28px; margin-top: 24px; }
.task-group-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.task-group-title.is-danger { color: var(--danger); }
.task-group-count { font-weight: 400; color: var(--faint); font-variant-numeric: tabular-nums; }
.task-list { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; }
.task-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--hover-bg); }
.task-title-btn { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 0; cursor: pointer; }
.task-title { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-title.is-done { color: var(--faint); text-decoration: line-through; }
.task-link { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--muted); }
.task-link:hover { color: var(--fg); }
.task-delete { opacity: 0; transition: opacity .15s ease; }
.task-row:hover .task-delete, .task-delete:focus-within { opacity: 1; }

/* Activity feed and composer */

.composer { padding: 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-card); background: var(--surface); }
.composer:focus-within { border-color: rgb(90 85 222 / 0.55); box-shadow: 0 0 0 3px rgb(90 85 222 / 0.1); }
.composer-kinds { display: flex; gap: 2px; }
.chip-radio { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.composer-kinds label { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: var(--radius-tile); font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; }
.composer-kinds label:hover { color: var(--fg); }
.composer-kinds label .icon { width: 14px; height: 14px; }
.chip-radio:checked + label { background: var(--surface-2); color: var(--fg); }
.chip-radio:focus-visible + label { outline: 2px solid rgb(90 85 222 / 0.55); }
.composer-input { min-height: 72px; border: 0; background: transparent; padding: 8px; box-shadow: none; }
.composer-input:focus { box-shadow: none; border-color: transparent; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 4px; }

.activity-feed { position: relative; display: flex; flex-direction: column; margin-top: 4px; }
.activity-feed::before { content: ''; position: absolute; left: 13px; top: 12px; bottom: 12px; width: 1px; background: var(--line); }
.activity-feed > li { position: relative; display: flex; gap: 12px; padding: 12px 0; }
.activity-feed .activity-icon { position: relative; z-index: 1; background: var(--surface); }
.activity-top { display: flex; align-items: baseline; gap: 8px; }
.activity-kind { font-size: 12.5px; font-weight: 500; text-transform: capitalize; }
.activity-contact { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-contact:hover { color: var(--fg); }
.activity-top .activity-time { margin-left: auto; }
.activity-text { margin-top: 2px; font-size: 13.5px; line-height: 1.55; color: var(--text-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.activity-remove { align-self: flex-start; opacity: 0; transition: opacity .15s ease; }
.activity-feed > li:hover .activity-remove, .activity-remove:focus-within { opacity: 1; }

/* Empty state */

.empty-state { display: flex; flex-direction: column; align-items: center; padding: 48px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); color: var(--muted); }
.empty-icon .icon { width: 20px; height: 20px; }
.empty-state h2 { margin-top: 14px; font-size: 15px; font-weight: 600; }
.empty-state p { max-width: 340px; margin-top: 4px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.empty-action { margin-top: 16px; }

/* Settings */

.settings-section { margin-top: 32px; }
.settings-section h2 { font-size: 14px; font-weight: 600; }
.settings-account { display: flex; align-items: center; gap: 16px; margin-top: 12px; padding: 16px; }
.settings-list { margin-top: 12px; padding: 0; overflow: hidden; }
.settings-list li { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.settings-list li:last-child { border-bottom: 0; }

/* Charts */

.chart { width: 100%; height: auto; margin-top: 16px; display: block; }
.chart-label { font-family: var(--font-sans); font-size: 11px; fill: var(--faint); }
.chart-grid { stroke: var(--line); }
.chart-line { stroke: var(--accent); }
.chart-dot { fill: var(--surface); stroke: var(--accent); }
.chart-stop-a { stop-color: var(--accent); stop-opacity: 0.22; }
.chart-stop-b { stop-color: var(--accent); stop-opacity: 0; }

/* Theme toggle */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--fg); }
.theme-toggle .icon { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
[data-theme='dark'] .theme-toggle .icon-sun { display: block; }
[data-theme='dark'] .theme-toggle .icon-moon { display: none; }
.topbar .theme-toggle { margin-left: 0; }
.chart-note { margin-top: 6px; font-size: 12px; color: var(--faint); }

.stage-bars { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.stage-bar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.stage-name { display: inline-flex; align-items: center; gap: 7px; color: var(--fg); }
.stage-value { color: var(--muted); }
.stage-track { height: 6px; margin-top: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.stage-fill { display: block; height: 100%; border-radius: 99px; background: var(--line-strong); }
.stage-fill--qualified { background: #9d99f0; }
.stage-fill--proposal { background: var(--accent); }
.stage-fill--negotiation { background: var(--info); }
.stage-fill--won { background: var(--success); }
.stage-fill--lost { background: var(--danger); }

/* Dialogs */

.dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-dialog);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-dialog);
}
.dialog::backdrop { background: rgb(20 20 24 / 0.28); }
.dialog-form { display: flex; flex-direction: column; max-height: min(80vh, 720px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 8px 20px; }
.dialog-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.dialog-body { padding: 8px 20px 4px; overflow-y: auto; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px 20px; }

.confirm-dialog { width: min(420px, calc(100vw - 32px)); }
.confirm-body { padding: 4px 20px 8px; font-size: 13.5px; color: var(--muted); line-height: 1.55; }

/* Responsive */

@media (max-width: 1100px) {
  .company-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: 1fr; }
  .grid-span-2 { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1023px) {
  body { overflow: auto; }
  .app { display: block; height: auto; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 8px;
    border-bottom: 1px solid var(--line);
    background: var(--topbar-bg);
    backdrop-filter: blur(8px);
  }
  .topbar-title { font-size: 14px; font-weight: 600; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: 280px;
    background: var(--bg);
    box-shadow: var(--shadow-dialog);
    transform: translateX(-102%);
    transition: transform .2s ease;
  }
  .sidebar.is-open { transform: none; }
  .scrim.is-open { display: block; position: fixed; inset: 0; z-index: 45; background: rgb(20 20 24 / 0.2); }
  .main { padding: 0; }
  .surface { border: 0; border-radius: 0; height: auto; overflow: visible; }
  .page { padding: 20px; }
  .board-scroll { padding: 20px; }
  .page--full { padding: 20px; }
  .grid--2 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .company-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .hide-md, .hide-lg { display: none; }
  .task-link.hide-sm { display: none; }
}

@media (max-width: 520px) {
  .hide-sm { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .detail-identity { align-items: flex-start; }
}

/* Accounts */

.auth-body { overflow: auto; }
.auth {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}
.auth-flash {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 60;
  transform: translateX(-50%);
  border: 1px solid var(--flash-line);
  border-radius: var(--radius-control);
  padding: 10px 16px;
  box-shadow: var(--shadow-pop);
}
.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 40px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand .brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--primary-bg); color: var(--primary-fg); }
.auth-brand .brand-mark svg { width: 16px; height: 16px; }
.auth-brand .brand-name { font-size: 14px; font-weight: 600; }
.auth-form h1 { font-size: 30px; font-weight: 600; letter-spacing: -0.025em; }
.auth-sub { margin-top: 8px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.auth-fields { display: flex; flex-direction: column; gap: 14px; margin-top: 28px; }
.auth-submit { width: 100%; height: 42px; margin-top: 4px; }
.auth-switch { margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-switch a { color: var(--fg); font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }
.auth-foot { font-size: 12px; color: var(--faint); }
.auth-aside { display: grid; place-items: center; padding: 48px 40px; background: var(--surface); border-left: 1px solid var(--line); }
.auth-art { width: 100%; max-width: 480px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-dialog); }
.auth-art-head { display: flex; align-items: center; justify-content: space-between; }
.auth-art-head strong { font-size: 14px; }
.auth-art-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.auth-art-stats div { padding: 12px; border-radius: 14px; background: var(--bg); }
.auth-art-stats span { display: block; font-size: 12px; color: var(--muted); }
.auth-art-stats strong { display: block; margin-top: 4px; font-size: 20px; letter-spacing: -0.02em; }
.auth-art-stats .accent { color: var(--accent); }
.auth-art-stats .success { color: var(--success); }
.auth-art-list { display: flex; flex-direction: column; margin-top: 16px; }
.auth-art-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.auth-art-list li:first-child { border-top: 0; }
.auth-art-stage { padding: 2px 8px; border-radius: 8px; background: var(--surface-2); font-size: 12px; color: var(--muted); white-space: nowrap; }
.flash--error { background: var(--danger-soft); color: var(--danger-text); border-bottom-color: var(--danger); }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-panel { padding: 28px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
