:root {
  --tfam-bg: #f6f7f4;
  --tfam-surface: #ffffff;
  --tfam-surface-soft: #f1f3ee;
  --tfam-border: #dbe1d8;
  --tfam-border-strong: #c6d0c2;
  --tfam-text: #1f2926;
  --tfam-muted: #65716b;
  --tfam-muted-2: #7d877f;
  --tfam-ink: #243c39;
  --tfam-teal: #315f59;
  --tfam-green: #3f7f5f;
  --tfam-amber: #b77a2f;
  --tfam-red: #a94b3f;
  --tfam-lavender: #746882;
  --tfam-shadow: 0 12px 28px rgba(31, 41, 38, .08);
}

html,
body {
  background: var(--tfam-bg) !important;
  color: var(--tfam-text) !important;
}

body {
  letter-spacing: 0 !important;
}

.wrap,
.container {
  max-width: 1440px !important;
}

.hero,
header {
  background: var(--tfam-ink) !important;
  color: #f8faf7 !important;
  border: 1px solid rgba(255, 255, 255, .12) !important;
  border-radius: 10px !important;
  box-shadow: var(--tfam-shadow) !important;
}

.hero h1,
header h1 {
  font-size: 28px !important;
  line-height: 1.18 !important;
  letter-spacing: 0 !important;
}

.hero p,
header .subtitle {
  color: rgba(248, 250, 247, .86) !important;
}

.pill,
.badge {
  background: rgba(255, 255, 255, .12) !important;
  border: 1px solid rgba(255, 255, 255, .18) !important;
  color: #f8faf7 !important;
  border-radius: 999px !important;
}

.back,
.back-link,
.exp-upload,
.upload-btn,
.exp-link,
.filter-chip.active {
  background: var(--tfam-teal) !important;
  color: #ffffff !important;
  border-color: var(--tfam-teal) !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}

.upload-btn:hover,
.back:hover,
.back-link:hover,
.exp-link:hover {
  background: #254d49 !important;
}

.panel,
.exp-chart-panel,
.exp-kpi,
.exp-card,
.exp-detail-card,
.kpi-card,
.summary-card,
.risk-card,
.owner-card,
.schedule-card,
.cat-card,
.project-card,
.exp-inline-panel,
.exp-inline-kpi {
  background: var(--tfam-surface) !important;
  border: 1px solid var(--tfam-border) !important;
  border-radius: 8px !important;
  box-shadow: 0 6px 18px rgba(31, 41, 38, .05) !important;
}

.panel h2,
.exp-chart-panel h2 {
  color: var(--tfam-ink) !important;
  border-bottom-color: var(--tfam-border) !important;
  font-size: 17px !important;
}

.exp-mini,
.exp-note,
.exp-note.small,
.muted,
.kpi-sub,
.kpi-label,
.project-meta,
.progress-label,
.exp-progress-label,
.exp-progress-caption,
.exp-status.soft,
.footnote {
  color: var(--tfam-muted) !important;
}

.exp-topbar {
  gap: 8px !important;
  margin-bottom: 12px !important;
}

.exp-status,
.exp-control,
.exp-search,
.search-box,
select,
.filter-chip {
  background: var(--tfam-surface) !important;
  border: 1px solid var(--tfam-border-strong) !important;
  color: var(--tfam-text) !important;
  border-radius: 8px !important;
}

.tabs {
  background: #e4e9e1 !important;
  border: 1px solid var(--tfam-border) !important;
  border-radius: 8px !important;
}

.tab-btn {
  color: var(--tfam-muted) !important;
  border-radius: 6px !important;
}

.tab-btn.active {
  background: var(--tfam-surface) !important;
  color: var(--tfam-teal) !important;
  box-shadow: 0 1px 3px rgba(31, 41, 38, .1) !important;
}

.kpi-row,
.exp-kpi-grid,
.exp-card-grid,
.chart-grid {
  gap: 12px !important;
}

.kpi-card,
.exp-kpi {
  border-left: 4px solid var(--tfam-teal) !important;
}

.kpi-card.paid {
  border-left-color: var(--tfam-green) !important;
}

.progress-fill.paid,
.exp-progress-fill.budget,
.exp-progress-fill.ok,
.exp-dot.ok {
  background-color: var(--tfam-green) !important;
}

.kpi-card.sign {
  border-left-color: var(--tfam-amber) !important;
}

.progress-fill.sign,
.exp-progress-fill.time,
.exp-progress-fill.warn,
.exp-dot.warn {
  background-color: var(--tfam-amber) !important;
}

.kpi-card.risk,
.exp-progress-fill.bad,
.exp-dot.bad {
  border-left-color: var(--tfam-red) !important;
}

.kpi-label,
.exp-kpi span {
  font-size: 12px !important;
  font-weight: 700 !important;
}

.kpi-value,
.exp-kpi strong,
.exp-meta strong,
.budget-amount,
.cat-card .amount {
  color: var(--tfam-text) !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: 0 !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
}

.kpi-value {
  font-size: 24px !important;
  line-height: 1.12 !important;
  white-space: nowrap !important;
}

.kpi-card.risk .kpi-value {
  font-size: 30px !important;
}

.kpi-sub {
  line-height: 1.5 !important;
}

.exp-kpi-grid.top {
  grid-template-columns: minmax(330px, 1.1fr) minmax(220px, .82fr) minmax(220px, .82fr) !important;
}

.exp-kpi-grid.top .exp-kpi {
  min-height: auto !important;
}

.exp-kpi.metric.rate strong {
  font-size: 44px !important;
}

