/* Integrity Ag brand: Albert Sans throughout, Crimson Text italic as a sparing accent,
   large areas of Cloud / Farm, then Grain, with Wattle as the accent. */

@font-face { font-family: "Albert Sans"; font-weight: 400; font-display: swap; src: url("fonts/AlbertSans-Regular.5e8202c18f9b.ttf") format("truetype"); }
@font-face { font-family: "Albert Sans"; font-weight: 500; font-display: swap; src: url("fonts/AlbertSans-Medium.917b89a98893.ttf") format("truetype"); }
@font-face { font-family: "Albert Sans"; font-weight: 700; font-display: swap; src: url("fonts/AlbertSans-Bold.cb38a724dede.ttf") format("truetype"); }
@font-face { font-family: "Crimson Text"; font-weight: 400; font-style: italic; font-display: swap; src: url("fonts/CrimsonText-Italic.684cf58ea500.ttf") format("truetype"); }

:root {
  /* Brand palette */
  --cloud: #F3F4F1;
  --farm: #282320;
  --wheat: #F6F0E3;
  --dusk: #CED0C6;
  --wattle: #F5FF8A;
  --rust: #C25B3C;
  --crop: #BBCA80;
  --grain: #79806A;
  --field: #1A3A25;

  /* Roles */
  --bg: var(--cloud);
  --surface: #ffffff;
  --text: var(--farm);
  --muted: #5c5856;          /* Farm softened for secondary text (AA on Cloud/white) */
  --border: var(--dusk);
  --radius: 12px;

  --font-sans: "Albert Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Crimson Text", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 500; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; font-weight: 500; }
code { font-size: .82em; background: var(--wheat); padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; }
a { color: var(--field); }

:focus-visible { outline: 3px solid var(--grain); outline-offset: 2px; }

/* ---- Top bar ---------------------------------------------------------- */

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .9rem 24px; background: var(--farm); color: var(--cloud);
}
.brand { display: flex; align-items: center; gap: .9rem; color: var(--cloud); text-decoration: none; }
.brand img { height: 30px; width: auto; display: block; }
.brand-product {
  padding-left: .9rem; border-left: 1px solid rgba(243, 244, 241, .3);
  font-weight: 500; font-size: .95rem; letter-spacing: .01em;
}
.topbar-nav { display: flex; gap: 1.25rem; align-items: center; font-size: .9rem; }
.topbar-nav form { margin: 0; }
.topbar .muted { color: var(--dusk); }
.topbar .link-button { color: var(--wattle); }

/* ---- Layout ----------------------------------------------------------- */

.container { max-width: 1120px; margin: 0 auto; padding: 2rem 16px 4rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem 1.75rem; margin-bottom: 1.25rem;
}

.muted { color: var(--muted); }
.small { font-size: .85rem; }

.eyebrow {
  font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--grain); margin: 0 0 .35rem;
}

/* ---- Forms ------------------------------------------------------------ */

.stack { display: flex; flex-direction: column; gap: 1.1rem; }
.stack > label { display: flex; flex-direction: column; gap: .4rem; font-weight: 500; }

