/* ---------- buttons ---------- */
/* Buttons do not float, bounce or glow. They are one height, one radius, and the only thing that changes on
   hover is the surface under them — the lift-on-hover made every toolbar feel like it was breathing. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--control-h); padding: 0 14px; border-radius: var(--r-sm); font-weight: 600; font-size: var(--fs-sm);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); white-space: nowrap; }
.btn svg { width: 16px; height: 16px; } .btn:hover { background: var(--surface-hover); border-color: var(--border-strong); } .btn:active { background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: var(--on-solid); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-solid); }
.btn-accent { background: var(--accent); color: var(--on-solid); border-color: var(--accent); } .btn-accent:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-solid); }
.btn-ai { background: var(--ai); color: var(--on-solid); border-color: var(--ai); } .btn-ai:hover { background: var(--ai-strong); border-color: var(--ai-strong); color: var(--on-solid); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); } .btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; } .btn-soft:hover { background: var(--blue-100); }
[data-theme="dark"] .btn-soft:hover { background: rgba(47,196,189,.24); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; } .btn-danger:hover { background: var(--danger); color: var(--on-solid); }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-xs); border-radius: var(--r-xs); } .btn-sm svg { width: 14px; height: 14px; }
/* Smallest control on the 28 / 34 / 40 scale: a compact icon button that still hits the 28px minimum. */
.btn.btn-xs { height: 28px; padding: 0 6px; font-size: var(--fs-xs); border-radius: var(--r-xs); } .btn.btn-xs svg { width: 14px; height: 14px; } .btn-icon.btn-xs { width: 28px; }
.btn-lg { height: 40px; padding: 0 20px; font-size: var(--fs-md); border-radius: var(--r-sm); }
.btn-icon { width: var(--control-h); padding: 0; } .btn-icon.btn-sm { width: 28px; }
.btn.loading { pointer-events: none; opacity: .8; } .btn.loading::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite; }

/* ---------- cards ---------- */
/* A card is a surface, not an object floating over the page: border + hairline, and it does not move. */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); transition: border-color var(--t-base); }
.card-hover:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--border-strong); }
.card-body { padding: var(--sp-4); } .card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); min-height: 46px; }
.card-head h3 { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); font-weight: var(--fw-semi); } .card-head h3 svg.ic { width: 16px; height: 16px; color: var(--text-3); }
.card-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
/* A tinted card is a flat wash, not a fade. A gradient that ends in the page colour makes the card look
   like it is dissolving, and it reads differently at every card height. */
.card.tint-brand { background: var(--brand-soft); } .card.tint-ai { background: var(--ai-soft); }
.card.tint-accent { background: var(--accent-soft); }

/* stat tiles */
/* A KPI tile is a number and its name. The old one had a big coloured blob bleeding out of the corner, which
   fought the figure it was supposed to frame; the colour now lives in a 3px rule and the icon only. */
.stat { position: relative; overflow: hidden; padding: var(--sp-4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.stat::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--stat-v, var(--stat-c, var(--border-strong))); }
.stat { transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); } .stat:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.stat .label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 6px; }
.stat .label svg { width: 26px; height: 26px; padding: 6px; box-sizing: border-box; border-radius: 7px; background: var(--stat-soft, var(--surface-3)); color: var(--stat-c, var(--text-3)); flex: none; }
.stat .value { font-size: var(--fs-3xl); font-weight: var(--fw-semi); letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: var(--fs-xs); color: var(--text-3); } .stat .delta.up { color: var(--success); } .stat .delta.down { color: var(--danger); }
.stat { --stat-c: var(--brand); --stat-v: var(--brand-vivid); --stat-soft: var(--brand-soft); }
.stat.c-accent { --stat-c: var(--accent); --stat-v: var(--accent-vivid); --stat-soft: var(--accent-soft); } .stat.c-ai { --stat-c: var(--ai); --stat-v: var(--ai-vivid); --stat-soft: var(--ai-soft); } .stat.c-success { --stat-c: var(--success); --stat-v: var(--success-vivid); --stat-soft: var(--success-soft); } .stat.c-warning { --stat-c: var(--warning); --stat-v: var(--warning-vivid); --stat-soft: var(--warning-soft); } .stat.c-danger { --stat-c: var(--danger); --stat-v: var(--danger-vivid); --stat-soft: var(--danger-soft); } .stat.c-info { --stat-c: var(--info); --stat-v: var(--info-vivid); --stat-soft: var(--info-soft); }

