:root {
  color-scheme: light;
  font: 15px/1.45 "Instrument Sans", "Segoe UI", sans-serif;
  --ink: #182322;
  --muted: #526361;
  --border: #d9e1df;
  --panel: #fff;
  --surface: #f3f6f4;
  --accent: #d3ef9e;
  --accent-hover: #bedf81;
  --sidebar: #182724;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--surface); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button, a, input, select, textarea { outline-offset: 3px; }
:focus-visible { outline: 2px solid #47754d; }
a { color: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
aside { padding: 27px 18px; color: #f4f8f3; background: var(--sidebar); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; width: fit-content; margin-inline: 7px; font-size: 27px; font-weight: 750; letter-spacing: -1.4px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 9px; color: var(--sidebar); background: var(--accent); font-size: 23px; font-style: italic; letter-spacing: -1px; }
.brand-accent { color: var(--accent); }
.workspace { margin: 27px 7px 15px; font-size: 13px; color: #c2ceca; }
nav { display: flex; flex-direction: column; gap: 6px; }
nav button, nav a { text-align: left; background: transparent; color: #e8f0ed; border: 0; padding: 10px 12px; border-radius: 8px; text-decoration: none; }
nav button:hover, nav button[aria-current], nav a:hover, nav a[aria-current] { background: #30423c; }
nav button > span { color: var(--accent); margin-right: 7px; }
main { width: 100%; max-width: 1510px; padding: 36px clamp(22px, 4vw, 62px) 55px; }
#status { display: none; margin: 0 0 16px; padding: 10px 14px; background: #e2efdb; border: 1px solid #bccdb5; border-radius: 8px; }
#status:not(:empty) { display: block; }
#status.error { background: #fff0eb; border-color: #e5bbb0; color: #7e3220; }
.page-header, .register-header, .actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.page-header { margin-bottom: 26px; }
.editor-header { margin-top: 12px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(31px, 4vw, 43px); letter-spacing: -.05em; line-height: 1.12; }
h2 { font-size: 18px; letter-spacing: -.02em; }
h3 { font-size: 19px; }
.page-header p, .sign-in > p { color: var(--muted); margin-top: 7px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.sign-in { max-width: 440px; margin: min(10vh, 75px) auto 0; padding: clamp(22px, 4vw, 36px); }
.sign-in h1 { font-size: 32px; }
.sign-in form { margin-top: 24px; display: grid; gap: 16px; }
.primary, .secondary { border: 1px solid transparent; border-radius: 8px; padding: 10px 16px; font-weight: 650; white-space: nowrap; }
.primary { background: var(--accent); border-color: #bfd88c; color: #172616; }
.primary:hover:enabled { background: var(--accent-hover); }
.primary span { font-size: 18px; line-height: 0; margin-right: 4px; }
.secondary { background: #fff; border-color: var(--border); color: var(--ink); }
.secondary:hover:enabled { background: var(--surface); }
.text-button { border: none; padding: 0; background: transparent; color: #3e6350; text-decoration: underline; text-underline-offset: 3px; }
.register-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.count { display: inline-block; margin-left: 5px; padding: 2px 8px; border-radius: 20px; background: #edf3ed; color: var(--muted); font-size: 12px; vertical-align: 2px; }
.search input { width: min(280px, 36vw); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 12px 18px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
th { font-size: 13px; color: var(--muted); background: #f8faf9; }
td:last-child { white-space: nowrap; }
tbody tr:last-child td { border: 0; }
.align-right { text-align: right; }
.empty { padding: 62px 16px 72px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; background: #eef3e8; color: #365340; margin: 0 auto 15px; border-radius: 10px; font-size: 23px; }
.empty p { color: var(--muted); margin-top: 7px; }
#invoice-form { display: grid; gap: 14px; }
.details-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
fieldset, .notes, .totals { margin: 0; min-width: 0; padding: 16px 19px; }
fieldset h2 { margin-bottom: 12px; }
fieldset > label, .field-pair, .item-head, .item-row { margin-top: 10px; }
label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
input, textarea, select { width: 100%; min-width: 0; border: 1px solid #c4cfcc; border-radius: 7px; padding: 8px 9px; background: white; color: var(--ink); font-size: 15px; }
textarea { resize: vertical; }
.field-pair { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.item-row, .item-head { display: grid; gap: 8px; align-items: center; grid-template-columns: minmax(150px, 3fr) minmax(55px, .65fr) minmax(83px, 1fr) minmax(100px, 1fr) minmax(70px, auto) 33px; }
.item-head { color: var(--muted); font-size: 13px; }
.item-row label > span { position: absolute; clip-path: inset(50%); }
.item-row output { text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.item-row button { padding: 3px; font-size: 19px; }
#add-line { margin-top: 13px; }
.totals { align-self: start; }
.totals div { display: flex; justify-content: space-between; padding: 7px 0; }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.grand-total { border-top: 1px solid var(--border); font-weight: 700; font-size: 21px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#print-page { display: none; }
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 176px minmax(0, 1fr); }
  .item-head, .item-row { grid-template-columns: minmax(105px, 2fr) 51px 75px 94px minmax(55px, auto) 31px; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  aside { padding: 12px 16px; flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .workspace { display: none; }
  main { padding: 22px 14px 34px; }
  .brand { margin: 0; font-size: 23px; }
  .details-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .page-header, .register-header { align-items: flex-start; flex-direction: column; }
  .search, .search input { width: 100%; }
  .item-head { display: none; }
  .item-row { grid-template-columns: .65fr 1fr 1.15fr; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
  .item-row label > span { position: static; clip-path: none; }
  .item-row label:first-child { grid-column: 1 / -1; }
  .item-row output { grid-column: 1 / 3; text-align: left; }
}
@media print {
  .app-shell { display: none !important; }
  #print-page:not([hidden]) { display: block; color: #000; font-size: 10pt; }
  #print-page h1 { font-size: 23pt; margin-bottom: 8pt; }
  #print-page h2 { font-size: 12pt; margin: 9pt 0 4pt; }
  #print-page table { margin: 12pt 0; }
  #print-page th, #print-page td { padding: 5pt; border-color: #bbb; }
  #print-page tr { break-inside: avoid; }
  #print-page p { white-space: pre-wrap; overflow-wrap: anywhere; }
  .print-parties { display: grid; gap: 12pt; grid-template-columns: 1fr 1fr; }
  .print-totals { text-align: right; }
}
