/* Ishxonaga Ovqat — admin Mini App styles.
 * Mobile-first (360–430 px), follows the Telegram theme (var(--tg-theme-*)),
 * with light/dark fallbacks for use outside Telegram (?mock=1 in a browser). */

/* ---------- design tokens ---------- */
:root {
  /* light fallbacks (used when Telegram does not provide a theme value) */
  --fb-page-bg: #eff1f4;
  --fb-card-bg: #ffffff;
  --fb-text: #0f1419;
  --fb-hint: #8b929b;
  --fb-subtext: #5f6670;
  --fb-accent: #2481cc;
  --fb-separator: #e2e5e9;
  --fb-red: #d93a35;
  --fb-media-bg: #e6e9ee;
  --fb-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --fb-skeleton: #e4e7eb;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fb-page-bg: #0f1115;
    --fb-card-bg: #1b1e24;
    --fb-text: #eef0f3;
    --fb-hint: #8a919b;
    --fb-subtext: #a7adb6;
    --fb-accent: #5ea8ff;
    --fb-separator: #2b2f36;
    --fb-red: #f0524c;
    --fb-media-bg: #121418;
    --fb-shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --fb-skeleton: #262a31;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --fb-page-bg: #0f1115;
  --fb-card-bg: #1b1e24;
  --fb-text: #eef0f3;
  --fb-hint: #8a919b;
  --fb-subtext: #a7adb6;
  --fb-accent: #5ea8ff;
  --fb-separator: #2b2f36;
  --fb-red: #f0524c;
  --fb-media-bg: #121418;
  --fb-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --fb-skeleton: #262a31;
  color-scheme: dark;
}

:root {
  --page-bg: var(--tg-theme-secondary-bg-color, var(--fb-page-bg));
  --card-bg: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-card-bg)));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --subtext: var(--tg-theme-subtitle-text-color, var(--tg-theme-hint-color, var(--fb-subtext)));
  --accent: var(--tg-theme-accent-text-color, var(--tg-theme-link-color, var(--fb-accent)));
  --link: var(--tg-theme-link-color, var(--fb-accent));
  --button: var(--tg-theme-button-color, var(--fb-accent));
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --separator: var(--tg-theme-section-separator-color, var(--fb-separator));
  --destructive: var(--tg-theme-destructive-text-color, var(--fb-red));
  --input-bg: var(--page-bg);
  --media-bg: var(--fb-media-bg);
  --shadow: var(--fb-shadow);
  --skeleton: var(--fb-skeleton);

  /* fixed semantic colours (readable on both themes, white text on top) */
  --green: #1d9a50;
  --green-press: #178343;
  --red: #dc3d38;
  --red-press: #bf302c;
  --amber: #c27c00;
  --blue: #2f80d1;
  --green-soft: rgba(29, 154, 80, .14);
  --red-soft: rgba(220, 61, 56, .13);
  --amber-soft: rgba(214, 140, 0, .16);
  --blue-soft: rgba(47, 128, 209, .14);
  --grey-soft: rgba(130, 138, 150, .16);

  --radius: 14px;
  --radius-lg: 18px;
  --tabbar-h: 58px;
  --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px));
  --safe-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px));
  --kb: 0px; /* on-screen keyboard overlap (set from JS via visualViewport) */
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--page-bg);
  overscroll-behavior-y: none;
}
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}
body.locked { overflow: hidden; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
a { color: var(--link); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--hint); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.wrap-any { overflow-wrap: anywhere; word-break: break-word; }

/* ---------- shell ---------- */
#app { min-height: 100vh; }
#view {
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}
.pane { min-height: 50vh; }
.page { animation: page-in .18s ease-out; }
@keyframes page-in { from { opacity: .4; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: calc(6px + var(--safe-top)) 12px 6px;
  background: var(--page-bg);
}
.page-head.stack { flex-direction: column; align-items: stretch; }
.page-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.head-back {
  flex: none;
  width: 44px; height: 44px;
  margin-left: -6px;
  border: 0; border-radius: 22px;
  background: transparent;
  color: var(--accent);
  font-size: 26px; line-height: 1;
}
.head-action {
  flex: none;
  min-width: 44px; height: 44px;
  padding: 0 10px;
  border: 0; border-radius: 22px;
  background: transparent;
  color: var(--accent);
  font-size: 15px; font-weight: 600;
}
.content { padding: 4px 12px 12px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: var(--card-bg);
  border-top: 1px solid var(--separator);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}
.tabbar-inner { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 640px; margin: 0 auto; }
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: var(--tabbar-h);
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--hint);
  font-size: 11.5px; font-weight: 600;
}
.tab .ico { font-size: 22px; line-height: 1.1; filter: grayscale(1); opacity: .75; transition: filter .15s, opacity .15s; }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] .ico { filter: none; opacity: 1; }
.badge {
  position: absolute;
  top: 4px; left: calc(50% + 7px);
  min-width: 19px; height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-size: 11.5px; font-weight: 700; line-height: 19px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--card-bg);
}
.badge.pop { animation: badge-pop .3s ease; }
@keyframes badge-pop { 50% { transform: scale(1.25); } }

