/* Fonts, colours, inputs, buttons, switch and the sidebar action come from
   the ID Unlimited design system (tokens/ + components.css). This file holds
   the CRM's own layout and widgets; the app shell matches QR Generator's. */

body {
  min-width: 320px;
  background: var(--surface-sunken);
}

label { margin-bottom: 0; }
textarea {
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--idu-white);
  box-shadow: inset 0 0 0 1px var(--border-default);
  color: var(--text-strong);
  padding: 10px 14px;
  font: inherit;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
textarea:focus { box-shadow: inset 0 0 0 2px var(--idu-black); }
select:focus { outline: none; box-shadow: inset 0 0 0 2px var(--idu-black); }

[hidden] { display: none !important; }

/* Stage colours: the three energy colours carry the live stages, greys the
   passive ones. Used by card stripes, tags, map markers and charts. */
[data-stage="high_priority"] { --stage: var(--surge-orange); --stage-ink: var(--surge-orange-ink); }
[data-stage="in_progress"] { --stage: var(--sprint-blue); --stage-ink: var(--sprint-blue-ink); }
[data-stage="won"] { --stage: var(--pulse-green); --stage-ink: var(--pulse-green-ink); }
[data-stage="discovery"] { --stage: var(--idu-black); --stage-ink: var(--idu-black); }
[data-stage="on_hold"] { --stage: var(--grey-400); --stage-ink: var(--grey-600); }
[data-stage="lost"] { --stage: var(--grey-200); --stage-ink: var(--grey-500); }
[data-stage="unclassified"], [data-stage="partner"] { --stage: var(--grey-300); --stage-ink: var(--grey-500); }

/* ---------- App shell ---------- */

.app-frame {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 28px;
  padding: 24px 16px;
  background: var(--idu-black);
}
.sidebar-brand { padding: 0 6px; }
.sidebar-brand-logo { width: 100%; height: auto; display: block; }
.sidebar-brand-eyebrow { color: var(--grey-500); margin: 10px 0 0; font-size: 10px; }

.side-nav { display: grid; align-content: start; gap: 4px; min-height: 0; overflow-y: auto; }
.side-nav a {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--grey-400);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.06); color: var(--grey-400); }
.side-nav a.active { background: var(--grey-900); color: var(--idu-white); box-shadow: inset 3px 0 0 var(--pulse-green); }
.side-nav svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--surge-orange);
  color: var(--idu-white);
  font-family: var(--font-alt);
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0;
}

.sidebar-footer { display: grid; gap: 12px; }
.sidebar-user { display: grid; gap: 2px; margin: 0; padding: 0 6px; color: var(--grey-500); font-size: var(--text-xs); }
.sidebar-user strong { color: var(--idu-white); font-size: var(--text-sm); }
.idu-sidebar-action svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.workspace { min-width: 0; padding: 24px 28px 32px; }
.workspace > * { max-width: 1560px; margin-left: auto; margin-right: auto; }

