/* The mini app shell — every value here is the shared token set (§2.1 of the
   spec; the console's globals.css is the point of record). The layout is the
   mobile column the console's desktop rail is not: one screen, one column,
   the primary action the ONE visible action (§2.1).

   NAV-267 — mobile hardening + design pass. The fonts are declared here, from
   the self-hosted subsets the build copies into `fonts/` (relative to this
   stylesheet at `/app/styles.css`), so Khmer shapes with Hanuman and nothing
   is fetched from a CDN. The layout rules below are the fix for the phone
   horizontal overflow: no flex/grid child is allowed to keep a min-content
   width wider than the viewport, and the tab row is a grid, not a nowrap run. */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/roboto/roboto-latin-ext-400_700.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/roboto/roboto-latin-400_700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Hanuman";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/hanuman/hanuman-khmer-400_700.woff2") format("woff2");
  unicode-range: U+1780-17FF, U+19E0-19FF, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Hanuman";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/hanuman/hanuman-latin-400_700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/poppins/poppins-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --background: #ffffff;
  --foreground: #0a0a0a;
  --primary: #0071e3;
  --primary-hover: #0068d1;
  --primary-pressed: #005fbf;
  --primary-foreground: #ffffff;
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  --border: #e5e5e5;
  --destructive: #dc2626;
  --row-hover: #fafafa;
  --status-done: #22c55e;
  --t-signin: 20px;
  --t-title: 14px;
  --t-h1: 18px;
  --t-body: 14px;
  --t-label: 11px;
  --t-micro: 10px;
  --lh-body: 20px;
  --lh-km: 1.75;
  --tr-label: 0.025em;
  --r-control: 6.4px;
  --r-panel: 8px;
  --r-full: 9999px;
  /* NAV-267: one touch height for every control (44pt iOS / 48dp Android —
     the smaller of the two, so a control never falls under either floor). */
  --control-h: 44px;
  /* NAV-270: the *measured* height of the bottom tab bar, written onto #app by
     the shell once the bar is drawn (wrapped labels + the home-indicator inset
     make it variable, so it is never guessed). The page clears it. */
  --tabbar-h: 0px;
  --gap-row: 8px;
  --focus: 2px;
  --font-ui: "Roboto", "Hanuman", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-brand: "Poppins", "Roboto", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* NAV-270: no rubber-band bounce behind a fixed tab bar. The layout itself
     is still allowed to report overflow honestly — this is scroll chaining,
     not `overflow-x: hidden`, which would mask a real sideways overflow. */
  overscroll-behavior-y: none;
}

/* Every layout box may shrink below its content's intrinsic width; the text
   inside wraps or breaks instead of pushing the page sideways (NAV-267). */
.flex-safe,
.shell-header,
.shell-nav,
.today-screen,
.orders-screen,
.order-screen,
.customers-screen,
.money-screen,
.staff-screen,
.plan-screen {
  min-width: 0;
}

img,
svg {
  max-width: 100%;
}

:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--focus) solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* The fixed tab bar floats over the page; the page reserves its measured
     height (plus the home-indicator inset it already carries) so no control
     ever hides behind it (NAV-270). */
  padding-bottom: var(--tabbar-h, 0px);
}

/* ---- NAV-270: screen transitions (motion 3/10) -------------------------
   A short, subtle slide in the direction of travel. `data-nav` is set by the
   shell before the screen is drawn; the global `prefers-reduced-motion` rule
   above collapses it to nothing for a reader who asked for no motion. */
@keyframes nav-enter-fwd {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes nav-enter-back {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}
#app[data-nav="fwd"] > :not(.shell-header):not(.shell-nav):not(.shell-banner),
#app[data-nav="back"] > :not(.shell-header):not(.shell-nav):not(.shell-banner) {
  animation-duration: 200ms;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
}
#app[data-nav="fwd"] > :not(.shell-header):not(.shell-nav):not(.shell-banner) {
  animation-name: nav-enter-fwd;
}
#app[data-nav="back"] > :not(.shell-header):not(.shell-nav):not(.shell-banner) {
  animation-name: nav-enter-back;
}

/* ---- NAV-270: loading skeletons, never a spinner in an empty page ---- */
.skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 0;
}
.skeleton-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
}
.skeleton-line {
  display: block;
  height: 12px;
  border-radius: var(--r-control);
  background: linear-gradient(90deg, var(--muted) 25%, #ececec 37%, var(--muted) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-line-lg {
  height: 16px;
  width: 58%;
}
@keyframes skeleton-shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-line {
    animation: none;
    background: var(--muted);
  }
}