/* ---------- badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-xs); font-size: var(--fs-xs); font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1; box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent); }
.badge svg { width: 12px; height: 12px; } .badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
/* Badge text uses the semantic token, which is the shade computed to clear 4.5:1 on its own tint.
   --amber-700 was still only 3.7:1 at 11.5px, which is exactly the "hard to see" the client reported. */
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); } .badge-info { background: var(--info-soft); color: var(--info); } .badge-ai { background: var(--ai-soft); color: var(--ai); } .badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-orange { background: var(--amber-50); color: var(--stage-negotiation); }
[data-theme="dark"] .badge-success { color: var(--success); } [data-theme="dark"] .badge-warning { color: var(--warning); } [data-theme="dark"] .badge-danger { color: var(--danger); } [data-theme="dark"] .badge-info { color: var(--info); }
[data-theme="dark"] .badge-ai { color: var(--ai-strong); } [data-theme="dark"] .badge-accent { color: var(--accent-strong); } [data-theme="dark"] .badge-orange { background: rgba(255,154,87,.14); color: #FFB27A; }
.badge-stage { color: var(--on-solid); background: var(--stage-c); } .badge-stage.s-new { --stage-c: var(--stage-new); } .badge-stage.s-at_operations { --stage-c: var(--stage-at_operations); } .badge-stage.s-quoted { --stage-c: var(--stage-quoted); }
.badge-stage.s-negotiation { --stage-c: var(--stage-negotiation); } .badge-stage.s-won { --stage-c: var(--stage-won); } .badge-stage.s-lost { --stage-c: var(--stage-lost); }
.temp { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 700; padding: 2px 9px; border-radius: 999px; } .temp svg { width: 12px; height: 12px; }
.temp { box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 22%, transparent); }
.temp.hot { background: var(--danger-soft); color: var(--hot); } .temp.warm { background: var(--warning-soft); color: var(--warm); } .temp.cold { background: var(--info-soft); color: var(--cold); }
[data-theme="dark"] .temp.hot { background: var(--accent-soft); color: var(--accent-strong); } [data-theme="dark"] .temp.warm { background: var(--warning-soft); color: var(--warning); } [data-theme="dark"] .temp.cold { background: var(--info-soft); color: var(--info); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.chip:hover { border-color: var(--brand); color: var(--brand-ink); } .chip.active { background: var(--brand); border-color: var(--brand); color: var(--on-solid); }
.chip svg { width: 13px; height: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.prio { width: 9px; height: 9px; border-radius: 50%; display: inline-block; } .prio.low { background: var(--slate-500); } .prio.normal { background: var(--info-vivid); } .prio.high { background: var(--warning-vivid); } .prio.urgent { background: var(--danger-vivid); box-shadow: 0 0 0 3px var(--danger-soft); }

/* avatars */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; color: #FFFFFF; background: linear-gradient(135deg, var(--blue-600), var(--navy)); flex: none; letter-spacing: .02em; }
.avatar.sm { width: 26px; height: 26px; font-size: 10px; } .avatar.lg { width: 48px; height: 48px; font-size: 16px; } .avatar.xl { width: 72px; height: 72px; font-size: 24px; }
/* Avatar hues start at a shade where the white initials actually clear 4.5:1 — the old gradients began
   on a 300-level pastel, where two-letter initials were nearly invisible (1.4:1). */
.avatar.h1 { background: linear-gradient(135deg, var(--navy), var(--navy-deep)); }
.avatar.h2 { background: linear-gradient(135deg, var(--indigo-600), var(--indigo-700)); }
.avatar.h3 { background: linear-gradient(135deg, var(--sky-600), var(--blue-700)); }
.avatar.h4 { background: linear-gradient(135deg, var(--blue-700), var(--blue-800)); }
.avatar.h5 { background: linear-gradient(135deg, var(--leaf-600), var(--leaf-700)); }
.avatar.h6 { background: linear-gradient(135deg, var(--slate-600), var(--navy)); }
.avatar-stack { display: inline-flex; } .avatar-stack .avatar { margin-inline-start: -8px; box-shadow: 0 0 0 2px var(--surface); } .avatar-stack .avatar:first-child { margin: 0; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field { gap: 5px; }
.field label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field label .req { color: var(--danger); } .field .hint { font-size: var(--fs-xs); color: var(--text-4); } .field .err { font-size: var(--fs-xs); color: var(--danger); }
.input, .select, .textarea { width: 100%; height: var(--control-h); border-radius: var(--r-xs); border: 1px solid var(--border); background: var(--surface); padding: 0 10px; transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast); color: var(--text); }
.textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; line-height: var(--lh-base); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: var(--ring); background: var(--surface); }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.select { appearance: none; padding-inline-end: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236B7A8F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
[dir="rtl"] .select { background-position: left 10px center; }
.input-wrap { position: relative; } .input-wrap svg { position: absolute; top: 9px; inset-inline-start: 10px; width: 16px; height: 16px; color: var(--text-4); pointer-events: none; } .input-wrap .input { padding-inline-start: 34px; }
/* Filter dropdowns above a table are one of the standard control heights, not a bespoke one — an inline
   style here is how a fourth height crept into the app. */
.select.sel-filter { height: var(--control-h); width: auto; min-width: 128px; max-width: 200px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); } .form-grid .span-2 { grid-column: span 2; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); } .form-grid-3 .span-3 { grid-column: span 3; } .form-grid-3 .span-2 { grid-column: span 2; }
@media (max-width: 760px) { .form-grid, .form-grid-3 { grid-template-columns: 1fr; } .form-grid .span-2, .form-grid-3 .span-2, .form-grid-3 .span-3 { grid-column: span 1; } }
.form-section { display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); animation: rise-in var(--t-base) var(--ease-out) both; }
.form-section > h3 { display: flex; align-items: center; gap: 8px; font-size: var(--fs-md); font-weight: var(--fw-semi); color: var(--text); } .form-section > h3 svg { width: 16px; height: 16px; color: var(--text-3); }
.form-section > h3 .n { width: 22px; height: 22px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-size: 11px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-sm); } .check input { width: 17px; height: 17px; accent-color: var(--brand); }
/* NOTE: switchEl() renders a <span>, which is display:inline — without an explicit display the width and
   height below are ignored and every switch in the app collapses to 0x0 and disappears. */