/* ---------- generic UI ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.section { margin: 0 0 12px; padding: 14px; }
.section-title {
  margin: 18px 4px 8px;
  font-size: 13px; font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--subtext);
}
.section-title:first-child { margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 16px;
  border: 0; border-radius: 12px;
  background: var(--grey-soft);
  color: var(--text);
  font-size: 15px; font-weight: 600; line-height: 1.15;
  text-align: center;
  transition: transform .08s ease, background-color .15s ease, opacity .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { display: flex; width: 100%; }
.btn-primary { background: var(--button); color: var(--button-text); }
.btn-secondary { background: var(--blue-soft); color: var(--accent); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-ghost { background: var(--red-soft); color: var(--destructive); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }
.btn-stack { display: grid; gap: 10px; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-secondary.busy::after, .btn.busy:not(.btn-primary):not(.btn-danger):not(.btn-accept):not(.btn-reject)::after {
  border-color: var(--grey-soft); border-top-color: var(--accent);
}

.chip {
  display: inline-flex; align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--separator);
  border-radius: 18px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px; font-weight: 500;
  white-space: nowrap;
}
.chip[aria-pressed="true"], .chip.active { background: var(--button); border-color: var(--button); color: var(--button-text); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -12px;
  padding: 2px 12px;
}
.chips.scroll::-webkit-scrollbar { display: none; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  background: var(--grey-soft); color: var(--subtext);
}
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--destructive); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }

/* tiny superscript-style method label ("karta" / "naqd") — intentionally small and muted */
.method-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .02em;
  text-transform: lowercase;
  color: var(--hint);
  vertical-align: super;
}

.segmented {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--grey-soft);
  width: 100%;
}
.segmented button {
  min-height: 38px;
  padding: 0 6px;
  border: 0; border-radius: 9px;
  background: transparent;
  color: var(--subtext);
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.segmented button[aria-selected="true"] { background: var(--card-bg); color: var(--text); box-shadow: var(--shadow); }
.seg-count { color: var(--accent); margin-left: 3px; }

.list { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 12px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  position: relative;
}
.list-item + .list-item::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 0;
  border-top: 1px solid var(--separator);
}
button.list-item:active { background: var(--grey-soft); }
.li-ico { flex: none; font-size: 22px; width: 30px; text-align: center; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; overflow-wrap: anywhere; }
.li-sub { font-size: 13px; color: var(--subtext); overflow-wrap: anywhere; margin-top: 1px; }
.li-end { flex: none; text-align: right; font-size: 13.5px; color: var(--subtext); }
.li-chev { flex: none; color: var(--hint); font-size: 20px; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--subtext);
}
.empty .big { font-size: 44px; line-height: 1; margin-bottom: 12px; }
.empty .title { font-size: 17px; font-weight: 600; color: var(--text); }
.empty .btn { margin-top: 16px; }

.banner {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--amber-soft);
  color: var(--text);
  font-size: 13.5px;
}
.banner.red { background: var(--red-soft); }

.spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--grey-soft);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.center-spin { display: flex; justify-content: center; padding: 40px 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: var(--skeleton); border-radius: 8px; position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .18), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- full-screen messages (outside Telegram / not admin / fatal) ---------- */
.blocker {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 24px calc(32px + var(--safe-bottom));
  text-align: center;
}
.blocker .big { font-size: 56px; margin-bottom: 16px; }
.blocker h1 { font-size: 20px; margin: 0 0 8px; }
.blocker p { margin: 0 0 16px; color: var(--subtext); max-width: 340px; }

/* ---------- toast ---------- */
.toast-root {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px + var(--kb));
  z-index: 80;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  max-width: 520px;
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(28, 31, 36, .94);
  color: #fff;
  font-size: 14.5px; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  pointer-events: auto;
  animation: toast-in .2s ease-out;
  overflow-wrap: anywhere;
}
.toast.error { background: rgba(196, 43, 38, .96); }
.toast.success { background: rgba(23, 131, 67, .96); }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- payments ---------- */
.pay-list { padding: 4px 12px 12px; }
.pay-card {
  margin: 0 0 14px;
  overflow: hidden;
  transition: transform .24s cubic-bezier(.4, 0, .2, 1), opacity .24s ease;
}
.pay-card.leaving-right { transform: translateX(110%); opacity: 0; }
.pay-card.leaving-left { transform: translateX(-110%); opacity: 0; }
.pay-card.leaving-fade { transform: scale(.96); opacity: 0; }
.pay-card.collapsing { transition: height .22s ease, margin .22s ease; }
.pay-card.is-new { animation: card-in .3s ease-out; }
@keyframes card-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.pay-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px;
  min-height: 20px;
  padding: 5px 12px 3px 12px;
}
.pay-top .method-tag { margin-top: 0; }
.pay-time { font-size: 11.5px; color: var(--hint); line-height: 1.2; white-space: nowrap; }

.pay-media {
  position: relative;
  display: block;
  width: 100%;
  height: 55vh;
  height: clamp(240px, calc(100dvh - 330px), 65vh);
  padding: 0;
  border: 0;
  background: var(--media-bg);
  cursor: zoom-in;
  overflow: hidden;
}
.pay-media img {
  display: block;
  width: 100%; height: 100%;
  object-fit: contain;
}
.pay-media .zoom-hint {
  position: absolute; right: 8px; bottom: 8px;
  width: 34px; height: 34px;
  border-radius: 17px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: 16px; line-height: 34px; text-align: center;
  pointer-events: none;
}
.pay-media .media-fail {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--subtext); font-size: 14px;
}
.pay-card.history .pay-media { height: 34vh; min-height: 200px; }

.pay-body { padding: 10px 14px 14px; }
.pay-row1 { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pay-who { min-width: 0; }
.pay-name { font-size: 16.5px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.pay-username { font-size: 13px; color: var(--hint); overflow-wrap: anywhere; }
.pay-amount {
  flex: none;
  font-size: 25px; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: -.01em;
}
.pay-amount small { font-size: 14px; font-weight: 700; }
.pay-meta { margin-top: 6px; font-size: 14px; color: var(--subtext); line-height: 1.45; overflow-wrap: anywhere; }
.pay-meta div { display: flex; gap: 6px; }
.pay-meta .ico { flex: none; width: 18px; text-align: center; }
.pay-warn {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--destructive);
  font-size: 13.5px; font-weight: 600;
}
.pay-warn.amber { background: var(--amber-soft); color: var(--amber); }
.pay-status { margin-top: 8px; font-size: 13.5px; color: var(--subtext); }
.pay-status b { color: var(--text); }
.pay-actions { display: grid; grid-template-columns: 3fr 2fr; gap: 10px; margin-top: 12px; }
.btn-accept, .btn-reject {
  min-height: 52px;
  border-radius: 13px;
  color: #fff;
  font-size: 17px; font-weight: 700;
}
.btn-accept { background: var(--green); }
.btn-accept:active:not(:disabled) { background: var(--green-press); }
.btn-reject { background: var(--red); }
.btn-reject:active:not(:disabled) { background: var(--red-press); }
.pay-card.is-cash .pay-body { padding-top: 4px; }

.pay-skel { margin: 0 0 14px; padding: 12px; }
.pay-skel .skeleton.media { height: 46vh; margin: 8px -12px 12px; border-radius: 0; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .2s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--kb);
  z-index: 51;
  max-width: 600px;
  margin: 0 auto;
  max-height: 88vh;
  max-height: calc(88dvh - var(--kb));
  display: flex; flex-direction: column;
  background: var(--card-bg);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 30px rgba(0, 0, 0, .18);
  transform: translateY(105%);
  transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-bottom);
}
.sheet.open { transform: none; }
.sheet-head { position: relative; padding: 8px 56px 8px 16px; }
.sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--separator); margin: 0 auto 10px; transform: translateX(20px); }
.sheet-title { margin: 0; font-size: 18px; font-weight: 700; }
.sheet-sub { margin-top: 2px; font-size: 13.5px; color: var(--subtext); overflow-wrap: anywhere; }
.sheet-close {
  position: absolute; top: 10px; right: 8px;
  width: 44px; height: 44px;
  border: 0; border-radius: 22px;
  background: transparent;
  color: var(--hint);
  font-size: 22px;
}
.sheet-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px 16px 16px;
}
.sheet-foot { padding: 10px 16px 12px; border-top: 1px solid var(--separator); }
.reasons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.reasons .chip { min-height: 44px; white-space: normal; text-align: left; line-height: 1.2; padding: 8px 14px; }