.workspace-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-default);
}
.workspace-header h1 { margin: 0; font-size: var(--display-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-title { flex: 1; min-width: 0; }
.workspace-title .idu-eyebrow { margin: 0 0 4px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.header-action { width: auto; flex: 0 0 auto; }
.app-tile {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--idu-white);
  box-shadow: inset 0 0 0 1px var(--border-default);
}
.app-tile img { width: 40px; height: 40px; object-fit: contain; }

/* Admin/manager panel switcher, on the same line as the header buttons. */
.panel-picker { display: flex; align-items: center; gap: 10px; }
.panel-picker-label {
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-2xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.panel-picker .picker { width: 230px; }
.panel-picker .picker-trigger { box-shadow: inset 0 0 0 2px var(--idu-black); }

.sub { margin: 0; color: var(--text-subtle); font-size: var(--text-xs); line-height: 1.5; }
.view-hint { margin: 0 0 10px; color: var(--text-subtle); font-size: var(--text-xs); }
.empty-state { margin: 24px auto; color: var(--text-muted); text-align: center; font-size: var(--text-sm); }
.field-label { color: var(--text-muted); font-size: var(--text-xs); font-weight: 600; }

/* ---------- KPI tiles ---------- */

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi {
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: start;
  gap: 6px;
  padding: 14px 18px;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  text-align: left;
  font: inherit;
}
.kpi:first-child { background: var(--idu-black); border-color: var(--idu-black); }
.kpi:first-child .kpi-label { color: var(--grey-400); }
.kpi:first-child .kpi-value { color: var(--idu-white); }
button.kpi { cursor: pointer; transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out); }
button.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi.is-alert { box-shadow: inset 0 -3px 0 var(--surge-orange); }
.kpi.is-alert:hover { box-shadow: var(--shadow-md), inset 0 -3px 0 var(--surge-orange); }
.kpi.is-on { box-shadow: inset 0 0 0 2px var(--idu-black), inset 0 -3px 0 var(--surge-orange); }
.kpi-label { color: var(--text-muted); font-family: var(--font-display); font-weight: 600; font-size: var(--text-2xs); letter-spacing: 0.12em; text-transform: uppercase; }
.kpi-value { color: var(--text-strong); font-family: var(--font-alt); font-weight: 700; font-size: var(--display-sm); line-height: 1; }

/* ---------- Search + filters ---------- */

.toolbar { display: grid; gap: 10px; margin-bottom: 18px; }
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 16px;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--border-default);
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
.search:focus-within { box-shadow: inset 0 0 0 2px var(--idu-black); }
.search svg { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linecap: round; }
.search input { height: 100%; padding: 0; box-shadow: none; background: transparent; font-size: var(--text-md); }
.search input:focus, .search input:focus-visible { box-shadow: none; outline: none; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.filters {
  display: none;
  grid-template-columns: auto repeat(9, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
  padding: 10px 12px 12px;
  background: var(--grey-100);
  border-radius: var(--radius-md);
}
.filters-title {
  align-self: center;
  padding: 14px 8px 0 4px;
  color: var(--text-strong);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.filter { display: grid; gap: 4px; min-width: 0; }
.filter span { color: var(--text-muted); font-family: var(--font-display); font-weight: 600; font-size: var(--text-2xs); letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter select { height: 36px; padding-top: 0; padding-bottom: 0; padding-left: 10px; font-size: var(--text-xs); }
.filter select.is-set { box-shadow: inset 0 0 0 2px var(--idu-black); }
.filters-clear { grid-column: 1 / -1; justify-self: start; width: auto; padding: 0 4px; font-size: var(--text-xs); }

/* ---------- Picker (custom dropdown) ---------- */

.picker { position: relative; min-width: 0; }
.picker-trigger {
  width: 100%;
  height: var(--control-md);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--idu-white);
  box-shadow: inset 0 0 0 1px var(--border-default);
  color: var(--text-strong);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
.picker-trigger:hover { box-shadow: inset 0 0 0 1px var(--idu-black); }
.picker.is-open .picker-trigger, .picker-trigger:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--idu-black); }
.picker-trigger:disabled { cursor: not-allowed; opacity: 0.6; }
.picker-value { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.picker-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-placeholder { color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-chevron { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: var(--grey-600); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur-fast) var(--ease-out); }
.picker.is-open .picker-chevron { transform: rotate(180deg); }

.picker-pop {
  position: fixed;
  z-index: 90;
  display: grid;
  max-height: 340px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--idu-white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--idu-black);
  overflow: hidden;
  animation: pop-in var(--dur-fast) var(--ease-out) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.picker-search { padding: 8px; border-bottom: 1px solid var(--border-subtle); }
.picker-pop.is-sheet { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--idu-black); }
.picker-pop.is-sheet .picker-search input { height: 44px; font-size: 16px; }
.picker-search input { height: 34px; padding: 0 10px; font-size: var(--text-sm); }
.picker-list { margin: 0; padding: 4px 0; list-style: none; overflow-y: auto; }
.picker-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--text-body);
  font-size: var(--text-sm);
  cursor: pointer;
}
.picker-option.is-active { background: var(--grey-100); color: var(--text-strong); }
.picker-option.is-selected { box-shadow: inset 3px 0 0 var(--pulse-green); color: var(--text-strong); font-weight: 600; }
.picker-option.is-null { color: var(--text-subtle); font-style: italic; }
.picker-option-text { display: grid; min-width: 0; }
.picker-option-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-option-text small { color: var(--text-subtle); font-size: var(--text-2xs); font-weight: 400; }
.picker-empty { padding: 10px 12px; color: var(--text-subtle); font-size: var(--text-sm); }
.picker-foot { border-top: 1px solid var(--border-default); }
.picker-add {
  text-transform: none !important;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: var(--idu-black);
  color: var(--idu-white);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}
.picker-add:hover { filter: brightness(1.35); }
.picker-media {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--idu-white);
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}
.picker-media img { width: 100%; height: 100%; object-fit: contain; }
.picker-swatch { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.picker-initials { background: var(--idu-black); color: var(--idu-white); border-radius: var(--radius-pill); font-family: var(--font-alt); font-weight: 700; font-size: 10px; }

/* ---------- Logos ---------- */

.logo {
  flex: 0 0 auto;
  width: var(--logo-size, 36px);
  height: var(--logo-size, 36px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--idu-white);
  box-shadow: inset 0 0 0 1px var(--border-default);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: calc(var(--logo-size, 36px) * 0.36);
  letter-spacing: 0.02em;
}
.logo img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.logo.has-image { box-shadow: inset 0 0 0 1px var(--border-subtle); }
.partner-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font-size: var(--text-xs); font-weight: 600; color: var(--text-strong); }
.partner-chip .logo { --logo-size: 20px; }
.partner-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Kanban / radar boards ---------- */

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: start;
}
.board-radar { grid-auto-columns: minmax(230px, 1fr); }

.column {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 220px;
  background: var(--grey-100);
  border-radius: var(--radius-md);
  box-shadow: inset 0 3px 0 var(--stage, var(--idu-black));
}
.column-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 10px; }
.column-head h2 { margin: 0; font-size: var(--text-md); display: flex; align-items: center; gap: 8px; }
.column-head h2::before { content: ""; width: 10px; height: 10px; border-radius: var(--radius-pill); background: var(--stage); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.column-count { font-family: var(--font-alt); font-weight: 700; font-size: var(--text-sm); color: var(--text-muted); }
.column-cards { display: grid; align-content: start; gap: 10px; padding: 0 8px 10px; min-height: 80px; border-radius: var(--radius-md); }
.column.is-drop-target .column-cards { background: rgba(87, 0, 255, 0.06); box-shadow: inset 0 0 0 2px var(--sprint-blue); }

/* Account card: a stripe and a cut corner in the stage colour. */
.lead-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 14px 14px 12px 18px;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), inset 0 0 0 1px var(--border-default);
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.lead-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--stage); }
.lead-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 26px;
  height: 26px;
  background: var(--stage);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.lead-card[data-stage="high_priority"] { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), inset 0 0 0 1px rgba(255, 33, 65, 0.45); }
.lead-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md), inset 0 0 0 1px var(--grey-300); }
.lead-card:focus-visible { outline: 2px solid var(--sprint-blue); outline-offset: 2px; }
.lead-card.is-dragging { opacity: 0.4; }
.lead-card[draggable="true"] { cursor: grab; }
.lead-card-top { display: flex; align-items: center; gap: 10px; padding-right: 22px; min-width: 0; }
.lead-card-title { display: grid; gap: 2px; min-width: 0; flex: 1; }
.lead-card h3 { margin: 0; font-size: var(--text-xl); line-height: 1; overflow-wrap: anywhere; }
.lead-card-market { color: var(--text-muted); font-family: var(--font-display); font-weight: 600; font-size: var(--text-2xs); letter-spacing: 0.12em; text-transform: uppercase; }
.lead-card-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lead-card-partner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; background: var(--surface-sunken); border-radius: var(--radius-sm); }
.lead-card-partner .sub { white-space: nowrap; }
.lead-card-next { margin: 0; color: var(--text-body); font-size: var(--text-xs); line-height: 1.45; }
.lead-card-next strong { color: var(--text-strong); }
.lead-card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; min-width: 0; color: var(--text-subtle); font-size: var(--text-2xs); }
.lead-card-tags, .lead-card-partner, .lead-card-next { min-width: 0; }
.lead-card-people { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.due { font-family: var(--font-alt); font-weight: 700; white-space: nowrap; }
.due.is-overdue { color: var(--status-danger-ink); }
.due.is-soon { color: var(--status-info-ink); }

.avatar {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--idu-black);
  color: var(--idu-white);
  font-family: var(--font-alt);
  font-weight: 700;
  font-size: 10px;
}