.switch { display: inline-block; position: relative; width: 46px; height: 26px; border-radius: 999px; background: var(--border-strong);
  border: 1px solid color-mix(in srgb, var(--text-4) 35%, transparent); transition: background var(--t-base), border-color var(--t-base); flex: none; cursor: pointer; vertical-align: middle; }
.switch:hover { border-color: var(--brand); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform var(--t-base) var(--ease-spring); box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.switch.on { background: var(--brand); border-color: var(--brand); } .switch.on::after { transform: translateX(20px); } [dir="rtl"] .switch.on::after { transform: translateX(-20px); }
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.service-tile { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; user-select: none; transition: all var(--t-fast) var(--ease); font-size: var(--fs-sm); font-weight: 500; }
.service-tile svg { width: 20px; height: 20px; color: var(--text-3); } .service-tile:hover { border-color: var(--brand); transform: translateY(-1px); }
.service-tile.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); box-shadow: 0 0 0 3px rgba(18,150,143,.12); } .service-tile.on svg { color: var(--brand); }
.service-tile .tick { margin-inline-start: auto; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; } .service-tile.on .tick { background: var(--brand); border-color: var(--brand); color: var(--on-solid); } .service-tile .tick svg { width: 11px; height: 11px; color: inherit; }
.tags-input { display: flex; flex-wrap: wrap; gap: 6px; min-height: 40px; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); } .tags-input input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 80px; height: 28px; }
.tags-input .tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-sm); background: var(--brand-soft); color: var(--brand-ink); font-size: var(--fs-xs); font-weight: 600; } .tags-input .tag button { color: inherit; opacity: .7; line-height: 1; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--r-sm); background: var(--surface-3); gap: 2px; }
/* The buttons must lay out as a row themselves: an icon + a label inside a plain <button> wraps onto two
   lines the moment the icon is wide enough, which is exactly what happened to Board / List. */
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: var(--r-xs); font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); white-space: nowrap; transition: background var(--t-fast), color var(--t-fast); } .segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.range { accent-color: var(--brand); width: 100%; }