.check-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--separator);
}
.check-row:last-child { border-bottom: 0; }
.check-row input[type="checkbox"] { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--button); }
.check-row .li-main { flex: 1; }
.check-row.disabled { opacity: .55; }

.result-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--separator); }
.result-row:last-child { border-bottom: 0; }

/* ---------- image viewer ---------- */
.viewer {
  position: fixed; inset: 0;
  z-index: 60;
  background: #000;
  touch-action: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity .18s ease;
  -webkit-user-select: none; user-select: none;
}
.viewer.open { opacity: 1; }
.viewer img {
  position: absolute; left: 0; top: 0;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
.viewer img.animate { transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
.viewer-close {
  position: absolute;
  top: calc(10px + var(--safe-top)); right: calc(10px + var(--safe-right));
  z-index: 2;
  width: 46px; height: 46px;
  border: 0; border-radius: 23px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 22px; line-height: 46px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.viewer-hint {
  position: absolute; left: 0; right: 0;
  bottom: calc(14px + var(--safe-bottom));
  text-align: center;
  color: rgba(255, 255, 255, .65);
  font-size: 12.5px;
  padding: 0 24px;
  pointer-events: none;
  transition: opacity .3s;
}
.viewer-spinner { position: absolute; left: 50%; top: 50%; margin: -14px 0 0 -14px; border-color: rgba(255, 255, 255, .2); border-top-color: #fff; }
.viewer-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; }

/* ---------- forms ---------- */
.field { display: block; margin: 0 0 14px; }
.field-label { display: block; margin: 0 0 6px 2px; font-size: 13.5px; font-weight: 600; color: var(--subtext); }
.field-help { display: block; margin: 5px 2px 0; font-size: 12.5px; color: var(--hint); }
.field-key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; color: var(--hint); font-weight: 500; }
.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--separator);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 16px; /* >=16px prevents iOS zoom on focus */
  line-height: 1.35;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--blue-soft); }