.exp-kpi-value.compact {
  font-size: 23px !important;
  white-space: nowrap !important;
}

.exp-kpi-canvas {
  height: 168px !important;
}

.exp-split-card,
.exp-kpi-compare,
.exp-card.scope,
.ledger-box,
.mapping-note,
.footnote {
  background: var(--tfam-surface-soft) !important;
  border-color: var(--tfam-border) !important;
  border-radius: 8px !important;
}

.exp-kpi-compare {
  padding: 12px !important;
}

.exp-progress-track,
.progress-bar,
.exp-progress,
.tfam-rail {
  background: #e1e7df !important;
  border-radius: 999px !important;
}

.exp-progress-track,
.tfam-rail {
  height: 14px !important;
}

.tfam-rail-wrap {
  margin-top: 12px;
}

.tfam-rail {
  position: relative;
  overflow: visible;
  width: 100%;
}

.tfam-rail::after {
  content: "";
  position: absolute;
  top: -4px;
  right: 0;
  bottom: -4px;
  border-right: 1px solid rgba(49, 95, 89, .55);
}

.tfam-rail-sm {
  height: 10px !important;
}

.tfam-rail-axis {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
  color: var(--tfam-muted);
  font-size: 10.5px;
  line-height: 1.2;
}

.tfam-rail-axis strong {
  color: var(--tfam-ink);
  font-weight: 800;
}

.tfam-rail-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 999px;
}

.tfam-rail-fill.allocated {
  background: rgba(49, 95, 89, .2);
  box-shadow: inset 0 0 0 1px rgba(49, 95, 89, .28);
}

.tfam-rail-fill.executed {
  background: rgba(183, 122, 47, .72);
}

.tfam-rail-fill.paid {
  background: var(--tfam-green);
}

.tfam-time-marker,
.exp-time-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 0;
  border-left: 2px dashed var(--tfam-red) !important;
}

.tfam-rail-head,
.tfam-rail-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tfam-rail-head {
  margin-bottom: 8px;
}

.tfam-rail-head strong {
  color: var(--tfam-ink);
  font-size: 16px;
}

.tfam-rail-head span,
.tfam-rail-legend {
  color: var(--tfam-muted);
  font-size: 12px;
}

.tfam-rail-legend {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-top: 8px;
  line-height: 1.5;
}

.tfam-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.tfam-card-rail {
  margin-top: 10px;
}

.tfam-card-rail .tfam-rail-axis {
  margin-top: 4px;
  font-size: 9.5px;
}

.tfam-card-rail-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--tfam-muted);
}

.tfam-card-rail-label strong {
  display: block;
  margin-top: 2px;
  color: var(--tfam-ink);
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}

.tfam-card-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 7px;
  color: var(--tfam-muted);
  font-size: 10px;
  line-height: 1.4;
}

.tfam-card-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tfam-card-legend .tfam-swatch {
  width: 8px;
  height: 8px;
}

.exp-card-grid.fixed-order {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 14px !important;
}

.exp-card {
  padding: 16px !important;
}

@media (max-width: 980px) {
  .exp-card-grid.fixed-order {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 560px) {
  .exp-card-grid.fixed-order {
    grid-template-columns: 1fr !important;
  }
}

.tfam-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.tfam-swatch.budget { background: #e1e7df; border: 1px solid #cbd5c8; }
.tfam-swatch.allocated { background: rgba(49, 95, 89, .25); border: 1px solid rgba(49, 95, 89, .4); }
.tfam-swatch.executed { background: var(--tfam-amber); }
.tfam-swatch.paid { background: var(--tfam-green); }
.tfam-swatch.time { background: var(--tfam-red); width: 2px; border-radius: 0; }

.rail-card,
.tfam-kpi-rail {
  grid-column: 1 / -1;
}

.rate.ok,
.rate-badge.rate-ok,
.exp-badge.ok {
  background: #dfeade !important;
  color: #285a3c !important;
}

.rate.mid,
.rate-badge.rate-warn,
.exp-badge.warn {
  background: #f3e3c7 !important;
  color: #80510f !important;
}

.rate.low,
.rate-badge.rate-low,
.exp-badge.bad {
  background: #f1d9d4 !important;
  color: #81352d !important;
}

table th {
  background: #eef2eb !important;
  color: var(--tfam-muted) !important;
}

tbody tr:hover {
  background: #f7f9f5 !important;
}

.chart-box,
.chart-box-compact,
.chart-box-tall,
.chart-box-person,
.exp-chart-box {
  min-height: 260px;
}

@media (max-width: 1120px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .exp-kpi-grid.top {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 760px) {
  body {
    padding: 10px !important;
  }

  .hero,
  header {
    padding: 16px !important;
    margin-bottom: 12px !important;
  }

  .hero h1,
  header h1 {
    font-size: 21px !important;
  }

  .hero .meta,
  header .actions {
    gap: 6px !important;
  }

  .kpi-row,
  .exp-kpi-grid.top,
  .exp-kpi-grid,
  .chart-grid,
  .cat-grid,
  .exp-progress-pair,
  .exp-detail-grid {
    grid-template-columns: 1fr !important;
  }

  .kpi-value {
    font-size: 22px !important;
  }

  .kpi-card.risk .kpi-value,
  .exp-kpi.metric.rate strong {
    font-size: 34px !important;
  }

  .exp-kpi-value.compact {
    font-size: 21px !important;
  }

  .panel,
  .exp-chart-panel,
  .kpi-card,
  .exp-kpi {
    padding: 14px !important;
  }

  .tfam-rail-head,
  .tfam-rail-legend {
    align-items: flex-start;
    flex-direction: column;
  }
}
