/* The admin app: one palette for every store (palm green), a phone layout with a bottom tab bar,
   and a side menu once the window is wide enough. */
:root {
  --primary: #2f4a3c;
  --on-primary: #ffffff;
  --primary-ink: #2f4a3c;
  --primary-tint: #e6eee9;
  --viz-series: #1e7f4f;
  --viz-line: #257de0;
  --viz-critical: #dc3c3d;
  --viz-grid: #e7e7e7;
  --viz-axis: #c2c2c2;
  --viz-band: rgba(25, 25, 25, .05);
  --side-w: 248px;
  --content-w: 1040px;
}

/* ---------------------------------------------------------------- sign in */
.login { display: flex; flex-direction: column; gap: 20px; max-width: 420px; margin: 0 auto; padding: calc(var(--safe-top) + 36px) 4px 24px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login-icon { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 10px 24px rgba(20, 40, 30, .22); }
.login-brand h1 { font-size: 22px; font-weight: 800; }
.login-brand p { color: var(--muted); }

/* ---------------------------------------------------------------- layout pieces */
.banner { margin-bottom: 12px; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.col { min-width: 0; }
/* on a phone the columns stack: the second one needs the usual space above whatever starts it */
.col + .col > :first-child { margin-top: 22px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.toolbar > .btn { flex: 1 1 auto; }
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.lead-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.hero-card { display: flex; flex-direction: column; gap: 8px; }
.hero-card .big { line-height: 1.25; }

.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.more-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 96px; padding: 12px 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  text-decoration: none; color: var(--ink); font-size: 13px; font-weight: 700; text-align: center;
}
.more-tile:active { background: var(--press); }
.more-tile .dot-badge { top: 8px; inset-inline-start: 8px; }

.row-done .row-icon { background: var(--ok-bg); color: var(--ok); }
.row-done .row-title { color: var(--muted); }
.row-alert .row-icon { background: var(--warn-bg); color: var(--warn); }
.row-urgent .row-icon { background: var(--bad-bg); color: var(--bad); }
.row-muted { opacity: .62; }
.row-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

.form-heading { margin: 8px 0 -2px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 15px; font-weight: 800; }
.form > .form-heading:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.live { min-height: 48px; transition: opacity .2s; }
.live.is-loading { opacity: .5; pointer-events: none; }
.period { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.period-custom { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.period-custom label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
table.data th { background: #faf9f7; color: var(--muted); font-size: 12.5px; font-weight: 700; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.wrap { white-space: normal; min-width: 160px; }
.table-empty { padding: 6px 2px; }

.timeline { list-style: none; margin: 0; padding: 0 6px 0 0; }
.timeline li { position: relative; padding: 0 16px 14px 0; border-inline-start: 2px solid var(--line); }
.timeline li:last-child { border-inline-start-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; top: 6px; inset-inline-start: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline p { font-size: 14px; font-weight: 600; }
.timeline small { color: var(--muted); }

.pick-line { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; color: var(--muted); }
.pick-line .code { color: var(--ink); }

.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 14px; }
.image-cell { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.image-cell img { width: 100%; height: 100%; object-fit: cover; }
.image-cell .icon-btn { position: absolute; top: 4px; inset-inline-end: 4px; width: 34px; height: 34px; background: rgba(255, 255, 255, .92); }
.image-add { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; aspect-ratio: 1; border: 1.5px dashed var(--field-line); border-radius: 14px; background: transparent; color: var(--primary-ink); font-size: 13px; font-weight: 700; cursor: pointer; }
.image-add[aria-busy="true"] { color: transparent; }
.image-add[aria-busy="true"] > * { visibility: hidden; }
.image-add[aria-busy="true"]::after { content: ""; position: absolute; width: 24px; height: 24px; border: 2.5px solid var(--primary-ink); border-inline-end-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }

.variant-card { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.variant-list { display: flex; flex-direction: column; gap: 10px; }

.pos-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pos-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 92px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-align: start; cursor: pointer; }
.pos-item:active { background: var(--press); }
.pos-item:disabled { opacity: .45; cursor: default; }
.pos-item strong { font-size: 14px; line-height: 1.4; }
.pos-item .price { margin-top: auto; }
.pos-item.is-chosen { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.pos-count { align-self: flex-end; margin-top: -2px; }
.pos-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pos-line:last-child { border-bottom: 0; }
.pos-side { display: none; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--field-line); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 600; }
.check-chip input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }

.temp { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.temp-out { color: var(--bad); font-weight: 800; }

.preview-welcome { position: relative; overflow: hidden; width: min(220px, 70%); aspect-ratio: 9 / 16; margin: 0 auto; border-radius: 22px; background: #2a1a10; color: #fff; }
.preview-media { position: absolute; inset: 0; }
.preview-media > img, .preview-media > svg { display: block; width: 100%; height: 100%; object-fit: cover; }
.preview-welcome-text { position: absolute; inset: auto 0 0; display: flex; flex-direction: column; gap: 4px; padding: 40px 14px 16px; text-align: center; background: linear-gradient(transparent, rgba(18, 10, 4, .88) 45%); }
.preview-welcome-text strong { font-size: 15px; }
.preview-welcome-text span { font-size: 12px; opacity: .9; }
.preview-welcome-text i { align-self: stretch; margin-top: 8px; padding: 8px; border-radius: 999px; background: var(--store-color, #e9b54c); color: var(--store-ink, #231b15); font-style: normal; font-weight: 800; font-size: 12.5px; }
.preview-skip { position: absolute; top: 10px; inset-inline-end: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, .35); font-size: 11px; font-weight: 700; }
input[type=color].input { width: 96px; height: 48px; padding: 4px; cursor: pointer; }
.poster { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.poster h2 { font-size: 22px; }
.poster .code { font-size: 12.5px; word-break: break-all; }

.logo-preview { width: 76px; height: 76px; border-radius: 18px; object-fit: contain; background: var(--surface); border: 1px solid var(--line); }
.share-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.share-card .qr-img { width: 200px; height: 200px; }

/* ---------------------------------------------------------------- charts */
.viz { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.viz-stage { position: relative; width: 100%; min-height: 190px; }
.viz-svg { display: block; overflow: visible; touch-action: pan-y; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis { stroke: var(--viz-axis); stroke-width: 1; }
.viz-tick { fill: var(--muted); font-size: 11px; }
.viz-bar { fill: var(--viz-series); }
.viz-bar.is-active { fill: #14633c; }
.viz-bar-empty { fill: var(--viz-axis); }
.viz-hit { fill: transparent; cursor: pointer; }
.viz-band { fill: var(--viz-band); }
.viz-band-edge { stroke: var(--viz-axis); stroke-width: 1; }
.viz-line { fill: none; stroke: var(--viz-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { fill: var(--viz-line); stroke: var(--surface); stroke-width: 2; }
.viz-out { fill: var(--viz-critical); stroke: var(--surface); stroke-width: 2; }
.viz-end { fill: var(--ink); font-size: 12px; font-weight: 700; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.viz-cross { stroke: #8d8d8d; stroke-width: 1; }
.viz-focus { fill: none; stroke: var(--ink); stroke-width: 2; }
.viz-tip {
  position: absolute; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 12px; border-radius: 10px; background: #251c15; color: #fff; font-size: 12.5px; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2); transform: translateX(-50%); pointer-events: none;
}
.viz-tip-warn { display: inline-flex; align-items: center; gap: 4px; color: #ffd6cf; font-weight: 700; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 12.5px; }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 16px; }
.key-line { height: 0; border-top: 2px solid var(--viz-line); }
.key-band { height: 11px; background: #efefef; border-block: 1px solid var(--viz-axis); }
.key-out { width: 9px; height: 9px; background: var(--viz-critical); transform: rotate(45deg); }
.viz > .btn { align-self: flex-start; }

/* ---------------------------------------------------------------- tablets and computers */
@media (min-width: 700px) {
  :root { --app-width: 760px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .more-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

@media (min-width: 960px) {
  body.has-sidebar .sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: 35; display: block; width: var(--side-w);
    overflow-y: auto; padding: 14px 12px 24px; background: var(--surface); border-inline-end: 1px solid var(--line);
  }
  .side-head { display: flex; align-items: center; gap: 10px; padding: 2px 6px 14px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
  .side-head img { width: 40px; height: 40px; border-radius: 11px; object-fit: contain; }
  .side-head strong { display: block; line-height: 1.35; }
  .side-head small { color: var(--muted); }
  .side-group + .side-group { margin-top: 14px; }
  .side-title { padding: 0 10px 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
  .side-link { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 10px; color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none; }
  .side-link:hover { background: var(--press); }
  .side-link.is-active { background: var(--primary-tint); color: var(--primary-ink); }
  .side-badge { min-width: 20px; height: 20px; margin-inline-start: auto; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; line-height: 20px; text-align: center; }

  body.has-sidebar .frame { max-width: none; margin-inline-start: var(--side-w); }
  body.has-sidebar .screen { max-width: var(--content-w); margin-inline: auto; padding: 18px 24px 36px; }
  body.has-sidebar .appbar { padding-inline: max(16px, calc((100% - var(--content-w)) / 2 + 16px)); }
  body.has-sidebar .tabbar { display: none; }
  body.has-sidebar .actionbar {
    bottom: 0; inset-inline-start: var(--side-w); max-width: none; margin: 0;
    padding-inline: max(24px, calc((100% - var(--content-w)) / 2 + 24px));
  }
  body.has-sidebar.has-tabbar .screen-host { padding-bottom: 0; }
  body.has-sidebar.has-actionbar .screen-host { padding-bottom: var(--bar-h, var(--action-h)); }
  body.has-sidebar .toasts { inset-inline-start: var(--side-w); }
  body.has-sidebar.has-tabbar:not(.has-actionbar) .toasts { bottom: 18px; }
  body.has-sidebar.has-actionbar .toasts { bottom: calc(var(--bar-h, var(--action-h)) + 12px); }
  body.has-sidebar .actionbar > .btn-block { flex: 0 1 340px; }

  .columns { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .col + .col > :first-child { margin-top: 0; }
  .col + .col > .section:first-child { margin-top: 4px; }
  .columns-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar > .btn { flex: 0 0 auto; }

  .pos-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
  .pos-side { position: sticky; top: 76px; display: block; }
}

@media print {
  .sidebar { display: none !important; }
  body.has-sidebar .frame { margin: 0 !important; }
  body.has-sidebar .screen { max-width: none !important; }
}

.ltr-sub .row-sub { direction: ltr; text-align: right; }
.receipt-image { width: 100%; border-radius: 12px; }
details > summary { min-height: 36px; padding: 6px 0; cursor: pointer; }
details > .stack { padding-top: 8px; }

.label-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.label-sheet .box-label { break-inside: avoid; }
@media print {
  .label-sheet { grid-template-columns: 1fr 1fr; gap: 5mm; }
}

.signatures { display: none; }
@media print {
  .signatures { display: flex; justify-content: space-between; margin-top: 28px; }
}

.scan-video { width: 100%; max-height: 50vh; border-radius: 16px; background: #111; object-fit: cover; }
.room-card { display: flex; flex-direction: column; gap: 8px; }
.room-temp { font-size: 34px; font-weight: 800; line-height: 1.1; }
.report-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin: 12px 0; }