.textarea { resize: vertical; min-height: 84px; }
.select {
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--hint) 50%), linear-gradient(135deg, var(--hint) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.input[type="date"], .input[type="time"] { min-width: 0; }
.input::placeholder, .textarea::placeholder { color: var(--hint); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search { position: relative; }
.search .input { padding-left: 38px; }
.search::before { content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .6; pointer-events: none; }

.switch { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; flex: none;
  width: 50px; height: 30px;
  border-radius: 15px;
  background: var(--grey-soft);
  transition: background-color .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .15s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.progress { height: 6px; border-radius: 3px; background: var(--grey-soft); overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; width: 0; background: var(--button); transition: width .15s; }

/* ---------- date bar ---------- */
.datebar { display: flex; align-items: center; gap: 6px; }
.datebar .nav {
  flex: none;
  width: 46px; height: 46px;
  border: 0; border-radius: 12px;
  background: var(--card-bg);
  color: var(--accent);
  font-size: 24px; line-height: 1;
  box-shadow: var(--shadow);
}
.datebar .label {
  position: relative;
  flex: 1; min-width: 0;
  min-height: 46px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  border: 0;
  text-align: center;
}
.datebar .label .d1 { font-weight: 700; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.datebar .label .d2 { font-size: 12px; color: var(--hint); }
.datebar .label input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  border: 0;
  cursor: pointer;
}
.datebar-chips { margin-top: 10px; }

/* ---------- menu page ---------- */
.status-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 14px; }
.kv > span:first-child { color: var(--subtext); }
.kv > span:last-child { text-align: right; overflow-wrap: anywhere; }

.dish-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dish-tile {
  position: relative;
  display: flex; flex-direction: column;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
  color: inherit;
}
.dish-tile .ph, .dish-card .ph {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--media-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  overflow: hidden;
}
.dish-tile img, .dish-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dish-tile .nm {
  padding: 6px 7px 8px;
  font-size: 13px; font-weight: 600; line-height: 1.2;
  min-height: 2.6em;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dish-tile[aria-pressed="true"] { border-color: var(--green); }
.dish-tile .tick {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px;
  border-radius: 13px;
  background: var(--green);
  color: #fff;
  font-size: 13px; font-weight: 800; line-height: 26px; text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  display: none;
}
.dish-tile[aria-pressed="true"] .tick { display: block; }
.dish-tile.inactive .ph { opacity: .5; }
.dish-tile:disabled { cursor: default; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; font-size: 14px; }
.bar-row .bn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bc { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-row .bt { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--grey-soft); overflow: hidden; }
.bar-row .bt > div { height: 100%; background: var(--green); border-radius: 4px; transition: width .3s ease; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { padding: 12px 14px; }
.stat .sl { font-size: 12.5px; color: var(--subtext); font-weight: 600; }
.stat .sv { margin-top: 2px; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.2; }
.stat.wide { grid-column: 1 / -1; }
.stat .sv.green { color: var(--green); }
.stat .sv.red { color: var(--destructive); }

details.fold { margin-bottom: 10px; overflow: hidden; }
details.fold > summary {
  display: flex; align-items: center; gap: 10px;
  min-height: 54px;
  padding: 10px 14px;
  list-style: none;
  cursor: pointer;
  font-weight: 600;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "›"; margin-left: auto; color: var(--hint); font-size: 22px; transition: transform .15s; }
details.fold[open] > summary::after { transform: rotate(90deg); }
details.fold > summary .sum-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
details.fold > summary .sum-end { color: var(--subtext); font-weight: 600; white-space: nowrap; }
.fold-body { padding: 0 14px 10px; }
.person {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding: 9px 0;
  border-top: 1px solid var(--separator);
  font-size: 14px;
}
.person .pn { font-weight: 600; overflow-wrap: anywhere; }
.person .pd { color: var(--subtext); font-size: 13px; overflow-wrap: anywhere; }
.person .pa { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.person .ps { text-align: right; }

.table-days .list-item { min-height: 52px; }

/* ---------- dishes page ---------- */
.dish-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dish-card { position: relative; padding: 0; border: 0; overflow: hidden; text-align: left; color: inherit; }
.dish-card .info { padding: 8px 10px 10px; }
.dish-card .nm { font-weight: 700; font-size: 14.5px; overflow-wrap: anywhere; }
.dish-card .ds { font-size: 12.5px; color: var(--subtext); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dish-card.inactive .ph { opacity: .45; }
.dish-card .off-tag { position: absolute; top: 8px; left: 8px; }

.photo-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: var(--media-bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--hint);
  margin-bottom: 10px;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

.link-box {
  padding: 12px;
  border-radius: 12px;
  background: var(--input-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  overflow-wrap: anywhere;
  word-break: break-all;
  margin-bottom: 10px;
  -webkit-user-select: all; user-select: all;
}

.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

@media (min-width: 520px) {
  .dish-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dish-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