/* ---------- Tags ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--grey-100);
  color: var(--text-strong);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: var(--text-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-plain { background: transparent; box-shadow: inset 0 0 0 1px var(--border-default); color: var(--text-muted); }
.tag-free { background: rgba(0, 255, 119, 0.18); color: var(--status-success-ink); }
.tag-doubtful { background: rgba(87, 0, 255, 0.1); color: var(--status-info-ink); }
.tag-taken { background: var(--grey-100); color: var(--text-muted); }
.tag-unknown { background: transparent; color: var(--text-subtle); box-shadow: inset 0 0 0 1px var(--border-default); }
.tag-renewed { background: var(--idu-black); color: var(--pulse-green); }
.tag-money { background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--idu-black); font-family: var(--font-alt); font-style: normal; letter-spacing: 0; }
.tag-stage { background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--border-default); }
.tag-stage::before { content: ""; width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--stage); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }

/* ---------- Table: fits the window, scrolls inside ---------- */

.table-card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: calc(100vh - var(--table-top, 340px) - 34px);
  min-height: 240px;
}
.table-scroll { overflow-x: auto; }
.lead-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.fit-table { table-layout: fixed; }
.lead-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 10px;
  background: var(--surface-card);
  box-shadow: inset 0 -1px 0 var(--border-default);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.lead-table th button { padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.lead-table th button:hover { color: var(--text-strong); }
.lead-table th[aria-sort] button { color: var(--text-strong); }
.lead-table th[aria-sort="ascending"] button::after { content: " ↑"; }
.lead-table th[aria-sort="descending"] button::after { content: " ↓"; }
.lead-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); color: var(--text-body); vertical-align: middle; }
.fit-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fit-table .tag { display: inline-block; max-width: 100%; line-height: 22px; vertical-align: middle; }
.fit-table .tag-stage::before { display: inline-block; margin-right: 5px; vertical-align: 1px; }
.lead-table tbody tr[data-id] { cursor: pointer; transition: background var(--dur-fast) var(--ease-out); }
.lead-table tbody tr[data-id]:hover { background: var(--surface-sunken); }
.cell-company { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-company .logo { --logo-size: 30px; }
.cell-company > span:last-child { display: grid; min-width: 0; }
.cell-company strong { color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; }
.cell-company small { color: var(--text-subtle); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.08em; }
.cell-two { display: grid; min-width: 0; }
.cell-two > * { overflow: hidden; text-overflow: ellipsis; }
.cell-two small { color: var(--text-subtle); font-size: var(--text-2xs); }
.row-stripe { width: 4px; padding: 0 !important; }
.row-stripe span { display: block; width: 4px; height: 44px; background: var(--stage); }
.lead-table td.num, .lead-table th.num { text-align: right; font-family: var(--font-alt); font-weight: 700; }
.nowrap { white-space: nowrap; }
.muted { color: var(--text-subtle); }

/* ---------- Map + route planner ---------- */

.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.map-card, .route-card { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.map-card { padding: 12px; }
.map-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.map-reset { width: auto; height: var(--control-sm); font-size: var(--text-xs); }
.map { height: 620px; border-radius: var(--radius-sm); background: var(--grey-100); z-index: 0; }
.map-note { margin: 8px 0 0; color: var(--text-subtle); font-size: var(--text-2xs); }
.map .leaflet-tile-pane { filter: grayscale(1) contrast(0.92) brightness(1.04); }
.map .leaflet-control-attribution { font-size: 10px; }
.marker {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--stage);
  box-shadow: 0 0 0 2px var(--idu-white), 0 1px 4px rgba(0, 0, 0, 0.35);
  color: var(--idu-black);
  font-family: var(--font-alt);
  font-weight: 700;
  font-size: 10px;
}
.marker[data-stage="unclassified"], .marker[data-stage="lost"] { box-shadow: 0 0 0 2px var(--grey-500), 0 1px 4px rgba(0, 0, 0, 0.35); }
.marker[data-stage="discovery"], .marker[data-stage="in_progress"], .marker[data-stage="high_priority"] { color: var(--idu-white); }
.marker.in-route { box-shadow: 0 0 0 3px var(--idu-white), 0 0 0 5px var(--idu-black), 0 1px 6px rgba(0, 0, 0, 0.4); }
.leaflet-popup-content-wrapper { border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
.leaflet-popup-content { margin: 14px 16px; font-family: var(--font-body); }
.popup { display: grid; gap: 6px; min-width: 230px; }
.popup-head { display: flex; align-items: center; gap: 10px; }
.popup h3 { margin: 0; font-size: var(--text-lg); }
.popup dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 10px; margin: 0; font-size: var(--text-xs); }
.popup dt { color: var(--text-muted); }
.popup dd { margin: 0; color: var(--text-strong); }
.popup-next { margin: 2px 0 0; padding: 6px 8px; background: var(--surface-sunken); border-left: 3px solid var(--idu-black); font-size: var(--text-xs); }
.popup-actions { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 4px; }
.popup-actions button { height: var(--control-sm); font-size: var(--text-xs); }
.popup-actions .secondary-button { padding: 0 10px; }

.route-card { position: sticky; top: 20px; display: grid; gap: 12px; padding: 16px; }
.route-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.route-head h2 { margin: 0; font-size: var(--text-xl); }
.route-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; max-height: 420px; overflow-y: auto; }
.route-stop { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 6px 8px 8px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); }
.route-num { font-family: var(--font-alt); font-weight: 700; color: var(--text-strong); }
.route-name { display: grid; min-width: 0; }
.route-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); }
.route-name span { color: var(--text-subtle); font-size: var(--text-2xs); }
.route-tools { display: flex; }
.route-tools .idu-icon-button { width: 28px; height: 28px; }
.route-tools .idu-icon-button svg { width: 15px; height: 15px; }
.route-tools .idu-icon-button:disabled { opacity: 0.25; cursor: default; background: none; }
.route-empty { margin: 0; color: var(--text-subtle); font-size: var(--text-sm); text-align: center; padding: 16px 0; }
.route-actions { display: grid; gap: 8px; }
.route-actions .secondary-button { width: 100%; }

