:root {
  color-scheme: light;
  --bg: #f2f3ed;
  --surface: #ffffff;
  --surface-soft: #f8f8f4;
  --ink: #17211b;
  --muted: #69736d;
  --line: #dfe3dc;
  --brand: #176b4d;
  --brand-dark: #0e533a;
  --brand-soft: #e4f2eb;
  --orange: #e9782c;
  --shadow: 0 12px 35px rgba(28, 42, 34, 0.08);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { min-width: 320px; }
button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: #12271f; color: #fff; display: flex; flex-direction: column; z-index: 20; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 11px; padding: 0 10px; font-size: 20px; font-weight: 750; letter-spacing: -0.03em; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: #ecf5ad; color: #183e2e; font-family: Georgia, serif; font-size: 23px; }
.nav-list { display: grid; gap: 8px; margin-top: 48px; }
.nav-item { border: 0; background: transparent; color: #aebdb6; padding: 12px 13px; border-radius: 12px; display: flex; align-items: center; gap: 12px; cursor: pointer; text-align: left; font-weight: 650; }
.nav-item.active { color: #fff; background: rgba(255,255,255,.11); }
.nav-item:disabled { opacity: .48; cursor: not-allowed; }
.nav-icon { width: 22px; text-align: center; font-size: 19px; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 18px; }
.status-pill { font-size: 12px; color: #c2d0ca; display: flex; align-items: center; gap: 8px; padding: 0 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #97d94d; box-shadow: 0 0 0 4px rgba(151,217,77,.13); }
.profile { border: 1px solid rgba(255,255,255,.1); color: #fff; background: rgba(255,255,255,.06); padding: 10px; border-radius: 14px; display: flex; align-items: center; gap: 10px; text-align: left; }
.profile .avatar { width: 34px; height: 34px; background: #eb8d4e; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.profile strong, .profile small { display: block; }
.profile strong { font-size: 13px; }
.profile small { color: #9fb0a8; margin-top: 2px; }

.main-content { min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.topbar { height: 102px; padding: 22px 30px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); background: rgba(242,243,237,.92); backdrop-filter: blur(14px); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; letter-spacing: -0.04em; }
h2 { font-size: 21px; letter-spacing: -0.025em; }
.eyebrow { margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow.accent { color: var(--brand); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.printer-status { padding: 9px 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left; }
.printer-status:disabled { opacity: .65; cursor: wait; }
.printer-status[data-state="connected"] { border-color: #9bc7b4; background: var(--brand-soft); }
.printer-status[data-state="connected"] .printer-icon { background: var(--brand); color: #fff; }
.printer-status[data-state="error"] { border-color: #dfb18e; }
.printer-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: #f1e9e4; color: #a85626; transform: rotate(90deg); }
.printer-status small, .printer-status strong { display: block; }
.printer-status small { color: var(--muted); font-size: 10px; }
.printer-status strong { font-size: 12px; margin-top: 1px; }
.icon-button { border: 1px solid var(--line); background: var(--surface); width: 46px; height: 46px; border-radius: 14px; cursor: pointer; letter-spacing: 2px; }

.sale-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: calc(100vh - 102px); }
.catalog-panel { overflow-y: auto; padding: 24px 28px 70px; }
.search-row { position: sticky; top: -24px; z-index: 10; padding: 0 0 20px; background: linear-gradient(var(--bg) 78%, transparent); }
.search-box { height: 50px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); display: flex; align-items: center; gap: 10px; padding: 0 14px; box-shadow: 0 4px 18px rgba(20,40,30,.035); }
.search-box > span { font-size: 24px; color: var(--muted); transform: rotate(-15deg); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-box input::placeholder { color: #929b96; }
.search-box kbd { color: #89928d; background: #f3f4f0; border: 1px solid var(--line); border-radius: 7px; padding: 3px 7px; font-size: 10px; white-space: nowrap; }
.product-section + .product-section { margin-top: 34px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 15px; }
.section-note { color: var(--muted); font-size: 12px; }
.product-grid { display: grid; grid-template-columns: repeat(4, minmax(135px, 1fr)); gap: 12px; }
.product-card { min-height: 145px; position: relative; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); padding: 16px; display: flex; flex-direction: column; text-align: left; box-shadow: 0 4px 16px rgba(30,50,40,.035); overflow: hidden; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #cbd2ca; }
.product-card.featured { min-height: 158px; border: 0; color: #fff; background: var(--card-color, var(--brand)); }
.product-card.featured::after { content: ""; width: 105px; height: 105px; border: 18px solid rgba(255,255,255,.08); border-radius: 50%; position: absolute; right: -28px; top: -32px; }
.item-name { font-weight: 760; font-size: 16px; line-height: 1.2; }
.item-price { margin-top: 5px; color: var(--muted); font-size: 13px; font-weight: 650; }
.featured .item-price { color: rgba(255,255,255,.78); }
.card-controls { margin-top: auto; height: 38px; display: flex; align-items: center; justify-content: flex-end; position: relative; z-index: 2; }
.add-button, .quantity-button { border: 0; display: grid; place-items: center; cursor: pointer; font-weight: 600; }
.add-button { width: 38px; height: 38px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-size: 23px; }
.featured .add-button { background: #fff; color: var(--ink); }
.quantity-control { height: 38px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; overflow: hidden; }
.featured .quantity-control { color: #fff; background: rgba(255,255,255,.18); }
.quantity-button { width: 36px; height: 38px; background: transparent; font-size: 19px; }
.quantity-value { min-width: 28px; text-align: center; font-weight: 800; }
.load-sentinel { height: 2px; }
.empty-state { padding: 55px; text-align: center; color: var(--muted); }

.cart-panel { min-width: 0; border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; }
.cart-heading { padding: 24px 22px 17px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.cart-heading h2 { display: flex; align-items: center; gap: 8px; }
.count-badge { min-width: 23px; height: 23px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-dark); font-size: 11px; }
.text-button { border: 0; background: transparent; color: var(--brand); cursor: pointer; font-weight: 700; font-size: 12px; }
.text-button:disabled { color: #adb4af; cursor: default; }
.cart-items { overflow-y: auto; padding: 10px 21px; }
.cart-item { padding: 14px 0; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; border-bottom: 1px solid #edf0eb; }
.cart-item-name { font-weight: 750; font-size: 14px; }
.cart-item-price { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.cart-line-total { font-size: 13px; font-weight: 800; text-align: right; }
.cart-item .quantity-control { margin-top: 9px; width: fit-content; height: 31px; }
.cart-item .quantity-button { height: 31px; width: 31px; }
.empty-cart { margin: auto 30px; text-align: center; color: var(--muted); }
.empty-cart-icon { width: 58px; height: 58px; margin: 0 auto 14px; display: grid; place-items: center; border: 1px dashed #bdc6c0; background: var(--surface-soft); border-radius: 18px; color: var(--brand); font-size: 27px; }
.empty-cart h3 { color: var(--ink); font-size: 16px; }
.empty-cart p { max-width: 220px; margin: 7px auto 0; line-height: 1.5; font-size: 12px; }
.cart-summary { margin-top: auto; border-top: 1px solid var(--line); padding: 18px 22px 15px; background: #fcfcfa; }
.summary-line, .summary-total { display: flex; justify-content: space-between; align-items: center; }
.summary-line { font-size: 13px; margin-bottom: 7px; }
.summary-line.muted { color: var(--muted); font-size: 11px; }
.summary-total { border-top: 1px dashed #ccd2cc; margin-top: 14px; padding-top: 14px; font-size: 17px; }
.summary-total strong { font-size: 25px; letter-spacing: -.03em; }
.checkout-button { width: 100%; height: 55px; margin-top: 17px; padding: 0 18px; border: 0; border-radius: 15px; background: var(--brand); color: #fff; display: flex; justify-content: space-between; align-items: center; font-weight: 800; cursor: pointer; box-shadow: 0 8px 18px rgba(23,107,77,.22); }
.checkout-button:disabled { background: #c8cdc9; box-shadow: none; cursor: default; }
.checkout-hint { color: var(--muted); text-align: center; margin-top: 9px; font-size: 10px; }

.items-page { padding: 28px 30px; }
.items-intro { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.items-intro p { color: var(--muted); font-size: 13px; margin-top: 6px; }
.search-box.compact { width: 285px; height: 44px; }
.primary-button, .secondary-button { border-radius: 12px; padding: 12px 17px; border: 0; font-weight: 750; cursor: pointer; }
.primary-button { background: var(--brand); color: #fff; }
.secondary-button { background: #edf0eb; color: var(--ink); }
.table-card { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; overflow: hidden; }
.table-row { min-height: 68px; padding: 10px 20px; display: grid; grid-template-columns: 2fr .8fr 1fr 44px; gap: 14px; align-items: center; border-top: 1px solid #ecefea; }
.table-header { min-height: 45px; border-top: 0; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; }
.table-item-name { display: flex; align-items: center; gap: 11px; font-weight: 730; }
.item-swatch { width: 35px; height: 35px; border-radius: 10px; background: var(--swatch); display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 800; }
.table-cell-muted { color: var(--muted); font-size: 13px; }
.mini-toggle { position: relative; display: inline-flex; width: 42px; height: 24px; }
.mini-toggle input, .feature-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.mini-toggle span, .toggle-ui { position: absolute; inset: 0; border-radius: 99px; background: #d8ddd8; cursor: pointer; transition: background .2s; }
.mini-toggle span::after, .toggle-ui::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.mini-toggle input:checked + span, .feature-toggle input:checked + .toggle-ui { background: var(--brand); }
.mini-toggle input:checked + span::after, .feature-toggle input:checked + .toggle-ui::after { transform: translateX(18px); }
.edit-button { border: 0; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }

.reports-page { padding: 28px 30px 60px; }
.report-total-card { min-height: 164px; padding: 27px 30px; border-radius: 22px; color: #fff; background: linear-gradient(135deg, #176b4d, #0e4e38); box-shadow: 0 16px 35px rgba(23,107,77,.18); display: flex; align-items: center; justify-content: space-between; overflow: hidden; position: relative; }
.report-total-card::after { content: ""; position: absolute; width: 190px; height: 190px; border: 35px solid rgba(255,255,255,.055); border-radius: 50%; right: -52px; top: -72px; }
.report-total-card .eyebrow { color: rgba(255,255,255,.68); }
.report-total-card strong { display: block; font-size: 45px; letter-spacing: -.055em; line-height: 1.1; }
.report-total-card > div > span { display: block; color: rgba(255,255,255,.7); font-size: 12px; margin-top: 10px; }
.report-total-mark { position: relative; z-index: 1; width: 55px; height: 55px; border-radius: 17px; display: grid; place-items: center; background: rgba(255,255,255,.13); font-size: 27px; }
.report-controls { margin: 18px 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); display: flex; align-items: end; gap: 12px; }
.date-field { display: grid; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.date-field input { height: 43px; min-width: 165px; border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; color: var(--ink); background: var(--surface-soft); outline: 0; }
.date-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.date-separator { color: var(--muted); margin-bottom: 13px; font-size: 12px; }
.report-download { height: 43px; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.report-download:disabled { background: #b9c0bb; cursor: default; }
.report-sales-card { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); overflow: hidden; }
.report-list-heading { min-height: 79px; padding: 18px 21px; display: flex; align-items: center; justify-content: space-between; }
.report-row { min-height: 68px; padding: 10px 21px; display: grid; grid-template-columns: 1.15fr 2fr .85fr .7fr; gap: 15px; align-items: center; border-top: 1px solid #ecefea; font-size: 13px; }
.report-row-header { min-height: 40px; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.report-row > :last-child { text-align: right; font-weight: 800; }
.report-time strong, .report-time small { display: block; }
.report-time small { color: var(--muted); margin-top: 3px; }
.report-receipt strong, .report-receipt small { display: block; }
.report-receipt small { color: var(--muted); margin-top: 4px; line-height: 1.35; }
.report-status { width: fit-content; padding: 5px 8px; border-radius: 8px; background: #f5eadf; color: #8f5428; font-size: 10px; font-weight: 750; }
.report-status.printed { background: var(--brand-soft); color: var(--brand-dark); }
.report-empty { padding: 55px 20px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); }
.report-empty > span { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-soft); color: var(--brand); font-size: 21px; }
.report-empty h3 { color: var(--ink); font-size: 15px; }
.report-empty p { margin-top: 6px; font-size: 12px; }

dialog { color: var(--ink); border: 0; padding: 0; border-radius: 22px; box-shadow: 0 30px 90px rgba(10,30,20,.25); }
dialog::backdrop { background: rgba(9,24,17,.52); backdrop-filter: blur(3px); }
.item-dialog { width: min(530px, calc(100vw - 30px)); }
.item-dialog form { padding: 25px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 23px; }
.dialog-close { border: 0; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-soft); font-size: 23px; cursor: pointer; }
.field { display: grid; gap: 7px; margin-top: 15px; font-size: 12px; font-weight: 700; color: #49544e; }
.field > input, .money-input { width: 100%; height: 47px; border: 1px solid var(--line); border-radius: 12px; padding: 0 13px; outline: none; color: var(--ink); background: #fff; }
.field > input:focus, .money-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1.5fr; gap: 13px; }
.money-input { display: flex; align-items: center; gap: 6px; }
.money-input input { min-width: 0; border: 0; outline: 0; width: 100%; }
.feature-toggle { position: relative; margin-top: 21px; padding: 15px 60px 15px 15px; border-radius: 13px; background: var(--surface-soft); display: block; }
.feature-toggle strong, .feature-toggle small { display: block; }
.feature-toggle strong { font-size: 13px; }
.feature-toggle small { color: var(--muted); font-size: 11px; margin-top: 4px; }
.feature-toggle .toggle-ui { width: 42px; height: 24px; left: auto; right: 14px; top: 50%; transform: translateY(-50%); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.checkout-dialog { width: min(400px, calc(100vw - 30px)); padding: 30px; text-align: center; }
.checkout-dialog .success-mark { width: 58px; height: 58px; margin: 0 auto 18px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); border-radius: 18px; font-size: 28px; }
.checkout-dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.55; font-size: 13px; margin: 10px 0 22px; }
.printer-error-dialog { width: min(560px, calc(100vw - 24px)); padding: 26px; }
.printer-error-dialog .error-mark { width: 48px; height: 48px; margin-bottom: 17px; display: grid; place-items: center; border-radius: 14px; background: #f8e8dc; color: #a44725; font-size: 25px; font-weight: 850; }
.printer-error-message { margin-top: 9px; color: #7d3b23; font-size: 13px; line-height: 1.45; }
.printer-error-dialog pre { max-height: 235px; overflow: auto; margin: 17px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f5f6f2; color: #344039; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.printer-connect-dialog { width: min(480px, calc(100vw - 24px)); padding: 25px; }
.printer-connect-options { display: grid; gap: 10px; }
.printer-connect-options > button { width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); display: flex; align-items: center; gap: 13px; text-align: left; cursor: pointer; }
.printer-connect-options > button:hover { border-color: #9bc7b4; background: var(--brand-soft); }
.printer-connect-options > button:disabled { display: none; }
.printer-connect-options strong, .printer-connect-options small { display: block; }
.printer-connect-options small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.connection-mark { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-dark); font-size: 10px; font-weight: 850; }
.printer-connect-help { margin-top: 15px; color: var(--muted); font-size: 11px; line-height: 1.5; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding-inline: 13px; }
  .brand > span:last-child, .nav-item > span:last-child, .profile > span:last-child, .status-pill { display: none; }
  .brand { justify-content: center; padding: 0; }
  .nav-item { justify-content: center; }
  .profile { justify-content: center; }
  .product-grid { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
}

@media (max-width: 800px) {
  .app-shell { display: block; padding-bottom: 67px; }
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 67px; padding: 8px 18px calc(8px + env(safe-area-inset-bottom)); flex-direction: row; z-index: 50; }
  .brand, .sidebar-bottom { display: none; }
  .nav-list { margin: 0; width: 100%; display: flex; justify-content: space-around; }
  .nav-item { min-width: 100px; padding: 8px 12px; flex-direction: column; gap: 2px; font-size: 10px; }
  .nav-item > span:last-child { display: inline; }
  .nav-icon { font-size: 18px; }
  .topbar { height: 82px; padding: 15px 18px; }
  .topbar-actions { gap: 7px; }
  .printer-status { padding: 6px 9px; border-radius: 12px; }
  .printer-icon { width: 28px; height: 28px; }
  .printer-status small { display: none; }
  .icon-button { display: none; }
  .sale-layout { display: block; height: auto; }
  .catalog-panel { overflow: visible; padding: 18px 16px 230px; }
  .search-row { top: 0; }
  .product-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .cart-panel { position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 30; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 45px rgba(20,35,28,.2); }
  .cart-heading, .cart-items, .empty-cart, .summary-line, .checkout-hint { display: none !important; }
  .cart-summary { border: 0; padding: 12px; display: grid; grid-template-columns: 1fr 1.5fr; gap: 12px; align-items: center; border-radius: 18px; }
  .summary-total { border: 0; margin: 0; padding: 0; display: block; }
  .summary-total span { display: block; font-size: 10px; color: var(--muted); }
  .summary-total strong { font-size: 21px; }
  .checkout-button { margin: 0; }
  .items-page { padding: 20px 15px; }
  .items-intro { align-items: stretch; flex-direction: column; gap: 16px; }
  .search-box.compact { width: 100%; }
  .table-row { grid-template-columns: 1.5fr .8fr .8fr 38px; }
  .reports-page { padding: 18px 15px 40px; }
  .report-total-card { min-height: 140px; padding: 22px; }
  .report-total-card strong { font-size: 37px; }
  .report-controls { align-items: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .date-field input { width: 100%; min-width: 0; }
  .date-separator { display: none; }
  .report-download { width: 100%; justify-content: center; grid-column: 1 / -1; margin: 3px 0 0; }
  .report-row { grid-template-columns: 1.05fr 1.7fr .8fr; }
  .report-row > :nth-child(3) { display: none; }
}

@media (max-width: 420px) {
  .featured-grid { grid-template-columns: repeat(2, 1fr); }
  .product-card { min-height: 137px; padding: 14px; }
  .section-note, .search-box kbd { display: none; }
  h1 { font-size: 24px; }
}