/* lookup dropdown */
.lookup { position: relative; } .lookup-menu { position: absolute; top: calc(100% + 4px); inset-inline: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); z-index: 40; max-height: 260px; overflow: auto; padding: 4px; animation: drop-in var(--t-fast) var(--ease-out) both; }
.lookup-menu div { padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-sm); display: flex; justify-content: space-between; gap: 8px; } .lookup-menu div:hover, .lookup-menu div.hl { background: var(--surface-hover); } .lookup-menu small { color: var(--text-4); }
.lookup-menu .add { color: var(--brand); font-weight: 600; }

/* ---------- tables ---------- */
/* A wide table scrolls sideways inside its own box. Without a cue the last visible column just looks cut
   off, so the edge of the scroller carries a small shadow that disappears once you reach the end. */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm);
  background-image: linear-gradient(to left, rgba(15,27,45,.10), transparent 14px), linear-gradient(to right, rgba(15,27,45,.10), transparent 14px);
  background-position: right center, left center; background-repeat: no-repeat; background-size: 14px 100%, 14px 100%; background-attachment: local, local; }
[data-theme="dark"] .table-wrap { background-image: linear-gradient(to left, rgba(0,0,0,.4), transparent 14px), linear-gradient(to right, rgba(0,0,0,.4), transparent 14px); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl th { text-align: start; font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: .05em; text-transform: uppercase; padding: 9px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; cursor: pointer; user-select: none; }
.tbl th.sorted { color: var(--brand); } .tbl th svg { width: 12px; height: 12px; vertical-align: -1px; margin-inline-start: 4px; }
.tbl td { padding: 9px 16px; height: var(--row-h); border-bottom: 1px solid var(--border); vertical-align: middle; }
/* Numbers line up by place value so you can compare magnitudes without reading every digit. */
.tbl td.num, .tbl th.num, .tbl .tabular { font-variant-numeric: tabular-nums; }
.tbl td.num, .tbl th.num { text-align: end; }
.tbl tbody tr { transition: background var(--t-fast); animation: row-in var(--t-base) var(--ease-out) both; } .tbl tbody tr:hover { background: var(--surface-hover); } .tbl tbody tr.clickable { cursor: pointer; } .tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td .primary { font-weight: 600; color: var(--text); } .tbl td .secondary { font-size: var(--fs-xs); color: var(--text-3); margin-top: 1px; }
.tbl td .primary, .tbl td .secondary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .actions { white-space: nowrap; text-align: end; } .tbl .actions .btn { opacity: 0; transition: opacity var(--t-fast); } .tbl tr:hover .actions .btn { opacity: 1; }
.tbl tr.selected { background: var(--brand-soft); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 10px 14px; font-size: var(--fs-sm); color: var(--text-3); border-top: 1px solid var(--border); background: var(--surface-2); }
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.toolbar .search { position: relative; } .toolbar .search input { width: 260px; }
.bulkbar { display: flex; align-items: center; gap: var(--sp-2); padding: 10px 14px; background: var(--brand-ink); color: var(--on-solid); border-radius: var(--r-md); animation: rise-in var(--t-base) var(--ease-out) both; } .bulkbar .btn { height: 28px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { position: relative; height: 40px; padding: 0 12px; font-weight: 600; font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; transition: color var(--t-fast); }
.tabs button svg { width: 16px; height: 16px; } .tabs button:hover { color: var(--text); } .tabs button.active { color: var(--brand-ink); }
.tabs button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand); animation: grow-x var(--t-base) var(--ease-out) both; }
.tabs button .count { font-size: 11px; background: var(--surface-3); padding: 1px 7px; border-radius: 999px; color: var(--text-3); } .tabs button.active .count { background: var(--brand-soft); color: var(--brand-ink); }
.subnav { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: var(--r-md); } .subnav a { padding: 7px 14px; border-radius: var(--r-xs); font-weight: 600; font-size: var(--fs-sm); color: var(--text-3); } .subnav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- modal / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(9,17,32,.45); backdrop-filter: blur(4px); z-index: var(--z-modal); display: grid; place-items: center; padding: 20px; animation: fade-in var(--t-base) var(--ease-out) both; }
.overlay.closing { animation: fade-out var(--t-fast) var(--ease) both; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 40px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: modal-in var(--t-slow) var(--ease-spring) both; overflow: hidden; }
.modal.wide { width: min(1040px, 100%); } .modal.narrow { width: min(460px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal header h2 { font-size: var(--fs-lg); display: flex; align-items: center; gap: 10px; } .modal header h2 svg { width: 22px; height: 22px; color: var(--brand); }
.modal .body { padding: 22px; overflow: auto; display: flex; flex-direction: column; gap: var(--sp-4); }
.modal footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.drawer-overlay { position: fixed; inset: 0; background: rgba(9,17,32,.35); z-index: var(--z-drawer); animation: fade-in var(--t-base) both; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(560px, 100%); background: var(--surface); box-shadow: var(--shadow-lg); z-index: calc(var(--z-drawer) + 1); display: flex; flex-direction: column; animation: drawer-in var(--t-slow) var(--ease-out) both; }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); } .drawer .body { padding: 22px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: var(--sp-4); }
.drawer footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; inset-inline-end: 20px; display: flex; flex-direction: column; gap: 8px; z-index: var(--z-toast); }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--text); color: var(--text-inverse); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); animation: toast-in var(--t-slow) var(--ease-spring) both; }
[data-theme="dark"] .toast { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); }
.toast svg { width: 18px; height: 18px; flex: none; } .toast.success svg { color: var(--success-vivid); } .toast.error svg { color: var(--rose-500); } .toast.info svg { color: var(--sky-500); } .toast.ai svg { color: var(--indigo-500); } .toast.warning svg { color: var(--amber-500); }
.toast.leaving { animation: toast-out var(--t-base) var(--ease) both; }

