/* App styling shared by the three apps. Colours come from the date trade: date skin, rutab gold,
   palm green. The store's own colour is applied at runtime to --primary. */
:root {
  --primary: #5a3a22;
  --on-primary: #ffffff;
  --primary-ink: #5a3a22;
  --primary-tint: #f1ebe6;
  --bg: #f4f4f2;
  --bar: rgba(244, 244, 242, .93);
  --surface: #ffffff;
  --ink: #231b15;
  --muted: #6f665e;
  --line: #e4e0da;
  --field-line: #d6d0c8;
  --press: #efebe6;
  --gold: #b9801f;
  --ok: #2e6a47;
  --ok-bg: #e5f0e9;
  --warn: #8a5c07;
  --warn-bg: #fbefd6;
  --bad: #a8312a;
  --bad-bg: #f8e4e2;
  --app-width: 560px;
  --tab-h: 62px;
  --action-h: 76px;
  /* The Android app passes --safe-area-inset-*, because older Android web views get env() wrong. */
  --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "SF Arabic", "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
img, svg { max-width: 100%; }
a { color: var(--primary-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, label, select { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

.appbar, .tabbar, .btn, .row, .chip, .segment, .icon-btn, .stepper, .sidebar, .toast {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------------------------------------------------------------- frame */
.frame { position: relative; max-width: var(--app-width); margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--bg); }
.appbar {
  position: sticky; top: 0; z-index: 20;
  padding: var(--safe-top) 8px 0;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}
.appbar-compact { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; min-height: calc(54px + var(--safe-top)); border-bottom: 1px solid var(--line); }
.appbar-compact .bar-actions { min-width: 44px; justify-content: flex-end; }
.bar-title { font-size: 17px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.appbar-large { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: calc(64px + var(--safe-top)); padding-inline: 16px 8px; }
.bar-lead { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar-titles { min-width: 0; }
.large-title { font-size: 22px; font-weight: 800; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-subtitle { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; align-items: center; gap: 2px; }
.bar-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; background: var(--surface); border: 1px solid var(--line); }

.screen-host { outline: none; }
.screen { padding: 12px 16px 28px; }
.has-tabbar .screen-host { padding-bottom: calc(var(--tab-h) + var(--safe-bottom)); }
/* --bar-h is the bottom bar's measured height: it is taller when it holds two buttons. */
.has-actionbar .screen-host { padding-bottom: var(--bar-h, calc(var(--action-h) + var(--safe-bottom))); }
.has-tabbar.has-actionbar .screen-host { padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + var(--bar-h, var(--action-h))); }

.tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 30;
  max-width: var(--app-width); margin-inline: auto;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600; min-width: 0; }
.tab-icon { position: relative; display: grid; place-items: center; width: 52px; height: 28px; border-radius: 999px; transition: background-color .18s; }
.tab.is-active { color: var(--primary-ink); }
.tab.is-active .tab-icon { background: var(--primary-tint); }
.tab:active .tab-icon { transform: scale(.94); }
.tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab-badge, .dot-badge {
  position: absolute; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.tab-badge { top: -4px; inset-inline-start: 4px; }

.actionbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 25;
  max-width: var(--app-width); margin-inline: auto;
  display: flex; align-items: center; gap: 10px;
  min-height: var(--action-h);
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.has-tabbar .actionbar { bottom: calc(var(--tab-h) + var(--safe-bottom)); padding-bottom: 10px; }
.actionbar > .btn-block { flex: 1; }
.actionbar .grow { flex: 1; min-width: 0; }

.sidebar { display: none; }

@keyframes push-in { from { opacity: 0; transform: translateX(-32px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateX(32px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: .35; } to { opacity: 1; } }
.screen.enter-push { animation: push-in .24s cubic-bezier(.2, .8, .2, 1); }
.screen.enter-pop { animation: pop-in .22s cubic-bezier(.2, .8, .2, 1); }
.screen.enter-tab { animation: fade-in .18s ease-out; }

/* ---------------------------------------------------------------- buttons */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 12px;
  background: var(--primary); color: var(--on-primary);
  font-weight: 700; font-size: 15px; line-height: 1.3; text-decoration: none; text-align: center; cursor: pointer;
  transition: transform .08s, filter .15s, opacity .15s;
}
.btn:active { transform: scale(.98); filter: brightness(.94); }
.btn:disabled { opacity: .45; cursor: default; transform: none; filter: none; }
.btn-secondary { background: var(--primary-tint); color: var(--primary-ink); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--field-line); }
.btn-ghost { background: transparent; color: var(--primary-ink); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger-soft { background: var(--bad-bg); color: var(--bad); }
.btn-lg { min-height: 52px; font-size: 16px; border-radius: 14px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; gap: 6px; }
.btn-block { width: 100%; }
.btn[aria-busy="true"] { opacity: .85; }
.btn[aria-busy="true"] > * { visibility: hidden; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite;
}
.icon-btn {
  position: relative; display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink); text-decoration: none; cursor: pointer;
}
.icon-btn:active { background: rgba(35, 27, 21, .08); }
.dot-badge { top: 4px; inset-inline-start: 2px; }
.icon { flex: none; }

/* ---------------------------------------------------------------- lists, cards, text */
.section { margin-top: 22px; }
.section:first-child { margin-top: 4px; }
.section-title { font-size: 15px; font-weight: 800; margin: 0 2px 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section-head .section-title { margin-bottom: 0; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 11px 14px;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit;
  text-align: start; text-decoration: none;
}
.row:last-child { border-bottom: 0; }
a.row, button.row { cursor: pointer; }
a.row:active, button.row:active { background: var(--press); }
.row-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--primary-tint); color: var(--primary-ink); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row-value { flex: none; max-width: 48%; font-size: 14px; font-weight: 600; text-align: end; }
.row-chevron { color: #a59c93; }
.row-danger .row-title { color: var(--bad); }
.row-danger .row-icon { background: var(--bad-bg); color: var(--bad); }
.row-thumb { width: 52px; height: 52px; flex: none; border-radius: 12px; object-fit: cover; background: var(--primary-tint); }
.row-art { display: grid; place-items: center; }
.row-art .date-art { width: 46px; height: 38px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.card + .card { margin-top: 10px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; background: #ecebe7; color: #4d453f; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--primary-tint); color: var(--primary-ink); }

.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px; background: #ebeef2; color: #2c3440; font-size: 14px; }
.notice + .notice, .notice + .card, .card + .notice, .notice + .list, .list + .card, .card + .list { margin-top: 10px; }
.notice-ok { background: var(--ok-bg); color: #1f4a31; }
.notice-warn { background: var(--warn-bg); color: #5e3f05; }
.notice-bad { background: var(--bad-bg); color: #7a231e; }
.notice-body { flex: 1; min-width: 0; }
.notice-action { margin-top: 8px; }

.kv { margin: 0; }
.kv-row { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); flex: none; max-width: 45%; }
.kv dd { margin: 0; text-align: end; font-weight: 600; overflow-wrap: anywhere; }
.totals dt { max-width: 70%; }
.totals dd { white-space: nowrap; }
.totals .kv-row:last-child dt, .totals .kv-row:last-child dd { color: var(--ink); font-size: 17px; font-weight: 800; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 20px; text-align: center; }
.empty h2 { font-size: 18px; }
.empty p { color: var(--muted); max-width: 34ch; }
.empty .btn { margin-top: 6px; }
.empty-icon { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; background: var(--primary-tint); color: var(--primary-ink); }
.empty .date-art { width: 120px; height: 96px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }

/* Blocks that simply follow one another still keep their distance (flex columns use gap instead). */
:not(.stack, .stack-sm, .form, .toolbar, .actionbar, .sheet-actions, .radio-list, .login) >
  :is(.list, .card, .notice, .stat-grid, .btn-block, .toolbar, .viz, .table-wrap, .stack) +
  :is(.list, .card, .notice, .stat-grid, .btn-block, .toolbar, .viz, .form, .stack) { margin-top: 10px; }
:not(.stack, .stack-sm, .form, .toolbar, .actionbar, .login) > :is(.notice, .section) + .form { margin-top: 18px; }
:not(.stack, .stack-sm, .form, .toolbar, .actionbar, .sheet-actions) > p + :is(.btn-block, .list, .card) { margin-top: 12px; }
.inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.big { font-size: 24px; font-weight: 800; }
.center { text-align: center; }
.nowrap { white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.price { font-weight: 800; white-space: nowrap; }
.strike { color: var(--muted); text-decoration: line-through; font-weight: 500; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; direction: ltr; unicode-bidi: isolate; letter-spacing: .02em; }
.pre-line { white-space: pre-line; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.offscreen { position: fixed; top: -200px; opacity: 0; pointer-events: none; }
.search { position: relative; }
.search .input { padding-inline-start: 44px; border-radius: 999px; }
.search > .icon { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.qr-img { width: 168px; height: 168px; image-rendering: pixelated; background: #fff; }
/* number tiles */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: inherit; text-decoration: none; }
a.stat:active { background: var(--press); }
.stat-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 20px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.stat-sub { font-size: 12.5px; color: var(--muted); }
.stat-hero { grid-column: 1 / -1; }
.stat-hero .stat-value { font-size: 30px; }
.stat-warn { background: var(--warn-bg); border-color: transparent; }
.stat-bad { background: var(--bad-bg); border-color: transparent; }
.stat-warn .stat-label, .stat-warn .stat-sub { color: #6b4a06; }
.stat-bad .stat-label, .stat-bad .stat-sub { color: #7a231e; }

.secret-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; border: 1px dashed var(--field-line); border-radius: 14px; background: var(--surface); }
.secret-box .code { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.secret-long .code { font-size: 12.5px; font-weight: 600; }

/* ---------------------------------------------------------------- pickers */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; border-radius: 13px; background: #e8e5e0; }
.segment { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 40px; padding: 4px 6px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; font-size: 14px; cursor: pointer; color: #4d453f; }
.segment small { font-weight: 500; font-size: 12px; }
.segment.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(35, 27, 21, .14); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px; margin-inline: -16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; flex: none; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip small { font-size: 12px; opacity: .75; }
.chip:disabled { opacity: .4; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stepper-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 0; background: transparent; cursor: pointer; border-radius: 11px; }
.stepper-btn:active { background: var(--press); }
.stepper-btn:disabled { opacity: .3; }
.stepper-value { min-width: 34px; text-align: center; font-weight: 800; }

/* ---------------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field-label { font-size: 14px; font-weight: 700; padding: 0; }
legend.field-label { margin-bottom: 8px; }
.optional { color: var(--muted); font-weight: 400; }
.field-hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--bad); font-weight: 600; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; font-size: 16px;
  border: 1px solid var(--field-line); border-radius: 12px; background-color: var(--surface);
}
.input:focus { border-color: var(--primary); }
.input:disabled { background-color: #eeece8; color: var(--muted); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }
select.input {
  -webkit-appearance: none; appearance: none; padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f665e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; background-size: 18px;
}
input[type="date"].input { -webkit-appearance: none; appearance: none; }
input[type="color"].input { padding: 6px; height: 52px; }
input[type="file"].input { padding: 11px 14px; }
.has-error .input { border-color: var(--bad); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-start-end-radius: 0; border-end-end-radius: 0; }
.suffix { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--field-line); border-inline-start: 0; border-start-end-radius: 12px; border-end-end-radius: 12px; background: #f8f7f4; color: var(--muted); font-size: 14px; white-space: nowrap; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; cursor: pointer; }
.switch-text { display: flex; flex-direction: column; font-weight: 600; }
.switch-text small { font-weight: 400; color: var(--muted); font-size: 13px; }
.switch {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 52px; height: 31px; margin: 0;
  border-radius: 999px; background: #cdc7bf; cursor: pointer; transition: background-color .2s;
}
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: inset-inline-start .2s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { inset-inline-start: 24px; }
.radio-list { display: grid; gap: 8px; }
.radio-card { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px; border: 1px solid var(--field-line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.radio-card input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); flex: none; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }
.radio-text { display: flex; flex-direction: column; }
.radio-text small { color: var(--muted); font-size: 13px; }
.form-alert { padding: 11px 14px; border-radius: 12px; background: var(--bad-bg); color: #7a231e; font-weight: 600; font-size: 14px; }
.form-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
/* Two fields side by side share their rows, so the inputs stay level even when one label wraps. */
.fieldset-row { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; row-gap: 0; align-items: start; }
.fieldset-row > .field { display: grid; grid-template-rows: subgrid; grid-row: span 4; row-gap: 0; align-content: start; }
.fieldset-row > .field > .field-label { align-self: end; }
.fieldset-row > .field > * + * { margin-top: 6px; }

/* ---------------------------------------------------------------- sheets and messages */
dialog.sheet {
  width: 100%; max-width: var(--app-width); max-height: 92vh; max-height: 92dvh; margin: auto auto 0; padding: 0;
  border: 0; background: transparent; color: var(--ink); overflow: visible;
}
dialog.sheet::backdrop { background: rgba(29, 19, 10, .42); }
.sheet-panel { display: flex; flex-direction: column; max-height: 92vh; max-height: 92dvh; border-radius: 22px 22px 0 0; background: var(--bg); box-shadow: 0 -8px 30px rgba(0, 0, 0, .18); }
dialog.sheet[open] .sheet-panel { animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet-up { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 40px; height: 5px; margin: 8px auto 0; border-radius: 9px; background: #cbc5bd; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 16px 4px 8px; }
.sheet-head h2 { font-size: 17px; font-weight: 800; }
.sheet-body { overflow-y: auto; padding: 6px 16px calc(20px + var(--safe-bottom)); overscroll-behavior: contain; }
.sheet-message { margin-bottom: 6px; }
.sheet-actions { display: grid; gap: 8px; margin-top: 16px; }

.toasts { position: fixed; inset-inline: 0; bottom: calc(18px + var(--safe-bottom)); z-index: 100; display: flex; justify-content: center; pointer-events: none; padding: 0 12px; }
.has-tabbar .toasts { bottom: calc(var(--tab-h) + 18px + var(--safe-bottom)); }
.has-actionbar .toasts { bottom: calc(var(--bar-h, calc(var(--action-h) + var(--safe-bottom))) + 12px); }
.has-tabbar.has-actionbar .toasts { bottom: calc(var(--tab-h) + var(--safe-bottom) + var(--bar-h, var(--action-h)) + 10px); }
.toast { display: flex; align-items: center; gap: 10px; max-width: 520px; padding: 12px 16px; border-radius: 14px; background: #251c15; color: #fff; font-weight: 600; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .22); pointer-events: auto; animation: toast-in .2s ease-out; }
.toast-ok .icon { color: #9bd9b2; }
.toast-bad { background: #8f2b23; }
.toast-action { border: 0; background: transparent; color: #f6cf86; font-weight: 800; padding: 4px 6px; cursor: pointer; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.ptr {
  position: fixed; top: calc(var(--safe-top) + 14px); left: 50%; z-index: 40; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface); box-shadow: 0 2px 10px rgba(0, 0, 0, .16);
  color: var(--muted); opacity: 0; pointer-events: none; transform: translate(-50%, var(--pull, -20px)); transition: opacity .15s;
}
.ptr.is-visible { opacity: 1; }
.ptr .spinner { animation-play-state: paused; }
.ptr.is-ready { color: var(--primary-ink); }
.ptr.is-loading { transform: translate(-50%, 56px); }
.ptr.is-loading .spinner { animation-play-state: running; }

/* ---------------------------------------------------------------- loading */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 22px; height: 22px; border: 2.5px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.loading { display: flex; justify-content: center; padding: 28px; color: var(--muted); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton { border-radius: 14px; background: linear-gradient(90deg, #eae8e4 25%, #f6f5f2 50%, #eae8e4 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton-title { width: 46%; height: 22px; margin-bottom: 14px; }
.skeleton-row { height: 64px; margin-bottom: 10px; }
.skeleton-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.skeleton-card { aspect-ratio: 3 / 4; }

/* ---------------------------------------------------------------- opening screen */
.splash {
  position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--primary); color: var(--on-primary); transition: opacity .35s ease, visibility .35s;
}
.splash.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-icon { width: 104px; height: 104px; border-radius: 26px; box-shadow: 0 14px 36px rgba(0, 0, 0, .28); }
.splash-name { max-width: 80vw; font-size: 23px; font-weight: 800; text-align: center; }
.splash .spinner { margin-top: 14px; opacity: .7; }

/* ---------------------------------------------------------------- app window on large screens */
@media (min-width: 700px) {
  body:not(.has-sidebar) { background: #e5e2dc; }
  body:not(.has-sidebar) .frame { box-shadow: 0 0 0 1px #d8d3cc, 0 18px 50px rgba(35, 27, 21, .12); }
  dialog.sheet { margin: auto; }
  dialog.sheet.sheet-wide { max-width: min(760px, 94vw); }
  .sheet-panel { border-radius: 22px; }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .spinner, .btn[aria-busy="true"]::after, .image-add[aria-busy="true"]::after { animation-duration: 1.2s !important; animation-iteration-count: infinite !important; }
}

@media print {
  @page { margin: 10mm; }
  body { background: #fff !important; }
  .appbar, .tabbar, .actionbar, .sidebar, .toasts, .ptr, .no-print, dialog.sheet { display: none !important; }
  /* A screen made for paper (invoice, label, slip, poster) prints that and nothing around it. */
  .screen:has(.printable) *:not(.printable, .printable *, :has(.printable)) { display: none !important; }
  .table-wrap { overflow: visible !important; }
  .printable table { font-size: 11px; }
  /* white paper: no screen tint, even when the browser prints background colours */
  html, .frame, .screen-host, .screen { background: #fff !important; }
  .frame { max-width: none !important; min-height: 0 !important; box-shadow: none !important; }
  .screen-host { padding: 0 !important; }
  .screen { padding: 0 !important; animation: none !important; }
}
