/* Stocked app. Same tokens and type as stocked.pt: teal for the plan, amber for excess, red for risk. */
@font-face { font-family: "Heros"; src: url("/fonts/heros-regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Heros"; src: url("/fonts/heros-bold.woff") format("woff"); font-weight: 700; font-display: swap; }
:root {
  --teal: #0E5C55; --teal-deep: #0A4540; --amber: #F2B33D; --ink: #14211E; --muted: #55615D;
  --mist: #E8F0EE; --line: #D3D9D7; --paper: #FFFFFF; --red: #B42318; --wash: #F6F8F7;
}
* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; }
body { font-family: "Heros", "Helvetica Neue", Helvetica, Arial, sans-serif; color: var(--ink); background: var(--wash); font-size: 15px; line-height: 1.5; font-variant-numeric: tabular-nums; }
h1 { font-size: 1.9rem; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 0; }
p { margin: 0 0 1rem; }
.lead { color: var(--muted); max-width: 72ch; margin-bottom: 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.flag { color: var(--red); font-weight: 700; margin: 0.25rem 0 0; }
.ok { color: var(--teal); font-weight: 700; }
button { font: inherit; cursor: pointer; border-radius: 3px; border: 2px solid var(--teal); background: var(--teal); color: #fff; padding: 0.5rem 0.9rem; font-weight: 700; }
button:hover { background: var(--teal-deep); border-color: var(--teal-deep); }
button.secondary { background: transparent; color: var(--teal); }
button.secondary:hover { background: var(--mist); }
button.link { background: none; border: 0; color: var(--teal); padding: 0.25rem 0; font-weight: 700; text-decoration: underline; }
button:disabled { opacity: 0.6; cursor: default; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
a { color: var(--teal); }
input, select { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 3px; padding: 0.45rem 0.6rem; background: #fff; min-height: 38px; }

/* shell */
.shell { min-height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1.25rem; padding: 0.7rem 1.5rem; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.35rem; color: var(--ink); text-decoration: none; }
.brand::before { content: ""; width: 0.8rem; height: 0.8rem; background: var(--amber); }
.org { color: var(--muted); border-left: 1px solid var(--line); padding-left: 1.25rem; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.langs button { background: #fff; color: var(--muted); border: 0; border-radius: 0; padding: 0.3rem 0.55rem; font-size: 0.8rem; }
.langs button.active { background: var(--ink); color: #fff; }
.demo-banner { margin: 0; padding: 0.5rem 1.5rem; background: #FDF3DD; color: #7A5300; font-size: 0.875rem; border-bottom: 1px solid #F2D9A0; }
.body { flex: 1; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.side { display: flex; flex-direction: column; gap: 0.15rem; padding: 1.25rem 0.75rem; border-right: 1px solid var(--line); background: var(--paper); }
.side button { text-align: left; background: transparent; color: var(--ink); border: 0; padding: 0.55rem 0.75rem; font-weight: 400; }
.side button:hover { background: var(--mist); }
.side button.active { background: var(--mist); color: var(--teal); font-weight: 700; box-shadow: inset 3px 0 0 var(--teal); }
.side .disabled { padding: 0.55rem 0.75rem; color: #9AA4A0; }
.side small { font-size: 0.72rem; margin-left: 0.25rem; }
.content { padding: 2rem clamp(1rem, 3vw, 2.5rem) 3rem; min-width: 0; }
.center { min-height: 60vh; display: grid; place-items: center; }

/* figures: a ruled list, as in the reports */
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 0 2rem; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); background: var(--paper); }
.figures > div { padding: 0.9rem 1rem; border-right: 1px solid var(--line); }
.figures > div:last-child { border-right: 0; }
.figures dt { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; color: var(--teal); line-height: 1.1; }
.figures dd { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.875rem; }
.figures .warn dt { color: var(--red); }

/* this week, per supplier */
.supplier { background: var(--paper); border: 1px solid var(--line); margin-bottom: 1.25rem; padding: 1rem 1.25rem 0.75rem; }
.supplier header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.75rem; }
.meta { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.875rem; display: flex; flex-wrap: wrap; gap: 0 1.1rem; }
.meta strong { color: var(--ink); }
table.grid { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.grid th { text-align: left; font-weight: 700; font-size: 0.78rem; color: var(--muted); border-bottom: 1px solid var(--ink); padding: 0.4rem 0.5rem; vertical-align: bottom; }
.grid td { border-bottom: 1px solid var(--line); padding: 0.45rem 0.5rem; }
.grid th:first-child, .grid td:first-child { padding-left: 0; }
.num { text-align: right; }
.code { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.strong { font-weight: 700; }
.risk { color: var(--red); }

/* products, virtualised */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.9rem; margin-bottom: 1rem; }
.filters input[type=search] { width: min(320px, 100%); }
.check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; }
.check input { min-height: 0; }
.count { margin-left: auto; font-size: 0.875rem; }
.vtable { background: var(--paper); border: 1px solid var(--line); font-size: 0.85rem; overflow-x: auto; }
.vrow { display: grid; grid-template-columns: 74px minmax(160px, 2.2fr) 44px minmax(90px, 1fr) 84px 66px 72px 84px 84px 76px minmax(88px, 1fr); align-items: center; gap: 0 0.5rem; padding: 0 0.9rem; height: 41px; border-bottom: 1px solid var(--line); min-width: 1030px; }
.vbody .vrow { position: absolute; top: 0; left: 0; right: 0; }
.vhead { height: auto; min-height: 48px; padding-top: 0.45rem; padding-bottom: 0.45rem; border-bottom: 1px solid var(--ink); font-size: 0.76rem; color: var(--muted); font-weight: 700; position: sticky; top: 0; background: var(--paper); z-index: 1; }
.vhead .sortable { cursor: pointer; }
.vhead .sorted { color: var(--teal); text-decoration: underline; }
.vbody { height: calc(100vh - 290px); min-height: 360px; overflow-y: auto; min-width: 1030px; }
.desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark polyline { fill: none; stroke: var(--ink); stroke-width: 1.1; }
.spark circle { fill: var(--ink); }

/* page head with an action on the right */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.head-action { text-align: right; flex-shrink: 0; padding-top: 0.4rem; }
.own { color: var(--teal); font-weight: 700; }
.nowrap { white-space: nowrap; }
.panel { background: var(--paper); border: 1px solid var(--line); padding: 0.75rem 1.25rem; overflow-x: auto; }
.panel.empty { padding: 1.25rem; }

/* action box */
.actionbox { background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--amber); padding: 0.9rem 1.1rem 0.4rem; margin: 0 0 2rem; }
.actionbox label { display: block; font-weight: 700; margin-bottom: 0.4rem; }
.ab-row { display: flex; gap: 0.6rem; }
.ab-row input { flex: 1; min-width: 0; }
.actionbox .muted.small { margin: 0.45rem 0 0.5rem; }
.examples { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.6rem; }
button.chip { background: var(--wash); color: var(--ink); border: 1px solid var(--line); font-weight: 400; font-size: 0.82rem; padding: 0.25rem 0.6rem; border-radius: 999px; }
button.chip:hover { background: var(--mist); border-color: var(--teal); }

/* preview dialog */
.overlay { position: fixed; inset: 0; background: rgba(20, 33, 30, 0.45); display: grid; grid-template-columns: minmax(0, 760px); justify-content: center; align-items: start; padding: 6vh 1rem 2rem; overflow-y: auto; z-index: 10; }
.dialog { width: 100%; min-width: 0; background: var(--paper); border-top: 4px solid var(--teal); padding: 1.5rem 1.75rem 1.25rem; box-shadow: 0 18px 50px rgba(20, 33, 30, 0.25); }
.dialog h2 { font-size: 1.35rem; margin-bottom: 0.6rem; }
.dialog h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 1.25rem 0 0.4rem; }
.quote { font-size: 1.05rem; border-left: 3px solid var(--line); padding-left: 0.75rem; color: var(--ink); }
.note { background: #FDF3DD; color: #7A5300; padding: 0.5rem 0.75rem; font-size: 0.875rem; }
.effect { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; border-top: 2px solid var(--ink); }
.effect > div { padding: 0.6rem 0.75rem 0.6rem 0; border-bottom: 1px solid var(--line); }
.effect dt { font-weight: 700; font-size: 1.1rem; color: var(--teal); }
.effect dd { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.82rem; }
.desc-cell { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dialog-actions { display: flex; gap: 0.6rem; margin-top: 1.5rem; }
.picker { list-style: none; margin: 0.5rem 0 0; padding: 0; max-height: 300px; overflow-y: auto; border-top: 1px solid var(--line); }
.picker li { border-bottom: 1px solid var(--line); padding: 0.35rem 0; }
.picker .code { margin-right: 0.35rem; }
.pick-all { font-weight: 700; }

/* suppliers */
.suppliers-table td:first-child { white-space: nowrap; }
.row-actions { display: flex; gap: 0.6rem; justify-content: flex-end; align-items: center; }
.suppliers-table tfoot td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 0; }
.suppliers-table tr.editing td { background: var(--mist); }
.cell-input { width: 4.5rem; min-height: 32px; padding: 0.2rem 0.4rem; text-align: right; }
.cell-input.wide { width: 6.5rem; }
button.small-btn { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

/* history */
.history { list-style: none; padding: 0; margin: 0; background: var(--paper); border: 1px solid var(--line); }
.history > li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--line); }
.history > li:last-child { border-bottom: 0; }
.history .is-undone .h-what { text-decoration: line-through; color: var(--muted); }
.h-what { margin: 0; font-weight: 700; }
.h-lines { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.875rem; }
.h-side { flex-shrink: 0; align-self: center; }
.tag { font-size: 0.78rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); padding: 0.15rem 0.5rem; border-radius: 3px; }

/* data */
.kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kind { background: var(--paper); border: 1px solid var(--line); padding: 1rem 1.25rem; display: flex; flex-direction: column; }
.kind header { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.kind p { margin-bottom: 0.6rem; }
.kind .muted.small { margin-top: auto; }
.file-btn { align-self: flex-start; display: inline-block; border: 2px solid var(--teal); color: var(--teal); font-weight: 700; padding: 0.4rem 0.8rem; border-radius: 3px; cursor: pointer; }
.file-btn:hover { background: var(--mist); }
.file-btn:focus-within { outline: 3px solid var(--amber); outline-offset: 2px; }
.file-btn.disabled { opacity: 0.55; cursor: default; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tag.new { color: #7A5300; background: #FDF3DD; border-color: #F2D9A0; }
.panel.update { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; padding: 1rem 1.25rem; border-left: 4px solid var(--teal); }
.panel.update h2 { margin-bottom: 0.3rem; }
.panel.update p { margin: 0 0 0.3rem; max-width: 70ch; }
.panel.update button { flex-shrink: 0; }
.panel.email { margin-top: 1rem; padding: 1rem 1.25rem; }
.panel.email h2 { margin-bottom: 0.3rem; }
.panel.email p { margin: 0 0 0.4rem; max-width: 70ch; }
label.check { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0; font-weight: 600; cursor: pointer; }
label.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--teal); }
.section-h { margin: 2rem 0 0.75rem; }
.status { font-size: 0.78rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 3px; margin-right: 0.35rem; }
.st-queued, .st-running { background: #FDF3DD; color: #7A5300; }
.st-done { background: var(--mist); color: var(--teal); }
.st-failed { background: #FBEBEB; color: var(--red); }
.checks { margin-top: 0.6rem; }
.chk { font-size: 0.75rem; font-weight: 700; }
.chk-OK { color: var(--teal); }
.chk-WARN { color: #7A5300; }
.chk-FAIL { color: var(--red); }
.runs .h-main { width: 100%; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-box { width: min(420px, 100%); background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--teal); padding: 2rem; }
.login-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.login form { display: grid; gap: 0.5rem; margin-bottom: 1.5rem; }
.login label { font-weight: 700; font-size: 0.9rem; }

@media (max-width: 860px) {
  .body { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0.5rem; }
  .side .disabled { display: none; }
  .kinds { grid-template-columns: minmax(0, 1fr); }
  .panel.update { flex-direction: column; align-items: stretch; }
  .figures { grid-template-columns: minmax(0, 1fr); }
  .figures > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .supplier header { flex-direction: column; }
  .org { display: none; }
  table.grid { display: block; overflow-x: auto; }
  .page-head, .ab-row { flex-direction: column; align-items: stretch; }
  .head-action { text-align: left; }
  .effect { grid-template-columns: minmax(0, 1fr); }
  .history > li { flex-direction: column; }
  .dialog { padding: 1.1rem 1rem; }
  .dialog .changes .nowrap { white-space: normal; }
  .dialog .desc-cell { max-width: 150px; }
  .overlay { padding: 1rem 0.5rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Porquê? */
.vrow.clickable { cursor: pointer; }
.vrow.clickable:hover { background: var(--mist, #E8F0EE); }
.why-cell { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.why-link { font-size: 0.82rem; white-space: nowrap; }
.product-link { text-align: left; font: inherit; color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; padding: 0; }
.product-link:hover { color: var(--teal); text-decoration-color: currentColor; }
.tag.mini { font-size: 0.7rem; padding: 0.05rem 0.35rem; margin-left: 0.4rem; }
.tag.order { color: var(--teal); border-color: var(--teal); }
.dialog.why .why-code { margin: 0 0 0.2rem; }
.dialog.why .tags { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0 0 0.75rem; }
.why-text p { margin: 0 0 0.55rem; max-width: 64ch; }
.why-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem 1rem; margin: 0; }
.why-facts div { border-top: 1px solid var(--line); padding-top: 0.35rem; }
.why-facts dt { font-size: 0.78rem; color: var(--muted); }
.why-facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.why-estimate { margin-top: 1.25rem; padding: 0.9rem 1rem; background: #FDF3DD; border-left: 3px solid #F2B33D; }
.why-estimate label { display: block; font-weight: 700; margin-bottom: 0.4rem; }
.why-estimate .row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.why-estimate input { width: 8rem; }
.why-estimate p { margin: 0.4rem 0 0; }
.dialog.why .dialog-actions { justify-content: space-between; align-items: center; }
@media (max-width: 640px) { .why-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
