:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef7f5;
  --ink: #15201e;
  --muted: #63706d;
  --line: #d8e0de;
  --accent: #0f766e;
  --accent-strong: #0b5f58;
  --amber: #b7791f;
  --red: #b42318;
  --green: #16794c;
  --shadow: 0 10px 26px rgba(21, 32, 30, 0.08);
  --touch: 46px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  overscroll-behavior: none;
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: var(--touch);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

button.primary,
.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.app-shell {
  width: min(1420px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.topbar-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.topbar-title > div {
  min-width: 0;
}

.back-btn {
  flex: 0 0 auto;
  width: 40px;
  min-width: 40px;
  padding: 8px;
  color: var(--accent-strong);
  background: var(--surface-soft);
  border-color: #b9e2dd;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.topbar strong {
  display: block;
  font-size: 24px;
}

.topbar span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mobile-switch {
  display: none;
}

.notice,
.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.notice {
  color: #0b4f35;
  background: #dff7ea;
  border: 1px solid #b7e8ca;
}

.alert {
  color: #7a1d16;
  background: #fff0ee;
  border: 1px solid #ffc8c2;
}

.hidden { display: none !important; }

.ledger-layout {
  display: grid;
  grid-template-columns: minmax(620px, 0.95fr) minmax(420px, 0.7fr);
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h1,
.panel-head h2 {
  margin: 0;
  font-size: 20px;
}

.panel-head span,
label span,
.section-title span,
.cash-summary span,
.history-summary span,
.entry-amounts span {
  color: var(--muted);
  font-size: 13px;
}

.workflow-hint {
  max-width: 620px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

#shiftHint {
  white-space: nowrap;
  color: var(--accent-strong);
  background: var(--surface-soft);
  border: 1px solid #b9e2dd;
  border-radius: 8px;
  padding: 8px 10px;
}

.form-grid,
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.handover-meta {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(0, 1.2fr);
  gap: 8px;
  margin: -2px 0 10px;
}

.handover-meta-item {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px 10px;
}

.handover-meta-item span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.handover-meta-item strong {
  min-width: 0;
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cashier-inline {
  gap: 2px;
  background: #fff;
}

.cashier-inline input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  padding: 0;
}

.cashier-inline input:focus {
  outline: 0;
  border-color: transparent;
}

.shift-workers {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: -2px 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.shift-workers > span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.worker-select-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.worker-select-list select {
  min-height: 38px;
  padding: 7px 9px;
  font-size: 15px;
}

.shift-workers button {
  min-height: 38px;
  padding: 7px 10px;
  color: var(--accent-strong);
  background: var(--surface-soft);
  border-color: #b9e2dd;
  font-weight: 700;
  white-space: nowrap;
}

.compact-form {
  align-items: start;
}

#entryForm[data-count-mode="opening"] .closing-only {
  display: none;
}

#entryForm[data-count-mode="opening"] .cash-summary {
  display: none;
}

#entryForm[data-count-mode="closing"] .opening-only {
  display: none;
}

#countingStageStatus {
  display: block;
  margin: -4px 0 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

#countingStageStatus.is-blocked {
  color: var(--red);
  font-weight: 700;
}

.filter-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 10px;
  margin-bottom: 12px;
}

.filter-grid .inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 5px;
  min-width: 0;
}

.filter-grid .inline-field span::after {
  content: "";
}

.filter-grid .inline-field input,
.filter-grid .inline-field select {
  width: 100%;
  min-width: 0;
  height: 42px;
  min-height: 42px;
  padding: 8px 10px;
  font-size: 16px;
  line-height: 1.2;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  align-content: start;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  padding: 10px 11px;
  min-height: var(--touch);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

input[readonly] {
  background: #f8fafc;
  color: var(--accent-strong);
  font-weight: 700;
}

input:disabled,
select:disabled {
  background: #f8fafc;
  color: var(--ink);
  font-weight: 700;
  opacity: 1;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 7px;
}

.input-action.auto-cash-sales {
  grid-template-columns: minmax(0, 1fr) 56px;
}

.pos-auto-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  border: 1px solid #b9e2dd;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.pos-auto-state[data-state="loading"] {
  color: #7a4d00;
  background: #fff8e8;
  border-color: #eed69d;
}

