.app-layout {
  --app-width: 680px;
  --app-dark: #312238;
  --app-plum: #663e6e;
  --app-lavender: #eee4f0;
  --app-paper: #fcfaf8;
  --app-surface: #fff;
  --app-line: #e9e0e4;
  --app-muted: #6f6471;
  --app-top-size: calc(58px + env(safe-area-inset-top));
  --app-tab-size: calc(66px + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
#load-error { padding: 16px; margin: 12px 0; background: #faf0e4; border-radius: 12px; }
#load-error button { margin-top: 8px; }

.app-layout body {
  color: var(--app-dark);
  background: var(--app-paper);
  font-size: 15px;
}
.app-layout body:has(dialog[open]) { overflow: hidden; }
.app-layout aside,
.app-layout #headerStore,
.app-layout .auth #app-top,
.app-layout .auth #app-tabs,
.app-layout .app-show-more #content { display: none !important; }
.app-layout main {
  width: min(100%, var(--app-width));
  margin: 0 auto;
  padding: 16px max(18px, env(safe-area-inset-right)) calc(22px + var(--app-tab-size)) max(18px, env(safe-area-inset-left));
}
.app-layout .page-header { display: flex; flex-direction: column-reverse; align-items: start; gap: 4px; padding: 0; border: 0; }
.app-layout .page-header time { color: var(--app-muted); font-size: 13px; }
.app-layout .page-header h2 { font-size: clamp(26px, 7vw, 34px); line-height: 1.3; letter-spacing: -.035em; }
.app-layout #content,
.app-layout #app-more { margin-top: 16px; min-width: 0; }
.app-layout :is(button, input, select, summary, .app-menu a) { min-height: 44px; }
.app-layout :is(input, select, textarea) { max-width: 100%; font-size: 16px; }
.app-layout header,
.app-layout .bar,
.app-layout .section-head { gap: 8px; }
.app-layout #content h3 { margin: 22px 0 10px; scroll-margin-top: calc(var(--app-top-size) + 12px); }
.app-layout #calendarDate { scroll-margin-top: calc(var(--app-top-size) + 12px); }
.app-layout #content .bar h3 { margin: 8px 0; }
.app-layout #content > :is(button, details) { margin: 0 4px 6px 0; }
.app-layout button { padding: 8px 13px; border-radius: 10px; }
.app-layout .primary { background: var(--app-plum); border-color: var(--app-plum); }
.app-layout .app-top {
  position: sticky;
  z-index: 3;
  top: 0;
  padding-top: env(safe-area-inset-top);
  background: var(--app-paper);
  border-bottom: 1px solid var(--app-line);
}
.app-top-inner {
  min-height: 57px;
  max-width: var(--app-width);
  margin: auto;
  padding: 6px max(18px, env(safe-area-inset-right)) 6px max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-mark {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: var(--app-dark);
}
.app-mark i {
  width: 14px;
  height: 23px;
  border: 1.5px solid #f5d9b9;
  border-radius: 7px;
  background: repeating-linear-gradient(-37deg, #f5d9b9 0 3px, transparent 3px 7px);
}
.app-layout .app-store {
  display: grid;
  min-width: 0;
  text-align: left;
  line-height: 1.15;
  background: transparent;
  border: 0;
  padding: 0;
}
.app-store strong { font-size: 18px; letter-spacing: .1em; }
.app-store small { color: var(--app-muted); margin-top: 3px; font-size: 12px; overflow-wrap: anywhere; }
.app-layout .app-bell {
  margin-left: auto;
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  min-width: 44px;
  background: var(--app-surface);
}
.app-bell i { position: absolute; width: 8px; height: 8px; top: 7px; right: 7px; background: #a94465; border-radius: 50%; }
.app-layout #app-tabs {
  position: fixed;
  z-index: 4;
  inset: auto 0 0;
  width: min(100%, var(--app-width));
  height: var(--app-tab-size);
  margin: auto;
  display: flex;
  flex-direction: row;
  gap: 2px;
  overflow: visible;
  padding: 4px max(10px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(10px, env(safe-area-inset-left));
  background: var(--app-surface);
  border-top: 1px solid var(--app-line);
  box-shadow: 0 -5px 22px #33243b0b;
}
.app-layout #app-tabs button {
  flex: 1 1 0;
  display: grid;
  justify-items: center;
  align-content: center;
  font-size: 12px;
  line-height: 1;
  gap: 5px;
  border: 0;
  border-radius: 13px;
  padding: 4px 0;
  color: var(--app-muted);
}
.app-layout #app-tabs button[aria-current] { color: var(--app-plum); background: var(--app-lavender); font-weight: 750; }
.app-icon { position: relative; display: inline-block; width: 22px; height: 22px; flex: 0 0 22px; color: inherit; }
.app-icon::before, .app-icon::after { content: ""; position: absolute; }
.icon-home::before { left: 3px; top: 3px; width: 7px; height: 7px; border-radius: 2px; background: currentColor; box-shadow: 9px 0, 0 9px, 9px 9px; }
.icon-calendar::before { inset: 4px 2px 2px; border: 1.7px solid; border-radius: 4px; }
.icon-calendar::after { left: 4px; right: 4px; top: 8px; height: 1.7px; background: currentColor; }
.icon-add::before { inset: 2px; border: 1.7px solid; border-radius: 5px; }
.icon-add::after { content: "+"; inset: 0; font: 600 18px/21px system-ui; text-align: center; }
.icon-card::before, .icon-cash::before { inset: 4px 1px; border: 1.7px solid; border-radius: 4px; }
.icon-card::after { left: 2px; right: 2px; top: 9px; height: 1.7px; background: currentColor; }
.icon-cash::after { content: "¥"; inset: 0; font: 700 11px/22px system-ui; text-align: center; }
.icon-person::before { top: 2px; left: 7px; width: 8px; height: 8px; border: 1.7px solid; border-radius: 50%; }
.icon-person::after { inset: 12px 3px 2px; border: 1.7px solid; border-radius: 8px 8px 4px 4px; }
.icon-more::before { width: 3px; height: 3px; top: 9px; left: 4px; border-radius: 50%; background: currentColor; box-shadow: 6px 0, 12px 0; }
.icon-list::before { inset: 2px 4px; border: 1.7px solid; border-radius: 3px; }
.icon-list::after { left: 8px; right: 8px; top: 7px; height: 1.5px; background: currentColor; box-shadow: 0 4px, 0 8px; }
.icon-bell::before { inset: 3px 4px 5px; border: 1.7px solid; border-radius: 9px 9px 4px 4px; }
.icon-bell::after { left: 9px; right: 9px; bottom: 2px; height: 2px; border-radius: 0 0 3px 3px; background: currentColor; }
.icon-box::before { inset: 4px 3px 2px; border: 1.7px solid; border-radius: 3px; }
.icon-box::after { inset: 4px 9px 11px; background: currentColor; border-radius: 0 0 2px 2px; }
.icon-exit::before { inset: 3px 7px 3px 3px; border: 1.7px solid; border-right: 0; border-radius: 3px; }
.icon-exit::after { content: "→"; right: 1px; top: 1px; font: 600 18px/20px system-ui; }

.app-overview {
  padding: 14px 18px 12px;
  color: white;
  background: linear-gradient(115deg, #3b2944, #62416c);
  border-radius: 19px;
  font-variant-numeric: tabular-nums;
}
.app-net { display: grid; gap: 3px; }
.app-net span, .app-metrics span { color: #efdeef; font-size: 13px; }
.app-net strong { font-size: clamp(28px, 8vw, 38px); line-height: 1.16; letter-spacing: -.025em; overflow-wrap: anywhere; }
.app-metrics { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #fff3; margin-top: 9px; padding-top: 7px; }
.app-metrics > div { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px; padding-right: 14px; }
.app-metrics > div + div { border-left: 1px solid #fff3; padding-left: 14px; padding-right: 0; }
.app-metrics strong { font-size: 20px; }
.app-quick { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin: 12px 0; }
.app-layout .app-quick button {
  display: flex;
  align-items: center;
  text-align: left;
  gap: 8px;
  min-width: 0;
  min-height: 54px;
  padding: 8px 9px;
  border-color: var(--app-line);
}
.app-quick button:first-child { background: var(--app-lavender); }
.app-quick button > span:last-child { min-width: 0; }
.app-quick strong { display: block; color: var(--app-dark); font-size: 14px; }
.app-quick small { display: block; color: var(--app-muted); font-size: 11px; font-weight: 500; }
.app-quick .app-icon { color: var(--app-plum); margin: 0 4px; }
.app-layout .app-approval { display: flex; align-items: center; gap: 8px; width: 100%; font-size: 13px; text-align: left; }
.app-approval strong { margin-left: auto; color: var(--app-plum); white-space: nowrap; }
.app-layout .app-orders {
  margin-top: 17px;
  background: transparent;
  border: 0;
  overflow: visible;
  border-radius: 0;
}
.app-layout .app-orders .section-head { padding: 0; margin: 0 0 8px; }
.app-orders .section-head span { color: var(--app-muted); font-size: 13px; }
.app-layout #content .app-orders h3 { margin: 0; }
.app-filters, .app-sections {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #c8b5cc transparent;
  padding: 2px 1px 5px;
}
.app-layout :is(.app-filters,.app-sections) button { flex: none; white-space: nowrap; padding: 5px 10px; font-size: 13px; }
.app-filters button span { padding-inline-start: 2px; font-variant-numeric: tabular-nums; }
.app-filters button[aria-pressed="true"] { color: #fff; background: var(--app-plum); border-color: var(--app-plum); }
.app-sections { margin-bottom: 12px; }
.app-layout .record-search { max-width: none !important; margin-bottom: 10px !important; }

.app-layout .panel:has(table) { background: transparent; border: 0; overflow: visible; border-radius: 0; margin: 8px 0 18px; }
.app-layout .panel table { display: block; position: relative; border: 0; white-space: normal; }
.app-layout table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.app-layout table tbody { display: grid; gap: 8px; }
.app-layout tbody tr {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px 12px;
  min-width: 0;
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: 13px;
  padding: 11px 12px;
}
.app-layout table td,
.app-layout tr:hover td { border: 0; padding: 0; background: transparent; min-width: 0; overflow-wrap: anywhere; }
.app-layout td::before { display: block; content: attr(data-label); color: var(--app-muted); font-size: 11px; }
.app-layout td:has(button) { grid-column: 1 / -1; }
.app-layout td:has(button)::before { display: none; }
.app-layout td button { margin: 2px 4px 2px 0; font-size: 13px; }
.app-layout .panel .empty { padding: 19px 10px; margin-top: 6px; background: var(--app-surface); border-radius: 12px; border: 1px dashed var(--app-line); }
.app-layout .panel .empty::before { display: none; }
.app-layout .app-orders tbody tr { align-items: start; }
.app-layout .app-orders td:nth-child(1) { grid-column: 1; grid-row: 1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 6px; }
.app-layout .app-orders td:nth-child(5) { grid-column: 2; grid-row: 1; justify-self: end; }
.app-layout .app-orders td:nth-child(2) { grid-column: 1 / -1; font-weight: 600; }
.app-layout .app-orders td:nth-child(4) { text-align: right; }
.app-layout .app-orders td:nth-child(-n+2)::before,
.app-layout .app-orders td:nth-child(5)::before,
.app-layout .app-orders td.no-actions { display: none; }
.app-layout .app-orders td:nth-child(6) { grid-column: 1 / -1; border-top: 1px solid var(--app-line); padding-top: 6px; }
.app-layout .badge[data-s="待核款"] { color: #8b3754; background: #f8e7ed; }
.app-layout .app-next-action { color: var(--app-plum); background: var(--app-lavender); border-color: transparent; }
.app-layout summary { display: flex; align-items: center; gap: 6px; padding: 8px; list-style: none; }
.app-layout summary::-webkit-details-marker { display: none; }
.app-layout summary::before { content: "›"; font-size: 18px; line-height: 1; }
.app-layout details[open] > summary::before { transform: rotate(90deg); }
.app-layout details > div { grid-template-columns: repeat(2,minmax(0,1fr)); }
.app-layout details > div.panel { display: block; }
.app-layout .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.app-layout .actions input { flex: 1 1 105px; min-width: 0; width: auto; }
.app-layout #reportRows .panel { max-height: none; }
.app-layout .app-menu { display: grid; gap: 2px; padding: 4px 8px; background: white; border: 1px solid var(--app-line); border-radius: 15px; }
.app-layout .app-menu :is(button,a) {
  display: grid;
  grid-template-columns: 22px minmax(0,1fr) 12px;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 11px 10px;
  min-height: 50px;
  text-decoration: none;
  color: inherit;
  text-align: left;
  font-weight: 550;
}
.app-layout .app-menu > * + * { border-top: 1px solid var(--app-line); border-radius: 0; }
.app-menu .app-icon, .app-menu :is(button,a) span:last-child { color: var(--app-plum); }
.app-layout .stats { grid-template-columns: repeat(2,minmax(0,1fr)); margin: 12px 0; gap: 8px; }
.app-layout .stat { padding: 12px; }
.app-layout .stat strong { margin-top: 5px; font-size: 22px; overflow-wrap: anywhere; }

.app-layout body:not(.auth) dialog[open] {
  position: fixed;
  inset: 0;
  width: min(100%, var(--app-width)) !important;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
  overscroll-behavior: contain;
  background: var(--app-paper);
}
.app-layout body:not(.auth) dialog form,
.app-layout #counter[open] { display: flex; flex-direction: column; min-height: 100%; }
.app-layout dialog :is(.app-form-heading,header) {
  display: flex;
  align-items: center;
  gap: 9px;
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 61px;
  padding: 8px 0;
  margin-bottom: 11px;
  background: var(--app-paper);
  border-bottom: 1px solid var(--app-line);
}
.app-layout dialog .app-form-heading h2,
.app-layout #counter h2 { margin: 0; font-size: 21px; line-height: 1.25; }
.app-layout dialog .app-form-back[hidden] { display: inline-block !important; }
.app-layout .auth .app-form-back[hidden],
.app-layout dialog form > .bar button:first-child,
.app-layout dialog form > .bar:has(.primary[hidden]),
.app-layout #counter footer:has(.counter-confirm[hidden]) { display: none !important; }
.app-layout body:not(.auth) dialog form > .bar,
.app-layout #counter footer {
  position: sticky;
  z-index: 2;
  bottom: 0;
  margin-top: auto;
  padding: 9px 0 max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--app-line);
  background: var(--app-paper);
}
.app-layout dialog form > .bar .primary, .app-layout #counter .counter-confirm { width: 100%; }
.app-layout dialog #fields, .app-layout dialog .counter-body { margin-bottom: 12px; min-width: 0; }
.app-layout #counter .pos-columns { display: grid; grid-template-columns: 1fr; gap: 12px; }
.app-layout #counter .pos-catalog { max-height: 230px; }
.app-layout #counter .pos-catalog button { min-width: 0; overflow-wrap: anywhere; }
.app-layout #counter .pos-presets button.selected { background: var(--app-plum); border-color: var(--app-plum); color: white; transition: none; }
.app-layout #counter details > div { display: block; }
.app-layout #counter .pos-pills span { min-height: 44px; display: grid; place-items: center; }
.app-layout .auth dialog[open] { display: block; max-height: 94dvh; width: min(450px, calc(100% - 30px)); }
.app-layout .auth dialog .auth-art { display: block; min-height: 124px; padding: 19px 22px; }
.app-layout .auth dialog .auth-art strong { font-size: 32px; }
.app-layout .auth dialog .auth-art .comb { width: 118px; height: 45px; bottom: 12px; }
.app-layout .auth dialog form { padding: 20px 22px; }
.app-layout .auth dialog .app-form-heading { position: static; min-height: initial; background: transparent; }
