@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Lora:ital,wght@0,400;0,600;1,400&family=Space+Grotesk:wght@400;500;600;700&display=swap');

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

/* ── Design tokens (light only — dam design system) ── */
:root {
  /* palette */
  --dam-black:    #0b0b0b;
  --dam-blue:     #0041ff;
  --warm-white:   #f4f2ed;

  /* surface */
  --bg:           #f4f2ed;
  --surface:      #ffffff;
  --surface-2:    #faf9f7;

  /* borders */
  --border:       #e8e6e1;
  --border-2:     #d0cec9;

  /* text */
  --text:         #0b0b0b;
  --text-sub:     #4d4d4d;
  --text-muted:   #808080;
  --task-name:    #0b0b0b;

  /* accent */
  --accent:       #0041ff;

  /* semantic */
  --warn:         #b45309;
  --warn-bg:      #fffbeb;
  --warn-border:  #fde68a;
  --ok:           #16a34a;
  --danger:       #dc2626;

  /* components */
  --radius:            5px;
  --sidebar-bg:        #ffffff;
  --nav-hover-bg:      rgba(11,11,11,.04);
  --nav-active-bg:     rgba(11,11,11,.06);
  --new-btn-hover:     rgba(11,11,11,.06);
  --th-bg:             #faf9f7;
  --row-hover:         #faf9f7;
  --drawer-bg:         #ffffff;
  --input-focus:       #0041ff;
  --sf-label:          #808080;
  --sf-warn-sub:       #b45309;
  --kpi-warn-label:    #78350f;
  --overlay-bg:        rgba(11,11,11,.3);

  /* badges */
  --badge-ok-bg:       #dcfce7;
  --badge-ok-text:     #166534;
  --badge-ok-border:   #bbf7d0;
  --badge-info-bg:     #eff6ff;
  --badge-info-text:   #1d4ed8;
  --badge-info-border: #bfdbfe;
  --badge-neu-bg:      #f3f4f6;
  --badge-neu-text:    #6b7280;
  --badge-neu-border:  #e5e7eb;
  --badge-bad-bg:      #fef2f2;
  --badge-bad-border:  #fecaca;
  --badge-exp-bg:      #fffbeb;
  --badge-exp-border:  #fde68a;
  --logout-color:      #b3b3b3;

  /* Primary CTAs — same height as invoices “+ New invoice” */
  --cta-height: 26px;
}

body {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 188px; background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  padding: 0 0 16px;
}
.sidebar-logo {
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.sidebar-logo-link {
  display: block;
  line-height: 0;
}
.sidebar-logo-link:hover { opacity: 0.92; }
.sidebar-logo-img {
  width: 40px;
  height: auto;
  display: block;
}
.sidebar-new-btn.btn.btn-primary {
  margin: 0 10px 14px;
  width: calc(100% - 20px);
  box-sizing: border-box;
}
.sidebar-new-btn.btn.btn-primary .plus {
  font-size: 13px;
  line-height: 1;
  opacity: 0.62;
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px; font-size: 11.5px; font-weight: 400; color: var(--text-muted);
  cursor: pointer; text-decoration: none; border-left: 2px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--nav-hover-bg); }