/* ---------- empty / skeleton ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 48px 20px; color: var(--text-3); }
.empty .ico { width: 64px; height: 64px; border-radius: var(--r-xl); background: var(--surface-3); display: grid; place-items: center; margin-bottom: 6px; color: var(--text-4); } .empty .ico svg { width: 30px; height: 30px; }
.empty b { color: var(--text-2); font-size: var(--fs-md); }
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: var(--r-sm); min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: shimmer 1.4s infinite; }
/* one table row's worth of placeholder while a list loads */
.skeleton-row { position: relative; overflow: hidden; height: 44px; border-radius: var(--r-md); background: var(--surface-3); }
.skeleton-row::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: shimmer 1.4s infinite; }
[data-theme="dark"] .skeleton-row::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); }
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--border); } .kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: var(--fs-sm); } .kv dt { color: var(--text-3); } .kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; } .progress > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue-600), var(--lime-mid)); transition: width var(--t-slow) var(--ease-out); }
.progress.warn > i { background: linear-gradient(90deg, var(--amber-500), var(--amber-500)); } .progress.danger > i { background: linear-gradient(90deg, var(--rose-500), var(--rose-500)); }
.ring { --p: 0; --c: var(--brand); width: 44px; height: 44px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); display: grid; place-items: center; font-size: 11px; font-weight: 700; position: relative; }
.ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); } .ring span { position: relative; }
.tooltip { position: relative; } .tooltip:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); inset-inline-start: 50%; transform: translateX(-50%); background: var(--text); color: var(--text-inverse); font-size: 11px; padding: 4px 8px; border-radius: var(--r-xs); white-space: nowrap; z-index: 50; }
[dir="rtl"] .tooltip:hover::after { transform: translateX(50%); }
.dropdown { position: relative; } .menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 210px; max-width: min(320px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 5px; z-index: var(--z-menu); animation: drop-in var(--t-fast) var(--ease-out) both; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text); text-align: start; } .menu button:hover, .menu a:hover { background: var(--surface-hover); } .menu svg { width: 16px; height: 16px; color: var(--text-3); }
.menu button.has-hint { align-items: flex-start; padding-block: 8px; }
.menu button.has-hint svg { margin-top: 2px; }
.mi-label { display: block; min-width: 0; }
.mi-label small { display: block; margin-top: 2px; font-size: var(--fs-xs); line-height: 1.4; color: var(--text-3); white-space: normal; font-weight: 400; }
.menu button.danger .mi-label small { color: var(--text-3); }
.menu .danger { color: var(--danger); } .menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); font-size: var(--fs-sm); border: 1px solid transparent; }
.callout svg { width: 20px; height: 20px; flex: none; } .callout.info { background: var(--info-soft); color: var(--info); } .callout.warning { background: var(--warning-soft); color: var(--warning); } .callout.ai { background: var(--ai-soft); color: var(--ai); } .callout.danger { background: var(--danger-soft); color: var(--danger); } .callout.success { background: var(--success-soft); color: var(--success); }
[data-theme="dark"] .callout.info { color: var(--info); } [data-theme="dark"] .callout.warning { color: var(--warning); } [data-theme="dark"] .callout.ai { color: var(--ai-strong); } [data-theme="dark"] .callout.danger { color: var(--danger); } [data-theme="dark"] .callout.success { color: var(--success); }
.timeline { position: relative; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 14px; } .timeline::before { content: ""; position: absolute; top: 6px; bottom: 6px; inset-inline-start: 7px; width: 2px; background: var(--border); }
.tl-item { position: relative; animation: rise-in var(--t-base) var(--ease-out) both; } .tl-item::before { content: ""; position: absolute; inset-inline-start: -21px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--tl-c, var(--brand)); box-shadow: 0 0 0 3px var(--surface); }
.tl-item .when { font-size: var(--fs-xs); color: var(--text-4); } .tl-item .what { font-size: var(--fs-sm); }
.kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface-2); }
.pill-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--brand-soft); color: var(--brand); }
.mini-bar { display: flex; gap: 3px; align-items: flex-end; height: 34px; } .mini-bar i { flex: 1; border-radius: 3px 3px 0 0; background: var(--brand); opacity: .75; min-height: 3px; transition: height var(--t-slow) var(--ease-out); } .mini-bar i:hover { opacity: 1; }