/* ---------- Agenda + notifications ---------- */

.agenda-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; align-items: start; }
.agenda-card, .notify-card { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 18px 20px 20px; }
.agenda-head, .notify-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.agenda-head h2, .notify-head h2 { margin: 0; font-size: var(--text-xl); }
.agenda-group + .agenda-group { margin-top: 18px; }
.agenda-group h3 { margin: 0 0 8px; font-size: var(--text-md); color: var(--text-strong); }
.agenda-group[data-group="overdue"] h3 { color: var(--status-danger-ink); }
.agenda-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 8px 14px;
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
}
.agenda-date { display: grid; font-family: var(--font-alt); font-weight: 700; color: var(--text-strong); font-size: var(--text-sm); }
.agenda-date small { color: var(--text-subtle); font-weight: 600; font-size: var(--text-2xs); }
.agenda-item[data-overdue] .agenda-date { color: var(--status-danger-ink); }
.agenda-main { display: grid; gap: 3px; min-width: 0; }
.agenda-lead { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0; border: 0; background: none; font: inherit; color: var(--text-strong); font-weight: 700; cursor: pointer; text-align: left; }
.agenda-lead:hover { text-decoration: underline; }
.agenda-notes { margin: 0; color: var(--text-body); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-actions { display: flex; gap: 6px; grid-column: 2; }
.agenda-actions button { width: auto; height: var(--control-sm); font-size: var(--text-xs); padding: 0 12px; }
.notify-card { position: sticky; top: 20px; }
.notify-form { display: grid; gap: 14px; margin-top: 14px; }
.notify-form.is-off { opacity: 0.5; }
.notify-actions { display: flex; justify-content: flex-end; gap: 8px; }
.notify-actions button { width: auto; }

.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.segmented button {
  height: 36px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--idu-white);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.segmented button:hover { border-color: var(--idu-black); color: var(--text-strong); }
.segmented button.active { border-color: var(--idu-black); color: var(--text-strong); box-shadow: inset 0 0 0 1px var(--idu-black), inset 0 -3px 0 var(--pulse-green); }

/* ---------- Analytics ---------- */

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chart-card { padding: 16px 18px 18px; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); min-width: 0; }
.chart-wide { grid-column: 1 / -1; }
.chart-card h2 { margin: 0 0 12px; font-size: var(--text-lg); }
.chart-empty { margin: 8px 0; color: var(--text-subtle); font-size: var(--text-sm); }
.bar-list { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) auto auto; align-items: center; gap: 10px; font-size: var(--text-sm); }
.bar-label { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text-body); }
.bar-label span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label .logo { --logo-size: 20px; }
.bar-track { height: 10px; background: var(--grey-100); border-radius: 0 4px 4px 0; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--stage, var(--idu-black)); border-radius: 0 4px 4px 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.bar-value { min-width: 28px; text-align: right; font-family: var(--font-alt); font-weight: 700; color: var(--text-strong); }
.bar-pct { min-width: 44px; text-align: right; font-family: var(--font-alt); color: var(--text-subtle); font-size: var(--text-xs); }
.market-table td, .market-table th { padding: 8px 10px; }

/* ---------- Account drawer ---------- */

.drawer-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; background: rgba(0, 0, 0, 0.55); }
.drawer {
  width: min(800px, 100vw);
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--idu-white);
  box-shadow: var(--shadow-lg);
  animation: drawer-in var(--dur-slow) var(--ease-out) both;
}
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.drawer-head { display: flex; align-items: flex-start; gap: 16px; padding: 22px 24px 16px; background: var(--idu-black); color: var(--idu-white); }
.drawer-title { flex: 1; min-width: 0; }
.drawer-title .idu-eyebrow { margin: 0 0 4px; color: var(--grey-500); }
.drawer-title h2 { margin: 0; color: var(--idu-white); font-size: var(--display-sm); overflow-wrap: anywhere; }
.drawer-meta { margin: 6px 0 0; color: var(--grey-500); font-size: var(--text-xs); }
.drawer-head .idu-icon-button { color: var(--idu-white); }
.drawer-head .idu-icon-button:hover { background: var(--grey-800); }
.logo-remove { margin-top: 6px; padding: 0; border: 0; background: none; color: var(--grey-400); font-size: var(--text-xs); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.logo-remove:hover { color: var(--surge-orange); }

.logo-picker {
  position: relative;
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--grey-900);
  box-shadow: inset 0 0 0 1px var(--grey-700);
  cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
.logo-picker:hover, .logo-picker:focus-within { box-shadow: inset 0 0 0 2px var(--pulse-green); }
.logo-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.logo-picker img { width: 100%; height: 100%; object-fit: contain; padding: 6px; background: var(--idu-white); }
.logo-placeholder { display: grid; justify-items: center; gap: 4px; color: var(--grey-500); font-family: var(--font-display); font-style: italic; font-weight: 700; font-size: var(--text-2xs); letter-spacing: 0.1em; text-transform: uppercase; }
.logo-placeholder svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.logo-picker-light { background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--border-default); }
.logo-picker-light:hover, .logo-picker-light:focus-within { box-shadow: inset 0 0 0 2px var(--idu-black); }
.logo-picker-light .logo-placeholder { color: var(--text-muted); }

.drawer-tabs { display: flex; gap: 24px; padding: 0 24px; background: var(--idu-black); }
.drawer-tabs button {
  position: relative;
  padding: 0 0 12px;
  border: 0;
  background: none;
  color: var(--grey-500);
  cursor: pointer;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.drawer-tabs button:hover { color: var(--grey-300); }
.drawer-tabs button.active { color: var(--idu-white); }
.drawer-tabs button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--pulse-green); }
.tab-count { margin-left: 4px; font-family: var(--font-alt); font-style: normal; font-size: var(--text-xs); color: var(--grey-500); }