.nav-item.active { color: var(--text); font-weight: 600; border-left-color: var(--accent); background: var(--nav-active-bg); }
.nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.nav-badge {
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border);
  border-radius: 3px; padding: 0 5px; font-size: 8px;
  font-family: 'IBM Plex Mono', monospace;
}
.sidebar-footer {
  margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--border);
}
.sf-label { font-family: 'IBM Plex Mono', monospace; font-size: 8px; color: var(--sf-label); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.sf-value { font-size: 15px; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.sf-sub { font-size: 9px; color: var(--text-muted); margin-bottom: 10px; }
.sf-warn { font-size: 13px; font-weight: 600; color: var(--warn); }
.sf-warn-sub { font-size: 9px; color: var(--sf-warn-sub); margin-bottom: 10px; }
.sidebar-logout {
  background: none; border: none; cursor: pointer; color: var(--logout-color);
  font-size: 9px; font-family: 'Space Grotesk', sans-serif;
  text-align: left; padding: 0; display: block; margin-top: 10px;
}
.sidebar-logout:hover { color: var(--text-muted); }
.sidebar-logout:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Main content area ── */
.app-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.app-content { flex: 1; overflow-y: auto; padding: 28px 32px; }

/* ── KPI row ── */
.kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  padding-bottom: 24px; border-bottom: 1px solid var(--border); margin-bottom: 24px;
}
.dashboard-kpis .kpi-row--primary {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 0;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(11,11,11,.05);
}
.kpi.kpi-received .kpi-value { color: var(--ok); }
.kpi.kpi-iva .kpi-value { color: var(--text); }
.kpi.kpi-proposals {
  border-color: rgba(0,65,255,.38);
  box-shadow: 0 2px 8px rgba(0,65,255,.08);
}
.kpi.kpi-proposals .kpi-value { color: var(--dam-blue); }
.kpi.kpi-proposals .kpi-label { color: var(--text-sub); opacity: .92; }
.kpi-sub-mix {
  font-size: 9px;
  line-height: 1.45;
  color: var(--text-muted);
}
.kpi-sub-mix a {
  color: var(--dam-blue);
  font-weight: 500;
  text-decoration: none;
}
.kpi-sub-mix a:hover { text-decoration: underline; }
.kpi-sub-link a {
  color: var(--dam-blue);
  font-weight: 500;
  text-decoration: none;
}
.kpi-sub-link a:hover { text-decoration: underline; }
.kpi .kpi-label { font-family: 'IBM Plex Mono', monospace; font-size: 8.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 7px; }
.kpi .kpi-value { font-size: 22px; font-weight: 600; letter-spacing: -.03em; }
.kpi .kpi-sub { font-size: 9px; color: var(--text-muted); margin-top: 4px; }
.kpi.kpi-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.kpi.kpi-warn .kpi-label { color: var(--kpi-warn-label); }
.kpi.kpi-warn .kpi-value { color: var(--warn); }
.kpi.kpi-ok .kpi-value { color: var(--ok); }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.page-header.dashboard-header {
  align-items: flex-start;
  margin-top: 0;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.page-header.dashboard-header h1 {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.dashboard-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-left: auto;
}
.dashboard-toolbar-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Dashboard: four KPI cards only (reference layout) ── */
.app-content:has(.dashboard-page--cards-only) {
  padding: 20px 28px 28px;
  background: var(--bg);
}
.dashboard-page--cards-only .page-header.dashboard-header {
  margin-bottom: 14px;
}
/* Exactly four tiles — scoped classes (avoid generic `.kpi` bleed / grid quirks) */
.dash-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  padding: 0;
  margin: 0;
}
.dash-metrics > .dash-metric {
  margin: 0;
}
.dashboard-page--cards-only .dash-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 0;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.06);
  background: #ffffff;
}
.dashboard-page--cards-only .dash-metric__label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  line-height: 1.35;
  width: 100%;
}
.dashboard-page--cards-only .dash-metric__value {
  font-size: clamp(22px, 2.2vw, 26px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.15;
  color: var(--text);
  width: 100%;
}
.dashboard-page--cards-only .dash-metric__foot {
  margin-top: 10px;
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  width: 100%;
}
.dashboard-page--cards-only .dash-metric--received .dash-metric__value {
  color: #15803d;
}
.dashboard-page--cards-only .dash-metric__foot--mix a {
  color: var(--dam-blue);
  font-weight: 500;
  text-decoration: none;
}
.dashboard-page--cards-only .dash-metric__foot--mix a:hover { text-decoration: underline; }
.dashboard-page--cards-only .dash-metric__foot--link a {
  color: var(--dam-blue);
  font-weight: 500;
  text-decoration: none;
}
.dashboard-page--cards-only .dash-metric__foot--link a:hover { text-decoration: underline; }
.dashboard-page--cards-only .dash-metric--proposals {
  border: 1px solid rgba(0, 65, 255, 0.42);
  box-shadow: 0 1px 3px rgba(0, 65, 255, 0.06);
}
.dashboard-page--cards-only .dash-metric--proposals .dash-metric__value {
  color: var(--dam-blue);
}

/* ── SS card: amber/orange accent ── */
.dashboard-page--cards-only .dash-metric--ss {
  border: 1px solid rgba(217, 119, 6, 0.32);
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.07);
}
.dashboard-page--cards-only .dash-metric--ss .dash-metric__value {
  color: #b45309;
}

