:root {
  /* Alberius palette: ivory ground, sage primary, gold secondary. */
  --color-bg: #f5f1ea;
  --color-surface: #ffffff;
  --color-surface-alt: #faf7f0;
  --color-border: #e2dbc9;
  --color-text: #2b2620;
  --color-text-muted: #7d7566;

  --color-sage: #5a8a5e;
  --color-sage-dark: #456b48;
  --color-sage-bg: rgba(90, 138, 94, 0.13);

  --color-gold: #8c7342;
  --color-gold-dark: #6f5b34;
  --color-gold-bg: rgba(140, 115, 66, 0.15);

  /* Muted brick — the over-budget tone. Desaturated on purpose so it reads
     as "attention" within this warm palette rather than a jarring stock red. */
  --color-brick: #a15c42;
  --color-brick-dark: #824a35;
  --color-brick-bg: rgba(161, 92, 66, 0.13);

  --shadow-sm: 0 1px 2px rgba(43, 38, 32, 0.06);
  --shadow-md: 0 4px 14px rgba(43, 38, 32, 0.08);
  --shadow-lg: 0 14px 34px rgba(43, 38, 32, 0.14);
  --radius-md: 10px;
  --radius-lg: 16px;
  /* Squared-off corners for spreadsheet-style data views (job list, cost-code
     grid, variance/exceptions tables) — everything that isn't a landing tile. */
  --radius-tight: 3px;

  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

/* Placeholder company/entity mark used in the header and anywhere a job
   page shows entity context. Swap the markup for an <img> once real logo
   files exist — sizing and spacing are already set up to take one. */
.company-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-sage), var(--color-gold));
  color: #fff;
  font-family: var(--font-serif);
  font-weight: 700;
}

.company-logo--placeholder {
  border: 1.5px dashed rgba(255, 255, 255, 0.55);
}

img.company-logo {
  background: var(--color-surface);
  object-fit: contain;
  padding: 2px;
  border: 1px solid var(--color-border);
}

.company-logo--header {
  width: 40px;
  height: 40px;
  font-size: 17px;
}

.company-logo--sm {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 10px;
  letter-spacing: -0.02em;
}

.app-header__title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.app-header__subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
}

.breadcrumbs {
  font-size: 13px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumbs a {
  color: var(--color-sage-dark);
  text-decoration: none;
  cursor: pointer;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

/* ---------- App shell: persistent left job rail + main content ---------- */

.app-shell {
  display: flex;
  align-items: flex-start;
  max-width: 1280px;
  margin: 0 auto;
}

.job-rail {
  flex: 0 0 240px;
  width: 240px;
  min-height: calc(100vh - 75px);
  padding: 24px 16px;
  border-right: 1px solid var(--color-border);
}

.job-rail[hidden] {
  display: none;
}

.job-rail__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
  padding: 0 8px;
}

.job-rail__entity-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.job-rail__entity {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-rail__all-jobs {
  font-size: 12px;
  color: var(--color-sage-dark);
  cursor: pointer;
  white-space: nowrap;
}

.job-rail__all-jobs:hover {
  text-decoration: underline;
}

.job-rail__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.job-rail__item {
  padding: 10px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border-left: 3px solid transparent;
}

.job-rail__item:hover {
  background: var(--color-surface-alt);
}

.job-rail__item.is-active {
  background: var(--color-sage-bg);
  border-left-color: var(--color-sage);
}

.job-rail__item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text);
}

.job-rail__item.is-active .job-rail__item-name {
  color: var(--color-sage-dark);
}

.job-rail__item-sale {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.job-rail__empty {
  font-size: 12.5px;
  color: var(--color-text-muted);
  padding: 8px;
}

.view-root {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

.view-heading {
  margin-bottom: 14px;
}

.view-heading h1 {
  font-size: 30px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.view-heading p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 14px;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.entity-tile {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.entity-tile__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--color-sage-bg);
  color: var(--color-sage-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.entity-tile h2 {
  margin: 0;
  font-size: 19px;
}

.entity-tile p {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  background: var(--color-sage);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease;
}

.btn:hover {
  background: var(--color-sage-dark);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-sage-dark);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-surface-alt);
}

.btn--small {
  padding: 6px 12px;
  font-size: 12px;
}

.form-panel {
  margin-top: 18px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.form-row input[type="text"],
.form-row input[type="number"] {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  font-size: 14px;
  font-family: inherit;
}

.form-row input:focus {
  outline: 2px solid var(--color-sage-bg);
  border-color: var(--color-sage);
}

.form-actions {
  display: flex;
  gap: 10px;
}

/* ---------- Job dashboard: hero + 4-KPI header strip ---------- */

.hero {
  margin-bottom: 14px;
}

.hero h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.hero__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero__status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.hero__entity {
  color: var(--color-text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.data-source-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-source-badge--sample {
  background: var(--color-gold-bg);
  color: var(--color-gold-dark);
}

.data-source-badge--qbo {
  background: var(--color-sage-bg);
  color: var(--color-sage-dark);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 12px 0 16px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-tight);
  overflow: hidden;
}

.kpi-card {
  background: var(--color-surface);
  padding: 12px 16px;
}

.kpi-card__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-gold);
  margin-bottom: 6px;
}

.kpi-card__value {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--color-text);
}

.kpi-card__value--warn {
  color: var(--color-brick);
}

.hero__stat-value--warn {
  color: var(--color-brick);
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 14px;
}

.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.is-active {
  color: var(--color-sage-dark);
  border-bottom-color: var(--color-sage);
}

/* ---------- Sticky bottom totals bar (Cost Codes tab only) ---------- */

.totals-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 10px 24px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
}