input[type=text], input[type=email], input[type=password], input[type=file] {
  font: inherit; padding: .6rem .7rem; border: 1px solid var(--dusk);
  border-radius: 8px; background: var(--surface); color: var(--text); max-width: 100%;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus { border-color: var(--farm); outline: none; box-shadow: 0 0 0 3px var(--wattle); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 500; margin-right: .8rem; padding: .35rem .9rem;
  border: 1px solid var(--farm); border-radius: 999px; background: var(--cloud); color: var(--farm); cursor: pointer;
}

fieldset { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .75rem; }
legend { font-weight: 500; margin-bottom: .5rem; }
label.choice {
  display: flex; flex-direction: row; align-items: flex-start; gap: .7rem; font-weight: 400;
  padding: .85rem 1rem; border: 1px solid var(--dusk); border-radius: 10px; cursor: pointer;
  background: var(--surface); transition: border-color .15s, background .15s;
}
label.choice:hover { border-color: var(--grain); }
label.choice:has(input:checked) { border-color: var(--farm); background: var(--wheat); box-shadow: inset 4px 0 0 var(--farm); }
label.choice input { margin-top: .3rem; accent-color: var(--farm); }

.button {
  font: inherit; font-weight: 500; color: var(--cloud); background: var(--farm);
  border: 0; border-radius: 999px; padding: .7rem 1.6rem; cursor: pointer;
  transition: background .15s, color .15s;
}
.button:hover { background: var(--wattle); color: var(--farm); }
.link-button { font: inherit; background: none; border: 0; color: var(--field); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }

.alert { padding: .85rem 1.1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid var(--dusk); border-left: 4px solid var(--rust); background: var(--wheat); }
.alert.error { border-color: var(--rust); border-left-width: 4px; }
.alert details { margin-top: .5rem; }
.alert summary { cursor: pointer; font-weight: 500; }
ul.errorlist { margin: 0; padding-left: 1.1rem; color: var(--rust); }

/* ---- Results ---------------------------------------------------------- */

.results-head { margin: 2.5rem 0 1.25rem; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem; margin-bottom: 1.25rem;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.35rem;
}
.stat-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--grain); }
.stat-value { font-size: 2.2rem; font-weight: 500; line-height: 1.15; letter-spacing: -.02em; margin-top: .3rem; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: .85rem; color: var(--muted); }
.stat.feature { background: var(--farm); border-color: var(--farm); color: var(--cloud); }
.stat.feature .stat-label { color: var(--crop); }
.stat.feature .stat-value { color: var(--wattle); }
.stat.feature .stat-unit { color: var(--dusk); }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--grain); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:hover td { background: var(--cloud); }
.table tbody tr:last-child td { border-bottom: 0; }
.bar-col { width: 22%; min-width: 150px; }
.bar { display: inline-block; vertical-align: middle; width: calc(100% - 3.5rem); height: 10px; background: var(--cloud); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--grain); border-radius: 999px; }

.pill { font-size: .75rem; font-weight: 500; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: var(--crop); color: var(--farm); }
.pill.scope-3 { background: var(--dusk); }

/* ---- Login ------------------------------------------------------------ */

.auth {
  display: grid; grid-template-columns: 1.1fr 1fr; max-width: 920px; margin: 3rem auto;
  border-radius: 16px; overflow: hidden; border: 1px solid var(--border); background: var(--surface);
}
.auth-panel {
  background: var(--farm); color: var(--cloud); padding: 2.5rem; display: flex;
  flex-direction: column; justify-content: space-between; gap: 2rem; min-height: 380px;
}
.auth-panel img { width: 190px; height: auto; }
.auth-panel h1 { font-size: 2.1rem; font-weight: 400; color: var(--cloud); }
.auth-panel h1 em { font-family: var(--font-serif); font-size: 1.12em; color: var(--wattle); font-style: italic; }
.auth-panel p { color: var(--dusk); margin: 0; }
.auth-form { padding: 2.5rem; display: flex; flex-direction: column; justify-content: center; }
.auth-form h2 { font-size: 1.5rem; }

@media (max-width: 720px) {
  .auth { grid-template-columns: 1fr; margin: 1rem 0; }
  .auth-panel { min-height: 0; padding: 1.75rem; }
  .auth-form { padding: 1.75rem; }
  .brand-product { display: none; }
  .card { padding: 1.25rem; }
  .bar-col { min-width: 90px; }
  .table th, .table td { padding: .5rem .45rem; }
  h1 { font-size: 1.6rem; }
}

/* ---- App navigation and page furniture ------------------------------- */