/* ── ×3 multiplier label on SS card ── */
.dash-metric__x3 {
  font-size: 11px;
  font-weight: 500;
  color: #b45309;
  vertical-align: middle;
  margin-left: 2px;
  font-family: 'IBM Plex Mono', monospace;
}

/* ── Quarter badge on tax cards ── */
.dashboard-page--cards-only .dash-metric__quarter-badge {
  display: inline-block;
  background: var(--badge-info-bg);
  color: var(--badge-info-text);
  border: 1px solid var(--badge-info-border);
  border-radius: 3px;
  padding: 0 5px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.6;
  vertical-align: middle;
  margin-left: 5px;
}

/* ── Tax deadline bar ── */
.dash-tax-deadline-bar {
  margin-top: 14px;
  background: rgba(11, 11, 11, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
}
.dash-tax-deadline-bar__inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 8px 14px;
  font-size: 10px;
  color: var(--text-muted);
}
.dash-tax-deadline-bar__label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sub);
  font-weight: 500;
}
.dash-tax-deadline-bar__item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-sub);
}
.dash-tax-deadline-bar__sep {
  color: var(--border-2);
  font-weight: 400;
}
.dash-tax-deadline-bar__badge {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Dashboard: daily activity bars (chart under KPI cards — month view) ── */
.dashboard-page--with-chart .dash-chart-heading {
  margin-top: 22px;
  margin-bottom: 10px;
}
.month-chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 16px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.06);
}
.month-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 104px;
  margin-bottom: 6px;
  min-width: 540px;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  min-width: 12px;
}
.chart-col-today .chart-day-label {
  color: var(--dam-blue);
  font-weight: 600;
}
.chart-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.chart-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 2px 2px 0 0;
  overflow: hidden;
}
.chart-day-label {
  font-size: 8px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-muted);
  line-height: 1;
}
.chart-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 10px;
}
.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.dash-chart-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dash-chart-footer__link {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
}
.dash-chart-footer__link:hover {
  color: var(--dam-blue);
  text-decoration: underline;
}
.dash-chart-footer__meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
}

/* ── Dashboard activity chart panel (alternate / year scaffolding) ── */
.activity-chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 12px;
  margin-bottom: 24px;
  box-shadow: 0 1px 4px rgba(11,11,11,.06);
}
.activity-chart-heading {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.activity-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
  font-size: 10px;
  color: var(--text-muted);
}
.activity-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-swatch.legend-billed { background: var(--dam-blue); }
.legend-swatch.legend-unbilled { background: #fbbf24; }
.activity-chart-canvas {
  display: flex;
  align-items: flex-end;
  gap: clamp(3px, 1vw, 8px);
  min-height: calc(var(--chart-bar-h, 120px) + 26px);
  padding-bottom: 4px;
  overflow-x: auto;
}
.activity-chart-canvas--year .activity-chart-col {
  min-width: 18px;
  flex: 1;
}
.activity-chart-col {
  flex: 1;
  min-width: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.activity-chart-stack {
  position: relative;
  width: 100%;
  height: var(--chart-bar-h, 120px);
}
.activity-seg {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 3px;
  min-height: 0;
}
.activity-seg--billed {
  background: var(--dam-blue);
}
.activity-seg--unbilled {
  background: linear-gradient(#fde68a, #fbbf24);
}
.activity-seg--empty {
  min-height: 1px;
  background: transparent;
}
.activity-chart-x {
  margin-top: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  color: var(--text-muted);
  text-align: center;
}
.activity-chart-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 10px;
}
.activity-chart-footer a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--dam-blue);
  text-decoration: none;
  font-weight: 500;
}
.activity-chart-footer a:hover { text-decoration: underline; }
.activity-chart-totals {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
}
.section-label.mt-after-chart {
  margin-top: 8px;
}
.dash-empty-msg {
  color: var(--text-muted);
  font-size: 11px;
  padding: 12px 0;
}