.pos-auto-state[data-state="ready"] {
  color: var(--green);
  background: #eaf7ef;
  border-color: #bfe8ce;
}

.pos-auto-state[data-state="error"] {
  color: var(--red);
  background: #fff0ee;
  border-color: #ffc8c2;
}

.input-action button {
  min-height: var(--touch);
  padding: 8px 10px;
  color: var(--accent-strong);
  background: var(--surface-soft);
  border-color: #b9e2dd;
  font-weight: 700;
}

.input-action button:disabled {
  color: #8b9895;
  background: #f3f5f5;
  border-color: var(--line);
}

label small {
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.compact-field small {
  display: block;
  min-height: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-field em {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #fff4e5;
  color: #9a5c00;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.compact-field em.checked {
  background: #eaf7ef;
  color: var(--green);
}

.readout-field strong {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--accent-strong);
  padding: 10px 11px;
}

.cash-out-section,
.denom-section {
  margin-top: 10px;
}

.cash-out-list {
  display: grid;
  gap: 6px;
}

.cash-out-head,
.cash-out-row {
  display: grid;
  grid-template-columns: 120px 110px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.cash-out-head {
  padding: 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cash-out-section.is-disabled {
  opacity: 0.72;
}

.cash-out-section.is-disabled select,
.cash-out-section.is-disabled input,
.cash-out-section.is-disabled button {
  cursor: not-allowed;
}

.cash-out-list.single-row .cash-out-row button {
  display: none;
}

.cash-out-list.single-row .cash-out-row {
  grid-template-columns: 120px 110px minmax(0, 1fr);
}

.cash-out-row [data-cash-out-note] {
  grid-column: auto;
}

.cash-out-row button {
  min-height: var(--touch);
  padding: 8px 10px;
  color: var(--red);
}

.add-cash-out-btn {
  width: 100%;
  margin-top: 8px;
  color: var(--accent-strong);
  background: var(--surface-soft);
  border-color: #b9e2dd;
  font-weight: 700;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.denomination-grid {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.denomination-grid.is-locked {
  border-color: #ffc8c2;
  background: #fff8f7;
}

.denomination-row {
  display: grid;
  grid-template-columns: minmax(76px, 0.8fr) minmax(90px, 1fr) minmax(104px, 1fr);
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
}

.denomination-row:last-child {
  border-bottom: 0;
}

.denomination-head,
.denomination-total {
  background: #f8fafc;
}

.denomination-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.denomination-row > :nth-child(1) {
  justify-self: start;
  text-align: left;
}

.denomination-row > :nth-child(2) {
  justify-self: stretch;
  text-align: center;
}

.denomination-row > :nth-child(3) {
  justify-self: end;
  text-align: right;
}

.denomination-row strong {
  color: #6f4d11;
  font-weight: 700;
}

.denomination-row input {
  text-align: center;
  min-height: 34px;
  padding: 5px 7px;
  font-size: 16px;
}

.denomination-row b,
.denomination-total strong {
  color: var(--ink);
  text-align: right;
  font-size: 14px;
}

.note-field {
  margin-top: 14px;
}

.cash-summary,
.history-summary,
.entry-amounts {
  display: grid;
  gap: 10px;
}

.cash-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 14px;
}

.history-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 12px;
  gap: 6px;
}

.entry-amounts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.cash-summary div,
.history-summary div {
  border: 1px solid var(--line);
  background: #fafafa;
  border-radius: 8px;
  padding: 10px;
}

.history-summary div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 9px;
}

.cash-summary strong,
.history-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1.15;
}

.history-summary strong {
  margin-top: 0;
  font-size: 13px;
  white-space: nowrap;
}

.history-summary span::after {
  content: "：";
}

.entry-amounts span {
  display: block;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fafafa;
  border-radius: 7px;
  padding: 7px 8px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-amounts b {
  color: var(--muted);
  font-weight: 600;
}

.entry-amounts strong {
  color: var(--ink);
  font-weight: 700;
}

.positive { color: var(--amber); }
.negative { color: var(--red); }
.money-positive { color: var(--amber) !important; }
.money-negative { color: var(--red) !important; }

.submit-btn {
  width: 100%;
  margin-top: 14px;
  min-height: 50px;
}

.entries-list {
  display: grid;
  gap: 10px;
}

.entry-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.entry-card.over { border-left-color: var(--amber); }
.entry-card.short { border-left-color: var(--red); }
.entry-card.missing {
  border-left-color: #c7d1cf;
  background: #fbfcfc;
}

.entry-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.entry-card header strong,
.entry-card header span {
  display: block;
}

.entry-card header strong {
  line-height: 1.25;
}

.entry-card header span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.entry-card em {
  align-self: flex-start;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-style: normal;
  font-weight: 700;
  padding: 5px 9px;
  white-space: nowrap;
}

.entry-card-actions {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-shrink: 0;
}

.mini-edit-btn {
  min-height: 30px;
  padding: 5px 9px;
  border-color: #dce6e4;
  background: #f2f6f5;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.entry-edited-line {
  color: #7a4d00 !important;
}

.entry-card.over em {
  color: #7a4d00;
  background: #fff3d0;
}

.entry-card.short em {
  color: #8a2118;
  background: #ffe4e1;
}

.entry-card.missing em {
  color: var(--muted);
  background: #eef2f1;
}

.entry-card details {
  margin-top: 7px;
}

.entry-card summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}

.entry-detail-section {
  margin-top: 8px;
}

.entry-detail-section h4 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
}

