:root { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #242521; background: #f6f5f1; font-synthesis: none; --primary: #33459e; --border: #e4e1d9; --muted: #77776e; }
* { box-sizing: border-box; }
body { margin: 0; padding-top: env(safe-area-inset-top); }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #33459e80; outline-offset: 3px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
.app-shell { max-width: 1120px; margin: auto; padding: 0 40px; }
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 28px 0; border-bottom: 1px solid var(--border); gap: 16px; }
.brand { text-decoration: none; display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 20px; font-weight: 700; letter-spacing: -.65px; }
.brand-byline { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.install-button { color: var(--primary); gap: 0; }
.button { border-radius: 8px; min-height: 48px; padding: 12px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-size: 14px; font-weight: 600; text-decoration: none; transition: background .15s, border-color .15s; }
.button-outline { border: 1px solid var(--border); background: transparent; color: #34362e; }
.button-outline:hover:not(:disabled) { background: #eeece6; border-color: #c9c5ba; }
.button-primary { border: 1px solid var(--primary); background: var(--primary); color: white; }
.button-primary:hover:not(:disabled) { background: #293981; border-color: #293981; }
.page-heading { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 32px 0 24px; }
h1 { margin: 0; font-size: 28px; font-weight: 650; letter-spacing: -1px; }
.page-heading p { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.free-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.mobile-total { display: none; }
.counter-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: stretch; }
.panel { background: white; border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
.keypad-panel { padding: 24px; }
.amount-heading { display: flex; align-items: center; justify-content: space-between; min-height: 36px; font-size: 13px; color: var(--muted); }
.text-button { background: transparent; color: var(--primary); border: 0; font-size: 13px; padding: 8px 12px; min-height: 44px; border-radius: 6px; }
.text-button:hover { background: #f3f4fa; }
.amount-entry { display: flex; align-items: baseline; gap: 8px; padding: 8px 0 12px; }
.amount-entry > span { font-size: 32px; color: #a1a096; }
.amount-entry input { border: 0; background: transparent; color: #242521; width: 100%; min-width: 0; font-size: clamp(32px, 4vw, 52px); font-weight: 550; font-variant-numeric: tabular-nums; letter-spacing: -2px; padding: 0; border-radius: 3px; }
.amount-entry input::placeholder { color: #242521; opacity: 1; }
.field-error { color: #b42318; font-size: 12px; margin: 0; line-height: 1.5; }
.field-error:not(:empty) { margin-bottom: 12px; }
.note-field { border: 1px solid var(--border); border-radius: 8px; display: flex; align-items: center; padding: 0 12px; gap: 8px; color: #939287; }
.note-field:focus-within { border-color: var(--primary); }
.note-field input { min-width: 0; width: 100%; min-height: 48px; font-size: 14px; padding: 12px 0; border: 0; background: transparent; color: #242521; }
.note-field input::placeholder { color: #8a8a81; }
.note-field input:focus-visible { outline: none; }
.keypad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 20px 0 0; }
.keypad button[data-key] { display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 6px; background: #f8f7f4; aspect-ratio: 1; min-height: 48px; font-size: 27px; font-weight: 500; color: #34362e; transition: background .1s; }
.keypad button[data-key]:hover { background: #eeece6; }
.keypad button[data-key]:active { background: #e2e4f2; border-color: #a2acd6; }
.keypad svg { width: 25px; height: 25px; }
.add-button { grid-column: 4; grid-row: 3 / span 2; flex-direction: column; width: 100%; min-height: 104px; font-size: 12px; padding: 12px 4px; text-align: center; line-height: 1.5; }
#add-symbol { font-size: 36px; font-weight: 400; line-height: 1; }
.keypad-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 11px; min-height: 22px; }
.receipt-panel { display: flex; flex-direction: column; padding: 24px; }
.receipt-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.4px; }
.receipt-heading p { color: var(--muted); font-size: 12px; margin: 5px 0 0; }
.receipt-heading .button { min-height: 44px; padding: 10px 14px; font-size: 12px; }
.receipt-paper { display: flex; flex-direction: column; flex: 1; }
.receipt-store { display: flex; flex-direction: column; gap: 5px; text-align: center; padding: 8px 0 20px; border-bottom: 1px dashed var(--border); overflow-wrap: anywhere; }
.receipt-store strong { font-size: 16px; font-weight: 600; }
.receipt-store span { font-size: 11px; color: var(--muted); line-height: 1.5; }
.empty-bill { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; min-height: 230px; padding: 24px 0; color: var(--muted); text-align: center; }
.empty-plus { font-size: 36px; color: #cbc8bf; font-weight: 300; margin-bottom: 12px; }
.empty-bill strong { font-weight: 500; font-size: 14px; color: #55574d; }
.empty-bill p { margin: 8px 0; font-size: 12px; line-height: 1.5; }
.bill-items { list-style: none; padding: 0; margin: 0; flex: 1; max-height: 300px; min-height: 230px; overflow-y: auto; scrollbar-width: thin; }
.bill-items:empty { display: none; }
.bill-item { display: flex; align-items: center; border-bottom: 1px solid #f0eee9; min-height: 64px; gap: 4px; }
.edit-item { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; min-height: 56px; text-align: left; background: none; border: 0; border-radius: 6px; padding: 8px 2px; color: inherit; }
.edit-item:hover { background: #f8f7f4; }
.item-number { font-size: 11px; color: #99988e; width: 14px; flex-shrink: 0; }
.item-note { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }
.item-price { font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }
.icon-button { display: flex; align-items: center; justify-content: center; border: 0; background: transparent; min-width: 44px; min-height: 44px; border-radius: 6px; color: #929186; font-size: 26px; }
.icon-button svg { width: 16px; height: 16px; }
.icon-button:hover { background: #f5f3ee; color: #484940; }
.bill-item.is-editing { background: #f2f3fa; }
.receipt-total { border-top: 1px dashed var(--border); padding: 24px 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; }
.receipt-total > div { display: flex; flex-direction: column; gap: 6px; }
.receipt-total span:first-child { font-size: 13px; font-weight: 550; }
#total-caption { font-size: 11px; color: var(--muted); }
#total { font-size: clamp(22px, 3vw, 32px); font-weight: 650; letter-spacing: -1px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; }
.receipt-actions { display: grid; grid-template-columns: 1.7fr 1fr; gap: 8px; }
.receipt-actions .button { padding: 12px 10px; font-size: 13px; }
.receipt-hint { font-size: 11px; color: var(--muted); text-align: center; margin: 14px 0 0; }
.karmos-banner { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 28px 32px; margin-top: 24px; border: 1px solid var(--border); border-radius: 12px; background: #eeece5; }
.eyebrow { display: block; font-size: 11px; color: #77776e; margin-bottom: 8px; }
.karmos-banner h2 { font-size: 20px; letter-spacing: -.6px; }
.karmos-banner p { margin: 8px 0 0; font-size: 13px; line-height: 1.6; color: #66675d; max-width: 480px; }
.karmos-link { flex-shrink: 0; background: #f6f5f1; color: var(--primary); border-color: #d4d0c5; }
.karmos-link span { margin-left: 12px; font-size: 18px; font-weight: 400; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; padding: 24px 0 28px; font-size: 11px; color: #85857b; }
.app-footer a { text-decoration: none; }
.app-footer a:hover { color: var(--primary); }
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); color: #242521; box-shadow: 0 16px 64px #24252120; }
dialog::backdrop { background: #25262070; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-description { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 12px 0 24px; }
.form-field { display: block; font-size: 13px; font-weight: 500; margin-bottom: 20px; }
.form-field input, .form-field select { display: block; margin-top: 8px; width: 100%; min-height: 48px; border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: #fff; color: #242521; font-size: 16px; }
.optional { font-weight: 400; color: var(--muted); }
.dialog-note { font-size: 12px; line-height: 1.6; color: var(--muted); margin: 0 0 24px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.full-width { width: 100%; }
.toast { position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #292b24; color: #fff; padding: 12px 16px; border-radius: 8px; display: flex; align-items: center; gap: 16px; max-width: calc(100% - 32px); font-size: 13px; box-shadow: 0 4px 24px #0002; z-index: 5; }
.toast button { background: none; border: 0; color: #d6defe; font-size: 13px; font-weight: 600; min-height: 36px; padding: 4px 8px; }
#print-receipt { display: none; }
.noscript { text-align: center; color: #b42318; }
.workspace-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 12px 0; overflow-x: auto; }
.workspace-nav button { background: transparent; border: 0; border-radius: 6px; min-height: 44px; padding: 10px 16px; color: #77776e; font-size: 13px; white-space: nowrap; }
.workspace-nav button[aria-pressed="true"] { background: #e9ebf5; color: var(--primary); font-weight: 600; }
.bill-tabs-bar { display: flex; gap: 8px; margin-bottom: 12px; }
#bill-tabs { display: flex; gap: 8px; min-width: 0; flex: 1; overflow-x: auto; padding: 3px; }
.bill-tab { display: flex; align-items: center; gap: 16px; white-space: nowrap; min-height: 48px; border: 1px solid var(--border); border-radius: 6px; background: white; padding: 10px 16px; color: #34362e; }
.bill-tab span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.bill-tab small { color: var(--muted); font-variant-numeric: tabular-nums; }
.bill-tab[aria-selected="true"] { border-color: var(--primary); background: #f0f1f8; color: var(--primary); }
#add-bill-tab { flex-shrink: 0; }
#rename-bill-tab { flex-shrink: 0; min-width: 44px; min-height: 44px; padding: 8px; }
#rename-tab-dialog .form-field { margin-top: 20px; }
.bill-label-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; color: var(--muted); font-size: 12px; }
.bill-label-bar input { min-width: 0; max-width: 220px; width: 100%; padding: 10px 12px; min-height: 44px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: #34362e; font-size: 14px; }
.bill-label-bar .text-button { margin-left: auto; white-space: nowrap; }
.payment-button { margin-top: 12px; }
.keypad-calculator-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.keypad-calculator-tools button { min-height: 44px; padding: 8px 4px; border: 1px solid var(--border); border-radius: 6px; background: #f0f1f8; color: var(--primary); font-size: 12px; }
.keypad-calculator-tools button:hover { background: #e9ebf5; }
.calculator-context { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.calculator-context > span { min-width: 0; overflow-wrap: anywhere; }
.calculator-actions .wide-action { grid-column: 1 / -1; }
.note-keyboard { margin-top: 20px; }
.letter-row { display: flex; justify-content: center; gap: 4px; margin-bottom: 6px; }
.letter-row button, .note-keyboard-controls button { min-height: 48px; border: 1px solid var(--border); border-radius: 4px; background: #f8f7f4; color: #34362e; }
.letter-row button { width: calc((100% - 36px) / 10); min-width: 0; padding: 4px 0; font-size: 15px; }
.letter-row button:hover, .note-keyboard-controls button:hover { background: #eeece6; }
.note-keyboard-controls { display: flex; gap: 6px; margin-top: 12px; }
.note-keyboard-controls button { min-width: 48px; padding: 8px; font-size: 13px; }
.note-keyboard-controls .space-key { flex: 1; }
#note-shift[aria-pressed="true"] { background: #e9ebf5; color: var(--primary); border-color: var(--primary); }
.note-keyboard-actions, .calculator-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.note-keyboard-actions .button, .calculator-actions .button { padding-inline: 10px; font-size: 13px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 24px; }
.summary-card { border: 1px solid var(--border); background: white; border-radius: 8px; padding: 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.summary-card > span { font-size: 12px; color: var(--muted); }
.summary-card > strong { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.7px; overflow-wrap: anywhere; }
.summary-card > small { font-size: 11px; color: var(--muted); line-height: 1.5; }
.section-toolbar { display: flex; gap: 12px; align-items: flex-end; margin: 0 0 20px; flex-wrap: wrap; }
.search-field { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; flex: 1; }
.search-field input, .search-field select { border: 1px solid var(--border); border-radius: 6px; min-height: 48px; padding: 12px; color: #34362e; background: white; font-size: 14px; width: 100%; min-width: 0; }
.search-field:first-child { flex: 2; }
.section-description { color: var(--muted); font-size: 12px; line-height: 1.65; margin: 12px 0 16px; }
.list-panel { padding: 24px; margin: 0 0 20px; }
.record-list { margin-top: 16px; }
.record-row { display: flex; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--border); }
.record-row:last-child { border-bottom: 0; }
.record-copy { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; overflow-wrap: anywhere; }
.record-copy > strong { font-size: 14px; font-weight: 550; }
.record-copy > small { font-size: 11px; line-height: 1.6; color: var(--muted); }
.record-amount { display: flex; flex-direction: column; text-align: right; gap: 6px; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.record-amount small { font-size: 11px; color: var(--muted); }
.record-row .button { font-size: 12px; min-height: 44px; padding: 10px 14px; }
.empty-message { color: var(--muted); font-size: 13px; line-height: 1.6; padding: 12px 0; }
.report-columns, .calculator-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.detail-row { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid #f0eee9; font-size: 13px; line-height: 1.5; }
.detail-row span { min-width: 0; overflow-wrap: anywhere; }
.detail-row strong { text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; font-weight: 550; }
.table-scroll { overflow-x: auto; margin-top: 16px; }
table { border-collapse: collapse; font-size: 12px; width: 100%; }
th, td { text-align: right; padding: 14px 12px; white-space: nowrap; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
th { font-weight: 500; color: var(--muted); }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
.wide-dialog { width: min(560px, calc(100% - 32px)); }
.saved-bill-totals { background: #f8f7f4; padding: 4px 12px; border-radius: 8px; margin: 20px 0; }
.record-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
h3 { font-size: 14px; font-weight: 600; margin: 24px 0 8px; }
.calculator-panel { padding: 24px; margin-bottom: 20px; }
.calculator-panel h2 { margin-bottom: 24px; }
#calc-expression { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 18px; }
.calculator-result { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 12px 0 24px; }
.calculator-result span { font-size: 12px; color: var(--muted); }
.calculator-result output { font-size: 32px; letter-spacing: -1px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.memory-controls { display: flex; align-items: center; gap: 6px; margin: 0 0 12px; }
.memory-controls button { border: 1px solid var(--border); min-width: 44px; min-height: 44px; border-radius: 4px; background: #f8f7f4; color: var(--primary); font-size: 12px; }
.memory-controls span { font-size: 11px; color: var(--muted); text-align: right; margin-left: auto; overflow-wrap: anywhere; min-width: 0; }
.calculator-keys { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.calc-key { aspect-ratio: 1; min-height: 44px; border: 1px solid var(--border); border-radius: 6px; background: #f8f7f4; color: #34362e; font-size: 22px; }
.calc-key:hover { background: #eeece6; }
.calc-equals { background: var(--primary); color: white; border-color: var(--primary); }
.calc-equals:hover { background: #293981; }
.history-row { border: 0; background: transparent; border-bottom: 1px solid var(--border); width: 100%; min-height: 56px; display: flex; gap: 20px; justify-content: space-between; align-items: center; padding: 12px 0; text-align: left; color: #34362e; font-size: 13px; }
.history-row span { min-width: 0; overflow-wrap: anywhere; }
.history-row strong { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.history-row:hover { background: #f8f7f4; }
.data-panel { padding: 24px; margin-bottom: 20px; }
.backup-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 24px 0; }
.form-field textarea { display: block; margin-top: 8px; width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; resize: vertical; background: #f8f7f4; color: #34362e; }
.backup-text-field { margin-top: 24px; }
@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calculator-layout { grid-template-columns: 1fr; }
  .calculator-keys { max-width: 440px; margin: auto; }
}
@media (max-width: 640px) {
  .workspace-nav { gap: 0; margin-inline: -16px; padding-inline: 8px; }
  .workspace-nav button { padding: 10px 12px; }
  .bill-label-bar { gap: 8px; }
  .bill-label-bar label { flex-shrink: 0; }
  .bill-label-bar input { font-size: 16px; }
  .bill-tab { padding: 10px 12px; gap: 12px; }
  .summary-grid { gap: 8px; }
  .summary-card { padding: 16px; }
  .summary-card > strong { font-size: 21px; }
  .section-toolbar .search-field { flex-basis: 40%; min-width: 0; }
  .search-field input, .search-field select, .note-field input { font-size: 16px; }
  .report-columns { grid-template-columns: 1fr; gap: 0; }
  .list-panel, .data-panel, .calculator-panel { padding: 16px; }
  .record-row { gap: 10px; flex-wrap: wrap; }
  .record-copy { flex-basis: 45%; }
  .record-amount { max-width: 50%; }
  .record-actions .button { flex: 1; }
  .workspace-view > .page-heading { flex-wrap: wrap; }
  .letter-row { gap: 3px; }
  .letter-row button { width: calc((100% - 27px) / 10); font-size: 14px; }
  .note-keyboard-controls { gap: 4px; }
  .note-keyboard-controls button { min-width: 44px; }
  .calculator-keys { gap: 5px; }
  .calculator-result output { font-size: 28px; }
  .detail-row { gap: 10px; }
  .detail-row strong { flex-shrink: 1; overflow-wrap: anywhere; }
}
@media (max-width: 900px) { .app-shell { padding: 0 24px; } .counter-layout { gap: 16px; } .keypad-panel, .receipt-panel { padding: 20px; } .receipt-actions { grid-template-columns: 1fr; } .receipt-actions .button { min-height: 44px; } .keyboard-hint, kbd { display: none; } .free-label { display: none; } .karmos-banner { padding: 24px; } }
@media (max-width: 640px) {
  .app-shell { padding: 0 16px; }
  .app-header { padding: 20px 0; }
  .brand strong { font-size: 18px; }
  .brand-byline { font-size: 11px; }
  .settings-button { padding: 10px; min-width: 44px; min-height: 44px; }
  .settings-button span { display: none; }
  .install-label-long { display: none; }
  .install-button { min-height: 44px; padding: 10px 12px; font-size: 12px; }
  .page-heading { padding: 24px 0 20px; }
  h1 { font-size: 24px; }
  .page-heading p { font-size: 13px; }
  .counter-layout { grid-template-columns: 1fr; gap: 16px; }
  .mobile-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 2; padding: 12px 16px; margin: 0 0 16px; background: #f6f5f1; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; font-size: 13px; }
  .mobile-total strong { color: var(--primary); font-size: 21px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .keypad-panel, .receipt-panel { padding: 20px; }
  .amount-entry input { font-size: 44px; }
  .keypad { padding-top: 16px; }
  .receipt-heading { margin-bottom: 12px; }
  .receipt-actions { grid-template-columns: 1.7fr 1fr; }
  .receipt-total { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin: 16px -4px; }
  .empty-bill, .bill-items { min-height: 140px; }
  #total { font-size: 28px; }
  .karmos-banner { flex-direction: column; align-items: flex-start; gap: 20px; margin-top: 16px; padding: 24px; }
  .karmos-link { width: 100%; justify-content: space-between; }
  .app-footer { font-size: 10px; padding-bottom: max(24px, env(safe-area-inset-bottom)); flex-wrap: wrap; }
}
@media (max-width: 360px) { .keypad-panel, .receipt-panel { padding: 16px; } .receipt-actions .button { font-size: 12px; gap: 5px; padding-inline: 6px; } .receipt-total { flex-wrap: wrap; } .dialog-actions { flex-direction: column; } }
@media (max-width: 360px) { .brand-byline { display: none; } }
.mobile-bill-bar, .back-to-keypad, .calculator-pane-nav { display: none; }
/* Keep the counter within the available screen, including browser chrome. */
@media screen and (max-width: 1400px), screen and (max-height: 850px) {
  html { height: 100%; }
  body { height: 100dvh; overflow: hidden; padding-bottom: env(safe-area-inset-bottom); }
  .app-shell { height: 100%; display: flex; flex-direction: column; padding-inline: 16px; }
  .app-header { flex: 0 0 auto; padding: 8px 0; min-height: 60px; }
  .brand img { width: 34px; height: 34px; }
  .brand strong { font-size: 18px; }
  .brand-byline { font-size: 10px; }
  .header-actions .button { min-height: 44px; padding: 8px 12px; }
  main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .workspace-nav { flex: 0 0 auto; margin: 0; padding: 4px 0; gap: 2px; scrollbar-width: none; }
  .workspace-nav button { flex: 1; padding: 8px 4px; min-height: 44px; font-size: 12px; }
  .workspace-view { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .page-heading { padding: 16px 0; }
  .page-heading h1 { font-size: 22px; }
  .page-heading p { font-size: 12px; margin-top: 4px; }
  #billing-view { display: flex; flex-direction: column; overflow: hidden; padding-top: 8px; }
  #billing-view > .page-heading { display: none; }
  .bill-tabs-bar { flex: 0 0 auto; gap: 6px; margin-bottom: 8px; }
  #bill-tabs { gap: 6px; padding: 0; scrollbar-width: none; }
  .bill-tab { min-height: 44px; padding: 8px 12px; gap: 10px; font-size: 13px; }
  #add-bill-tab { min-height: 44px; padding: 8px 12px; }
  .counter-layout { flex: 1; min-height: 0; gap: 12px; grid-template-columns: 1fr 1fr; }
  .keypad-panel, .receipt-panel { min-height: 0; padding: 12px; display: flex; flex-direction: column; overflow: hidden; }
  .keypad-panel { container-type: inline-size; }
  .amount-heading { flex-shrink: 0; min-height: 32px; }
  .amount-heading .text-button { min-height: 32px; padding: 4px 8px; }
  .amount-entry { flex-shrink: 0; padding: 0 0 8px; }
  .amount-entry input { font-size: clamp(30px, 5vw, 42px); letter-spacing: -1px; }
  .amount-entry > span { font-size: 24px; }
  .note-field { flex-shrink: 0; padding-inline: 10px; }
  .note-field input { min-height: 44px; padding: 8px 0; font-size: 16px; }
  .keypad-calculator-tools { flex-shrink: 0; gap: 6px; margin-top: 8px; }
  .keypad-calculator-tools button { min-height: 44px; }
  .keypad { flex: 1; min-height: 200px; max-height: calc(100cqw + 6px); grid-template-rows: repeat(4, minmax(44px, 1fr)); gap: 6px; padding-top: 8px; }
  .keypad button[data-key] { aspect-ratio: auto; min-height: 44px; font-size: 25px; }
  .add-button { min-height: 94px; padding: 4px; }
  .keypad-bottom { flex-shrink: 0; margin-top: auto; padding-top: 4px; min-height: 20px; }
  .keypad-bottom .text-button { min-height: 28px; padding: 2px 6px; }
  .keypad-bottom .keyboard-hint { display: none; }
  .field-error:not(:empty) { margin: 4px 0; font-size: 11px; line-height: 1.3; }
  .note-keyboard { flex: 1; min-height: 0; margin-top: 8px; display: flex; flex-direction: column; justify-content: flex-end; }
  #letter-keys { flex: 1; min-height: 144px; max-height: 204px; display: flex; flex-direction: column; }
  .letter-row { flex: 1; margin-bottom: 4px; }
  .letter-row button { min-height: 44px; }
  .note-keyboard-controls { margin-top: 4px; }
  .note-keyboard-controls button { min-height: 44px; padding: 4px; }
  .note-keyboard-actions { margin-top: 8px; }
  .note-keyboard-actions .button { min-height: 44px; padding: 8px 4px; }
  .bill-label-bar { flex-shrink: 0; gap: 8px; margin-bottom: 8px; }
  .bill-label-bar > label { display: none; }
  .bill-label-bar input { min-height: 44px; padding: 8px; font-size: 16px; max-width: none; }
  .bill-label-bar .text-button { padding: 8px; }
  .receipt-heading { flex-shrink: 0; margin-bottom: 8px; }
  .receipt-heading h2 { font-size: 16px; }
  .receipt-heading p { font-size: 11px; }
  .receipt-paper { min-height: 0; }
  .receipt-store { flex-shrink: 0; padding: 4px 0 8px; }
  .empty-bill { min-height: 0; padding: 12px 0; }
  .empty-plus { margin-bottom: 4px; }
  .bill-items { min-height: 0; max-height: none; overscroll-behavior: contain; }
  .bill-item { min-height: 52px; }
  .edit-item { min-height: 48px; }
  .receipt-total { flex-shrink: 0; margin: 0; border: 0; border-top: 1px dashed var(--border); border-radius: 0; padding: 10px 0; }
  #total { font-size: clamp(22px, 3vw, 30px); }
  .receipt-actions { flex-shrink: 0; grid-template-columns: 1.5fr 1fr; gap: 6px; }
  .receipt-actions .button { min-height: 44px; padding: 8px 4px; font-size: 12px; gap: 6px; }
  .payment-button { flex-shrink: 0; min-height: 44px; padding: 8px; margin-top: 6px; }
  .receipt-hint { display: none; }
  .karmos-banner { display: none; }
  .app-footer { flex-shrink: 0; padding: 6px 0; font-size: 10px; flex-wrap: nowrap; }
  .app-footer > span { display: none; }
  .app-footer a { margin: auto; color: var(--primary); }
  /* Calculator tools are views instead of a long vertical stack. */
  #calculator-view { display: flex; flex-direction: column; overflow: hidden; }
  #calculator-view > .page-heading { display: none; }
  .calculator-context { flex-shrink: 0; margin: 0; gap: 4px; min-height: 44px; font-size: 11px; }
  .calculator-context .text-button { padding: 8px 4px; white-space: nowrap; }
  .calculator-pane-nav { flex-shrink: 0; display: flex; gap: 4px; margin-bottom: 8px; }
  .calculator-pane-nav button { flex: 1; border: 1px solid var(--border); background: white; border-radius: 6px; color: var(--muted); min-height: 44px; padding: 8px 4px; font-size: 12px; }
  .calculator-pane-nav button[aria-pressed="true"] { background: #e9ebf5; color: var(--primary); border-color: #bac2e1; }
  .calculator-layout { flex: 1; display: flex; min-height: 0; }
  .calculator-panel { flex: 1; min-height: 0; padding: 12px; margin: 0; overflow: auto; overscroll-behavior: contain; }
  #arithmetic-panel { display: flex; flex-direction: column; overflow: hidden; container-type: inline-size; }
  #arithmetic-panel .form-field { flex-shrink: 0; margin: 0; font-size: 12px; }
  #calc-expression { min-height: 44px; padding: 8px; margin-top: 4px; font-size: 16px; }
  #arithmetic-panel .calculator-result { flex-shrink: 0; padding: 4px 0; }
  #arithmetic-panel .calculator-result output { font-size: 26px; }
  .memory-controls { flex-shrink: 0; margin-bottom: 6px; }
  .calculator-keys { flex: 1; min-height: 244px; width: 100%; max-width: 600px; max-height: min(420px, calc(100cqw + 6px)); grid-template-rows: repeat(5, minmax(44px, 1fr)); gap: 6px; margin: 0 auto; }
  .calc-key { aspect-ratio: auto; min-height: 44px; font-size: 20px; }
  #arithmetic-panel > .section-description { display: none; }
  #arithmetic-panel .calculator-actions { flex-shrink: 0; margin-top: auto; padding-top: 8px; gap: 6px; }
  #arithmetic-panel .calculator-actions .button { min-height: 44px; padding: 8px 4px; font-size: 12px; }
  #calculator-view[data-calculator-pane="calculator"] #business-panel,
  #calculator-view[data-calculator-pane="business"] #arithmetic-panel,
  #calculator-view:not([data-calculator-pane="history"]) #history-panel,
  #calculator-view[data-calculator-pane="history"] .calculator-layout { display: none; }
  #history-panel { flex: 1; min-height: 0; margin: 0; overflow: auto; }
}
@media screen and (max-width: 640px) {
  .app-shell { padding-inline: 10px; }
  .app-header { min-height: 52px; padding: 4px 0; gap: 8px; }
  .brand { gap: 8px; }
  .brand-byline { display: none; }
  .header-actions { gap: 4px; }
  .header-actions .button { padding: 8px; }
  .workspace-nav button { font-size: 11px; letter-spacing: -.2px; }
  #billing-view { padding-top: 6px; }
  .bill-tabs-bar { margin-bottom: 6px; }
  .counter-layout { grid-template-columns: 1fr; }
  .keypad-panel, .receipt-panel { padding: 10px; }
  #billing-view:not([data-receipt-open="true"]) .receipt-panel,
  #billing-view[data-receipt-open="true"] .keypad-panel { display: none; }
  .mobile-bill-bar { flex-shrink: 0; display: flex; align-items: stretch; gap: 8px; margin-top: 6px; }
  .mobile-total { display: flex; position: static; flex: 1; min-width: 0; min-height: 52px; margin: 0; padding: 6px 10px; background: white; font: inherit; text-align: left; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
  .mobile-total > span { font-size: 11px; color: var(--muted); }
  .mobile-total strong { font-size: 22px; line-height: 1.15; }
  #quick-payment { padding: 8px 12px; min-height: 52px; }
  .back-to-keypad { display: block; align-self: flex-start; min-height: 44px; margin: -4px 0 4px -4px; padding: 8px 4px; }
  #billing-view[data-receipt-open="true"] .mobile-bill-bar { display: none; }
  #billing-view[data-receipt-open="true"] .bill-tabs-bar { display: none; }
  .receipt-total { flex-wrap: nowrap; }
  .calculator-context > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .calculator-pane-nav { margin-bottom: 6px; }
}
@media screen and (max-height: 650px) {
  .keypad-panel { position: relative; padding: 8px; }
  .amount-heading { display: none; }
  .amount-entry { min-height: 44px; width: calc(100% - 144px); align-items: center; padding: 0; }
  .amount-entry input { font-size: 28px; }
  .keypad-calculator-tools { position: absolute; top: 8px; right: 8px; width: 136px; margin: 0; gap: 4px; }
  .keypad-calculator-tools button { min-height: 44px; font-size: 0; }
  .keypad-calculator-tools button::before { font-size: 22px; }
  #keypad-multiply::before { content: '×'; }
  #keypad-divide::before { content: '÷'; }
  #keypad-calculator::before { content: 'Calc'; font-size: 11px; }
  .keypad { padding-top: 0; margin-top: 4px; min-height: 188px; gap: 4px; }
  .add-button { min-height: 92px; }
  .keypad-bottom { font-size: 10px; }
  #billing-view[data-keyboard-mode="note"] .amount-entry { display: none; }
  .note-keyboard { margin-top: 4px; min-height: 232px; }
  #letter-keys { min-height: 140px; gap: 4px; }
  .letter-row { margin: 0; }
  .note-keyboard-actions { margin-top: 4px; }
  .receipt-store { display: none; }
}
@media screen and (max-height: 650px) {
  #calculator-view .calculator-context { min-height: 36px; }
  #calculator-view .calculator-context .text-button { min-height: 36px; }
  #arithmetic-panel { padding: 6px; display: grid; grid-template-columns: minmax(0, 1fr) 84px; grid-template-rows: 44px auto minmax(236px, 1fr) 44px; gap: 4px; }
  #arithmetic-panel .form-field { font-size: 0; }
  #calc-expression { margin-top: 0; }
  #arithmetic-panel .calculator-result { padding: 4px; flex-direction: column; align-items: flex-end; gap: 0; border-radius: 6px; background: #f0f1f8; }
  #arithmetic-panel .calculator-result span { font-size: 10px; }
  #arithmetic-panel .calculator-result output { font-size: 18px; max-width: 100%; white-space: nowrap; overflow-x: auto; }
  #calc-error { grid-column: 1 / -1; }
  .calculator-keys { grid-column: 1 / -1; grid-row: 3; min-height: 236px; gap: 4px; max-height: none; height: 100%; }
  .memory-controls button { min-height: 36px; }
  #arithmetic-panel .calculator-actions { grid-column: 1 / -1; grid-row: 4; margin: 0; padding: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #arithmetic-panel .calculator-actions .wide-action { grid-column: auto; }
  #arithmetic-panel .calculator-actions .button { font-size: 11px; }
}
@media screen and (max-height: 560px) {
  .app-header { min-height: 44px; padding: 0; }
  .brand-byline { display: none; }
  .workspace-nav { padding-block: 0; }
  .app-footer { padding-block: 3px; }
  #calculator-view .calculator-context { display: none; }
  .calculator-pane-nav { margin: 2px 0; }
  .calculator-pane-nav button { min-height: 36px; padding-block: 4px; }
  #arithmetic-panel { padding: 4px; gap: 2px; grid-template-rows: 44px auto minmax(228px, 1fr) 44px; }
  .calculator-keys { min-height: 228px; gap: 2px; }
}
@media screen and (max-width: 640px) and (max-height: 560px) {
  .bill-tabs-bar { margin-bottom: 4px; }
  #billing-view { padding-top: 4px; }
  .mobile-bill-bar { margin-top: 4px; }
  .mobile-total, #quick-payment { min-height: 48px; }
  .keypad-bottom { display: none; }
  .keypad { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(44px, 1fr)); min-height: 140px; max-height: calc(60cqw + 4px); }
  .keypad [data-key="7"] { grid-area: 1 / 1; }
  .keypad [data-key="8"] { grid-area: 1 / 2; }
  .keypad [data-key="9"] { grid-area: 1 / 3; }
  .keypad [data-key="backspace"] { grid-area: 1 / 4; }
  .keypad [data-key="clear"] { grid-area: 1 / 5; }
  .keypad [data-key="4"] { grid-area: 2 / 1; }
  .keypad [data-key="5"] { grid-area: 2 / 2; }
  .keypad [data-key="6"] { grid-area: 2 / 3; }
  .keypad [data-key="."] { grid-area: 2 / 4; }
  .keypad .add-button { grid-area: 2 / 5; min-height: 44px; font-size: 0; gap: 0; }
  #add-symbol { font-size: 28px; }
  .keypad [data-key="1"] { grid-area: 3 / 1; }
  .keypad [data-key="2"] { grid-area: 3 / 2; }
  .keypad [data-key="3"] { grid-area: 3 / 3; }
  .keypad [data-key="0"] { grid-area: 3 / 4; }
  .keypad [data-key="00"] { grid-area: 3 / 5; }
  .note-keyboard { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: minmax(140px, 1fr) 44px; gap: 4px; min-height: 188px; }
  #letter-keys { grid-column: 1 / -1; height: 100%; }
  .note-keyboard-controls, .note-keyboard-actions { display: contents; }
  .note-keyboard-controls button, .note-keyboard-actions .button { min-width: 0; min-height: 44px; padding: 2px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  @page { size: auto; margin: 0; }
  html, body { width: var(--paper-width, 80mm); margin: 0; padding: 0; background: white; color: black; }
  body > * { display: none !important; }
  body > #print-receipt { display: block !important; width: 100%; padding: 3mm; font-family: "Courier New", monospace; font-size: 10pt; line-height: 1.4; }
  .print-header, .print-footer { text-align: center; overflow-wrap: anywhere; }
  .print-header h1 { font: bold 13pt "Courier New", monospace; margin: 0 0 2mm; overflow-wrap: anywhere; }
  .print-header p { margin: 1mm 0; font-size: 9pt; }
  .print-rows { margin: 3mm 0; border-top: 1px dashed black; border-bottom: 1px dashed black; padding: 2mm 0; }
  .print-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 2mm; padding: 1.5mm 0; break-inside: avoid; }
  .print-row span:first-child { min-width: 0; overflow-wrap: anywhere; }
  .print-row span:last-child { flex-shrink: 0; }
  .print-total { display: flex; justify-content: space-between; gap: 2mm; font-size: 12pt; font-weight: bold; break-inside: avoid; flex-wrap: wrap; }
  .print-footer { font-size: 8pt; margin-top: 4mm; break-inside: avoid; }
  .print-footer p { margin: 1mm 0; }
}