@media (max-width: 1200px) {
  .dash-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .dash-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .dash-metrics {
    grid-template-columns: minmax(0, 1fr);
  }
}
.page-header h2 { font-size: 13px; font-weight: 600; }
.section-label { font-family: 'IBM Plex Mono', monospace; font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav-label { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-muted); min-width: 74px; text-align: center; }
.month-nav-btn { font-size: 12px; color: var(--text-muted); text-decoration: none; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.month-nav-btn:hover { background: var(--nav-hover-bg); color: var(--text); }
.month-nav-disabled { opacity: .3; cursor: default; }
.view-toggle { display: flex; background: var(--border); border-radius: 6px; padding: 2px; gap: 1px; }
.view-toggle-btn { font-size: 10px; color: var(--text-muted); text-decoration: none; padding: 3px 10px; border-radius: 4px; line-height: 1.4; }
.view-toggle-btn.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(11,11,11,.1); }

/* ── Task rows ── */
.task-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 4px;
}
.task-row:hover { border-color: var(--border-2); background: var(--row-hover); }
.task-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-2); flex-shrink: 0; }
.task-info { flex: 1; min-width: 0; }
.task-name { font-size: 11.5px; color: var(--task-name); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { font-family: 'IBM Plex Mono', monospace; font-size: 9px; color: var(--text-muted); margin-top: 2px; }
.task-hours { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-muted); flex-shrink: 0; min-width: 32px; text-align: right; }
.task-cost { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-sub); flex-shrink: 0; min-width: 52px; text-align: right; }
.task-actions { display: flex; gap: 5px; flex-shrink: 0; }
.task-total { font-family: 'IBM Plex Mono', monospace; font-size: 9px; color: var(--text-muted); text-align: right; padding: 6px 12px 2px; border-top: 1px solid var(--border); margin-top: 2px; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 7px; border-radius: 20px; font-family: 'IBM Plex Mono', monospace; font-size: 9.5px; font-weight: 500; }
.badge-paid, .badge-done, .badge-active    { background: var(--badge-ok-bg);   color: var(--badge-ok-text);   border: 1px solid var(--badge-ok-border); }
.badge-sent, .badge-in_progress, .badge-onboarding { background: var(--badge-info-bg); color: var(--badge-info-text); border: 1px solid var(--badge-info-border); }
.badge-draft, .badge-not_started, .badge-inactive { background: var(--badge-neu-bg); color: var(--badge-neu-text); border: 1px solid var(--badge-neu-border); }
.badge-invoiced { background: rgba(37, 99, 235, 0.12); color: #1e40af; border: 1px solid rgba(37, 99, 235, 0.28); }
.badge-unbilled { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.badge-paused, .badge-cancelled, .badge-rejected { background: var(--badge-bad-bg); color: var(--danger); border: 1px solid var(--badge-bad-border); }
.badge-accepted, .badge-approved { background: var(--badge-ok-bg); color: var(--badge-ok-text); border: 1px solid var(--badge-ok-border); }
.badge-expired { background: var(--badge-exp-bg); color: var(--warn); border: 1px solid var(--badge-exp-border); }
.badge-proposal { background: var(--badge-info-bg); color: var(--badge-info-text); border: 1px solid var(--badge-info-border); }

/* ── Table ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { font-family: 'IBM Plex Mono', monospace; font-size: 8.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); background: var(--th-bg); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 11.5px; color: var(--text); }
.nowrap-money { white-space: nowrap; display: inline-block; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--row-hover); }
tfoot tr td, tfoot tr th { background: var(--surface-2); border-top: 1px solid var(--border); }

/* ── Filters ── */
.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filters select {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 5px 8px; font-size: 11px;
  font-family: 'Space Grotesk', sans-serif; color: var(--text); cursor: pointer;
}

/* ── Forms ── */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 560px; }
.field { margin-bottom: 16px; }
/* Only the field caption (direct child label), not nested labels e.g. invoice task rows */
.field > label { display: block; font-family: 'IBM Plex Mono', monospace; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date],
input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-2);
  border-radius: var(--radius); font-size: 12px; font-family: 'Space Grotesk', sans-serif;
  background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.field-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) {
  .field-row.field-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Buttons (26px tall — matches “+ New invoice”) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--cta-height);
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  box-sizing: border-box;
  line-height: 1;
}
.btn-primary { background: var(--dam-black); color: #ffffff; }
.btn-primary:hover { opacity: .85; }
.btn-secondary { background: transparent; color: var(--text-sub); border-color: var(--border-2); }
.btn-secondary:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--badge-bad-border); }
.btn-danger:hover { background: var(--badge-bad-bg); }
.btn-full { width: 100%; }
.btn-sm {
  min-height: var(--cta-height);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
}
.actions { display: flex; gap: 6px; align-items: center; }
.cell-actions form { margin: 0; }
td.cell-actions { white-space: nowrap; width: 1%; }
td.cell-actions {
  padding-top: 4px;
  padding-bottom: 4px;
  text-align: right;
}
td.cell-actions .btn.btn-sm {
  min-height: 24px;
  padding: 0 8px;
}
td.cell-actions > a,
td.cell-actions > form {
  display: inline-flex;
  vertical-align: middle;
  margin: 0;
}
td.cell-actions > * + * {
  margin-left: 6px;
}