/* ---- the one error surface (§12.1) ---- */
.shell-banner {
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  border-radius: var(--r-panel);
  margin: 10px;
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.shell-banner-line {
  font-size: var(--t-body);
  line-height: var(--lh-body);
  color: var(--foreground);
  min-width: 0;
  overflow-wrap: anywhere;
}
.shell-banner-detail {
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--muted-foreground);
  border-radius: var(--r-control);
  padding: 2px 10px;
  font-size: var(--t-label);
  cursor: pointer;
}
.shell-banner-rid {
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--muted-foreground);
  word-break: break-all;
}

.mono {
  font-family: var(--font-mono);
}

/* ---- shared panel: a refusal is a normal screen (§12.2) ---- */
.panel {
  margin: auto;
  width: min(100%, 480px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel-title {
  margin: 0;
  font-size: var(--t-signin);
  font-weight: 600;
  line-height: var(--lh-km);
  letter-spacing: var(--tr-title);
}
.panel-body {
  margin: 0;
  color: var(--muted-foreground);
  line-height: var(--lh-km);
}

/* ---- buttons: the ONE action is --primary (§2.1) ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-h);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease;
}
.btn:hover {
  background: var(--row-hover);
}
.btn:active {
  background: var(--muted);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-primary:active {
  background: var(--primary-pressed);
  border-color: var(--primary-pressed);
}
.btn-block {
  width: 100%;
}
.btn-small {
  min-height: var(--control-h);
  padding: 8px 12px;
  font-size: var(--t-body);
}

a.btn {
  text-decoration: none;
}

/* ---- Entry states ---- */
.splash {
  margin: auto;
  padding: 24px;
  color: var(--muted-foreground);
}

.shell-screen {
  margin: auto;
  width: min(100%, 480px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.entry-names {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.shop-name {
  margin: 0;
  font-size: var(--t-h1);
  font-weight: 600;
  line-height: var(--lh-km);
  letter-spacing: var(--tr-title);
  overflow-wrap: anywhere;
}
.person-name {
  margin: 0;
  color: var(--muted-foreground);
  line-height: var(--lh-body);
  overflow-wrap: anywhere;
}

/* The first-open language ask (§12.2): a card in the content flow, not chrome,
   so a tall ask never sticks to the top of the screen. */
.lang-ask {
  width: min(100% - 32px, 480px);
  margin: 12px auto 0;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  background: var(--muted);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lang-ask .row-actions {
  display: flex;
  gap: 8px;
}
.lang-ask .row-actions .btn {
  flex: 1;
}

.field-issue {
  margin-top: 6px;
  font-size: var(--t-label);
  color: var(--destructive);
}

/* ---- the app bar (§12.1): the shop, the person, the language, Plan ----
   A compact, sticky bar: the tab row used to live here and wrapped to three
   rows on a 320 px phone. It is at the thumb now (below), and the bar carries
   only the identity, the language and the one secondary action. */
.shell-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}
.shell-header-inner {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.appbar-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.langbar {
  display: inline-flex;
  gap: 3px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--muted);
}
.langbar .btn-small {
  padding: 6px 12px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  font-size: 12px;
}
.langbar .btn-small:hover {
  background: var(--row-hover);
}
.langbar .btn-primary,
.langbar .btn-primary:hover {
  background: var(--primary);
  color: var(--primary-foreground);
}
.appbar-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  background: var(--background);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease,
    background-color 0.15s ease;
}
.appbar-action:hover {
  background: var(--row-hover);
}
.appbar-action-on {
  color: var(--primary);
  border-color: var(--primary);
}
.appbar-action .nav-icon {
  width: 22px;
  height: 22px;
}

/* ---- the bottom tab bar (NAV-270): the screens that exist ----
   Primary navigation at the thumb, not a wrapped row in the header. One equal
   column per tab, so five (or three, for a staff member) always fit a 320 px
   phone without clipping. */
.shell-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--background);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.shell-nav-inner {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 6px 8px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--gap-row);
  min-width: 0;
}
.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: var(--control-h);
  padding: 6px 2px;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-tab:hover {
  background: var(--row-hover);
}
.nav-tab-on,
.nav-tab-on:hover {
  color: var(--primary);
}
.nav-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}
.nav-tab-label {
  min-width: 0;
  max-width: 100%;
  font-size: 10px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

/* ---- Screen 2 — Today (§12.3) ---- */
.today-screen {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 18px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.today-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.today-title {
  margin: 0;
  font-size: var(--t-signin);
  font-weight: 600;
  line-height: var(--lh-km);
  letter-spacing: var(--tr-title);
}
.today-date {
  margin: 0;
  color: var(--muted-foreground);
  line-height: var(--lh-km);
}

/* the day's figures: read from the report, never summed (§3.12, OQ-27) */
.today-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  background: var(--muted);
  padding: 12px;
}
.total-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.total-label {
  font-size: var(--t-label);
  letter-spacing: var(--tr-label);
  color: var(--muted-foreground);
  line-height: 1.4;
}
.total-value {
  font-size: var(--t-h1);
  font-weight: 600;
  line-height: var(--lh-body);
  word-break: break-word;
}
.today-totals-note {
  grid-column: 1 / -1;
  margin: 0;
  font-size: var(--t-label);
  color: var(--muted-foreground);
  line-height: 1.4;
}

.today-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.today-section-title {
  margin: 0;
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.today-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  overflow: hidden;
}
.today-row-item + .today-row-item {
  border-top: 1px solid var(--border);
}
.order-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
}
.order-row:hover,
.order-row:focus-visible {
  background: var(--row-hover);
}
.order-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.order-customer {
  font-weight: 600;
  line-height: var(--lh-km);
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.order-amount {
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
  white-space: nowrap;
}
.order-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--muted-foreground);
  font-size: var(--t-label);
}
.order-state {
  color: var(--foreground);
}
.order-promised {
  font-style: italic;
}