.drawer-body { overflow-y: auto; padding: 18px 24px 24px; display: grid; align-content: start; gap: 18px; }
.required-note { margin: 0; color: var(--text-subtle); font-size: var(--text-xs); font-style: italic; }
.form-section { margin: 0; padding: 0; border: 0; display: grid; gap: 12px; min-width: 0; }
.form-section legend { margin-bottom: 10px; padding: 0; color: var(--text-strong); font-family: var(--font-display); font-style: italic; font-weight: 700; font-size: var(--text-md); letter-spacing: 0.04em; text-transform: uppercase; }
.form-section + .form-section { padding-top: 18px; border-top: 1px solid var(--border-subtle); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field > label { color: var(--text-muted); font-size: var(--text-xs); font-weight: 600; }
.field input, .field select { height: var(--control-md); padding-top: 0; padding-bottom: 0; font-size: var(--text-sm); }
.field textarea { font-size: var(--text-sm); }
.field-wide { grid-column: 1 / -1; }
.field-end { align-content: end; }
.place-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.field-end .secondary-button, .field-end .primary-button { width: 100%; }
.field.is-current-season .field-label { color: var(--text-strong); }
.field.is-current-season .picker-trigger { box-shadow: inset 0 0 0 1px var(--idu-black); }
.form-error { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(255, 33, 65, 0.08); color: var(--status-danger-ink); font-size: var(--text-sm); }
.add-link { width: auto; justify-self: start; padding: 0; color: var(--text-strong); font-weight: 600; text-decoration: none; }
.add-link:hover { text-decoration: underline; }

.contacts { display: grid; gap: 10px; }
.contact-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) 32px; gap: 8px; align-items: end; padding: 10px; background: var(--surface-sunken); border-radius: var(--radius-sm); }
.contact-row .field > label { font-size: var(--text-2xs); }
.contact-row .idu-icon-button { width: 32px; height: 40px; }

.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border-default); background: var(--surface-sunken); }
.drawer-foot .spacer { flex: 1; }
.drawer-foot .primary-button { width: auto; min-width: 140px; }

.pending-note { padding: 10px 12px; background: rgba(87, 0, 255, 0.07); border-radius: var(--radius-sm); color: var(--status-info-ink); }
.activity-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-bottom: 1px solid var(--border-default); }
.activity-tabs button {
  position: relative;
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.activity-tabs button.active { color: var(--text-strong); }
.activity-tabs button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--idu-black); }
.activity-tabs button[data-mode="planned"].active::after { background: var(--sprint-blue); }
.activity-form { display: grid; gap: 12px; padding: 14px; background: var(--surface-sunken); border-radius: var(--radius-md); }
.activity-submit-row { display: flex; justify-content: flex-end; }
.activity-submit-row .primary-button { width: auto; min-width: 160px; }
.activity-section h3 { margin: 0 0 10px; font-size: var(--text-md); }

.task-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.task {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--border-default), inset 3px 0 0 var(--sprint-blue);
}
.task[data-overdue] { box-shadow: inset 0 0 0 1px rgba(255, 33, 65, 0.4), inset 3px 0 0 var(--surge-orange); }
.task-when { display: grid; font-family: var(--font-alt); font-weight: 700; font-size: var(--text-sm); color: var(--text-strong); white-space: nowrap; }
.task-when small { color: var(--text-subtle); font-size: var(--text-2xs); }
.task[data-overdue] .task-when { color: var(--status-danger-ink); }
.task-text { margin: 0; font-size: var(--text-sm); color: var(--text-body); white-space: pre-line; }
.task-actions { display: flex; gap: 6px; }
.task-actions button { width: auto; height: var(--control-sm); font-size: var(--text-xs); padding: 0 10px; }

.timeline { display: grid; margin: 0; padding: 0; list-style: none; }
.timeline-item { position: relative; display: grid; gap: 4px; padding: 0 0 16px 22px; }
.timeline-item::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 0; width: 1px; background: var(--border-default); }
.timeline-item:last-child::before { display: none; }
.timeline-item::after { content: ""; position: absolute; left: 0; top: 4px; width: 11px; height: 11px; border-radius: var(--radius-pill); background: var(--idu-black); }
.timeline-item[data-feedback="positive"]::after { background: var(--pulse-green); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); }
.timeline-item[data-feedback="negative"]::after { background: var(--surge-orange); }
.timeline-item[data-feedback="no_answer"]::after { background: var(--grey-300); }
.timeline-item[data-status="cancelled"] { opacity: 0.55; }
.timeline-item[data-status="cancelled"] .timeline-text { text-decoration: line-through; }
.timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline-date { font-family: var(--font-alt); font-weight: 700; color: var(--text-strong); font-size: var(--text-sm); }
.timeline-who { color: var(--text-subtle); font-size: var(--text-xs); }
.timeline-text { margin: 0; color: var(--text-body); font-size: var(--text-sm); line-height: 1.5; white-space: pre-line; }
.text-action { margin-left: auto; padding: 0; border: 0; background: none; color: var(--text-subtle); cursor: pointer; font-size: var(--text-xs); text-decoration: underline; text-underline-offset: 2px; }
.text-action:hover { color: var(--status-danger-ink); }

/* ---------- Dialogs ---------- */

.modal-backdrop { z-index: 70; }
.dialog-head h2 { margin: 0; font-size: var(--text-xl); }
.dialog-head .sub { margin-top: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions .primary-button, .dialog-actions .secondary-button, .dialog-actions .danger-button { width: auto; }
.confirm-dialog, .complete-dialog, .partner-dialog { width: min(480px, calc(100vw - 32px)); display: grid; gap: 16px; }
.confirm-dialog h2 { margin: 0; font-size: var(--text-xl); }
.confirm-dialog p { margin: 0; color: var(--text-body); font-size: var(--text-sm); }
.partner-dialog { width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lg), inset 0 3px 0 var(--pulse-green); }
.partner-fields { display: flex; gap: 16px; align-items: flex-start; }
.partner-fields-main { flex: 1; display: grid; gap: 14px; min-width: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--radius-sm); background: var(--swatch, var(--idu-white)); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--idu-white), 0 0 0 4px var(--idu-black); }
.swatch-custom { display: block; overflow: hidden; background: conic-gradient(#ff2141, #ffb300, #00ff77, #00b3ff, #5700ff, #ff2141); }
.swatch-custom.active { background: var(--swatch); }
.swatch-custom input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; opacity: 0; cursor: pointer; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--idu-black);
  color: var(--idu-white);
  box-shadow: var(--shadow-lg), inset 0 -3px 0 var(--pulse-green);
  font-size: var(--text-sm);
  animation: toast-in var(--dur-base) var(--ease-out) both;
}
.toast[data-state="error"] { box-shadow: var(--shadow-lg), inset 0 -3px 0 var(--surge-orange); }
body.sheet-open .toast { left: auto; right: 24px; bottom: 88px; transform: none; max-width: min(560px, calc(100vw - 48px)); animation-name: toast-in-side; }
@keyframes toast-in-side { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.boot-error { margin: 40px auto; max-width: 520px; padding: 16px; color: var(--status-danger-ink); text-align: center; }

/* ---------- Reach a contact: call, WhatsApp, email, directions ---------- */

.search-row { display: flex; gap: 8px; }
.search-row .search { flex: 1; min-width: 0; }
.filters.is-open { display: grid; }
.filters-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface-card);
  box-shadow: inset 0 0 0 1px var(--border-default);
  color: var(--text-strong);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.filters-toggle[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--idu-black); }