/* ── Detail card ── */
.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.detail-item label { font-family: 'IBM Plex Mono', monospace; font-size: 8.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); display: block; margin-bottom: 4px; }
.detail-item span { font-size: 12px; }

/* ── List rows ── */
.list-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row-name { flex: 1; font-size: 11px; }
.list-row-meta { font-size: 10px; color: var(--text-muted); }

/* ── Drawer ── */
.drawer-overlay {
  position: fixed; inset: 0; background: var(--overlay-bg);
  display: none; justify-content: flex-end; z-index: 100;
}
.drawer {
  width: 320px; background: var(--drawer-bg); border-left: 1px solid var(--border);
  padding: 24px 20px; display: flex; flex-direction: column; gap: 14px;
  height: 100%; overflow-y: auto;
}
.drawer h2 { font-size: 14px; font-weight: 600; letter-spacing: -.02em; }
.drawer .btn-primary { margin-top: auto; }

/* Generic iframe entity drawer */
#entity-drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: none;
  justify-content: flex-end;
  z-index: 140;
}
.entity-drawer-panel {
  display: flex;
  flex-direction: column;
  width: min(520px, 92vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -2px 0 18px rgba(11, 11, 11, 0.12);
  overflow: hidden;
}
#entity-drawer-frame {
  width: 100%;
  flex: 1;
  min-height: 0;
  border: 0;
  display: block;
  background: var(--surface);
}
.drawer-page-shell {
  min-height: 100vh;
  background: var(--surface);
  padding: 18px 20px 28px;
  box-sizing: border-box;
}
.drawer-page-shell .page-header { margin-bottom: 14px; }
.drawer-page-shell .page-header h1 { flex: 1; min-width: 0; }
.drawer-page-shell .form-card {
  max-width: none;
  width: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
}
/* In drawer context, parent already provides close/back affordance. */
.drawer-page-shell .page-header .btn.btn-secondary {
  display: none;
}

.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(11, 11, 11, 0.5);
}
.confirm-modal {
  width: min(420px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 42px rgba(11, 11, 11, 0.2);
  padding: 16px;
}
.confirm-modal h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.confirm-modal p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}
.confirm-modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Unbilled page ── */
.unbilled-client {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 8px; display: flex; align-items: flex-start; gap: 16px;
}
.unbilled-client-name { width: 150px; flex-shrink: 0; font-size: 15px; font-weight: 600; letter-spacing: -.02em; padding-top: 10px; }
.unbilled-client .task-list { flex: 1; min-width: 0; }
.unbilled-client-meta { font-size: 10px; color: var(--text-muted); }
.unbilled-client-value { font-size: 14px; font-weight: 600; color: var(--warn); min-width: 80px; text-align: right; }