.totals-bar[hidden] {
  display: none;
}

.totals-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.totals-bar__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-gold);
}

.totals-bar__value {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}

.view-root--totals-pad {
  padding-bottom: 120px;
}

/* ---------- Cost-code grid ---------- */
/*
 * Spreadsheet/Buildertrend-style dense data grid: squared corners, full
 * 1px gridlines on every cell (not just row-bottom rules), a sticky header
 * row pinned below the sticky app header (75px — see .job-rail's own
 * calc(100vh - 75px) for the same header-height assumption), and a smaller
 * body font so more rows fit above the fold without scrolling.
 */

table.cost-table,
table.cost-grid,
table.job-list-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

table.cost-table th,
table.cost-table td,
table.cost-grid th,
table.cost-grid td,
table.job-list-table th,
table.job-list-table td {
  padding: 7px 12px;
  text-align: left;
  font-size: 12.5px;
  border: 1px solid var(--color-border);
}

table.cost-table th,
table.cost-grid th,
table.job-list-table th {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  position: sticky;
  top: 75px;
  z-index: 5;
}

table.job-list-table tbody tr {
  cursor: pointer;
}

table.job-list-table tbody tr:hover {
  background: var(--color-surface-alt);
}

.cost-grid__group-row {
  cursor: pointer;
  background: var(--color-surface-alt);
  font-weight: 700;
}

.cost-grid__group-row:hover {
  background: var(--color-gold-bg);
}

.cost-grid__group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 14px;
}

.cost-grid__disclosure {
  display: inline-block;
  width: 10px;
  transition: transform 0.12s ease;
  color: var(--color-gold);
}

.cost-grid__group-row.is-expanded .cost-grid__disclosure {
  transform: rotate(90deg);
}

.cost-grid__code-row {
  cursor: pointer;
}

.cost-grid__code-row:hover {
  background: var(--color-surface-alt);
}

.cost-grid__code-row td:first-child {
  padding-left: 32px;
}

.cost-grid__drilldown-row td {
  background: var(--color-bg);
  padding: 0 12px 10px 36px;
}

.progress-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--color-border);
  overflow: hidden;
  margin-top: 6px;
  width: 100%;
}

.progress-bar__fill {
  height: 100%;
  background: var(--color-sage);
}

.progress-bar__fill.is-over {
  background: var(--color-brick);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--unmapped {
  background: var(--color-gold-bg);
  color: var(--color-gold-dark);
}

.badge--mapped {
  background: var(--color-sage-bg);
  color: var(--color-sage-dark);
}

.badge--status-over {
  background: var(--color-brick-bg);
  color: var(--color-brick-dark);
}

.badge--status-under {
  background: var(--color-sage-bg);
  color: var(--color-sage-dark);
}

.badge--status-unbudgeted {
  background: var(--color-gold-bg);
  color: var(--color-gold-dark);
}

/* An over-budget variance figure in the variance table. */
.is-over-text {
  color: var(--color-brick-dark);
  font-weight: 600;
}

.drilldown {
  margin-top: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-tight);
  padding: 6px 0;
}

.drilldown table {
  width: 100%;
  border-collapse: collapse;
}

.drilldown th,
.drilldown td {
  padding: 6px 12px;
  font-size: 12px;
  text-align: left;
}

.drilldown th {
  color: var(--color-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10.5px;
}

.drilldown tr:not(:last-child) td {
  border-bottom: 1px solid var(--color-border);
}

table.version-history tbody tr.version-history__row--active {
  background: var(--color-sage-bg);
}

table.version-history .badge {
  margin-left: 8px;
  vertical-align: middle;
}

.upload-panel {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: center;
}

.upload-panel input[type="file"] {
  margin: 14px 0;
}

.upload-panel__hint {
  font-size: 12px;
  color: var(--color-text-muted);
  max-width: 480px;
  margin: 0 auto 16px;
}

.callout {
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  margin-top: 16px;
}

.callout--error {
  background: var(--color-brick-bg);
  color: var(--color-brick-dark);
  border: 1px solid rgba(161, 92, 66, 0.35);
}

.callout--success {
  background: var(--color-sage-bg);
  color: var(--color-sage-dark);
  border: 1px solid rgba(90, 138, 94, 0.35);
}

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 28px 20px;
  font-size: 14px;
}