.today-empty {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  background: var(--muted);
  padding: 18px;
}
.today-empty-title {
  margin: 0;
  font-weight: 600;
  line-height: var(--lh-km);
}

/* ---- Screen 3 — Orders (§12.4) ---- */
.orders-screen {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 18px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.orders-filters {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: 14px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-label {
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.filter-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.filter-dates > * {
  min-width: 0;
}
.filter-input {
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  /* 16px keeps iOS/Telegram WebView from zooming the page on focus. */
  font-size: 16px;
  line-height: 1.25;
  padding: 10px;
}
.filter-input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-h);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  line-height: 1.25;
  padding: 8px 14px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease;
}
.chip:hover {
  background: var(--row-hover);
}
.chip-on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.chip-on:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.chip-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.filter-customer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.customer-chosen:empty {
  display: none;
}
.customer-results:empty {
  display: none;
}
.customer-results {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  overflow: hidden;
}
.customer-option {
  min-height: var(--control-h);
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}
.customer-option:last-child {
  border-bottom: 0;
}
.customer-option:hover {
  background: var(--row-hover);
}

.orders-export {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.orders-export-note {
  margin: 0;
  font-size: var(--t-label);
  color: var(--muted-foreground);
  line-height: 1.4;
}

.orders-list-host {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.orders-empty {
  gap: 10px;
}

/* ---- Screen 4 — One order (§12.5) ---- */
.order-screen {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 18px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.order-notice {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  background: var(--muted);
  color: var(--foreground);
  font-weight: 600;
}

.order-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.order-customer-name {
  margin: 0;
  font-size: var(--t-h1);
  font-weight: 600;
  line-height: var(--lh-km);
}
.order-head-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--muted-foreground);
  font-size: var(--t-label);
}
.order-status,
.order-paid-state {
  color: var(--foreground);
}
.order-promised {
  font-style: italic;
}

.order-raw {
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  background: var(--muted);
  padding: 12px 14px;
}
.order-raw-summary {
  cursor: pointer;
  font-weight: 600;
  line-height: var(--lh-km);
}
.order-raw-text {
  margin: 10px 0 0;
  padding: 0;
  font-family: inherit;
  font-size: var(--t-body);
  line-height: var(--lh-km);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.order-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.order-section-title {
  margin: 0;
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.order-items {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  overflow: hidden;
}
.order-item + .order-item {
  border-top: 1px solid var(--border);
}
.order-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
}
.order-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.order-item-desc {
  min-width: 0;
  overflow-wrap: anywhere;
}
.order-item-line {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.order-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--muted-foreground);
  font-size: var(--t-label);
}

.order-money {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  background: var(--muted);
  padding: 12px;
}

.order-history {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  overflow: hidden;
}
.order-event + .order-event {
  border-top: 1px solid var(--border);
}
.order-event {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
}
.order-event-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.order-event-kind {
  font-weight: 600;
}
.order-event-time {
  color: var(--muted-foreground);
  font-size: var(--t-label);
  white-space: nowrap;
}
.order-event-detail {
  color: var(--muted-foreground);
  font-size: var(--t-label);
  overflow-wrap: anywhere;
}

.order-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: 14px;
}

.order-item-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.order-item-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 8px;
}
.order-item-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.order-item-remove {
  align-self: center;
  justify-self: end;
}

.order-currency {
  font-weight: 600;
}

.chip-danger {
  border-color: var(--destructive);
  color: var(--destructive);
}
.chip-danger.chip-on {
  background: var(--destructive);
  border-color: var(--destructive);
  color: var(--primary-foreground);
}

/* ---- Screen 5 — Customers (§12.6) ---- */
.customers-screen {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 18px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.customers-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.customers-bar .filter-input {
  flex: 1;
}
.customers-bar .btn {
  white-space: nowrap;
}

.customer-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
}
.customer-row:hover,
.customer-row:focus-visible {
  background: var(--row-hover);
}