/* ── Billing summary ── */
.billing-summary { display: flex; gap: 1px; margin-top: 16px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.bs-item { flex: 1; background: var(--surface); padding: 14px 16px; }
.bs-label { font-family: 'IBM Plex Mono', monospace; font-size: 8.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 7px; }
.bs-hours { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.bs-value { font-size: 15px; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.bs-warn { color: var(--warn); }
.bs-ok   { color: var(--ok); }
.task-dot-invoiced { background: var(--warn) !important; }
.task-dot-paid     { background: var(--ok) !important; }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0 32px 32px; width: 320px; }
.login-brand { display: flex; align-items: center; justify-content: flex-start; margin: 0 0 16px; }
.login-brand-logo {
  width: 52px;
  height: auto;
  flex-shrink: 0;
  display: block;
}
.login-error { color: var(--danger); font-family: 'IBM Plex Mono', monospace; font-size: 11px; margin-bottom: 12px; }

/* ── Invoice tasks fragment ── */
.invoice-task-empty {
  color: var(--text-muted);
  font-size: 13px;
}
.invoice-help-text {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
}
.invoice-form-actions {
  margin-top: 8px;
}
.task-check-group { margin-bottom: 14px; }
.task-check-group-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.35;
}
.task-check-group-rate {
  font-weight: 500;
}
.task-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.task-check-row:last-child { border-bottom: none; }
.task-check-name {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  line-height: 1.35;
}
.task-check-meta {
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}
.task-check-value {
  font-size: 11px;
  font-weight: 600;
  min-width: 56px;
  text-align: right;
  white-space: nowrap;
}
.invoice-task-locked-note {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 8px;
}

/* Read-only calculated amount on invoice form */
#amount_field[readonly] {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
  border-style: dashed;
}

/* ── Month/Year nav ── */
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav-label { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-muted); min-width: 74px; text-align: center; }
.month-nav-btn { font-size: 12px; color: var(--text-muted); text-decoration: none; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.month-nav-btn:hover { background: var(--nav-hover-bg); color: var(--text); }
.month-nav-disabled { opacity: .3; cursor: default; }

/* ── Client detail (dam-crm reference: beige canvas, white cards, toolbar + tables) ── */
.app-content:has(.client-detail-page) {
  background: #f9f8f3;
  padding-top: 24px;
}
.client-detail-page { padding-bottom: 8px; }
.client-page-actions { flex-wrap: wrap; gap: 8px; }
.client-page-header { margin-bottom: 18px; }

.client-summary-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
.client-summary-strip__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 14px 28px;
}
.client-summary-item { min-width: 0; }
.client-summary-item__label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9a9188;
  display: block;
  margin-bottom: 4px;
}
.client-summary-item__value { font-size: 13px; font-weight: 500; letter-spacing: -0.02em; }

.client-project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 20px 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.04);
}
.client-project-card--empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
.client-project-card .muted { color: var(--text-muted); font-size: 13px; margin: 0; }

.client-project-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px 16px;
  margin-bottom: 18px;
}
.client-project-toolbar__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  min-width: 0;
  flex: 1;
}
.client-project-card__name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.25;
}
.client-project-card__name a { color: inherit; text-decoration: none; }
.client-project-card__name a:hover { text-decoration: underline; }

