/* ===========================================================================
   WasteFlow — prototype styles
   Design direction: sober operational CRM. Light neutral canvas, near-black
   structural ink, Innovando brand orange as the single primary/emphasis color
   (see BrandIdentity/IstruzioniIA.md), green=won / red=lost/hazard.
   1px hairline borders, no heavy shadows, labels above fields.
   =========================================================================== */

:root {
  /* Brand (innovando) — sourced from BrandIdentity/brandColors.css, loaded before this file */
  --brand: var(--brand-orange-500);

  /* Working palette (per spec §5.3) */
  --ink: #1a1a1a;
  --ink-2: #3d3d3d;
  --muted: #6b6b6b;
  --line: #e3e1dc;
  --line-strong: #cfccc4;
  --bg: var(--brand-main-bg);
  --surface: #ffffff;
  --surface-2: #faf9f6;

  /* Primary is always the brand orange (IstruzioniIA.md §4.3) — no separate muted accent */
  --accent: var(--brand-orange-500);
  --accent-soft: var(--brand-orange-100);
  --won: #2cb278;
  --won-soft: #e3f0e8;
  --lost: #cb3a3a;
  --lost-soft: #f4e0e0;

  /* role badge tints */
  --producer: #5b3fa8;
  --producer-soft: #ece7f6;
  --receiver: #2e7d52;
  --receiver-soft: #e3f0e8;

  --radius: 8px;
  --radius-sm: 6px;
  --gap: 16px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;

  --shadow-soft: 0 1px 2px rgba(26, 26, 26, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- App shell ---------- */
.app-shell { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 56px;
  padding: 0 18px;
  background: var(--ink);
  color: #f3f1ec;
  flex: 0 0 auto;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.brand { display: inline-flex; }
.brand__name { font-weight: 700; letter-spacing: -0.01em; font-size: 15px; }

.breadcrumb { display: flex; align-items: center; gap: 8px; flex: 1; color: #b8b5ad; font-size: 13px; }
.breadcrumb__item--current { color: #f3f1ec; font-weight: 600; }
.breadcrumb__sep { color: #6f6c64; }

.layout { display: flex; flex: 1; min-height: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 12px 10px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-group__header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--ink);
  font-size: 13.5px;
}
.nav-group__header:hover { background: var(--surface-2); }
.nav-group__label { flex: 1; text-align: left; }
.nav-group__chev { transition: transform 0.18s ease; font-size: 11px; color: var(--muted); }
.nav-group--open > .nav-group__header .nav-group__chev { transform: rotate(180deg); }
.nav-group__body { display: none; padding-left: 12px; margin: 2px 0 4px; }
.nav-group--open > .nav-group__body { display: block; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13.5px;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link--active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link i { font-size: 15px; width: 16px; text-align: center; }

.nav__sep {
  margin: 14px 10px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

/* ---------- Main / page ---------- */
.main { flex: 1; min-width: 0; overflow-y: auto; padding: 26px 30px 60px; }
.page { max-width: 1180px; margin: 0 auto; }
.page__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page__title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.page__lead { color: var(--muted); margin: 4px 0 0; }
.page__actions { display: flex; gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--surface);
}
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: #000; }
.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--lost-soft); color: var(--lost); border-color: transparent; }
.btn--danger:hover { background: #efcfcf; }

.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn--danger:hover { background: var(--lost-soft); color: var(--lost); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  border: 0; background: transparent; padding: 10px 14px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--ink); }
.tab--active { color: var(--ink); border-bottom-color: var(--accent); }
.tab__count {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 0 7px; font-size: 11.5px; color: var(--ink-2);
}

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar__push { margin-left: auto; }

.banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent-soft); border: 1px solid #ecdcc0;
  color: #7d5210; padding: 10px 14px; border-radius: var(--radius);
  margin-bottom: 14px; font-size: 13px;
}

/* ---------- Inputs ---------- */
.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
  background: var(--surface);
  color: var(--ink);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input--sm { width: auto; min-width: 210px; padding: 7px 10px; }
select.input { min-width: 150px; }
.input--invalid { border-color: var(--lost); }
.input--invalid:focus { outline-color: var(--lost); border-color: var(--lost); }
.textarea { resize: vertical; min-height: 70px; }

/* ---------- Card grid ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-soft);
}
.entity-card { cursor: pointer; transition: border-color 0.15s ease, transform 0.05s ease; }
.entity-card:hover { border-color: var(--line-strong); }
.entity-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.entity-card--prospect { background: repeating-linear-gradient(135deg, #fffdf7, #fffdf7 14px, #fcf8ee 14px, #fcf8ee 28px); border-style: dashed; }

.card__top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card__title { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.card__code { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card__badges { display: flex; gap: 5px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.card__meta { margin: 12px 0; display: flex; flex-direction: column; gap: 5px; }
.card__meta-item { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 12.5px; }
.card__meta-item i { color: var(--muted); width: 14px; text-align: center; }
.card__stats { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.stat-chip { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 2px 9px; }
.stat-chip strong { color: var(--ink); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; letter-spacing: 0.02em; }
.badge--producer { background: var(--producer-soft); color: var(--producer); }
.badge--receiver { background: var(--receiver-soft); color: var(--receiver); }
.badge--hazard { background: var(--lost-soft); color: var(--lost); margin-left: auto; }
.badge--won { background: var(--won-soft); color: var(--won); }
.badge--lost { background: var(--lost-soft); color: var(--lost); }
.badge--neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge i { font-size: 10px; }

/* status pills (prospect) */
.pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.pill--open { background: var(--accent-soft); color: var(--accent); }
.pill--qualifying { background: #e7eefb; color: #2f5bba; }
.pill--converted { background: var(--won-soft); color: var(--won); }
.pill--dropped { background: #ece9e4; color: var(--muted); }

/* ---------- Empty states ---------- */
.empty, .placeholder { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty i, .placeholder i { font-size: 34px; display: block; margin-bottom: 12px; opacity: 0.5; }
.pad { padding: 30px; }
.muted { color: var(--muted); }

/* ---------- Table ---------- */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.table__row { cursor: pointer; }
.table__row:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Modal ---------- */
/* Chrome (overlay/dialog/header/footer) now comes from Bootstrap's .modal component
   (js/components/modal.js). These are utility classes callers still add to their own
   footer/body content, independent of Bootstrap's modal structure itself. */
.modal-titles { flex: 1 1 auto; }
.modal__actions { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.modal__actions .btn--danger { margin-right: auto; }
.readonly-hint { margin-right: auto; font-size: 12.5px; }

/* ---------- Form ---------- */
.form-sections { display: flex; flex-direction: column; gap: 18px; }
.form-section { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.form-section__title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); margin: 0 0 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field--full { grid-column: 1 / -1; }
.field__label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field__required { color: var(--lost); margin-left: 2px; }

.collapsible.form-section { padding: 0; }
.collapsible__summary { list-style: none; cursor: pointer; padding: 16px; display: flex; align-items: center; justify-content: space-between; }
.collapsible__summary::-webkit-details-marker { display: none; }
.collapsible__chevron { transition: transform 0.15s ease; color: var(--muted); }
.collapsible[open] .collapsible__chevron { transform: rotate(180deg); }
.collapsible__body { padding: 0 16px 16px; }

.row--error td { background: var(--lost-soft); }
.detail-error-banner { display: flex; align-items: flex-start; gap: 8px; background: var(--lost-soft); color: var(--lost); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 12px; font-size: 13px; font-weight: 600; }

.detail-row { display: grid; grid-template-columns: 100px 1fr; gap: 10px; padding: 4px 0; align-items: start; }
.detail-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 16px; margin: 10px 0; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-chip { display: flex; flex-direction: column; gap: 2px; }
.detail-chip__label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.detail-chip__value { font-size: 13px; }
.detail-body-source { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-size: 13px; min-height: 220px; max-height: 420px; overflow: auto; margin: 0; }

.checkrow { display: flex; gap: 22px; padding-top: 4px; }
.checkrow--invalid { outline: 2px solid var(--lost); outline-offset: 4px; border-radius: var(--radius-sm); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: 16px; height: 16px; }

.rows { display: flex; flex-direction: column; gap: 10px; grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; }
.row--contact .input { flex: 1; }
.row--stream { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; }
.stream-grid { display: grid; grid-template-columns: 1fr 1.4fr 1.6fr 0.7fr auto; gap: 8px; align-items: end; width: 100%; }
.mini-field { display: flex; flex-direction: column; gap: 3px; }
.mini-field--full { grid-column: 1 / -1; }
.mini-field__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }

/* ---------- Facility blocks ---------- */
.facility-block { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.facility__head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.facility__name { flex: 1; font-weight: 600; }
.facility-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- EWC combobox ---------- */
.ewc-combobox { position: relative; }
.ewc-list {
  position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  list-style: none; margin: 0; padding: 4px; max-height: 260px; overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}
.ewc-option { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12.5px; }
.ewc-option--active, .ewc-option:hover { background: var(--accent-soft); }
.ewc-code { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ewc-desc { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ---------- User menu ---------- */
.usermenu { position: relative; }
.usermenu__trigger { display: flex; align-items: center; gap: 9px; background: transparent; border: 0; color: #f3f1ec; padding: 6px 8px; border-radius: var(--radius-sm); }
.usermenu__trigger:hover { background: rgba(255,255,255,0.08); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.usermenu__meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.usermenu__name { font-size: 13px; font-weight: 600; }
.usermenu__role { font-size: 11px; color: #b8b5ad; }
.usermenu__dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); width: 260px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 12px 36px rgba(0,0,0,0.18);
  padding: 6px; display: none;
}
.usermenu--open .usermenu__dropdown { display: block; }
.usermenu__section { padding: 6px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.usermenu__hint { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 6px; font-weight: 700; }
.usermenu__item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; background: transparent; border: 0; padding: 8px 9px; border-radius: var(--radius-sm); font-size: 13px; color: var(--ink); text-align: left; }
.usermenu__item:hover { background: var(--surface-2); }
.usermenu__item--user { font-weight: 500; }
.usermenu__userrole { font-size: 11px; color: var(--muted); }

/* Toast chrome now comes from Bootstrap's .toast component (js/components/toast.js). */

/* ---------- Opportunity report: scatter ---------- */
.scatter-svg { width: 100%; height: auto; display: block; }

/* rich bubble tooltip (dark card) */
.bubble-tip { position: absolute; z-index: 3000; width: 320px; background: #1b2435; color: #e7ebf2; border-radius: 12px; padding: 14px 16px; box-shadow: 0 18px 50px rgba(0,0,0,0.35); pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity 0.12s ease, transform 0.12s ease; }
.bubble-tip--on { opacity: 1; transform: translateY(0); }
.btip__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.btip__code { font-size: 11.5px; font-weight: 700; color: #aab4c5; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }
.btip__title { font-size: 14.5px; font-weight: 700; margin-bottom: 12px; line-height: 1.25; }
.btip__rows { display: flex; flex-direction: column; gap: 6px; }
.btip__row { display: grid; grid-template-columns: 78px 1fr; gap: 10px; font-size: 12.5px; }
.btip__k { color: #8895aa; }
.btip__v { color: #e7ebf2; }
.btip__v--pos { color: #6fd3a6; font-weight: 600; }
.btip__v--neg { color: #f1a3a3; font-weight: 600; }
.btip__alert { margin-top: 11px; padding-top: 10px; border-top: 1px solid #2c374a; color: #f0a6a6; font-size: 12.5px; display: flex; align-items: center; gap: 4px; }
.btip__hint { margin-top: 9px; font-size: 11px; color: #6f7c91; font-style: italic; }
.bubble-tip .pill { font-size: 10px; }

.scatter-axis { font-size: 11px; fill: var(--muted); }
.scatter-axis-title { font-size: 12.5px; fill: var(--ink-2); font-weight: 600; }
.scatter-crit { font-size: 14px; fill: #c0392b; font-weight: 700; }
.scatter-crit-sub { font-size: 11.5px; fill: #c0392b; }

/* ---------- Tender timeline tiles ---------- */
.timeline-tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 4px; }
.timeline-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.timeline-tile__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.timeline-tile__left { min-width: 0; flex: 1; }
.timeline-tile__code-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.timeline-tile__code { font-size: 10.5px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.timeline-tile__title { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.timeline-tile__issuer { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-tile__right { text-align: right; flex-shrink: 0; }
.timeline-tile__countdown { font-size: 12px; font-weight: 700; white-space: nowrap; }
.timeline-tile__potential { font-size: 11px; color: var(--muted); margin-top: 2px; }
.timeline-tile__meta { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.timeline-tile__meta-row { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-tile__meta-row .bi { font-size: 11px; }
.timeline-tile__legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.tl-leg { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); }
.tl-leg__line { width: 12px; height: 0; border-top: 1.5px dashed #888; display: inline-block; }

/* ---------- Radial chart KPI row ---------- */
.radial-kpi-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 16px; padding: 0 4px; }
.radial-kpi { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.radial-kpi__val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.radial-kpi__lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Aging heatmap matrix (Report) ---------- */
.aging-legend { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 11px; }
.aging-legend__lbl { font-size: 10.5px; }
.aging-legend__swatch { width: 16px; height: 14px; border-radius: 3px; display: inline-block; }
.aging-grid { display: grid; grid-template-columns: 160px repeat(5, 1fr); gap: 4px; margin-bottom: 10px; }
.aging-cell { border-radius: 5px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 62px; text-align: center; transition: transform .12s ease; }
.aging-cell--corner { min-height: auto; background: transparent; }
.aging-cell--head { min-height: auto; font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 4px; }
.aging-cell--rowhead { min-height: 62px; background: transparent; font-size: 12.5px; font-weight: 500; flex-direction: row; justify-content: flex-start; padding: 8px 10px; gap: 8px; }
.aging-cell--data { cursor: default; }
.aging-cell--data:hover { transform: scale(1.04); z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.aging-cell__n { font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1; }
.aging-cell__n--empty { font-size: 18px; color: var(--muted); opacity: .4; font-weight: 400; }
.aging-cell__v { font-size: 10.5px; margin-top: 3px; opacity: .85; }
.aging-dot { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }

.aging-h0 { background: transparent; }
.aging-h1 { background: #F1EFE8; color: #5F5E5A; }
.aging-h2 { background: #FAEEDA; color: #854F0B; }
.aging-h3 { background: #FAC775; color: #412402; }
.aging-h4 { background: #E24B4A; color: #fff; }
.aging-h5 { background: #791F1F; color: #fff; }

.aging-caption { font-size: 12px; margin-top: 4px; padding: 8px 12px; background: var(--surface-2, #f8f7f3); border-radius: var(--radius-sm, 6px); border-left: 3px solid var(--line); }
.aging-caption i { margin-right: 4px; }

/* ---------- Funnel Sankey caption (Report) ---------- */
.funnel-caption { font-size: 12.5px; margin-top: 14px; padding: 10px 14px; background: var(--surface-2, #f8f7f3); border-radius: var(--radius-sm, 6px); border-left: 3px solid var(--line); line-height: 1.55; }
.chart-card + .chart-card { margin-top: 24px; }

/* ---------- Opportunity map ---------- */
.map-split { display: grid; grid-template-columns: 1fr 360px; gap: 14px; }
.geo-map { height: 620px; border: 1px solid var(--line); border-radius: var(--radius); z-index: 0; }
.map-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow-y: auto; max-height: 620px; }
.map-panel__head { display: flex; align-items: flex-start; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.map-panel__title { font-size: 16px; font-weight: 700; margin: 0; }
.map-panel__sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.map-panel__chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.map-panel__group { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 6px; }
.map-panel__grouplabel { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; }
.map-panel__grouplabel--recv { color: var(--won); }
.map-panel__grouplabel--prod { color: var(--producer); }
.map-panel__count { font-size: 11.5px; color: var(--muted); }
.map-opp { padding: 10px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.map-opp:hover { background: var(--surface-2); }
.map-opp__top { display: flex; justify-content: space-between; align-items: center; }
.map-opp__code { font-size: 11.5px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.map-opp__value { font-size: 12.5px; font-weight: 700; }
.map-opp__title { font-size: 13px; margin: 3px 0 6px; }
.map-opp__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.map-opp__cp { font-size: 11.5px; color: var(--muted); }

.map-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; padding: 10px 4px; }
.legend-fac { width: 18px; height: 18px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.legend-fac--active { background: #1f3a5f; }
.legend-fac--lead { background: #a8adb6; }
.legend-fac--selected { background: #1c9e8f; }
.legend-arc { width: 22px; height: 0; border-top: 3px solid #3f6fb0; display: inline-block; }
.legend-arc--out { border-top-color: #3f6fb0; }
.legend-arc--in { border-top-color: #1f9e8f; }

/* factory markers on the map */
.fac-divicon { background: none; border: 0; }
.fac-marker { display: flex; align-items: center; justify-content: center; background: var(--fac); color: #fff; border-radius: 7px; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
.fac-marker--sel { box-shadow: 0 0 0 4px rgba(28,158,143,0.3), 0 2px 8px rgba(0,0,0,0.35); }
.fac-marker--lead { opacity: 0.9; }

/* animated flowing arcs: il tratteggio scorre nel verso del flusso */
.flow-arc { stroke-dasharray: 10 12; animation: flow-dash 1.1s linear infinite; }
/* il tratteggio scorre sempre nel verso producer -> receiver, coerente con la freccia */
@keyframes flow-dash { to { stroke-dashoffset: -22; } }
@media (prefers-reduced-motion: reduce) { .flow-arc { animation: none; } }

.arc-arrow-icon { background: none; border: 0; }
.arc-arrow { color: var(--c); font-size: 15px; line-height: 1; text-shadow: 0 0 2px #fff, 0 0 2px #fff; }

/* indicatore stato entità nel riepilogo country */
.dotstate { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dotstate--active { background: #1f3a5f; }
.dotstate--lead { background: #a8adb6; }



/* ---------- Activity log ---------- */
.toolbar--wrap { flex-wrap: wrap; gap: 10px; }
.toolbar__field { display: flex; align-items: center; gap: 6px; }
.toolbar__label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.audit-counter { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.audit-day-sep { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 20px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.audit-timeline { display: flex; flex-direction: column; gap: 2px; }
.audit-row { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: flex-start; padding: 10px 8px; border-radius: var(--radius-sm); }
.audit-row:hover { background: var(--surface-2); }
.audit-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex: 0 0 auto; margin-top: 1px; }
.audit-icon--won     { background: var(--won-soft);  color: var(--won); }
.audit-icon--accent  { background: var(--accent-soft); color: var(--accent); }
.audit-icon--neutral { background: var(--surface-2); color: var(--ink-2); }
.audit-icon--lost    { background: var(--lost-soft); color: var(--lost); }
.audit-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.audit-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13px; }
.audit-user { font-weight: 700; }
.audit-action { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }
.audit-action--won     { background: var(--won-soft);  color: var(--won); }
.audit-action--accent  { background: var(--accent-soft); color: var(--accent); }
.audit-action--neutral { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.audit-action--lost    { background: var(--lost-soft); color: var(--lost); }
.audit-obj { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); }
.audit-obj-code { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }
.audit-diff { display: flex; flex-direction: column; gap: 4px; }
.audit-diff--create { font-size: 12px; color: var(--muted); }
.audit-diff-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 8px; background: var(--surface-2); border-radius: 4px; flex-wrap: wrap; }
.audit-diff-field { font-weight: 600; color: var(--ink-2); min-width: 140px; }
.audit-diff-old { color: var(--lost); text-decoration: line-through; font-variant-numeric: tabular-nums; }
.audit-diff-arrow { color: var(--muted); font-size: 11px; }
.audit-diff-new { color: var(--won); font-weight: 600; font-variant-numeric: tabular-nums; }
.audit-time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: 4px; }

/* ---------- Settings: alert cards ---------- */
.settings-area-title { font-size: 14px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.alert-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.alert-card__head { display: flex; align-items: flex-start; gap: 12px; }
.alert-card__icon { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 16px; flex: 0 0 auto; }
.alert-card__info { flex: 1; min-width: 0; }
.alert-card__title { font-size: 13.5px; font-weight: 700; margin-bottom: 3px; }
.alert-card__who { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.alert-card__desc { font-size: 12.5px; color: var(--ink-2); }
.alert-card__option { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.alert-card__recipients { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.recipients--inline { padding: 0; }
.recipients-section { padding: 0; margin: 0; border: 0; }

/* toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 0 0 auto; }
.toggle-wrap input[type=checkbox] { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { width: 40px; height: 22px; background: var(--line-strong); border-radius: 11px; position: relative; transition: background .15s; display: block; }
.toggle-track::after { content: ""; position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%; top: 3px; left: 3px; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle-wrap input:checked + .toggle-track { background: var(--accent); }
.toggle-wrap input:checked + .toggle-track::after { transform: translateX(18px); }

/* tender team section */
.team-section { display: flex; flex-direction: column; gap: 10px; }
.team-row { display: flex; align-items: center; gap: 10px; }
.team-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 4px; }
.team-badge--owner { background: var(--accent-soft); color: var(--accent); }
.team-name { font-size: 13.5px; font-weight: 600; }
.team-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.team-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; font-size: 12.5px; }
.team-chip__remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 0 0 2px; }
.team-chip__remove:hover { color: var(--lost); }

/* Settings Recipients / Users */
/* ---------- Users (RBAC) ---------- */
.role-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.role-chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); border-radius: 20px; padding: 4px 12px; font-size: 12px; font-weight: 600; transition: all 0.12s ease; }
.role-chip:hover { border-color: var(--ink); color: var(--ink); }
.role-chip--on { color: #fff; border-color: transparent; }
.role-chip--on.role-chip--accent { background: var(--accent); }
.role-chip--on.role-chip--won { background: var(--won); }
.role-chip--on.role-chip--teal { background: #1c9e8f; }
.role-chip--on.role-chip--warn { background: #ba7517; }
.role-chip--on.role-chip--neutral { background: var(--ink-2); }
.tag-you { margin-left: 7px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 2px 6px; }

/* ---------- Conversion email preview ---------- */
.mail-preview { display: flex; flex-direction: column; gap: 12px; }
.mail-preview__banner { display: flex; align-items: center; gap: 8px; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 12.5px; }
.mail-row { display: flex; gap: 10px; align-items: flex-start; }
.mail-row__k { width: 64px; flex: 0 0 auto; font-size: 12px; color: var(--muted); font-weight: 600; padding-top: 3px; }
.mail-row__v { font-size: 13px; }
.mail-row__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mail-chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; font-size: 12px; }
.mail-body { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; font-family: inherit; margin: 0; }

/* ---------- Settings: recipients ---------- */
.recipients { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.recipient-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; align-items: center; }
.form-actions { margin-top: 16px; display: flex; align-items: center; gap: 12px; }

/* ---------- Home ---------- */
.kpi__split { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; }.kpi__split-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; }
.kpi__split-k { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.kpi__split-v { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.kpi--clickable { cursor: pointer; transition: border-color 0.12s ease, transform 0.12s ease; }
.kpi--clickable:hover { border-color: var(--line-strong); transform: translateY(-1px); }

/* ---------- Home: section label + performance KPI strip ---------- */
.home-section-label { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; }
.home-section-label__text { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); white-space: nowrap; }
.home-section-label__line { flex: 1; height: .5px; background: var(--line); }
.kpi-row--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.home-perf-row { margin-bottom: 18px; }
.kpi--perf { padding: 11px 14px; }
.kpi--perf .kpi__value { font-size: 20px; margin: 3px 0 2px; }
.perf-bar-track { height: 4px; background: rgba(128,128,128,0.10); border-radius: 2px; margin: 5px 0 4px; overflow: hidden; }
.perf-bar-fill { height: 4px; border-radius: 2px; }

/* ---------- Home 2-col widget height alignment ---------- */
.home-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; align-items: stretch; }
.home-2col > * { display: flex; flex-direction: column; }
.home-2col > .chart-card { justify-content: flex-start; min-height: 220px; }
.home-2col > .chart-card .donut-wrap { flex: 1; align-items: center; }
.home-2col > .chart-card .home-list { flex: 1; }
.home-2col > .chart-card .tenders-status-body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.home-2col > .chart-card .home-list__body { flex: 1; }
.chart-card__head--tight { margin-bottom: 8px; }
.home-list__title { font-size: 14px; font-weight: 700; }
.home-list__link { font-size: 12.5px; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }
.home-list__link:hover { text-decoration: underline; }
.home-list { display: flex; flex-direction: column; }
.home-list__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); cursor: pointer; }
.home-list__row:hover { background: var(--surface-2); }
.home-list__main { display: flex; flex-direction: column; min-width: 0; }
.home-list__code { font-size: 11.5px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.home-list__name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.home-list__right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.home-list__val { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.home-list__date { font-size: 12px; color: var(--muted); }

.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut-svg { flex: 0 0 auto; }
.donut-total { font-size: 22px; font-weight: 800; fill: var(--ink); }
.donut-sub { font-size: 10px; fill: var(--muted); }
.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.donut-legend__item { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; font-size: 12.5px; }
.donut-legend__dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.donut-legend__val { font-weight: 700; font-variant-numeric: tabular-nums; }
.home-total { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; font-size: 13px; color: var(--ink-2); }
.home-total strong { font-size: 14px; }

/* ---------- Status pills (opportunity) ---------- */
.pill--opp-neutral { background: #eceae5; color: var(--ink-2); }
.pill--opp-lead { background: #f0e6d6; color: #8a5a12; }
.pill--opp-accent { background: var(--accent-soft); color: var(--accent); }
.pill--opp-warn { background: #fbe6cf; color: #8a5a12; }
.pill--opp-won { background: var(--won-soft); color: var(--won); }
.pill--opp-lost { background: var(--lost-soft); color: var(--lost); }

/* days-left pills */
.pill--days { font-weight: 700; }
.pill--days-ok { background: var(--won-soft); color: var(--won); }
.pill--days-warn { background: #fbe6cf; color: #8a5a12; }
.pill--days-danger { background: var(--lost-soft); color: var(--lost); }

/* ---------- Tender modal: sub-tabs (lots) ---------- */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 14px; }
.subtab { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 20px; padding: 6px 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.subtab--active { background: var(--ink); color: #fff; border-color: var(--ink); }
.subtab--add { border-style: dashed; color: var(--muted); }
.lot-panel { display: flex; flex-direction: column; gap: 16px; }
.lot-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 4px; }
.outputs-wrap { display: flex; flex-direction: column; gap: 12px; }
.outputs { display: flex; flex-direction: column; gap: 10px; }
.output-block { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.output-grid { display: grid; grid-template-columns: 1.4fr 1.4fr 0.9fr 0.9fr 1fr auto; gap: 10px; align-items: end; }
.output-value { font-weight: 700; padding: 8px 0; color: var(--accent); }
.output-row-actions { display: flex; gap: 4px; align-items: center; }

/* ---------- Tender dates / milestones ---------- */
.dates-wrap { display: flex; flex-direction: column; gap: 14px; }
.milestone-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.milestone-add .input--sm:nth-child(2) { flex: 1; min-width: 160px; }
.milestones { display: flex; flex-direction: column; position: relative; }
.ms-item { display: flex; gap: 14px; padding: 0 0 16px; position: relative; }
.ms-item:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: -2px; width: 2px; background: var(--line); }
.ms-dot { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--line-strong); background: var(--surface); flex: 0 0 auto; margin-top: 1px; z-index: 1; }
.ms-dot--control { border-color: var(--accent); background: var(--accent-soft); }
.ms-dot--submission { border-color: var(--lost); background: var(--lost-soft); }
.ms-dot--result { border-color: #2f5bba; background: #e7eefb; }
.ms-body { flex: 1; }
.ms-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ms-label { font-weight: 600; font-size: 13.5px; }
.ms-meta { font-size: 12px; color: var(--muted); }
.ms-tag { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.ms-tag--control { background: var(--accent-soft); color: var(--accent); }
.ms-tag--submission { background: var(--lost-soft); color: var(--lost); }
.ms-tag--result { background: #e7eefb; color: #2f5bba; }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: block; }
.ms-tag--auto { background: #eceae5; color: var(--muted); }

/* ---------- OSM map ---------- */
.osm-map { width: 100%; height: 380px; border-radius: var(--radius-sm); border: 1px solid var(--line); grid-column: 1 / -1; z-index: 0; }

/* ---------- Tender analytics ---------- */
.analytics-2col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin: 16px 0; }
.gantt-legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 4px 4px 16px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-diamond { width: 9px; height: 9px; background: #3d3d3d; transform: rotate(45deg); display: inline-block; }
.gantt-svg { width: 100%; height: auto; display: block; }
.gantt-month { font-size: 10px; fill: var(--muted); }
.gantt-label { font-size: 12px; fill: var(--ink); font-weight: 600; }
.gantt-sub { font-size: 10.5px; font-weight: 600; }

.bars { display: flex; flex-direction: column; gap: 9px; }
.barrow { display: grid; grid-template-columns: 180px 1fr auto; gap: 12px; align-items: center; }
.barrow__label { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barrow__track { background: var(--surface-2); border-radius: 20px; height: 18px; overflow: hidden; }
.barrow__fill { height: 100%; border-radius: 20px; }
.barrow__value { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }


/* ---------- Wide pages ---------- */
.page--wide { max-width: 1400px; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; align-items: start; }
.kanban__col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); min-height: 120px; display: flex; flex-direction: column; }
.kanban__col--over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.kanban__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 2px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.kanban__head--neutral { border-bottom-color: var(--line-strong); }
.kanban__head--accent { border-bottom-color: var(--accent); }
.kanban__head--warn { border-bottom-color: #d79a3a; }
.kanban__head--won { border-bottom-color: var(--won); }
.kanban__head--lost { border-bottom-color: var(--lost); }
.kanban__title { font-weight: 700; font-size: 13px; }
.kanban__count { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 0 8px; font-size: 11.5px; }
.kanban__body { padding: 10px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px; cursor: pointer; box-shadow: var(--shadow-soft); }
.kcard[draggable="true"] { cursor: grab; }
.kcard--dragging { opacity: 0.5; }
.kcard--locked { opacity: 0.92; }
.kcard__title { font-weight: 600; font-size: 13px; margin-bottom: 6px; line-height: 1.3; }
.kcard__route { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); margin-bottom: 8px; flex-wrap: wrap; }
.kcard__route i { color: var(--muted); }
.kcard__facts { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.kcard__foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 7px; font-size: 11px; color: var(--muted); }

/* ---------- Compact table sorting ---------- */
.table--compact td, .table--compact th { padding: 9px 12px; }
.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort:hover { color: var(--ink); }
.th-num, .td-num { text-align: right; font-variant-numeric: tabular-nums; }
.td-neg { color: var(--lost); }

/* ---------- Opportunity modal subfields ---------- */
.subfields { display: flex; gap: 10px; margin-top: 8px; }
.subgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.subgrid .mini-field--full { grid-column: 1 / -1; }

.margin-readout { grid-column: 1 / -1; display: flex; gap: 20px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 4px; }
.margin-readout__unit, .margin-readout__total { font-weight: 700; font-size: 13.5px; }
.margin-pos { color: var(--won); }
.margin-neg { color: var(--lost); }

/* ---------- Timeline (activities) ---------- */
.timeline-wrap, .docs-wrap { display: flex; flex-direction: column; gap: 12px; }
.activity-add, .doc-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.activity-add .input:nth-child(2) { flex: 1; min-width: 200px; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline__item { display: flex; gap: 12px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.timeline__type { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 9px; border-radius: 20px; height: fit-content; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.timeline__type--call { background: #e7eefb; color: #2f5bba; }
.timeline__type--email { background: var(--won-soft); color: var(--won); }
.timeline__type--meeting { background: #f3e8f9; color: var(--producer); }
.timeline__text { margin: 0 0 4px; font-size: 13px; }
.timeline__meta { font-size: 11.5px; color: var(--muted); }

/* ---------- Documents ---------- */
.docs { display: flex; flex-direction: column; gap: 8px; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.doc-row i { font-size: 18px; color: var(--muted); }
.doc-row__main { display: flex; flex-direction: column; flex: 1; }
.doc-row__name { font-size: 13px; font-weight: 600; }
.doc-row__link { color: var(--accent); display: inline-flex; align-items: center; gap: 5px; }
.doc-row__link:hover { text-decoration: underline; }
.deadline-field .input { max-width: 280px; }
.doc-row__meta { font-size: 11.5px; color: var(--muted); }

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 28px 16px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone--over { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone__icon { font-size: 26px; color: var(--muted); }
.drop-zone--over .drop-zone__icon, .drop-zone:hover .drop-zone__icon { color: var(--accent); }
.drop-zone__label { font-size: 13px; color: var(--muted); }
.drop-zone__link { color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; }
.drop-zone__hint { font-size: 11px; color: var(--muted); }

/* ---------- Table party cell + category badge ---------- */
.td-code { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); white-space: nowrap; }
.party-cell { display: flex; flex-direction: column; line-height: 1.25; }
.party-cell__name { font-size: 13px; }
.party-cell__country { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.badge--cat { background: var(--accent-soft); color: var(--accent); }

/* ---------- Analytics dashboard ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 22px; align-items: stretch; }
.kpi-row--4 { grid-template-columns: repeat(4, 1fr); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-soft); display: flex; flex-direction: column; min-height: 110px; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kpi__label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
.kpi__icon { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.kpi__icon--teal { background: #d9efe9; color: #1c7a64; }
.kpi__icon--ink { background: #e9e7e2; color: var(--ink); }
.kpi__icon--won { background: var(--won-soft); color: var(--won); }
.kpi__icon--lost { background: var(--lost-soft); color: var(--lost); }
.kpi__icon--accent { background: var(--accent-soft); color: var(--accent); }
.kpi__value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi__value--teal { color: #1c7a64; }
.kpi__value--won { color: var(--won); }
.kpi__value--lost { color: var(--lost); }
.kpi__value--accent { color: var(--accent); }
.kpi__value--ink { color: var(--ink); }
.kpi__sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: block; }

.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-soft); }
.chart-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.chart-card__title { font-size: 15px; font-weight: 700; margin: 0; }
.chart-card__hint { font-size: 12px; color: var(--muted); margin: 3px 0 0; }

.metric-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 3px; gap: 2px; flex: 0 0 auto; }
.metric-toggle__btn { border: 0; background: transparent; padding: 6px 14px; border-radius: 18px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.metric-toggle__btn--active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-soft); }

.bubble-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.bubble-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.bubble-col--status { border-top: 3px solid var(--accent); }
.bubble-col__head { text-align: center; padding: 6px 0 10px; }
.bubble-col__head-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 4px; }
.bubble-col__title { display: block; font-size: 13.5px; font-weight: 700; }
.bubble-col__meta { font-size: 11.5px; color: var(--muted); }
.bubble-col__crit-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 10px; background: #FCEBEB; color: #A32D2D; }
.bubble-col__crit-badge i { font-size: 9px; }
.bubble-col__stats { display: flex; justify-content: center; gap: 14px; padding: 4px 0 2px; }
.bubble-col__stat { display: flex; flex-direction: column; align-items: center; }
.bubble-col__stat-v { font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.bubble-col__stat-l { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 1px; }
.bubble-svg { width: 100%; height: auto; display: block; }
.bubble { transition: opacity 0.12s ease; }
.bubble:hover { opacity: 0.82; }
.bubble:focus-visible { outline: 2px solid var(--accent); }
.bubble__label { pointer-events: none; }
.bubble__empty { fill: var(--muted); font-size: 13px; }

/* ---------- Opportunity modal: tabs + timeline ---------- */
.opp-modal { display: flex; flex-direction: column; gap: 16px; }

/* status stepper */
.stepper-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; flex: 1; min-width: 280px; }
.stepper__node { display: flex; align-items: center; gap: 8px; }
.stepper__dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.stepper__label { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.stepper__node--done .stepper__dot { background: var(--ink); border-color: var(--ink); color: #fff; }
.stepper__node--done .stepper__label { color: var(--ink-2); }
.stepper__node--current .stepper__dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper__node--current .stepper__label { color: var(--accent); }
.stepper__node--won.stepper__node--current .stepper__dot { background: var(--won); border-color: var(--won); }
.stepper__node--won.stepper__node--current .stepper__label { color: var(--won); }
.stepper__node--lost.stepper__node--current .stepper__dot { background: var(--lost); border-color: var(--lost); }
.stepper__node--lost.stepper__node--current .stepper__label { color: var(--lost); }
.stepper__bar { flex: 1; height: 2px; background: var(--line); margin: 0 10px; min-width: 24px; }
.stepper__bar--done { background: var(--ink); }
.stepper__hold { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: #8a5a12; background: #fbe6cf; padding: 4px 10px; border-radius: 20px; }

.mini-timeline-wrap { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.mini-timeline__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; display: block; margin-bottom: 10px; }
.mini-timeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.mini-event { display: flex; gap: 8px; align-items: flex-start; }
.mini-event__body { display: flex; flex-direction: column; min-width: 0; }
.mini-event__text { font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-event__meta { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.tabs--modal { border-bottom: 1px solid var(--line); gap: 2px; margin: 0; }
.tabs--modal .tab { padding: 9px 14px; }
.tab-content { min-height: 200px; }

/* ---------- Storyboard ---------- */
.story-wrap { display: flex; flex-direction: column; gap: 16px; }
.story-add { display: flex; gap: 8px; align-items: center; }
.story-add .input:not(.story-type) { flex: 1; }
.story-type { min-width: 130px; }
.storyboard { display: flex; flex-direction: column; position: relative; }
.story-item { display: flex; gap: 14px; padding: 0 0 18px 0; position: relative; }
.story-item:not(:last-child)::before {
  content: ""; position: absolute; left: 6px; top: 14px; bottom: -4px; width: 2px; background: var(--line);
}
.story-dot { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--accent); background: var(--surface); flex: 0 0 auto; margin-top: 1px; z-index: 1; }
.story-dot--note { border-color: #2f5bba; }
.story-dot--call { border-color: var(--accent); }
.story-dot--email { border-color: var(--won); }
.story-dot--meeting { border-color: var(--producer); }
.story-body { flex: 1; min-width: 0; }
.story-head { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.story-type { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.story-meta { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.story-text { margin: 0; font-size: 13.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kanban { grid-template-columns: repeat(2, 1fr); }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .analytics-2col { grid-template-columns: 1fr; }
  .map-split { grid-template-columns: 1fr; }
  .home-2col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 56px; bottom: 0; z-index: 90; transform: translateX(-100%); transition: transform 0.2s ease; }
  .form-grid { grid-template-columns: 1fr; }
  .stream-grid { grid-template-columns: 1fr 1fr; }
  .facility-grid { grid-template-columns: 1fr 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 50px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
