:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  color: #1c2927;
  background: #f3f5f4;
  --paper: #fff;
  --muted: #50625e;
  --line: #d9e3de;
  --soft: #f5f8f6;
  --ink: #192b26;
  --accent: #17664e;
  --selected: #eaf4ee;
  --radius: .5rem;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; line-height: 1.5; }
a { color: var(--accent); text-underline-offset: .18em; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid #258a67; outline-offset: 2px; }
[hidden] { display: none !important; }

.visually-hidden, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 10;
  padding: .65rem 1rem;
  background: var(--paper);
}

.workspace { display: grid; grid-template-columns: 13.75rem minmax(0, 1fr); }
.header { background: var(--ink); color: #fff; }
.workspace .header { position: sticky; top: 0; align-self: start; min-height: 100vh; }
.topbar { display: flex; align-items: center; padding: .95rem 1.25rem; }
.workspace .topbar { flex-direction: column; align-items: stretch; min-height: 100vh; padding: 1.45rem .9rem .85rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; color: inherit; line-height: 1.18; }
.workspace .brand { margin: 0 .35rem 1.8rem; }
.brand > span:last-child { font-size: .76rem; color: #c0cfc8; }
.brand strong { display: block; font-size: .98rem; color: #f5fbf7; margin-top: .16rem; }
.brand-mark { display: grid; place-items: center; flex: 0 0 2.35rem; height: 2.35rem; border-radius: .55rem; background: #c6edc9; color: #18352a; font-weight: 800; }
.topbar nav { display: grid; gap: .2rem; }
.topbar nav a, .plain { color: #d6e2dc; padding: .56rem .75rem; border-radius: .35rem; text-decoration: none; white-space: nowrap; }
.topbar nav a[aria-current], .topbar nav a:hover, .plain:hover { color: #fff; background: #304b40; }
.topbar nav a[aria-current] { font-weight: 650; box-shadow: inset 3px 0 #a8d9ae; }
.topbar form { margin-top: auto; }
.plain { border: 0; background: transparent; cursor: pointer; }

.container { width: min(100%, 98rem); margin-inline: auto; padding: 1.65rem clamp(1rem, 2.65vw, 2.85rem) 3rem; }
.centered { display: grid; justify-items: center; padding-top: clamp(2rem, 10vh, 7rem); }
h1, h2, p { margin-top: 0; }
h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.3rem); line-height: 1.14; letter-spacing: -.045em; overflow-wrap: anywhere; }
h2 { margin-bottom: .75rem; font-size: 1.08rem; line-height: 1.25; }
.heading, .section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .7rem; margin-bottom: 1.15rem; }
.section-heading { margin-top: 1.35rem; margin-bottom: .6rem; }
.section-heading h2 { margin: 0; }
.panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.padded, .login { padding: clamp(.9rem, 2vw, 1.4rem); }
.padded h1, .login h1 { margin-bottom: 1.05rem; }
.narrow { max-width: 40rem; }
.panel.login { width: min(100%, 24rem); }

.stock-workspace { display: grid; gap: .9rem; align-items: start; }
.stock-workspace:has(.stock-preview) { grid-template-columns: minmax(0, 1fr) minmax(15.5rem, 18rem); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .12rem .5rem; min-height: 3rem; padding: .35rem .7rem; border-bottom: 1px solid var(--line); }
.filters a { display: inline-flex; align-items: center; gap: .42rem; padding: .35rem .55rem; border-radius: .3rem; color: var(--muted); font-size: .88rem; font-weight: 650; text-decoration: none; }
.filters a:hover, .filters a[aria-current] { background: var(--selected); color: #13573f; }
.filters span { font-variant-numeric: tabular-nums; font-size: .8rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; padding: .75rem; border-bottom: 1px solid var(--line); }
.toolbar label { flex: 0 1 20rem; min-width: 9rem; }
.stock-search label { flex: 1 1 12rem; }
.stock-preview { padding: .9rem 1rem; scroll-margin-top: 6rem; }
.preview-heading { display: grid; justify-items: start; gap: .35rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.preview-heading .code { color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }
.preview-heading h2 { margin: 0; overflow-wrap: anywhere; }
.stock-preview dl { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); padding-block: .85rem; }
.stock-preview dd { text-align: right; font-variant-numeric: tabular-nums; }
.stock-preview .actions { padding-top: .75rem; border-top: 1px solid var(--line); }

.button { display: inline-flex; gap: .25rem; align-items: center; justify-content: center; border: 1px solid #c7d4cc; border-radius: .35rem; background: var(--paper); color: #233932; min-height: 2.25rem; padding: .35rem .72rem; font-size: .9rem; font-weight: 650; line-height: 1.25; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--soft); border-color: #8fa79b; }
.button:disabled { opacity: .55; cursor: default; }
.delete-link { color: #983539; white-space: nowrap; }
.movement-actions { display: flex; gap: .65rem; align-items: flex-start; }
.movement-actions > .delete-link { margin-top: .38rem; }
.print-menu { min-width: max-content; }
.print-toggle { list-style: none; min-width: 2.35rem; padding-inline: .45rem; }
.print-toggle::-webkit-details-marker { display: none; }
.print-menu[open] .print-toggle { background: var(--selected); }
.print-options { display: grid; width: max-content; margin-top: .3rem; background: var(--paper); border: 1px solid var(--line); border-radius: .35rem; }
.print-options a { padding: .35rem .55rem; text-decoration: none; }
.print-options a:hover, .print-options a:focus-visible { background: var(--soft); }
.danger { background: #983539; border-color: #983539; color: #fff; }
.danger:hover { background: #79272c; border-color: #79272c; }
.cancellation-form { margin-top: .8rem; }
.cancellation-form p { margin: 0; }
.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.primary:hover { background: #11533f; border-color: #11533f; }
.stack { display: grid; gap: .8rem; }
.stack > .button { justify-self: start; }
.login .stack > .button { justify-self: stretch; }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; }
label { display: grid; align-content: start; gap: .25rem; color: #334941; font-size: .87rem; font-weight: 650; }
input, select, textarea { width: 100%; min-width: 0; min-height: 2.25rem; padding: .32rem .5rem; background: var(--paper); border-radius: .33rem; border: 1px solid #bccdc2; color: #192a24; }
input::placeholder { color: #63756d; }
input[readonly] { background: var(--soft); }
textarea { resize: vertical; }
.warranty-editor { max-width: 66rem; }
.warranty-editor textarea { font-size: .95rem; font-weight: 400; line-height: 1.55; padding: .75rem; }
.fields, .split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); align-items: start; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .53rem .66rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
thead th { color: #3d534a; background: var(--soft); font-size: .81rem; font-weight: 650; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: var(--soft); }
tbody th { min-width: 8.5rem; font-weight: 650; }
tbody th a { color: #1b533f; text-decoration: none; }
tbody th a:hover { text-decoration: underline; }
.stock-table { min-width: 36rem; font-size: .89rem; }
.stock-table .price-cell { white-space: nowrap; }
.import-table { min-width: 59rem; }
.import-table .price-cell { white-space: nowrap; }
.import-table input[type="number"] { width: 6rem; }
.warranty-input { width: 5.5rem; }
.warranty-warning { max-width: 12rem; margin-top: .25rem; color: #81511c; }

.print-view .container { max-width: 56rem; }
.print-toolbar { justify-content: space-between; margin-bottom: .8rem; }
.print-sheet { padding: clamp(.8rem, 3vw, 2.2rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.print-brand { margin-bottom: .25rem; font-weight: 700; }
.print-meta { grid-template-columns: max-content minmax(0, 1fr); margin: 1rem 0; }
.print-table-wrap { overflow-x: auto; }
.print-items { min-width: 34rem; }
.print-items :is(th, td) { overflow-wrap: anywhere; }
.print-items .code { min-width: 9.5em; }
.print-items :is(th, td):nth-child(3), .print-items td:nth-child(4) { white-space: nowrap; }
.print-items tbody small { font-weight: 400; }
.print-terms { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }

@page { size: A4 portrait; margin: 14mm; }
@media print {
  :root { background: white; }
  .print-view { min-height: 0; color: black; font-size: 10pt; }
  .print-view .container { max-width: none; padding: 0; }
  .print-view h1 { font-size: 22pt; letter-spacing: normal; }
  .print-view h2 { font-size: 15pt; }
  .print-toolbar { display: none; }
  .print-sheet { padding: 0; border: 0; }
  .print-table-wrap { overflow: visible; }
  .print-items { min-width: 0; }
  .print-items thead { display: table-header-group; }
  .print-items tr { break-inside: avoid; }
  .print-items :is(th, td) { padding: 5pt; border-bottom: 1px solid #b7b7b7; }
  .print-terms { break-before: page; margin: 0; padding: 0; border: 0; }
}
.stock-table .selected-row { background: var(--selected); }
.stock-table .selected-row th { box-shadow: inset 3px 0 #3d946f; }
.table-footer { display: flex; gap: .5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; min-height: 2.65rem; padding: .4rem .75rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.table-footer .pagination { margin: 0; }
small { display: block; color: var(--muted); font-weight: 400; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: .86em; }
.tag { display: inline-block; padding: .12rem .4rem; border-radius: .27rem; white-space: nowrap; font-size: .8rem; font-weight: 650; }
.in-stock { color: #1c5d40; background: #e4f2e8; }
.low-stock { color: #6e4614; background: #fff1d6; }
.empty-stock, .out-stock { color: #8d363a; background: #fae8e9; }
.empty { color: var(--muted); margin: 0; padding: 1.2rem .75rem; }
.back { display: inline-block; margin-bottom: .55rem; color: var(--muted); }
.context .back { margin: 0 0 0 .65rem; }
dl { display: grid; grid-template-columns: minmax(6rem, 1fr) minmax(0, 1.5fr); gap: .42rem .65rem; margin: 0; font-size: .9rem; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.message { padding: .6rem .75rem; border: 1px solid; border-radius: .35rem; }
.message.error { color: #7d2529; background: #fdf0f1; border-color: #edbdc0; }
.message.success { color: #20593c; background: #eaf6ee; border-color: #b9d9c5; }
.pagination { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; color: var(--muted); }
.product-form { max-width: 72rem; }
.edit-columns { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 1.15rem; }
.edit-columns > section { min-width: 0; }
.edit-columns > section + section { border-inline-start: 1px solid var(--line); padding-inline-start: 1.15rem; }
.edit-columns h2 { margin: 0; }
.supplier-field { gap: .25rem; }
.supplier-field a { justify-self: start; font-size: .83rem; }
.form-actions { border-top: 1px solid var(--line); padding-top: .85rem; margin-top: .2rem; }
.price-box { border: 1px solid var(--line); border-radius: .36rem; margin: 0; padding: .68rem; min-width: 0; }
.price-box legend { padding-inline: .32rem; color: #334941; font-size: .9rem; font-weight: 650; }
.price-fields { grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(4.2rem, .66fr); gap: .45rem; }
.hint { font-weight: 400; font-size: .8rem; color: var(--muted); }
.note-panel { margin-block: .8rem; }
.multiline { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 0; }
.checkbox { display: inline-flex; align-items: center; gap: .35rem; margin-inline-end: .6rem; }
.checkbox input { width: 1rem; min-height: 1rem; accent-color: var(--accent); }
.movement-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(7rem, .25fr) auto; gap: .55rem; align-items: start; }
.movement-row > button { margin-top: 1.55rem; }
.product-picker { position: relative; min-width: 0; }
.product-results { position: absolute; z-index: 2; inset: auto 0 auto; background: var(--paper); border: 1px solid #aec1b6; border-radius: .35rem; box-shadow: 0 .45rem .95rem #19362a21; max-height: 16rem; overflow: auto; }
.product-results button { color: #1c2927; display: block; border: 0; background: transparent; text-align: start; width: 100%; padding: .45rem .6rem; cursor: pointer; }
.product-results button:hover, .product-results button:focus-visible { background: var(--selected); outline-offset: -2px; }
.product-results .hint { display: block; padding: .55rem; }
.add-line { margin-top: .55rem; }

@media (max-width: 79rem) {
  .stock-workspace:has(.stock-preview) { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 54rem) {
  .workspace { display: block; }
  .workspace .header { position: static; min-height: 0; }
  .workspace .topbar { flex-direction: row; align-items: center; flex-wrap: wrap; min-height: 0; gap: .45rem; padding: .65rem 1rem; }
  .workspace .brand { margin: 0; }
  .topbar nav { order: 3; width: 100%; display: flex; overflow-x: auto; padding: .15rem; }
  .topbar nav a { padding: .45rem .6rem; font-size: .9rem; }
  .topbar form { margin: 0 0 0 auto; }
  .stock-preview { scroll-margin-top: .75rem; }
}
@media (max-width: 44rem) {
  .split, .edit-columns { grid-template-columns: minmax(0, 1fr); }
  .edit-columns > section + section { border-inline-start: 0; border-top: 1px solid var(--line); padding: .85rem 0 0; }
}
@media (max-width: 36rem) {
  .movement-row { grid-template-columns: minmax(0, 1fr) auto; }
  .movement-row .product-picker { grid-column: 1 / -1; }
  .movement-row > button { margin-top: 1.55rem; }
}
@media (max-width: 25rem) {
  .fields:not(.price-fields) { grid-template-columns: minmax(0, 1fr); }
  .price-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .price-fields label:last-child { grid-column: 1 / -1; }
}