.client-project-inline-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  font-size: 12px;
  line-height: 1.4;
}
.client-project-inline-meta__item {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.client-project-inline-meta__k {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9a9188;
}
.client-project-inline-meta__v { font-weight: 500; color: var(--text); }
.client-billing-link {
  font-weight: 600;
  color: var(--dam-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.client-billing-link:hover { opacity: 0.88; }

.client-project-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.client-project-card__section { margin-bottom: 20px; }
.client-project-card__section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.client-table-link {
  font-weight: 500;
  color: var(--dam-blue);
  text-decoration: none;
}
.client-table-link:hover { text-decoration: underline; }

.client-project-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}
.client-project-table-wrap {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  overflow: hidden;
}
.client-project-table { font-size: 11px; width: 100%; border-collapse: collapse; }
.client-project-table thead {
  background: var(--th-bg);
}
.client-project-table th {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.client-project-table th,
.client-project-table td {
  padding: 8px 10px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.client-project-table tbody tr:last-child td { border-bottom: none; }
.client-project-table .col-name { font-weight: 500; max-width: 180px; }
.client-project-table .empty-cell {
  color: var(--text-muted);
  text-align: center;
}
.client-project-table td.client-table-actions {
  white-space: nowrap;
  width: 1%;
  text-align: right;
}

@media (max-width: 900px) {
  .client-project-split { grid-template-columns: 1fr; }
  .client-project-toolbar__actions { justify-content: flex-start; width: 100%; }
}

/* ── Prioridades card ── */
.dash-priorities {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 14px;
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.06);
}
.dash-priorities__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.dash-priorities__title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.dash-priorities__link {
  font-size: 9px;
  color: var(--text-muted);
  text-decoration: none;
}
.dash-priorities__link:hover {
  color: var(--dam-blue);
  text-decoration: underline;
}
.dash-priorities__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-priorities__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.4;
}
.dash-priorities__item:last-child {
  border-bottom: none;
}
.dash-priorities__project-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-priorities__client {
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-priorities__deadline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 48px;
  text-align: right;
}
.dash-priorities__deadline--at-risk {
  color: #b45309;
  font-weight: 500;
}
.dash-priorities__deadline--overdue {
  color: var(--danger);
  font-weight: 500;
}
.dash-priorities__empty {
  color: var(--text-muted);
  font-size: 11px;
  padding: 8px 0;
}

/* Status badges for priorities */
.badge-success {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  background: var(--badge-ok-bg);
  color: var(--badge-ok-text);
  border: 1px solid var(--badge-ok-border);
  white-space: nowrap;
}
.badge-warning {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  background: var(--badge-exp-bg);
  color: var(--warn);
  border: 1px solid var(--badge-exp-border);
  white-space: nowrap;
}
.badge-danger {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  background: var(--badge-bad-bg);
  color: var(--danger);
  border: 1px solid var(--badge-bad-border);
  white-space: nowrap;
}

/* ══════════════════════════════════════════
   MOBILE LAYOUT (< 768px)
   ══════════════════════════════════════════ */

/* ── Mobile header bar ── */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 12px;
  gap: 10px;
}
.mobile-header__hamburger {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
}
.mobile-header__hamburger:hover { background: var(--nav-hover-bg); }
.mobile-header__hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}
/* Hamburger → X when sidebar open (class toggled via JS) */
.mobile-header__hamburger.mobile-menu-open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.mobile-header__hamburger.mobile-menu-open span:nth-child(2) {
  opacity: 0;
}
.mobile-header__hamburger.mobile-menu-open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}
.mobile-header__logo { line-height: 0; }
.mobile-header__logo img { width: 28px; height: auto; display: block; }
.mobile-header__spacer { flex: 1; }

/* ── Sidebar off-canvas overlay ── */
.mobile-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.4);
  z-index: 100;
}