.entry-detail-section h5 {
  margin: 7px 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.entry-detail-total {
  border: 1px solid #b9e2dd;
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 7px 8px;
  color: var(--muted);
  font-size: 13px;
}

.entry-detail-total strong {
  color: var(--ink);
}

.entry-detail-grid {
  display: grid;
  gap: 4px;
}

.denom-detail-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cash-out-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.opening-detail-grid {
  display: block;
}

.entry-opening-line {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.entry-opening-line span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-workers-line {
  margin-top: 4px;
  grid-template-columns: 1fr;
}

.entry-workers-line span {
  white-space: normal;
}

.entry-opening-line strong {
  color: var(--ink);
}

.entry-detail-row {
  display: grid;
  grid-template-columns: minmax(74px, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  padding: 6px 8px;
  font-size: 13px;
}

.cash-out-detail-row {
  grid-template-columns: minmax(58px, 0.72fr) minmax(82px, 0.86fr) minmax(0, 1fr);
}

.denom-detail-row {
  grid-template-columns: minmax(52px, 0.8fr) minmax(0, 1fr);
}

.entry-detail-row span,
.entry-detail-row em {
  min-width: 0;
  color: var(--muted);
  font-style: normal;
  overflow-wrap: anywhere;
}

.entry-detail-row strong {
  min-width: 0;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.denom-detail-row strong {
  text-align: right;
  white-space: nowrap;
}

.entry-detail-row.detail-head {
  background: transparent;
  border-color: transparent;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.empty strong,
.empty span {
  display: block;
}

.empty strong {
  color: var(--ink);
  margin-bottom: 4px;
}

.cashbox-edit-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: min(88vh, 860px);
  border: 0;
  border-radius: 10px;
  padding: 0;
  background: #fff;
  box-shadow: 0 24px 70px rgba(21, 32, 30, 0.28);
}

.cashbox-edit-dialog::backdrop {
  background: rgba(11, 31, 28, 0.42);
}

.cashbox-edit-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(88vh, 860px);
}

.cashbox-edit-panel header,
.cashbox-edit-panel footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.cashbox-edit-panel footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.cashbox-edit-panel header strong,
.cashbox-edit-panel header span {
  display: block;
}

.cashbox-edit-panel header strong {
  font-size: 18px;
}

.cashbox-edit-panel header span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.danger-icon-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border-color: #c91f1f;
  background: #df2b2f;
  color: #fff;
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(180, 35, 24, 0.22);
}

.cashbox-edit-body {
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 16px;
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.edit-grid label,
.cashbox-edit-dialog .note-field {
  display: grid;
  gap: 5px;
}

.edit-grid span,
.cashbox-edit-dialog .note-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.edit-section {
  margin-top: 12px;
}

.edit-pos-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.edit-pos-action button {
  min-height: 42px;
  padding: 8px 12px;
  background: var(--surface-soft);
  border-color: #b9e2dd;
  color: var(--accent-strong);
  font-weight: 700;
}

.edit-pos-field small {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.edit-section .section-title button {
  min-height: 34px;
  padding: 6px 10px;
}

.edit-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pin-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(11, 31, 28, 0.42);
  padding: 20px;
}

.pin-panel {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 18px;
}

.pin-panel strong {
  font-size: 22px;
}

.pin-panel p {
  margin: 0;
  color: var(--red);
  min-height: 18px;
}

@media (max-width: 980px) {
  .ledger-layout {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-form {
    gap: 8px 10px;
  }

  .compact-field {
    gap: 4px;
  }

  .compact-field input,
  .compact-field select,
  .compact-field .input-action button,
  .pos-auto-state,
  .readout-field strong {
    min-height: 40px;
    padding: 8px 10px;
  }

  .cash-out-row {
    grid-template-columns: minmax(96px, 0.8fr) minmax(92px, 0.7fr) minmax(110px, 1fr) auto;
  }

  .cash-out-row select,
  .cash-out-row input,
  .cash-out-row button,
  .add-cash-out-btn {
    min-height: 40px;
    padding: 8px 10px;
  }

  .cash-out-list.single-row .cash-out-row {
    grid-template-columns: minmax(96px, 0.8fr) minmax(92px, 0.7fr) minmax(110px, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    padding: 0 10px calc(18px + env(safe-area-inset-bottom));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    margin: 0 -10px 8px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    background: rgba(246, 247, 249, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }

  .topbar strong {
    font-size: 20px;
    line-height: 1.15;
  }

  .topbar-title {
    gap: 8px;
  }

  .back-btn {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 7px;
    font-size: 18px;
  }

  .topbar span {
    font-size: 12px;
    line-height: 1.35;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .topbar-actions button,
  .topbar-actions .button-link {
    min-height: 40px;
    padding: 8px 12px;
    text-align: center;
  }

  .mobile-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin: 0 0 8px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #e9eeee;
  }

  .mobile-switch button {
    min-height: 42px;
    border-color: transparent;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
  }

  .mobile-switch button.active {
    background: #fff;
    color: var(--accent-strong);
    border-color: #fff;
    box-shadow: 0 1px 4px rgba(21, 32, 30, 0.08);
  }

  .app-shell[data-mobile-view="entry"] #historyPanel,
  .app-shell[data-mobile-view="history"] #entryPanel {
    display: none;
  }

  .ledger-layout {
    gap: 10px;
  }

  .panel {
    padding: 14px;
  }

  .panel-head {
    align-items: center;
    flex-direction: row;
    margin-bottom: 12px;
  }

  .panel-head h1,
  .panel-head h2 {
    font-size: 19px;
  }

  #shiftHint {
    padding: 8px 9px;
    font-size: 13px;
  }

  .handover-meta {
    grid-template-columns: minmax(126px, 0.9fr) minmax(0, 1.1fr);
    gap: 7px;
    margin-bottom: 9px;
  }

  .handover-meta-item {
    min-height: 38px;
    padding: 7px 9px;
  }

  .handover-meta-item span {
    font-size: 12px;
  }

  .handover-meta-item strong,
  .cashier-inline input {
    font-size: 15px;
  }

  .shift-workers {
    grid-template-columns: 1fr auto;
    gap: 7px;
    padding: 7px 9px;
  }

  .shift-workers > span {
    grid-column: 1 / -1;
    font-size: 12px;
  }

  .worker-select-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .worker-select-list select,
  .shift-workers button {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 14px;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .compact-form {
    gap: 7px 9px;
  }

  .compact-field {
    gap: 3px;
  }

  .compact-field input,
  .compact-field select,
  .compact-field .input-action button,
  .pos-auto-state,
  .readout-field strong {
    min-height: 38px;
    padding: 7px 9px;
    font-size: 15px;
  }

  .compact-field.system-field input,
  .compact-field.system-field select {
    font-size: 15px;
    font-weight: 700;
  }

  .compact-field small {
    min-height: 13px;
    font-size: 11px;
    line-height: 1.2;
  }

  .compact-field .input-action {
    grid-template-columns: minmax(0, 1fr) 62px;
    gap: 5px;
  }

  .compact-field .auto-cash-sales {
    grid-template-columns: minmax(0, 1fr) 52px;
  }

  .pos-auto-state {
    font-size: 12px;
  }

  .form-grid > *,
  .filter-grid > *,
  .denomination-row > *,
  .cash-out-row > *,
  .cash-summary > *,
  .history-summary > *,
  .entry-amounts > * {
    min-width: 0;
  }

  label span,
  .section-title span,
  .cash-summary span,
  .history-summary span {
    font-size: 12px;
  }

  .section-title {
    align-items: flex-end;
    margin-bottom: 4px;
  }

  .cash-out-head,
  .cash-out-row {
    grid-template-columns: minmax(72px, 0.72fr) minmax(76px, 0.78fr) minmax(0, 1fr) auto;
    gap: 5px;
  }

  .cash-out-list.single-row .cash-out-row {
    grid-template-columns: minmax(72px, 0.72fr) minmax(76px, 0.78fr) minmax(0, 1fr);
  }

  .cash-out-row [data-remove-cash-out] {
    grid-column: 4;
    grid-row: 1;
  }

  .cash-out-row [data-cash-out-note] {
    grid-column: auto;
    grid-row: auto;
  }

  .cash-out-row button {
    padding: 7px 8px;
  }

  .add-cash-out-btn {
    margin-top: 6px;
  }

  .denomination-row {
    grid-template-columns: minmax(58px, 0.7fr) minmax(72px, 0.9fr) minmax(90px, 1fr);
    gap: 5px;
    padding: 4px 7px;
  }

  .denomination-row input {
    min-height: 32px;
    padding: 4px 6px;
    font-size: 16px;
  }

  .denomination-row b,
  .denomination-total strong {
    font-size: 14px;
  }

  .note-field textarea {
    min-height: 82px;
  }

  .submit-dock {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 14px -14px -14px;
    padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
    backdrop-filter: blur(12px);
  }

  .cash-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    margin-top: 0;
  }

  #entryForm[data-count-mode="opening"] .cash-summary {
    display: none;
  }

  .cash-summary div:last-child {
    grid-column: 1 / -1;
  }

  .cash-summary div {
    padding: 7px 8px;
  }

  .cash-summary strong {
    font-size: 14px;
    white-space: nowrap;
  }

  .submit-btn {
    margin-top: 8px;
    min-height: 48px;
    font-size: 16px;
  }

  .filter-grid,
  .history-summary {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .history-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .history-summary div {
    padding: 9px;
  }

  .entry-card {
    padding: 9px 10px;
  }

  .entry-card header {
    align-items: flex-start;
  }

  .entry-card-actions {
    flex-direction: column;
    align-items: flex-end;
  }

  .cashbox-edit-dialog {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }

  .cashbox-edit-panel {
    max-height: 100dvh;
  }

  .cashbox-edit-panel header,
  .cashbox-edit-panel footer,
  .cashbox-edit-body {
    padding-left: 12px;
    padding-right: 12px;
  }

  .edit-grid,
  .edit-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cashbox-edit-dialog .cash-out-head,
  .cashbox-edit-dialog .cash-out-row {
    grid-template-columns: minmax(72px, 0.74fr) minmax(76px, 0.78fr) minmax(0, 1fr) auto;
  }

  .entry-amounts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .entry-opening-line {
    grid-template-columns: 1fr;
  }

  .entry-opening-line span {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .denom-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cash-out-detail-grid {
    grid-template-columns: 1fr;
  }

  .cash-out-detail-row {
    grid-template-columns: minmax(58px, 0.7fr) minmax(112px, 0.9fr) minmax(0, 1.3fr);
  }

  .cash-out-detail-row em {
    text-align: left;
  }

  .empty {
    padding: 26px 14px;
  }
}

@media (max-width: 380px) {
  .topbar-actions,
  .form-grid,
  .filter-grid,
  .cash-summary,
  .history-summary {
    grid-template-columns: 1fr;
  }

  .entry-opening-line,
  .cash-out-detail-grid,
  .denom-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .handover-meta {
    grid-template-columns: minmax(118px, 0.88fr) minmax(0, 1.12fr);
  }

  .mobile-switch {
    margin-bottom: 8px;
  }

  .worker-select-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cash-summary strong {
    font-size: 18px;
  }
}