.customer-owes {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.customer-owes-label {
  color: var(--muted-foreground);
  font-size: var(--t-label);
}
.customer-owes-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.customer-last {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
}
.customer-last-label {
  font-weight: 600;
}
.customer-last-none {
  font-style: italic;
}

.customer-form,
.customer-detail,
.customer-notice,
.customer-recent {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: 14px;
}
.customer-notice {
  background: var(--muted);
}
.customer-notice .panel-title {
  margin: 0;
}

.customer-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.customer-value {
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  gap: 8px;
}
.row-actions .btn {
  flex: 1;
}

.btn-danger {
  border-color: var(--destructive);
  color: var(--destructive);
}
.btn-danger:hover,
.btn-danger:active {
  background: var(--destructive);
  border-color: var(--destructive);
  color: var(--primary-foreground);
}
/* ---- Screen 7 — Staff and branches (§12.8) ---- */
.staff-screen {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 18px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.staff-people,
.staff-invites,
.staff-branches {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.staff-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.staff-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
}

.staff-row-top {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
}
.staff-name {
  font-weight: 600;
}
.staff-role,
.staff-status,
.staff-default {
  color: var(--muted-foreground);
  font-size: var(--t-label);
}
.staff-default {
  color: var(--primary);
}

.staff-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--muted-foreground);
  font-size: var(--t-label);
  overflow-wrap: anywhere;
}

.staff-last-owner {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--t-label);
}

.staff-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  padding: 14px;
}

.staff-scope {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 10px 12px;
  margin: 0;
}
.staff-scope-note {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--t-label);
}
.staff-check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.staff-check-box {
  width: 18px;
  height: 18px;
}
.staff-check-label {
  flex: 1;
}
.staff-value {
  overflow-wrap: anywhere;
}

.staff-notice {
  background: var(--muted);
}
.staff-notice .panel-title {
  margin: 0;
}

.staff-notice-line {
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--r-control);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--t-label);
}

.staff-address,
.staff-invite-branch {
  overflow-wrap: anywhere;
}

/* ---- Screen 8 — Plan and usage (§12.9) ---- */
.plan-screen {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 18px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.plan-current,
.plan-limits,
.plan-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plan-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
}
.plan-name {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.plan-status {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--t-label);
}

.plan-metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
}
.plan-metric-label {
  font-weight: 600;
}
.plan-metric-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--muted-foreground);
  font-size: var(--t-label);
}
.plan-metric-atlimit {
  margin: 0;
  color: var(--primary);
  font-size: var(--t-label);
}

.plan-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.plan-form .plan-select {
  flex: 1;
}

.plan-owner-note {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--t-label);
}

.plan-notice {
  background: var(--muted);
}
.plan-notice .panel-title {
  margin: 0;
}

/* ---- Screen 6 — Money (§12.7): four figures, and nothing else ---- */
.money-screen {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 18px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.money-report {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.money-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.money-figure {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  background: var(--muted);
}
.money-label {
  font-size: var(--t-label);
  letter-spacing: var(--tr-label);
  color: var(--muted-foreground);
  line-height: 1.4;
}
.money-amount {
  font-size: var(--t-h1);
  font-weight: 600;
  line-height: var(--lh-body);
  word-break: break-word;
}

.money-notes {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.money-note {
  margin: 0;
  font-size: var(--t-label);
  color: var(--muted-foreground);
  line-height: 1.4;
}

.money-notice {
  background: var(--muted);
}

/* ---- NAV-267: the last row of the grid can never be wider than the page ----
   The interactive rows ease on hover/tap (motion 3 — subtle), and the plan
   select is a flex child that must be allowed to shrink like every input. */
.order-row,
.customer-row {
  transition: background-color 0.15s ease;
}
.plan-form .plan-select {
  min-width: 0;
  min-height: var(--control-h);
}
.staff-check-label {
  min-width: 0;
}

/* ---- NAV-267: narrow phones (320–380 px) ---------------------------------
   At 320 px three figure columns cannot hold a long Khmer/amount value, so the
   figures become label/value rows and the page gutters tighten. Nothing here
   hides content: it reflows it. */
@media (max-width: 380px) {
  .shell-header-inner {
    padding: 8px 12px;
    gap: 8px;
  }
  .langbar .btn-small {
    padding: 6px 8px;
  }
  .today-screen,
  .orders-screen,
  .order-screen,
  .customers-screen,
  .money-screen,
  .staff-screen,
  .plan-screen {
    padding: 16px 16px 28px;
  }
  .panel,
  .shell-screen {
    padding: 20px 16px;
  }
  .today-totals,
  .order-money {
    grid-template-columns: minmax(0, 1fr);
  }
  .today-totals .total-cell,
  .order-money .total-cell {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }
  .total-value,
  .money-amount {
    font-size: 16px;
  }
}