@media (max-width: 768px) {
  /* Show mobile header */
  .mobile-header { display: flex; }

  /* Hide desktop shell, use vertical stack */
  .app-layout { flex-direction: column; height: auto; overflow: visible; }

  /* Sidebar: hidden by default, off-canvas when open */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 110;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 2px 0 24px rgba(11, 11, 11, 0.15);
  }
  .mobile-sidebar-overlay.mobile-open { display: block; }

  /* Main content */
  .app-main { flex: none; overflow: visible; }
  .app-content { padding: 16px 14px 24px; overflow-y: visible; }

  /* KPI cards — single column */
  .dash-metrics { grid-template-columns: 1fr; gap: 10px; }
  .kpi-row { grid-template-columns: 1fr; gap: 8px; }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-header.dashboard-header { gap: 10px; }
  .dashboard-toolbar {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .dashboard-toolbar-inner { flex-wrap: wrap; gap: 8px; }

  /* Tables — horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 560px; }

  /* Forms */
  .form-card { max-width: none; padding: 16px; }
  .field-row { grid-template-columns: 1fr; gap: 8px; }
  .field-row.field-row-4 { grid-template-columns: 1fr 1fr; }

  /* Filters */
  .filters { flex-wrap: wrap; gap: 6px; }
  .filters select { flex: 1; min-width: 120px; }

  /* Detail card */
  .detail-grid { grid-template-columns: 1fr; }

  /* Drawers: full width */
  .drawer { width: 100%; }
  .entity-drawer-panel { width: 100%; }
  .drawer-overlay { justify-content: flex-end; }

  /* Login box */
  .login-box { width: calc(100% - 32px); max-width: 340px; padding: 0 20px 24px; }

  /* Billing summary */
  .billing-summary { flex-direction: column; }

  /* Unbilled page */
  .unbilled-client {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .unbilled-client-name { width: auto; padding-top: 0; }
  .unbilled-client-value { text-align: left; min-width: auto; }

  /* Client detail */
  .client-summary-strip__inner { gap: 10px 16px; }
  .client-project-toolbar { flex-direction: column; gap: 10px; }
  .client-project-toolbar__actions { justify-content: flex-start; width: 100%; }
  .client-project-inline-meta { gap: 6px 14px; }

  /* Task rows */
  .task-row { flex-wrap: wrap; gap: 6px 10px; }
  .task-actions { width: 100%; justify-content: flex-end; }

  /* Confirm modal */
  .confirm-modal { margin: 16px; }

  /* Chart */
  .month-chart-wrap { padding: 12px 8px 10px; }
}

/* Extra small phones (< 400px) */
@media (max-width: 400px) {
  .app-content { padding: 12px 10px 20px; }
  .dash-metrics { gap: 8px; }
  .dashboard-page--cards-only .dash-metric { padding: 12px 14px; }
  .dashboard-page--cards-only .dash-metric__value { font-size: 20px; }
  .page-header h1 { font-size: 14px; }
  .page-header.dashboard-header h1 { font-size: 20px; }
  .sidebar { width: calc(100vw - 48px); }
  .field-row.field-row-4 { grid-template-columns: 1fr; }
  .pipeline-col { min-width: 150px; max-width: 180px; }
}


/* ═══════════════════════════════════════════════
   Leads pipeline kanban
   ═══════════════════════════════════════════════ */

.leads-page { }

.leads-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.leads-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-width: 120px;
  flex: 1;
}
.leads-stat__label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 2px;
}
.leads-stat__value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 600;
}
.leads-stat__value--ok { color: var(--ok); }

/* Pipeline horizontal scroll */
.pipeline {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.pipeline-col {
  min-width: 220px;
  max-width: 260px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}
.pipeline-col__header {
  padding: 8px 12px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.pipeline-col__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.pipeline-col__count {
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  border-radius: 10px;
  padding: 1px 8px;
  min-width: 20px;
  text-align: center;
}
.pipeline-col__cards {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 60px;
}
.pipeline-col__empty {
  color: var(--text-muted);
  text-align: center;
  padding: 16px;
  font-size: 11px;
}

.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.pipeline-card:hover {
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.pipeline-card__name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  display: block;
  margin-bottom: 2px;
}
.pipeline-card__name:hover { text-decoration: underline; }
.pipeline-card__company {
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.pipeline-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.pipeline-card__value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sub);
  font-family: 'IBM Plex Mono', monospace;
}
.pipeline-card__stage-dropdown select {
  font-size: 10px;
  padding: 2px 4px;
  border: 1px solid var(--border-2);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-sub);
  cursor: pointer;
}

/* Detail page grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.detail-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.detail-field__label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 2px;
}
.detail-field__value {
  font-size: 13px;
  color: var(--text);
}
.detail-notes {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 12px;
}
.detail-notes h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.detail-notes p {
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Entity form (shared by leads form) */
.entity-form-page { }
.entity-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 660px;
}

/* Pipeline responsive */
@media (max-width: 768px) {
  .pipeline { gap: 8px; }
  .pipeline-col { min-width: 180px; max-width: 220px; }
  .leads-stats { gap: 8px; }
  .leads-stat { min-width: 100px; padding: 8px 12px; }
}