.topbar-links { display: flex; gap: 1.5rem; margin-right: auto; margin-left: 1.5rem; font-size: .92rem; }
.topbar-links a { color: var(--dusk); text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; }
.topbar-links a:hover { color: var(--cloud); }
.topbar-links a[aria-current="page"] { color: var(--cloud); border-bottom-color: var(--wattle); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem 2rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
/* Period pages: the tabs always sit below the heading, whatever the page width. */
.period-head { flex-direction: column; align-items: flex-start; flex-wrap: nowrap; }
.period-actions { display: flex; gap: 1rem; margin: .35rem 0 0; }
.danger-link, .link-button.danger-link { color: var(--rust); }
.row-action { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .25rem; }
.tabs a { padding: .4rem .95rem; border-radius: 999px; color: var(--text); text-decoration: none; font-size: .88rem; font-weight: 500; white-space: nowrap; }
.tabs a:hover { background: var(--cloud); }
.tabs a[aria-current="page"] { background: var(--farm); color: var(--cloud); }
/* Period pages: the section's own pages, under the two main tabs. */
.subnav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; margin-top: -.35rem; padding-left: .6rem; font-size: .85rem; max-width: 100%; }
.subnav a { color: var(--muted); text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.subnav a:hover { color: var(--text); }
.subnav a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--farm); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 1.25rem; align-items: start; }
.grid-2.wide-left { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.narrow-card { max-width: 560px; }
.card-head { display: flex; justify-content: space-between; gap: 1rem; }
.h3, h2.h3 { font-family: var(--font-sans); font-size: 1.1rem; font-weight: 500; letter-spacing: 0; }
.empty { text-align: center; padding: 3rem 1.5rem; }
.empty .button { margin-top: .5rem; }

.actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.button.secondary { background: var(--surface); color: var(--farm); border: 1px solid var(--farm); }
.button.secondary:hover { background: var(--wattle); }
.button.danger { background: var(--rust); color: #fff; border: 1px solid var(--rust); }
.button.danger:hover { filter: brightness(.92); }
a.button { display: inline-block; text-decoration: none; }
.inline-form { margin: .9rem 0 .25rem; }
.stack.compact { gap: .75rem; }
.stack select, .ref-grid input, .energy-form input[type=number], select {
  font: inherit; padding: .5rem .6rem; border: 1px solid var(--dusk); border-radius: 8px; background: var(--surface); color: var(--text); width: 100%;
}
input[type=date], input[type=number] { font: inherit; padding: .55rem .65rem; border: 1px solid var(--dusk); border-radius: 8px; background: var(--surface); color: var(--text); }
.alert.success { border-left-color: var(--grain); background: var(--surface); }
.alert ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.error-text { color: var(--rust); font-weight: 500; }
details.other-facilities { margin-top: 1rem; }
details.other-facilities ul { columns: 3 200px; margin: .5rem 0 0; padding-left: 1.1rem; }
.table td .small.muted { display: block; }

/* Energy entry */
.energy-form .input-cell { width: 150px; }
.energy-form .input-cell input { text-align: right; }

/* Scope 3 table */
.container.scope3-page { max-width: 1400px; }
.container.boundary-page { max-width: none; }
.erp-blocked { max-width: 72ch; }
/* ERP tab tables */
.erp-table td .small.muted { display: block; }
.erp-table tr.flagged td { background: var(--wheat); }
.erp-open { white-space: nowrap; }
.erp-open .button { margin-right: .75rem; }
.erp-add { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0; }
.erp-add input[type=url] { flex: 1; min-width: 16rem; font: inherit; padding: .5rem .6rem; border: 1px solid var(--dusk); border-radius: 8px; background: var(--surface); color: var(--text); }
.erp-add .errorlist { flex-basis: 100%; }
/* One location's ERP assessment: fills the window under the top bar. */
body:has(> main.erp-full) { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.container.erp-full { flex: 1; min-height: 0; display: flex; flex-direction: column; max-width: none; width: 100%; margin: 0; padding: 0; }
.erp-full > .alert { margin: .5rem 24px; }
.erp-bar { display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; padding: .45rem 24px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: .9rem; }
.erp-bar-end { margin-left: auto; }
/* Shifted up by --erp-crop so the ERP's own title bar sits above the visible area. */
.erp-crop { flex: 1; min-height: 0; position: relative; overflow: hidden; background: var(--surface); }
.erp-crop iframe { position: absolute; left: 0; top: calc(-1 * var(--erp-crop, 0px)); width: 100%; height: calc(100% + var(--erp-crop, 0px)); border: 0; }
.erp-full .erp-blocked { margin: 2rem auto; }
.erp-links td:last-child { width: 60%; }
.erp-links td .small.muted { display: block; }
.erp-links tr.flagged td { background: var(--wheat); }
.erp-links input[type=url] { width: 100%; font: inherit; padding: .5rem .6rem; border: 1px solid var(--dusk); border-radius: 8px; background: var(--surface); color: var(--text); }
.erp-blocked p:last-child { margin-bottom: 0; }
.boundary-page .page-head p.small { max-width: 72ch; margin: .4rem 0 0; }
/* The page is wider than the others; keep its heading and tabs where they sit on every other period page. */
.scope3-page .period-head { width: 100%; max-width: 1088px; margin-left: auto; margin-right: auto; }
.scope3-entry { min-width: 1100px; }
.scope3-entry th, .scope3-entry td { padding-left: .3rem !important; padding-right: .3rem !important; }
.scope3-entry th span { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
.scope3-entry td { vertical-align: top; }
.scope3-entry tbody.s3-line tr td { border-bottom: 0; }
.scope3-entry tbody.s3-line tr:last-child td, .scope3-entry tbody.s3-line tr:first-child td { border-top: 1px solid var(--border); }
.scope3-entry tbody.s3-line tr:not(:first-child) td { border-top: 0; padding-top: 0; }
.scope3-entry input, .scope3-entry select { font: inherit; font-size: .85rem; padding: .35rem .45rem; border: 1px solid var(--dusk); border-radius: 6px; background: var(--surface); color: var(--text); width: 100%; min-width: 0; }
.scope3-entry input[type=checkbox] { width: auto; }
.scope3-entry td.num input { text-align: right; }
.scope3-entry th:nth-child(1) { width: 15%; }
.scope3-entry th:nth-child(2) { width: 16%; }
.scope3-entry th:nth-child(6) { width: 9%; }
.scope3-entry th:nth-child(7) { width: 8%; }
.scope3-entry th:nth-child(9) { width: 8%; }
.scope3-entry th:nth-child(3), .scope3-entry th:nth-child(5) { width: 12%; }
.scope3-entry th:nth-child(4) { width: 11%; }
.scope3-entry th:nth-child(8) { width: 6%; }
.scope3-entry th:nth-child(10) { width: 5.5rem; }
.scope3-entry .s3-calc { display: block; padding: .35rem 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.scope3-entry .errorlist { list-style: none; margin: .2rem 0 0; padding: 0; color: var(--rust); font-size: .78rem; text-align: left; }
.s3-line .s3-total, .s3-line .s3-freight { display: none; }
.s3-line[data-method="total"] .s3-factor, .s3-line[data-method="freight"] .s3-factor, .s3-line[data-method="total"] .s3-calc { display: none; }
.s3-line[data-method="total"] .s3-total { display: inline; }
.s3-line[data-method="freight"] .s3-freight { display: table-row; }
.s3-line.removed { opacity: .45; }
.s3-freight-fields { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem 1rem; padding-bottom: .5rem; }
.s3-freight-fields label { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; font-weight: 500; color: var(--muted); }
.s3-freight-fields input { width: 8rem; }
.scope3-summary tr.subtotal td { font-style: normal; border-top: 1px solid var(--border); background: var(--cloud); }
label.inline { display: inline-flex; gap: .4rem; align-items: center; }

/* Account tables */
.table.metrics .current, .table .current { background: var(--wheat); }
.table tr.band th { background: var(--cloud); text-transform: none; letter-spacing: 0; font-size: .85rem; font-weight: 700; color: var(--farm); }
.table tr.band.sub th { background: transparent; font-weight: 500; color: var(--grain); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.table tr.subtotal td { font-style: italic; font-weight: 500; border-top: 1px solid var(--farm); }
.table tr.total td { font-weight: 700; border-top: 2px solid var(--farm); }
.table tfoot td { border-top: 2px solid var(--farm); border-bottom: 0; }

/* Compare */
.table.compare tr.flagged td { background: var(--wheat); }
.table.compare tr.flagged td:last-child, .flagged-cell { color: var(--rust); font-weight: 700; }
.table .group-head { text-align: center; border-bottom: 1px solid var(--border); }
.ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem 1rem; margin-bottom: 1.25rem; }
.ref-grid label, .csv-upload { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 500; }
.csv-upload code { display: inline-block; margin-top: .25rem; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .topbar-links { order: 3; width: 100%; margin: .5rem 0 0; }
  .grid-2.wide-left { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .page-head { align-items: stretch; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; border-radius: 12px; max-width: 100%; scrollbar-width: none; }
}

/* Energy inventory grid */
.import-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem 2rem; flex-wrap: wrap; }
.import-bar > div { flex: 1 1 380px; }
.import-form { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.energy-grid-card { padding: 1rem 1rem 1.25rem; }
.grid-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 8px; }
.energy-grid { border-collapse: separate; border-spacing: 0; font-size: .85rem; min-width: 100%; }
.energy-grid th, .energy-grid td { padding: 0; border-bottom: 1px solid var(--border); border-right: 1px solid var(--cloud); white-space: nowrap; background: var(--surface); }
.energy-grid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--cloud); padding: .55rem .6rem; text-align: left;
  font-size: .72rem; font-weight: 700; color: var(--farm); white-space: normal; min-width: 108px; vertical-align: bottom;
}
.energy-grid thead th span { display: block; font-weight: 400; color: var(--grain); }
.energy-grid .sticky { position: sticky; left: 0; z-index: 1; padding: .4rem .7rem; text-align: left; font-weight: 500; min-width: 190px; box-shadow: 1px 0 0 var(--border); }
.energy-grid thead .sticky { z-index: 3; }
.energy-grid input, .energy-grid select { width: 100%; border: 0; border-radius: 0; padding: .45rem .6rem; font: inherit; background: transparent; }
.energy-grid input { text-align: right; font-variant-numeric: tabular-nums; min-width: 100px; }
.energy-grid input:focus, .energy-grid select:focus { outline: 2px solid var(--farm); outline-offset: -2px; background: var(--surface); }
.energy-grid select { min-width: 70px; }
.energy-grid select.missing { background: var(--wheat); }
.energy-grid td.imported, .energy-grid td.imported input { background: var(--wattle); }
.energy-grid td.pasted, .energy-grid td.pasted input { background: var(--wheat); }
.energy-grid td.result { padding: .45rem .6rem; color: var(--muted); }
.energy-grid tr.new-row .sticky { background: var(--wheat); }
.energy-grid tfoot th, .energy-grid tfoot td { padding: .5rem .6rem; font-weight: 700; border-top: 2px solid var(--farm); background: var(--surface); position: sticky; bottom: 0; }
.energy-grid tfoot .sticky { z-index: 2; }
.import-form input[type=file] { min-width: 0; max-width: 100%; }
@media (max-width: 720px) {
  .import-form, .import-form input[type=file] { width: 100%; }
  .energy-grid .sticky { min-width: 120px; white-space: normal; }
}
.sheet-options { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: .4rem .8rem; }
.sheet-options[hidden] { display: none; }
.sheet-options label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
.sheet-options input { font: inherit; padding: .5rem .6rem; border: 1px solid var(--dusk); border-radius: 8px; width: 100%; }
.sheet-options p { grid-column: 1 / -1; margin: 0; }

/* Background job progress */
.job-progress { margin-top: 1rem; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--cloud); }
.job-progress-head { display: flex; justify-content: space-between; gap: 1rem; font-size: .88rem; font-weight: 500; margin-bottom: .5rem; }
.job-percent { font-variant-numeric: tabular-nums; color: var(--muted); }
.job-bar { height: 10px; border-radius: 999px; background: var(--dusk); overflow: hidden; }
.job-bar span {
  display: block; height: 100%; width: 0; border-radius: 999px; transition: width .35s ease;
  background: repeating-linear-gradient(-45deg, var(--farm) 0 10px, #3d3632 10px 20px);
  background-size: 28px 28px; animation: job-stripes 1s linear infinite;
}
.job-progress.succeeded .job-bar span { background: var(--grain); animation: none; }
.job-progress.failed { border-color: var(--rust); background: var(--wheat); }
.job-progress.failed .job-bar span { background: var(--rust); animation: none; }
.job-progress.failed .job-stage { color: var(--rust); }
@keyframes job-stripes { to { background-position: 28px 0; } }
@media (prefers-reduced-motion: reduce) { .job-bar span { animation: none; transition: none; } }
.job-steps { list-style: none; margin: .6rem 0 0; padding: 0; font-size: .8rem; color: var(--muted); max-height: 9.5rem; overflow-y: auto; }
.job-steps li { padding: .1rem 0 .1rem 1.3rem; position: relative; }
.job-steps li::before { content: "○"; position: absolute; left: 0; }
.job-steps li.done::before { content: "✓"; color: var(--grain); font-weight: 700; }
.job-steps li.current { color: var(--text); font-weight: 500; }
.job-steps li.current::before { content: "●"; color: var(--farm); }
.job-steps li.error::before { content: "✕"; color: var(--rust); }
form.busy { opacity: .6; pointer-events: none; }

/* Microsoft sign-in */
.ms-button { display: inline-flex; align-items: center; gap: .65rem; width: 100%; justify-content: center; }
.password-login { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.password-login summary { cursor: pointer; font-size: .9rem; color: var(--muted); margin-bottom: .75rem; }

/* allauth pages (templates/allauth) */
.allauth h2 { margin-top: 0; }
.allauth .actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.allauth .field-error { color: var(--rust); font-size: .85rem; font-weight: 400; }
.auth-back { margin-top: 1.5rem; }

/* Compare page: editable reference column */
.compare-grid .section-head th { background: var(--farm); color: var(--cloud); font-weight: 500; text-align: left; padding: .5rem .75rem; }
.compare-grid td.ref-col { padding: 0; min-width: 130px; }
.compare-grid td.ref-col input { width: 100%; border: 0; border-radius: 0; padding: .5rem .6rem; font: inherit; text-align: right; font-variant-numeric: tabular-nums; background: var(--wheat); background: color-mix(in srgb, var(--wheat) 45%, transparent); }
.compare-grid td.ref-col input:focus { outline: 2px solid var(--farm); outline-offset: -2px; background: var(--surface); }
.compare-grid td.ref-col.pasted input { background: var(--wattle); }
.compare-grid td.ref-col.invalid input { outline: 2px solid var(--rust); outline-offset: -2px; }
.compare-grid tr.subtotal td.ref-col { padding: .6rem .75rem; }
.compare-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.compare-upload { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.compare-upload summary { cursor: pointer; font-weight: 500; margin-bottom: .75rem; }
button:disabled { opacity: .65; cursor: progress; }

/* Cropping */
.card-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.table tr.section-row th { background: var(--surface); text-align: left; padding-top: 1rem; font-weight: 600; }
.table tr.section-row th a.small { margin-left: .75rem; font-weight: 400; }
.crop-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1.25rem; align-items: start; }
.crop-section { border: 0; border-top: 1px solid var(--border); padding: 1rem 0 0; margin: 0; }
.crop-section legend { font-weight: 600; padding-right: .5rem; }
.crop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .75rem 1rem; }
.crop-grid label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 500; }
.crop-grid label.inline { flex-direction: row; align-items: center; gap: .5rem; align-self: end; padding-bottom: .5rem; }
.crop-grid input[type=number], .crop-grid select { width: 100%; }
.push-right { margin-left: auto; }
.table.compact td, .table.compact th { padding: .35rem .5rem; font-size: .85rem; }
@media (max-width: 860px) { .crop-layout { grid-template-columns: 1fr; } }

/* Feedlot assessments and results */
.feedlot-grid .guid-input { width: 100%; min-width: 300px; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; padding: .4rem .5rem; }
.feedlot-grid tr.has-error td { background: var(--wheat); }
.error-text { display: block; }
.results-tabs { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .75rem; font-size: .85rem; }
.results-section-block { margin-top: 2rem; scroll-margin-top: 1rem; }
.results-section-block > .card { margin-bottom: 1rem; }
.results-heading { display: flex; align-items: center; gap: .75rem; font-size: 1.15rem; color: var(--muted); }
.results-heading::after { content: ""; flex: 1; height: 3px; border-radius: 3px; background: var(--border); }
.results-table { font-size: .8rem; }
.results-table td, .results-table th { padding: .3rem .55rem; white-space: nowrap; }
.results-table tr.results-section td { background: var(--surface); font-weight: 600; color: var(--muted); }
.results-table tr.results-total td { background: var(--farm); color: var(--cloud); font-weight: 600; }
.h5 { font-size: .9rem; margin: 1rem 0 .2rem; }
.check-title { font-weight: 600; font-size: .85rem; margin: 0 0 .4rem; }
.benchmark-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1.25rem; }
.benchmark-filters { display: flex; flex-direction: column; gap: .75rem; }
.benchmark-filters label { display: flex; flex-direction: column; gap: .25rem; }
.benchmark-filters label.inline { flex-direction: row; align-items: center; gap: .4rem; }
.benchmark-filters fieldset { border: 0; padding: 0; margin: 0; }
.dof-range { display: flex; align-items: center; gap: .3rem; }
.dof-range input { width: 5.5rem; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: .5rem; }
.segmented button { border: 0; background: transparent; padding: .4rem .7rem; font: inherit; font-size: .8rem; cursor: pointer; }
.segmented button.active { background: var(--farm); color: var(--cloud); }
.benchmark-summary { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: .5rem; }
.benchmark-summary div { display: flex; flex-direction: column; }
.benchmark-summary strong { font-size: 1.3rem; }
.benchmark-summary .good { color: #2f6b3a; }
.benchmark-summary .bad { color: var(--rust); }
.svg-chart { width: 100%; min-height: 120px; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: middle; margin: 0 .25rem 0 .75rem; }
.key-current { background: #BBCA80; } .key-bench { background: #79806A; } .key-avg { background: #C25B3C; height: 3px; }
.trend-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.trend-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .35rem; }
@media (max-width: 760px) { .benchmark-layout { grid-template-columns: 1fr; } }

/* Drill-down: the items behind a line (accounting/_drill.html) */
.drill-toggle { appearance: none; border: 0; background: none; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.drill-toggle::before { content: "▸"; display: inline-block; width: 1em; color: var(--grain); text-decoration: none; }
.drill-toggle[aria-expanded="true"]::before { content: "▾"; }
.drill-toggle:hover { text-decoration-style: solid; }
.drill-toggle:focus-visible { outline: 2px solid var(--farm); outline-offset: 2px; }
tr.drill-row > td { padding: 0 !important; background: var(--cloud) !important; font-style: normal; font-weight: 400; text-align: left; }
.drill { padding: .75rem 1rem 1rem 1.75rem; border-left: 3px solid var(--crop); max-height: 28rem; overflow: auto; }
.drill-head { margin: 0 0 .5rem; display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; }
.drill-table { width: 100%; background: var(--surface); font-size: .85rem; }
.drill-table tfoot td { font-weight: 700; }
.drill-excluded { margin: .6rem 0 0; }
.drill-table td { vertical-align: top; }
.drill-table td:nth-child(2) { min-width: 12rem; }

/* Carbon account: contribution analysis donut */
.donut-wrap { display: flex; align-items: center; justify-content: center; gap: 2.5rem; flex-wrap: wrap; margin: 1rem 0 .5rem; }
.donut { width: 240px; height: 240px; flex: none; }
.donut-label { fill: var(--muted); font-size: 12px; }
.donut-total { fill: var(--text); font-size: 20px; font-weight: 600; }
.donut-legend { border-collapse: collapse; font-size: .9rem; }
.donut-legend td { padding: .25rem .6rem; border-bottom: 1px solid var(--border); }
.donut-legend tr:last-child td { border-bottom: 0; }
.donut-legend .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.donut-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: .5rem; box-shadow: 0 0 0 1px rgba(40, 35, 32, .2); }
@media (max-width: 720px) { .donut { width: 200px; height: 200px; } }

/* --- Planning: scenario tables of inputs by year ----------------------- */
.plan-card .card-title-row { align-items: flex-end; margin-bottom: 1rem; }
.plan-name { display: flex; flex-direction: column; gap: .3rem; flex: 0 1 360px; font-weight: 500; }
.plan-grid { width: 100%; }
.plan-grid th.sticky span, .plan-grid tfoot th span { font-weight: 400; color: var(--grain); margin-left: .25rem; }
.plan-grid tbody th.sticky { white-space: normal; max-width: 260px; }
.plan-grid thead th:not(.sticky) { text-align: right; }
.plan-grid tr.plan-group th, .plan-grid tr.plan-group td { background: var(--cloud); padding: .4rem .7rem; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--grain); }
.plan-grid .plan-out { padding: .45rem .6rem; text-align: right; font-variant-numeric: tabular-nums; transition: opacity .15s; }
.plan-grid tbody .plan-out { background: var(--cloud); }
.plan-grid input:invalid { box-shadow: inset 0 0 0 2px var(--rust); }
/* The whole footer sticks, so its result rows stack instead of overlapping. */
.plan-grid tfoot { position: sticky; bottom: 0; z-index: 2; }
.plan-grid tfoot th, .plan-grid tfoot td { position: static; background: var(--wheat); }
.plan-grid tfoot th.sticky { position: sticky; left: 0; bottom: auto; }
.plan-grid tfoot tr + tr th, .plan-grid tfoot tr + tr td { border-top: 0; }
.plan-card.calculating .plan-out { opacity: .5; }
.plan-problems { margin: .6rem 0 0; padding-left: 1.1rem; color: var(--rust); }
.plan-problems:empty, .plan-paste-status:empty { display: none; }
.plan-paste-status { margin: .6rem 0 0; }
@media (max-width: 900px) { .topbar-links { flex-wrap: wrap; gap: .25rem 1.25rem; } }
/* Projections: a row for each year (carbon account), and the chart comparing pathways. */
.plan-rows .sticky { min-width: 90px; }
.plan-rows thead th:last-child, .plan-rows td.plan-remove { min-width: 0; width: 1%; padding: .3rem .7rem; font-size: .8rem; }
.plan-grid tbody .plan-result { background: var(--wheat); font-weight: 700; }
.plan-suggest { display: block; width: 100%; border: 0; background: none; padding: 0 .6rem .35rem; font: inherit; font-size: .72rem; text-align: right; color: var(--grain); cursor: pointer; white-space: nowrap; }
.plan-suggest:hover, .plan-suggest:focus-visible { color: var(--field); text-decoration: underline; }
.plan-suggest.differs { color: var(--rust); }
.plan-chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem 1.5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.plan-chart-head h2 { margin: 0; }
.plan-legend { display: flex; flex-wrap: wrap; gap: .3rem 1.25rem; align-items: center; list-style: none; margin: 0; padding: 0; }
.plan-legend svg, .plan-tip svg { vertical-align: middle; margin-right: .35rem; flex: none; }
.plan-tip span { display: flex; align-items: center; }
.plan-plot { position: relative; }
.plan-plot[hidden], .plan-chart-empty[hidden] { display: none; }
.plan-plot > svg { display: block; width: 100%; height: auto; }
.plan-plot .grid { stroke: var(--border); stroke-width: 1; }
.plan-plot .crosshair { stroke: var(--grain); stroke-width: 1; }
.plan-plot .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.plan-plot .end-label { font-size: 12px; fill: var(--text); }
.plan-plot .mark { stroke: var(--surface); stroke-width: 2; }
.plan-chart-empty { margin: 1rem 0 0; }
.plan-chart-more { margin: .5rem 0 0; }
.plan-tip { position: absolute; top: 0; transform: translateX(12px); pointer-events: none; display: flex; flex-direction: column; gap: .15rem; background: var(--surface); color: var(--text); border: 1px solid var(--dusk); box-shadow: 0 4px 14px rgb(40 35 32 / .12); font-size: .8rem; padding: .45rem .65rem; border-radius: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; z-index: 3; }
.plan-tip.flip { transform: translateX(calc(-100% - 12px)); }
.plan-tip[hidden] { display: none; }