/* form validation: a filled-in field that is the wrong shape turns red and says why; empty is never an error */
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); background: var(--danger-soft); }
.input.invalid:focus, .textarea.invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.field-err { display: block; margin-top: 4px; font-size: var(--fs-xs); color: var(--danger); font-weight: 500; }

/* Stacked modals: the ones underneath are dimmed, pushed back and made inert, so it is always obvious
   which dialog is active and which one Escape will close. */
.overlay.is-behind { background: rgba(9,17,32,.28); pointer-events: none; }
/* `animation: modal-in ... both` pins opacity to its final keyframe, which beats a plain declaration —
   the parked state has to cancel the animation for the dimming to apply at all. */
.overlay.is-behind .modal { animation: none; transform: scale(.96); filter: saturate(.6) brightness(.94); opacity: .55; transition: all var(--t-base) var(--ease); }
[data-theme="dark"] .overlay.is-behind .modal { filter: saturate(.6) brightness(.7); }

/* Table headers must sit over their own column, whatever the cell holds. Numeric and action columns are
   aligned as a pair (header + cells) so the header never drifts off the data underneath it.
   Everything here is LOGICAL (start / end) so it flips with the document direction by itself — there is no
   [dir="rtl"] override any more: the old one had the same specificity as .num and, coming later, beat it,
   which is why numbers sat on the wrong side in Arabic. */
.tbl th, .tbl td { text-align: start; }
.tbl th.num, .tbl td.num, .tbl td.tabular, .tbl th.tabular { text-align: end; font-variant-numeric: tabular-nums; }
.tbl th.center, .tbl td.center { text-align: center; }
.tbl th:last-child:empty, .tbl td:last-child:has(> .row) { text-align: end; }
.tbl th { vertical-align: middle; white-space: nowrap; }
.tbl td > .row { display: flex; align-items: center; gap: 6px; }
.tbl th.actions, .tbl td.actions { text-align: end; white-space: nowrap; }
[dir="rtl"] .tbl th.num, [dir="rtl"] .tbl td.num, [dir="rtl"] .tbl td.tabular, [dir="rtl"] .tbl th.tabular, [dir="rtl"] .tbl th.actions, [dir="rtl"] .tbl td.actions { text-align: end; }
[dir="rtl"] .tbl th.center, [dir="rtl"] .tbl td.center { text-align: center; }
.tbl th[role="button"]:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* Topbar bell: an unread COUNT, not a dot. Notification rows carry a type word and a per-type icon colour. */
.icon-btn .notif-count { position: absolute; top: 4px; inset-inline-end: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--rose-500); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--surface); font-variant-numeric: tabular-nums; }
.icon-btn .notif-count.pulse { animation: pulse-dot 1.6s var(--ease) infinite; }
.notif-kind { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 2px; }
.notif .ico.k-inbox, .notif-kind.k-inbox { color: var(--info); } .notif .ico.k-inbox { background: var(--info-soft); }
.notif .ico.k-task, .notif-kind.k-task { color: var(--warning); } .notif .ico.k-task { background: var(--warning-soft); }
.notif .ico.k-deal, .notif-kind.k-deal { color: var(--brand); } .notif .ico.k-deal { background: var(--brand-soft); }
.notif .ico.k-chat, .notif-kind.k-chat { color: var(--ai); } .notif .ico.k-chat { background: var(--ai-soft); }
.notif .ico.k-system, .notif-kind.k-system { color: var(--text-3); }