.filters-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.filters-count { min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: var(--radius-pill); background: var(--idu-black); color: var(--idu-white); font-family: var(--font-alt); font-style: normal; font-size: 11px; letter-spacing: 0; }
.filters-empty { margin: 8px 0 16px; }
.lead-list { display: none; }
.nav-label-short { display: none; }
#new-lead svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-sm);
  padding: 0 12px;
  border: 1px solid var(--idu-black);
  border-radius: var(--radius-sm);
  background: var(--idu-white);
  color: var(--idu-black);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.action-link:hover { background: var(--grey-100); }
.action-link svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* In the black sheet header: white buttons, the call one in green. */
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick-actions .action-link { border-color: var(--idu-white); }
.quick-actions .action-link:first-child { background: var(--pulse-green); border-color: var(--pulse-green); }

.reach-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--border-default);
  color: var(--idu-black);
  background: var(--surface-card);
}
.reach-icon:hover { box-shadow: inset 0 0 0 1px var(--idu-black); }
.reach-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card-reach { display: flex; gap: 4px; margin-left: auto; }
.card-reach:empty { display: none; }

.contact-reach { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.contact-reach:empty { display: none; }

.cal-action { gap: 6px; }
.cal-action svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.agenda-actions, .task-actions { flex-wrap: wrap; justify-content: flex-end; align-items: center; }

.field.is-invalid input, .field.is-invalid .picker-trigger { box-shadow: inset 0 0 0 2px var(--surge-orange); }
.field.is-invalid .field-label, .field.is-invalid > label { color: var(--status-danger-ink); }

.data-credit { font-size: var(--text-2xs); }
.data-credit a, .credits-body a { color: inherit; text-underline-offset: 2px; }
.link-inline { padding: 0; border: 0; background: none; color: var(--text-strong); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.sidebar-credits { justify-self: start; padding: 0 6px; border: 0; background: none; color: var(--grey-500); font-size: var(--text-2xs); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.sidebar-credits:hover { color: var(--idu-white); }
.credits-dialog { width: min(620px, calc(100vw - 32px)); display: grid; gap: 16px; max-height: calc(100vh - 48px); overflow-y: auto; }
.credits-body { display: grid; gap: 14px; }
.credits-body h3 { margin: 0 0 6px; font-size: var(--text-md); }
.credits-body p { margin: 0 0 6px; color: var(--text-body); font-size: var(--text-sm); line-height: 1.5; }

.check-row { display: flex; align-items: center; gap: 10px; color: var(--text-body); font-size: var(--text-sm); cursor: pointer; }

.calendar-dialog { width: min(480px, calc(100vw - 32px)); display: grid; gap: 16px; box-shadow: var(--shadow-lg), inset 0 3px 0 var(--sprint-blue); }
.calendar-options { display: grid; gap: 8px; }
.calendar-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--idu-white);
  color: var(--text-body);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.calendar-option:hover { border-color: var(--idu-black); }
.calendar-option:disabled { opacity: 0.5; cursor: wait; }
.calendar-option svg { width: 24px; height: 24px; flex: 0 0 auto; fill: none; stroke: var(--idu-black); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.calendar-option span { display: grid; gap: 3px; }
.calendar-option strong { color: var(--text-strong); font-size: var(--text-sm); }
.calendar-option small { color: var(--text-subtle); font-size: var(--text-xs); line-height: 1.4; }

/* ---------- Performance + objectives (Análisis) ---------- */

.perf-card { margin-bottom: 12px; padding: 16px 18px 18px; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: inset 0 3px 0 var(--pulse-green); }
.perf-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.perf-title h2 { margin: 0; font-size: var(--text-xl); }
.perf-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.perf-controls select { width: auto; min-width: 200px; height: var(--control-md); padding-top: 0; padding-bottom: 0; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav span { min-width: 130px; text-align: center; font-family: var(--font-display); font-style: italic; font-weight: 700; font-size: var(--text-md); letter-spacing: 0.04em; text-transform: uppercase; }
.perf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.perf-member { display: grid; gap: 12px; align-content: start; padding: 14px; border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.perf-member.is-total { background: var(--idu-black); border-color: var(--idu-black); color: var(--idu-white); }
.perf-member-head { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 40px; }
.perf-member-name { flex: 1; display: grid; min-width: 0; }
.perf-member-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
.perf-member-name small { color: var(--text-subtle); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.08em; }
.perf-member.is-total .perf-member-name strong { font-family: var(--font-display); font-style: italic; text-transform: uppercase; font-size: var(--text-lg); }
.perf-member.is-total small, .perf-member.is-total dt { color: var(--grey-400); }
.perf-objectives { width: auto; height: var(--control-sm); padding: 0 12px; font-size: var(--text-xs); }
.meter { display: grid; gap: 5px; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: var(--text-xs); }
.meter-head span { color: var(--text-muted); font-weight: 600; }
.perf-member.is-total .meter-head span { color: var(--grey-400); }
.meter-head strong { font-family: var(--font-alt); font-size: var(--text-md); }
.meter-head small { color: var(--text-subtle); font-family: var(--font-body); font-weight: 400; font-size: var(--text-2xs); }
.meter-track { height: 8px; background: var(--grey-100); border-radius: 0 4px 4px 0; overflow: hidden; }
.perf-member.is-total .meter-track { background: var(--grey-800); }
.meter-track span { display: block; height: 100%; background: var(--sprint-blue); }
.meter.is-done .meter-track span { background: var(--pulse-green); }
.perf-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; padding-top: 10px; border-top: 1px solid var(--border-subtle); }
.perf-member.is-total .perf-stats { border-top-color: var(--grey-800); }
.perf-stats > div { min-width: 0; }
/* Long words in some languages (Abschlussquote) break instead of overlapping. */
.perf-stats dt { color: var(--text-muted); font-size: var(--text-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; overflow-wrap: anywhere; hyphens: auto; }
.perf-stats dd { margin: 2px 0 0; font-family: var(--font-alt); font-weight: 700; font-size: var(--text-sm); }
.perf-stats dd small { display: block; color: var(--text-subtle); font-family: var(--font-body); font-weight: 400; font-size: var(--text-2xs); }
.perf-note { margin-top: 12px; }

/* ---------- Teams (admin) ---------- */

.teams-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.teams-head .sub { max-width: 760px; font-size: var(--text-sm); }
.teams-head .primary-button { width: auto; flex: 0 0 auto; }
.teams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.team-card { display: grid; gap: 14px; padding: 16px 18px; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: inset 0 3px 0 var(--idu-black); }
.team-card .idu-eyebrow { margin: 0 0 4px; }
.team-card h2 { margin: 0; font-size: var(--text-xl); }
.team-row { display: grid; gap: 6px; }
.team-card footer { display: flex; justify-content: flex-end; gap: 8px; }
.team-card footer button { width: auto; height: var(--control-sm); font-size: var(--text-xs); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.person-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: var(--radius-pill); background: var(--grey-100); font-size: var(--text-xs); color: var(--text-strong); }
.person-chip .avatar { width: 22px; height: 22px; font-size: 9px; }
.person-chip.is-off { opacity: 0.5; text-decoration: line-through; }
.team-dialog { width: min(560px, calc(100vw - 32px)); display: grid; gap: 16px; max-height: calc(100vh - 48px); overflow-y: auto; }
.team-dialog select { height: var(--control-md); padding-top: 0; padding-bottom: 0; }
.objective-dialog { width: min(520px, calc(100vw - 32px)); display: grid; gap: 16px; box-shadow: var(--shadow-lg), inset 0 3px 0 var(--pulse-green); }
.member-list { display: grid; gap: 6px; max-height: 280px; overflow-y: auto; padding: 2px; }
.member-option { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); cursor: pointer; }
.member-option:has(input:checked) { border-color: var(--idu-black); box-shadow: inset 3px 0 0 var(--pulse-green); }
.member-option span { display: grid; min-width: 0; }
.member-option strong { font-size: var(--text-sm); color: var(--text-strong); }
.member-option small { color: var(--text-subtle); font-size: var(--text-2xs); }
.member-option.is-taken { opacity: 0.5; cursor: not-allowed; }

/* ---------- Narrow screens ---------- */

@media (max-width: 1400px) {
  .filters { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .filters-title { grid-column: 1 / -1; padding: 0 4px; }
}

@media (max-width: 1180px) {
  .workspace-header { flex-wrap: wrap; }
  .header-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .map-layout, .agenda-layout { grid-template-columns: 1fr; }
  .route-card, .notify-card { position: static; }
  .map { height: 480px; }
}

body[data-view="teams"] .header-actions { display: none; }

/* Dragging cards needs a mouse; on touch the stage is changed in the sheet. */
@media (hover: none) {
  .view[data-view="pipeline"] .view-hint, .view[data-view="radar"] .view-hint { display: none; }
  .marker { width: 30px; height: 30px; font-size: 12px; }
}

/* ---------- Phones: the CRM is used mostly from here ---------- */

@media (max-width: 760px), (max-height: 500px) and (pointer: coarse) {
  :root { --control-md: 44px; --control-sm: 40px; --nav-height: 62px; }

  /* Bigger than 16px or iOS zooms into every field on focus. */
  .search input, .field input, .field select, .field textarea, .filter select,
  .picker-trigger, .picker-search input, .notify-form select, textarea { font-size: 16px; }

  .app-frame { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; grid-template-rows: none; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .sidebar-brand-logo { width: 120px; }
  .sidebar-brand-eyebrow, .sidebar-user, .sidebar-credits { display: none; }
  .sidebar-footer .idu-sidebar-action { height: 34px; padding: 0 10px; }

  /* Tab bar at the bottom, within thumb reach. */
  .side-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0;
    padding: 4px 2px env(safe-area-inset-bottom);
    background: var(--idu-black);
    box-shadow: 0 -1px 0 var(--grey-800);
  }
  .side-nav a { position: relative; flex-direction: column; justify-content: center; gap: 3px; height: var(--nav-height); padding: 0 2px; font-size: 10px; letter-spacing: 0.04em; }
  .side-nav a:hover { background: none; }
  .side-nav a.active { background: none; color: var(--idu-white); box-shadow: inset 0 3px 0 var(--pulse-green); }
  .side-nav svg { width: 22px; height: 22px; }
  .nav-label { display: none; }
  .nav-label-short { display: inline; }
  .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; font-size: 10px; }

  .workspace { padding: 14px 16px calc(var(--nav-height) + 90px + env(safe-area-inset-bottom)); }
  .workspace-header { gap: 12px; margin-bottom: 12px; padding-bottom: 12px; }
  .workspace-header h1 { font-size: var(--display-sm); }
  .app-tile { width: 44px; height: 44px; }
  .app-tile img { width: 34px; height: 34px; }
  /* Without the panel picker the row is empty on phones (export is hidden,
     "Nueva cuenta" floats): let it vanish without hiding the floating button. */
  .header-actions:not(:has(.panel-picker:not([hidden]))) { display: contents; }
  .panel-picker { width: 100%; }
  .panel-picker .picker { flex: 1; width: auto; }
  #export-csv { display: none; }

  /* "Nueva cuenta" floats above the tab bar. */
  #new-lead {
    position: fixed;
    right: 16px;
    bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
    z-index: 45;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg), inset 0 -3px 0 var(--pulse-green);
  }
  #new-lead span { display: none; }
  #new-lead svg { width: 26px; height: 26px; }

  /* KPIs slide sideways instead of stacking five tiles. */
  .kpis { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
  .kpis::-webkit-scrollbar { display: none; }
  .kpi { flex: 0 0 auto; min-width: 128px; padding: 10px 14px; scroll-snap-align: start; }
  .kpi-value { font-size: var(--text-xl); }

  .toolbar { margin-bottom: 12px; }
  .filters.is-open { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-title { display: none; }
  .filter select { height: 44px; }

  /* Boards: one column per screen, swiped sideways. */
  .board, .board-radar { grid-auto-columns: 86vw; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 8px; scroll-padding: 0 16px; }
  .column { scroll-snap-align: start; }
  .lead-card h3 { font-size: var(--text-lg); }
  .reach-icon { width: 38px; height: 38px; }
  .reach-icon svg { width: 18px; height: 18px; }

  /* Cuentas: a list instead of the wide table. */
  .table-card { display: none; }
  .lead-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
  .lead-row { display: flex; align-items: center; gap: 4px; padding-right: 8px; background: var(--surface-card); border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px var(--border-default), inset 4px 0 0 var(--stage); }
  .lead-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 6px 12px 16px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
  .lead-row-text { display: grid; gap: 2px; min-width: 0; }
  .lead-row-text strong { color: var(--text-strong); font-size: var(--text-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lead-row-text small { color: var(--text-subtle); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lead-row-text .lead-row-next { color: var(--text-body); }
  .lead-row-reach { display: flex; gap: 6px; flex: 0 0 auto; }

  .charts { grid-template-columns: 1fr; }
  .perf-card { padding: 14px; }
  .perf-controls, .perf-controls select { width: 100%; }
  .month-nav { width: 100%; justify-content: space-between; }
  .perf-grid, .teams-grid { grid-template-columns: 1fr; }
  .teams-head { flex-direction: column; }
  .teams-head .primary-button { width: 100%; }
  .bar-row { grid-template-columns: minmax(0, 1fr) 80px auto auto; }

  .map { height: max(320px, calc(100dvh - 380px)); }
  .map-card { padding: 8px; }

  .agenda-card, .notify-card { padding: 14px; }
  .agenda-item { grid-template-columns: 1fr; gap: 8px; padding: 12px 0; }
  .agenda-date { display: flex; gap: 8px; align-items: baseline; }
  .agenda-notes { white-space: normal; }
  .agenda-actions { justify-content: stretch; }
  .agenda-actions > * { flex: 1 1 auto; height: 44px !important; }


  /* The account sheet takes the whole screen. */
  .drawer { width: 100vw; height: 100dvh; animation-name: sheet-up; }
  .drawer-head { gap: 12px; padding: calc(14px + env(safe-area-inset-top)) 16px 12px; }
  .logo-picker { width: 56px; height: 56px; }
  .drawer-title h2 { font-size: var(--text-xl); }
  .quick-actions .action-link { flex: 1 1 calc(50% - 4px); height: 44px; font-size: var(--text-sm); }
  .drawer-body { padding: 14px 16px 20px; }
  .drawer-tabs { padding: 0 16px; }
  .drawer-foot { gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .drawer-foot .spacer { display: none; }
  .drawer-foot button { flex: 1; min-width: 0 !important; padding: 0 10px; }
  .form-grid, .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .contact-row { grid-template-columns: 1fr 1fr; }
  .contact-row .idu-icon-button { height: 44px; }
  .contact-reach .action-link { flex: 1 1 auto; height: 40px; }

  .activity-submit-row .primary-button { width: 100%; }
  .task { grid-template-columns: 1fr; gap: 8px; }
  .task-actions { justify-content: stretch; }
  .task-actions > * { flex: 1 1 auto; height: 44px !important; }


  /* Dialogs become sheets from the bottom. */
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal-backdrop > .idu-dialog { width: 100% !important; max-height: 92dvh; overflow-y: auto; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); animation: sheet-up var(--dur-base) var(--ease-out) both; }
  .dialog-actions > * { flex: 1; height: 44px; }
  .partner-fields { flex-direction: column; }

  .toast { bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); }

  /* Map: the legend scrolls sideways; no floating button over the markers. */
  .map-legend { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .map-legend::-webkit-scrollbar { display: none; }
  body[data-view="map"] #new-lead { display: none; }
  .route-list { max-height: none; }
  .route-tools .idu-icon-button { width: 40px; height: 40px; }
  .board .column { min-height: 120px; }

  /* Bigger targets. */
  .segmented button { height: var(--control-md); }
  .drawer-tabs { gap: 8px; }
  .drawer-tabs button { padding: 10px 8px 14px; }
  .agenda-lead { min-height: 40px; }
  .reach-icon { width: 40px; height: 40px; }
  .filters-clear, .link-inline, .add-link { min-height: 40px; }
  .sidebar-footer .idu-sidebar-action { height: 40px; }
  .picker-option { min-height: 44px; }

  /* Account sheet: compact header, quick actions as one row of icons. */
  .drawer-meta { display: none; }
  .logo-picker { width: 48px; height: 48px; }
  .quick-actions { gap: 8px; margin-top: 10px; }
  .quick-actions .action-link { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; }
  .quick-actions .action-link span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .quick-actions .action-link svg { width: 20px; height: 20px; }
  /* Keyboard open: only the title stays, so the form has room. */
  body.kb-open .drawer-head .logo-picker, body.kb-open .quick-actions, body.kb-open .logo-remove { display: none; }
  body.kb-open .drawer-head { padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: 6px; }
  body.kb-open .drawer-title .idu-eyebrow { display: none; }
  body.kb-open .drawer-foot { display: none; }

  /* Contacts: one field per row; the remove button in the corner. */
  .contact-row { position: relative; grid-template-columns: 1fr; padding-right: 52px; }
  .contact-row .idu-icon-button { position: absolute; top: 8px; right: 6px; width: 40px; height: 40px; }
  .place-row { grid-template-columns: 1fr; }

  /* The sheet has no tab bar: toast just above its footer. */
  body.sheet-open .toast { left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; }
  .kpis { scroll-padding-inline: 16px; }
}

@keyframes sheet-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
