:root {
  color-scheme: light;
  font-family: 'DM Sans', system-ui, sans-serif;
  color: #202621;
  background: #f5f6f0;
  --ink: #202621;
  --muted: #5b665d;
  --line: #dfe4da;
  --paper: #fff;
  --green: #284135;
  --accent: #d4ef84;
  --soft: #ebf0e5;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #557b48;
  outline-offset: 3px;
}
h1, h2, .brand, .metric-value { font-family: 'Instrument Sans', system-ui, sans-serif; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2.15rem, 5vw, 3.35rem); font-weight: 800; line-height: 1.08; letter-spacing: -.065em; }
h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: -.035em; }
.loading { margin: 3rem; color: var(--muted); }
.brand { display: flex; align-items: center; gap: .7rem; font-size: 1.04rem; font-weight: 800; letter-spacing: -.035em; }
.mark {
  width: 2.15rem; height: 2.15rem; display: inline-grid; place-items: center;
  background: var(--accent); border-radius: .65rem; color: #243729; flex: none;
}
.mark::before {
  content: ''; width: .88rem; height: .88rem; border: 2px solid currentColor; border-radius: 2px;
  background: linear-gradient(90deg, transparent 43%, currentColor 44%, currentColor 56%, transparent 57%);
  transform: rotate(-12deg);
}
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(275px, .8fr) minmax(320px, 1fr); }
.auth-aside { background: #233a30; color: #f8faef; padding: clamp(1.5rem, 5vw, 4rem); display: flex; flex-direction: column; min-height: 450px; overflow: hidden; }
.auth-aside .brand { position: relative; z-index: 1; }
.auth-aside h2 { position: relative; max-width: 8em; margin: auto 0 0; font-size: clamp(2.8rem, 6vw, 5.7rem); line-height: .99; letter-spacing: -.075em; z-index: 1; }
.auth-art { width: min(82%, 28rem); aspect-ratio: 1; margin: 2rem 0 2.25rem auto; position: relative; opacity: .84; }
.auth-art span { position: absolute; border: 1px solid #aec688; border-radius: 20%; width: 70%; height: 70%; transform: rotate(-13deg) skewY(8deg); }
.auth-art span:nth-child(1) { right: 0; top: 5%; background: #314d3c; }
.auth-art span:nth-child(2) { right: 11%; top: 18%; background: #4a6646; }
.auth-art span:nth-child(3) { right: 22%; top: 31%; background: #b9d573; }
.auth-main { display: grid; place-items: center; padding: 2rem clamp(1.4rem, 5vw, 4rem); }
.auth-panel { width: min(100%, 405px); }
.auth-panel h1 { margin-bottom: .8rem; }
.auth-panel > p { color: var(--muted); margin-bottom: 1.6rem; line-height: 1.55; }
.auth-panel .primary { width: 100%; margin-top: .2rem; }
.auth-panel .secondary { width: 100%; margin-top: .7rem; }
.demo-options { margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.demo-options p { font-size: .83rem; font-weight: 700; color: var(--muted); margin-bottom: .55rem; }
.demo-buttons { display: flex; flex-wrap: wrap; gap: .4rem; }
.demo-buttons button { font-size: .8rem; }
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #263b32; color: #f2f5e9; min-width: 0; padding: 1.65rem 1.15rem 1.25rem; display: flex; flex-direction: column; gap: 1.8rem; }
.sidebar .brand { padding: 0 .35rem; }
.nav { display: grid; gap: .35rem; }
.nav button { color: #d5dfd5; background: transparent; border: 1px solid transparent; text-align: left; border-radius: .55rem; padding: .68rem .75rem; font-weight: 600; }
.nav button:hover { background: #364e42; }
.nav button[aria-current="page"] { background: var(--accent); color: #223529; font-weight: 800; }
.nav button::before { content: ''; width: .46rem; height: .46rem; border: 1.5px solid currentColor; border-radius: 2px; display: inline-block; margin-right: .65rem; vertical-align: .08em; }
.sidebar-footer { margin-top: auto; display: grid; gap: .55rem; }
.sidebar-footer p { padding: 0 .45rem; color: #d5dfd5; font-size: .86rem; overflow-wrap: anywhere; }
.sidebar-footer button { color: #f2f5e9; border: 1px solid #718478; border-radius: .55rem; padding: .52rem .7rem; text-align: left; background: transparent; }
.sidebar-footer button:hover { background: #364e42; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1.1rem clamp(1.2rem, 4vw, 3.1rem); border-bottom: 1px solid var(--line); background: #fafbf7; }
.topbar strong { font-size: .92rem; overflow-wrap: anywhere; }
.workspace { margin: 0 auto; max-width: 1280px; padding: clamp(1.6rem, 5vw, 3.4rem) clamp(1.2rem, 4vw, 3.1rem); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.7rem; }
.page-heading p { color: var(--muted); margin-top: .62rem; line-height: 1.5; }
.primary, .secondary, .subtle {
  border: 1px solid transparent; border-radius: .55rem; padding: .65rem 1rem;
  font-weight: 700; white-space: nowrap;
}
a.secondary { display: inline-block; text-decoration: none; }
.settings-form { padding: 1.2rem; }
#report-result { margin-top: 1rem; }
#report-result .dialog-actions { flex-wrap: wrap; }
.invoice-line-tax { display: block; font-size: .85em; color: var(--muted); }
.invoice-letterhead { display: block; max-width: 100%; max-height: 88px; object-fit: contain; margin: 0 auto .55rem; }
.thermal-print .invoice-letterhead { display: none; }
.invoice-qr { margin: .75rem 0; font-size: .85em; }
.invoice-qr img { display: block; }
#share-feedback { margin-top: .65rem; }
.primary { background: var(--green); color: #fff; }
.primary:hover { background: #395648; }
.secondary { border-color: #ccd4c8; background: #fff; color: #2e4135; }
.secondary:hover, .subtle:hover { background: var(--soft); }
.subtle { background: transparent; color: #2e4135; padding: .37rem .65rem; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; margin-bottom: 1.35rem; }
.metric { background: var(--paper); border: 1px solid var(--line); border-radius: .8rem; padding: 1rem 1.2rem; }
.metric:first-child { background: #e9f1d9; border-color: #dbe5cb; }
.metric p { font-weight: 700; color: #48574a; font-size: .84rem; }
.metric-value { display: block; font-weight: 800; font-size: clamp(1.3rem, 3.4vw, 2rem); margin-top: .26rem; letter-spacing: -.045em; }
.card { border: 1px solid var(--line); border-radius: .8rem; background: var(--paper); overflow: hidden; }
.card-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .7rem; padding: .85rem 1.1rem; }
.card-heading input { width: min(100%, 230px); }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: .91rem; }
th, td { padding: .77rem 1rem; border-top: 1px solid var(--line); vertical-align: middle; }
th { background: #f4f6f0; color: #49564b; font-size: .77rem; font-weight: 800; white-space: nowrap; }
td:first-child, th:first-child { padding-left: 1.1rem; }
.record-name { font-weight: 700; min-width: 10rem; overflow-wrap: anywhere; }
.number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.action { text-align: right; width: 1%; }
.pill { display: inline-block; padding: .19rem .56rem; border-radius: 99px; font-size: .76rem; white-space: nowrap; background: #edf1eb; color: #405144; font-weight: 700; }
.pill.active { background: #e2efd5; color: #34532a; }
.empty { padding: 1.5rem 1.1rem; color: var(--muted); }
.form-fields { display: grid; gap: 1rem; }
.field { display: grid; gap: .36rem; font-size: .88rem; font-weight: 700; min-width: 0; }
input, select { width: 100%; min-width: 0; border: 1px solid #c9d2c7; border-radius: .48rem; background: #fff; color: var(--ink); padding: .59rem .68rem; }
input::placeholder { color: #69736a; opacity: 1; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.check { display: flex; gap: .6rem; align-items: center; }
.check input { width: 1.06rem; height: 1.06rem; accent-color: var(--green); }
.hint { color: var(--muted); font-size: .8rem; line-height: 1.4; font-weight: 400; }
.error { color: #8b2726; font-size: .89rem; }
.notice { color: #2d4a2d; background: #e8f1dc; border: 1px solid #d7e5ca; border-radius: .5rem; padding: .65rem .8rem; margin-bottom: .85rem; }
[hidden] { display: none !important; }
dialog { width: min(535px, calc(100% - 1.6rem)); max-height: calc(100% - 1.6rem); border: 1px solid var(--line); border-radius: .95rem; color: var(--ink); padding: 1.35rem; box-shadow: 0 1rem 4rem #17241a30; }
dialog::backdrop { background: #1e3028a6; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.billing-dialog { width: min(740px, calc(100% - 1.6rem)); }
.bill-lines { min-width: 0; margin: 0; padding: .65rem; border: 1px solid var(--line); border-radius: .55rem; }
.bill-lines legend { font-weight: 700; padding: 0 .3rem; }
.return-line + .return-line { margin-top: .65rem; }
.bill-line { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: .55rem; align-items: end; margin-bottom: .65rem; }
.bill-total { justify-self: end; font-weight: 800; }
.invoice-heading { border-bottom: 1px solid var(--line); padding-bottom: .8rem; }
.invoice-shop { font-size: 1.2rem; font-weight: 700; margin-top: .28rem; }
.invoice-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .7rem; }
.invoice-details dt { color: var(--muted); font-size: .82rem; }
.invoice-details dd { margin: .2rem 0 0; overflow-wrap: anywhere; }
.invoice-items { border-bottom: 1px solid var(--line); }
.invoice-totals { margin-left: auto; width: min(100%, 330px); }
.invoice-totals div { display: flex; justify-content: space-between; gap: .75rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.invoice-totals dd { margin: 0; text-align: right; white-space: nowrap; font-weight: 700; }
.preview-actions { flex-wrap: wrap; }
.preview-actions [aria-pressed="true"] { background: var(--soft); border-color: var(--green); }
.print-hint { margin-top: .6rem; text-align: right; }
.thermal-print .transaction-sheet { max-width: 70mm; margin: 0 auto 1rem; font-size: 10px; }
.thermal-print .invoice-heading { text-align: center; }
.thermal-print .invoice-heading h2 { font-size: 14px; }
.thermal-print .invoice-shop { font-size: 13px; }
.thermal-print .invoice-details { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem; }
.thermal-print .invoice-details dt, .thermal-print .invoice-items th { font-size: 9px; }
.thermal-print .invoice-totals { width: 100%; }
.thermal-print .invoice-items { font-size: inherit; }
.thermal-print .invoice-items th, .thermal-print .invoice-items td { padding: .24rem .16rem; }
.thermal-print .invoice-items th:first-child, .thermal-print .invoice-items td:first-child { overflow-wrap: anywhere; padding-left: .16rem; }
[readonly] { background: #f4f6f0; }
@media (max-width: 560px) {
  .bill-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bill-item { grid-column: 1 / -1; }
}
@media print {
  @page { margin: 12mm; }
  @page thermal { margin: 3mm; }
  @page letter-receipt { size: 8in 6in; margin: 8mm; }
  html, body { min-width: 0; height: auto; overflow: visible; background: white; color: black; }
  body:has(.print-dialog[open]) #app, .preview-actions, .print-hint { display: none; }
  .print-dialog[open] { position: static; width: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; box-shadow: none; overflow: visible; }
  .print-dialog::backdrop { display: none; }
  .thermal-print[open] { page: thermal; }
  .letter-print[open] { page: letter-receipt; }
  .thermal-print .transaction-sheet { margin-bottom: 0; }
  .print-dialog .table-scroll { overflow: visible; }
  .invoice-items thead { display: table-header-group; }
  .invoice-items tr, .invoice-totals { break-inside: avoid; }
  .invoice-items th, .invoice-items td { padding: .32rem; }
  .invoice-items td:first-child { overflow-wrap: anywhere; }
  body:has(#report-result:not([hidden])) .sidebar,
  body:has(#report-result:not([hidden])) .report-form,
  #report-result .dialog-actions, #share-feedback, #share-fallback { display: none; }
  body:has(#report-result:not([hidden])) .shell { display: block; }
  #report-result .table-scroll { overflow: visible; }
  #report-result table { font-size: 7pt; }
  #report-result td, #report-result th { padding: 3px; white-space: normal; overflow-wrap: anywhere; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { gap: .9rem; padding: .75rem 1rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .sidebar .brand { padding: 0; }
  .nav { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; }
  .nav button { padding: .38rem .55rem; font-size: .83rem; }
  .sidebar-footer { margin: 0; }
  .sidebar-footer p { display: none; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { min-height: auto; padding: 1.15rem 1.4rem; }
  .auth-aside h2, .auth-art { display: none; }
  .auth-main { align-items: start; }
}
@media (max-width: 380px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}