/* Inline help. The client's feedback was mostly "what does this mean?", so the answer lives next to the
   label: a small dim "?" that only gains contrast on hover/focus, so it explains without shouting. */
.helptip { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  color: var(--text-3); background: transparent; border: 0; cursor: help; flex: none; vertical-align: middle; }
.helptip svg { width: 13px; height: 13px; }
.helptip:hover, .helptip:focus-visible { color: var(--brand); background: var(--brand-soft); }
.helptip:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
th .helptip { vertical-align: -2px; }

/* A company's initials disc is ringed by its temperature, not by a hash of its id. */
.avatar.t-hot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.avatar.t-warm { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--warning); }
.avatar.t-cold { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--info); }

/* ---- micro-interactions (9 Sep) ---- */
.btn { transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.btn:active { transform: scale(.975); }
.btn-primary:hover { background: var(--blue-700); box-shadow: var(--shadow-brand); }
[data-theme="dark"] .btn-primary:hover { background: var(--brand-strong); }
.btn-accent { background: var(--lime); color: var(--on-lime); border-color: transparent; } .btn-accent:hover { background: #C4EC3A; box-shadow: var(--shadow-accent); }
.tbl tbody tr { transition: background var(--t-fast) var(--ease); } .tbl tbody tr:hover { background: var(--brand-soft); }
.priority-card, a.card, .list-row, .work-row { transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.priority-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
/* live edge — a row that just changed from the server carries a lime flash on its leading edge for 1.4s */
/* live flash: an overlay (not the element's own background/shadow) so cards, rows and conversation items all
   keep their look; it holds for a beat, then fades. Table rows cannot host an overlay, so they animate directly. */
.just-changed { position: relative; }
.just-changed::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 1; background: color-mix(in srgb, var(--lime) 22%, transparent); box-shadow: inset 4px 0 0 var(--lime), 0 0 0 2px color-mix(in srgb, var(--lime) 55%, transparent); animation: fade-out 1.2s var(--ease-out) .35s both; }
[dir="rtl"] .just-changed::after { box-shadow: inset -4px 0 0 var(--lime), 0 0 0 2px color-mix(in srgb, var(--lime) 55%, transparent); }
.tbl tbody tr.just-changed { position: static; animation: live-flash 1.6s var(--ease-out) both; } tr.just-changed::after { display: none; }
[data-theme="dark"] .just-changed::after { background: color-mix(in srgb, var(--lime) 16%, transparent); }
.icon-btn.wiggle svg { animation: bell-wiggle .7s var(--ease) both; transform-origin: 50% 8%; }

/* A dialog that is already open, whose opener was clicked again: a short nudge instead of a second copy. */
.modal.attention, .drawer.attention { animation: attention .34s var(--ease); }
/* While a dialog is fetching what it needs, the pointer says "the click registered". */
body.awaiting, body.awaiting * { cursor: progress !important; }

/* "a newer version is available" — production only; local mode reloads itself instead of asking. */
.newbuild { position: fixed; inset-inline: 0; bottom: 0; z-index: 600; display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 10px 16px; background: var(--navy); color: #fff; font-size: var(--fs-sm); box-shadow: 0 -2px 12px rgba(18,42,68,.25); animation: rise-in .3s var(--ease-out) both; }
.newbuild button { background: var(--lime); color: var(--on-lime); border: 0; border-radius: var(--r-sm); padding: 6px 14px; font-weight: 600; font-family: inherit; cursor: pointer; }
.newbuild button:hover { filter: brightness(1.06); }
