/* Dream Rewards design system.
   Charcoal and brass from the Dream logo plate, on a neutral light page.
   Signature: the brass seal (stamps, the visit-code countdown ring, the QR frame). Everything else stays quiet.
   Logical properties throughout so right-to-left layout is native. */

:root {
  color-scheme: light;
  --page: #F2F2EF;
  --surface: #FFFFFF;
  --surface-2: #F8F8F6;
  --surface-3: #EDECE7;
  --line: #E4E2DC;
  --line-strong: #D0CDC4;
  --ink: #1C1D20;
  --ink-2: #3A3C41;
  --muted: #5F6167;
  --charcoal: #1B1C1F;
  --charcoal-2: #26272B;
  --charcoal-3: #34363B;
  --on-charcoal: #F4F3EF;
  --on-charcoal-muted: #B9BBC1;
  --brass: #B08D57;
  --brass-mark: #A0762E;
  --brass-text: #85622A;
  --brass-soft: #F4EDE0;
  --brass-light: #C9A66B;
  --success: #276B4E; --success-soft: #E6F2EC;
  --warning: #8A5A0E; --warning-soft: #FBF1DE;
  --danger: #B3261E;  --danger-soft: #FBE9E7;
  --info: #2F5E8C;    --info-soft: #E7EEF6;

  --font: "IBM Plex Sans Arabic", system-ui, "Segoe UI", Tahoma, sans-serif;
  --font-display: "Reem Kufi", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r-sm: 6px; --r: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --shadow-1: 0 1px 2px rgba(27, 28, 31, .05);
  --shadow-2: 0 8px 24px rgba(27, 28, 31, .08);
  --shadow-3: 0 20px 50px rgba(27, 28, 31, .20);
  --dur-1: 120ms; --dur-2: 180ms; --dur-3: 260ms;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 68px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.35; color: var(--ink); }
h2 { font-size: 15.5px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brass-mark); outline-offset: 2px; }
main:focus-visible { outline: none; }
a.link { color: var(--brass-text); font-weight: 600; text-decoration: underline; text-decoration-color: rgba(133, 98, 42, .35); text-underline-offset: 3px; }
a.link:hover { text-decoration-color: currentColor; }
.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; background: var(--charcoal); color: var(--on-charcoal); padding: 8px 14px; border-radius: var(--r); }
.skip-link:focus { top: 12px; }

/* ---------- Layout primitives ---------- */
.stack { display: flex; flex-direction: column; gap: var(--gap, 12px); }
.stack--lg { --gap: 18px; }
.stack--sm { --gap: 8px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, 8px); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(300px, 370px); align-items: start; }
@media (max-width: 1180px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1080px) { .grid-main-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Icons ---------- */
.icon { width: var(--icon, 18px); height: var(--icon, 18px); flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Buttons ---------- */
.btn {
  --btn-h: 36px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--btn-h); padding: 0 13px; border-radius: var(--r); border: 1px solid transparent;
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 13.5px; line-height: 1.2; white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.btn .icon { --icon: 17px; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--charcoal); color: var(--on-charcoal); }
.btn--primary:hover { background: #000; }
.btn--primary .icon { color: var(--brass-light); }
.btn--secondary { border-color: var(--line-strong); }
.btn--secondary:hover { border-color: #9F9B90; background: var(--surface-2); }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn--brass { background: var(--brass-soft); color: var(--brass-text); border-color: rgba(176, 141, 87, .45); }
.btn--brass:hover { background: #EEE2CC; }
.btn--danger { color: var(--danger); border-color: rgba(179, 38, 30, .35); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { background: #1F5A41; }
.btn--success .icon { color: #fff; }
.btn--sm { --btn-h: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn--sm .icon { --icon: 15px; }
.btn--lg { --btn-h: 44px; padding: 0 18px; font-size: 15px; border-radius: var(--r-md); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: var(--btn-h); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { pointer-events: none; }
.btn[aria-busy="true"] > * { visibility: hidden; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: baseline; gap: 6px; }
.optional { font-weight: 400; color: var(--muted); font-size: 12px; }
.field__hint { font-size: 12px; color: var(--muted); line-height: 1.6; display: flex; gap: 6px; align-items: flex-start; }
.field__hint .icon { --icon: 14px; margin-top: 3px; color: var(--brass-mark); }
.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font-size: 14px;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.textarea { min-height: 80px; resize: vertical; }
.select { appearance: none; padding-inline-end: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235F6167' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 11px center; }
.input::placeholder { color: #8E9096; }
.input:hover, .select:hover, .textarea:hover { border-color: #B4B0A6; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brass-mark); box-shadow: 0 0 0 3px rgba(176, 141, 87, .22); }
.input[readonly] { background: var(--surface-2); }
input[type="date"].input { direction: ltr; text-align: end; }
.input--ltr { direction: ltr; text-align: end; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); --icon: 16px; pointer-events: none; }
.input-icon > .input { padding-inline-start: 36px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; line-height: 1.55; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--charcoal); flex-shrink: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.sheet .form-grid { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); min-width: 0; }
.fieldset legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Segmented control (links or radios) */
.segmented { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 9px; }
.segmented a, .segmented label { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease); }
.segmented a:hover, .segmented label:hover { color: var(--ink); }
.segmented [aria-current="true"], .segmented label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(27, 28, 31, .12); }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--brass-mark); outline-offset: 1px; }
.segmented--block { display: flex; }
.segmented--block > * { flex: 1; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); line-height: 1; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--plain::before { display: none; }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--brass { background: var(--brass-soft); color: var(--brass-text); }
.badge--neutral { background: var(--surface-3); color: var(--muted); }
.badge--live::before { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.65); } }
.code-chip { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; letter-spacing: .03em; background: var(--surface-3); color: var(--ink); border-radius: 6px; padding: 1px 7px; direction: ltr; unicode-bidi: isolate; white-space: nowrap; display: inline-block; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 13px 16px 0; flex-wrap: wrap; }
.card__head h2 { display: flex; align-items: center; gap: 8px; }
.card__head h2 .icon { color: var(--brass-mark); --icon: 17px; }
.card__head--rule { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.card__sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.55; }
.card__body { padding: 12px 16px 16px; }
.card__body--flush { padding: 6px 0 0; }
.card__foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Staff shell ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
body[data-sidebar="collapsed"] .app-shell { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--charcoal); color: var(--on-charcoal); z-index: 30; min-width: 0; }
.sidebar :focus-visible { outline-color: var(--brass-light); }
.sidebar__brand { position: relative; display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px; border-bottom: 1px solid rgba(255, 255, 255, .07); min-height: 64px; }
.sidebar__home { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; border-radius: var(--r); }
.sidebar__logo { width: 50px; height: 38px; object-fit: contain; flex-shrink: 0; border-radius: 6px; background: #000; }
.sidebar__wordmark { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar__wordmark strong { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--on-charcoal); white-space: nowrap; }
.sidebar__wordmark small { font-size: 11.5px; color: var(--on-charcoal-muted); }
.sidebar__collapse { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r); border: 0; background: transparent; color: var(--on-charcoal-muted); cursor: pointer; flex-shrink: 0; }
.sidebar__collapse:hover { background: var(--charcoal-2); color: var(--on-charcoal); }
.sidebar__nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; scrollbar-color: var(--charcoal-3) transparent; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group__label { font-size: 11.5px; font-weight: 600; color: #8D8F95; padding: 0 10px 4px; white-space: nowrap; }
.nav-link { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border-radius: var(--r); color: var(--on-charcoal-muted); font-weight: 500; white-space: nowrap; transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease); }
.nav-link:hover { background: var(--charcoal-2); color: var(--on-charcoal); }
.nav-link[aria-current="page"] { background: var(--charcoal-2); color: var(--on-charcoal); }
.nav-link[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -10px; top: 8px; bottom: 8px; width: 3px; border-start-end-radius: 3px; border-end-end-radius: 3px; background: var(--brass-light); }
.nav-link[aria-current="page"] .icon { color: var(--brass-light); }
.nav-link__text { overflow: hidden; text-overflow: ellipsis; }
.nav-link__count { margin-inline-start: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brass-light); color: var(--charcoal); font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
.sidebar__foot { border-top: 1px solid rgba(255, 255, 255, .07); padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--r); min-width: 0; }
.sidebar__user:hover, .sidebar__user[aria-current="page"] { background: var(--charcoal-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--charcoal-3); color: var(--brass-light); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.sidebar__user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.sidebar__user-name { font-size: 13px; font-weight: 600; color: var(--on-charcoal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-role { font-size: 11.5px; color: var(--on-charcoal-muted); }
.sidebar__foot form { margin: 0; }
.sidebar__logout { width: 100%; justify-content: flex-start; color: var(--on-charcoal-muted); padding: 0 10px; }
.sidebar__logout:hover { background: var(--charcoal-2); color: var(--on-charcoal); }

body[data-sidebar="collapsed"] .sidebar__wordmark,
body[data-sidebar="collapsed"] .nav-group__label,
body[data-sidebar="collapsed"] .nav-link__text,
body[data-sidebar="collapsed"] .sidebar__user-meta,
body[data-sidebar="collapsed"] .sidebar__logout-text { display: none; }
body[data-sidebar="collapsed"] .sidebar__brand { flex-direction: column; padding: 10px 6px; }
body[data-sidebar="collapsed"] .sidebar__home { justify-content: center; flex: none; }
body[data-sidebar="collapsed"] .sidebar__logo { width: 46px; height: 34px; }
body[data-sidebar="collapsed"] .nav-link, body[data-sidebar="collapsed"] .sidebar__logout { justify-content: center; padding: 0; }
body[data-sidebar="collapsed"] .nav-link__count { position: absolute; top: 2px; inset-inline-end: 4px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
body[data-sidebar="collapsed"] .sidebar__user { justify-content: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 24px; background: rgba(242, 242, 239, .9); backdrop-filter: saturate(1.2) blur(10px); -webkit-backdrop-filter: saturate(1.2) blur(10px); border-bottom: 1px solid var(--line); }
.topbar__title { display: flex; flex-direction: column; min-width: 0; margin-inline-end: auto; line-height: 1.25; }
.topbar__eyebrow { font-size: 12px; color: var(--muted); }
.topbar__title h1 { font-family: var(--font-display); font-weight: 600; font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__search { width: min(320px, 30vw); }
.topbar__search .input { min-height: 36px; padding-inline-end: 34px; }
.topbar__search .kbd { position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); }
.kbd { font-family: var(--font-mono); font-size: 11px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--surface-2); color: var(--muted); display: inline-grid; place-items: center; }
.topbar__menu { display: none; }
.topbar__actions { flex-wrap: nowrap; }
.page { padding: 18px 24px 40px; display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 1480px; }
.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; }
.scrim { display: none; }

@media (max-width: 1000px) {
  .app-shell, body[data-sidebar="collapsed"] .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(284px, 86vw); transform: translateX(105%); visibility: hidden; transition: transform var(--dur-3) var(--ease), visibility 0s linear var(--dur-3); box-shadow: var(--shadow-3); }
  [dir="ltr"] .sidebar { transform: translateX(-105%); }
  body[data-nav="open"] .sidebar { transform: none; visibility: visible; transition: transform var(--dur-3) var(--ease); }
  body[data-nav="open"] .scrim { display: block; position: fixed; inset: 0; background: rgba(27, 28, 31, .45); z-index: 25; }
  body[data-sidebar="collapsed"] .sidebar__wordmark, body[data-sidebar="collapsed"] .nav-group__label, body[data-sidebar="collapsed"] .nav-link__text, body[data-sidebar="collapsed"] .sidebar__user-meta, body[data-sidebar="collapsed"] .sidebar__logout-text { display: revert; }
  body[data-sidebar="collapsed"] .sidebar__brand { flex-direction: row; padding: 12px; }
  body[data-sidebar="collapsed"] .nav-link, body[data-sidebar="collapsed"] .sidebar__logout { justify-content: flex-start; padding: 0 10px; }
  body[data-sidebar="collapsed"] .nav-link__count { position: static; }
  body[data-sidebar="collapsed"] .sidebar__user { justify-content: flex-start; }
  .sidebar__collapse { display: none; }
  .topbar { padding: 8px 14px; min-height: 58px; gap: 8px; }
  .topbar__menu { display: inline-flex; }
  .topbar__search { display: none; }
  .topbar__title h1 { font-size: 18px; }
  .page { padding: 14px 14px 32px; gap: 14px; }
}
@media (max-width: 600px) {
  .topbar__actions .btn__label { display: none; }
  .topbar__actions .btn { padding: 0; width: 38px; }
  .topbar__eyebrow { display: none; }
}

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; box-shadow: var(--shadow-1); }
a.kpi:hover { border-color: var(--line-strong); }
.kpi__label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi__label .icon { --icon: 15px; color: var(--brass-mark); }
.kpi__value { font-size: 26px; font-weight: 600; line-height: 1.25; color: var(--ink); }
.kpi__meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; line-height: 1.5; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; color: var(--ink-2); }
.delta .icon { --icon: 13px; stroke-width: 2.3; }
.delta--flat { color: var(--muted); }
.kpis--compact .kpi { padding: 10px 12px; }
.kpis--compact .kpi__value { font-size: 22px; }

/* ---------- Stat blocks ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; }
.stat { border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 10px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stat__value { font-size: 20px; font-weight: 600; line-height: 1.3; }
.stat__label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.stat__label .icon { --icon: 14px; }

/* ---------- Tables ---------- */
.toolbar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .field { min-width: 140px; }
.toolbar .field--grow { flex: 1 1 240px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; text-align: start; padding: 8px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background-color var(--dur-1) var(--ease); }
.table tbody tr:hover { background: #FAFAF8; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table__primary { font-weight: 600; color: var(--ink); display: block; }
.table__secondary { font-size: 12px; color: var(--muted); display: block; }
.table__actions { text-align: end; white-space: nowrap; }
.table__actions .cluster { justify-content: flex-end; flex-wrap: nowrap; }
.table tr.is-muted td { color: var(--muted); }
.table tr.is-muted .table__primary { color: var(--muted); }
tr[data-href] { cursor: pointer; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.list__item:last-child { border-bottom: 0; }
a.list__item:hover { background: #FAFAF8; }
.list__icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); flex-shrink: 0; }
.list__icon .icon { --icon: 15px; }
.list__icon--brass { background: var(--brass-soft); color: var(--brass-text); }
.list__icon--success { background: var(--success-soft); color: var(--success); }
.list__icon--warning { background: var(--warning-soft); color: var(--warning); }
.list__icon--danger { background: var(--danger-soft); color: var(--danger); }
.list__icon--info { background: var(--info-soft); color: var(--info); }
.list__body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.list__title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__aside { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: end; flex-shrink: 0; }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 16px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Empty and alerts ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 26px 20px; color: var(--muted); font-size: 13px; }
.empty__icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); margin-bottom: 4px; }
.empty__title { color: var(--ink); font-weight: 600; font-size: 14px; }
.empty .btn { margin-top: 8px; }
.alert { display: flex; gap: 9px; align-items: flex-start; padding: 9px 12px; border-radius: var(--r); font-size: 13px; line-height: 1.65; }
.alert > .icon { --icon: 17px; margin-top: 2px; }
.alert--info { background: var(--info-soft); color: var(--info); }
.alert--success { background: var(--success-soft); color: var(--success); }
.alert--warning { background: var(--warning-soft); color: var(--warning); }
.alert--danger { background: var(--danger-soft); color: var(--danger); }
.alert--brass { background: var(--brass-soft); color: var(--brass-text); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 90; top: 12px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; max-width: min(560px, 100%); padding: 10px 12px 10px 14px; border-radius: var(--r-md); background: var(--charcoal); color: var(--on-charcoal); box-shadow: var(--shadow-3); font-size: 13.5px; line-height: 1.65; animation: toast-in var(--dur-3) var(--ease) both; }
.toast > .icon { --icon: 18px; margin-top: 1px; color: #8FD1B1; }
.toast--error { background: #41120E; }
.toast--error > .icon { color: #F5A39B; }
.toast--notice > .icon { color: var(--brass-light); }
.toast__close { margin-inline-start: 4px; background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; }
.toast__close:hover { opacity: 1; background: rgba(255, 255, 255, .08); }
.toast.is-leaving { animation: toast-out var(--dur-2) var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

/* ---------- Dialogs: side sheet and modal ---------- */
dialog { color: var(--ink); }
dialog.sheet, dialog.modal { padding: 0; border: 0; background: var(--surface); box-shadow: var(--shadow-3); overflow: hidden; }
dialog.sheet::backdrop, dialog.modal::backdrop { background: rgba(27, 28, 31, .42); }
dialog.sheet[open]::backdrop, dialog.modal[open]::backdrop { animation: fade-in var(--dur-2) var(--ease) both; }
dialog.sheet { position: fixed; inset: 0; margin: 0; margin-inline-start: auto; width: min(480px, 100vw); max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh; }
dialog.sheet--wide { width: min(640px, 100vw); }
dialog.sheet[open] { animation: sheet-in var(--dur-3) var(--ease) both; }
dialog.modal { width: min(440px, calc(100vw - 24px)); border-radius: var(--r-lg); }
dialog.modal[open] { animation: modal-in var(--dur-3) var(--ease) both; }
.sheet__form, .sheet__frame { display: flex; flex-direction: column; height: 100%; margin: 0; }
.modal .sheet__form, .modal .sheet__frame { height: auto; }
.sheet__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 18px 12px; border-bottom: 1px solid var(--line); }
.sheet__head h2 { font-size: 16.5px; }
.sheet__body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.sheet__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
@keyframes sheet-in { from { opacity: 0; transform: translateX(-28px); } }
[dir="ltr"] dialog.sheet[open] { animation-name: sheet-in-ltr; }
@keyframes sheet-in-ltr { from { opacity: 0; transform: translateX(28px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@media (max-width: 600px) {
  dialog.sheet { width: 100vw; }
}

/* Dropdown menu built on details */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel { position: absolute; z-index: 15; top: calc(100% + 6px); inset-inline-end: 0; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: 6px; display: flex; flex-direction: column; }
.menu__panel a, .menu__panel button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; background: none; border: 0; text-align: start; cursor: pointer; color: var(--ink); }
.menu__panel a:hover, .menu__panel button:hover { background: var(--surface-3); }
.menu__panel .icon { --icon: 16px; color: var(--muted); }
.menu__label { font-size: 11.5px; color: var(--muted); padding: 6px 10px 4px; }

/* ---------- Period filter ---------- */
.period-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period-custom { position: relative; }
.period-custom > summary { list-style: none; }
.period-custom > summary::-webkit-details-marker { display: none; }
.period-custom[open] > summary { background: var(--surface-3); }
.period-custom__form { position: absolute; z-index: 15; top: calc(100% + 6px); inset-inline-start: 0; display: flex; align-items: flex-end; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2); }
.period-custom__form .field { width: 150px; }
@media (max-width: 600px) {
  .period-custom__form { position: fixed; inset-inline: 12px; top: auto; flex-wrap: wrap; }
  .period-custom__form .field { flex: 1 1 120px; width: auto; }
}

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart__grid line { stroke: #ECEAE4; stroke-width: 1; }
.chart__baseline { stroke: var(--line-strong); stroke-width: 1; }
.chart__axis text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart__bar { fill: var(--brass-mark); pointer-events: none; transition: fill var(--dur-1) var(--ease); }
.chart__hit { fill: transparent; cursor: default; }
.chart__hit:hover + .chart__bar, .chart__hit:focus + .chart__bar { fill: var(--charcoal); }
.chart__hit:focus-visible { outline: none; stroke: var(--brass-mark); stroke-width: 1; stroke-dasharray: 3 3; }
.chart__tooltip { position: absolute; z-index: 5; pointer-events: none; background: var(--charcoal); color: var(--on-charcoal); padding: 6px 10px; border-radius: var(--r); font-size: 12px; line-height: 1.5; white-space: nowrap; box-shadow: var(--shadow-2); transform: translate(-50%, calc(-100% - 8px)); opacity: 0; transition: opacity var(--dur-1) var(--ease); }
.chart__tooltip.is-visible { opacity: 1; }
.chart__tooltip strong { display: block; font-size: 13.5px; }
.chart-table { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.chart-table > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; list-style: none; border-radius: var(--r-sm); }
.chart-table > summary::-webkit-details-marker { display: none; }
.chart-table > summary .icon { --icon: 15px; }
.chart-table > summary:hover { color: var(--ink); }
.chart-table .table { margin-top: 8px; }
.chart-table .table-wrap { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 34%) minmax(0, 1fr) 36px; align-items: center; gap: 10px; font-size: 13px; }
.hbar__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__track { display: block; min-width: 0; }
.hbar__fill { display: block; height: 12px; min-width: 3px; background: var(--brass-mark); border-start-end-radius: 4px; border-end-end-radius: 4px; }
.hbar__value { font-weight: 600; font-variant-numeric: tabular-nums; text-align: end; }
.summary-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; line-height: 1.75; }
.summary-list li { position: relative; padding-inline-start: 16px; }
.summary-list li::before { content: ""; position: absolute; inset-inline-start: 0; top: .78em; width: 6px; height: 6px; border-radius: 50%; background: var(--brass); }

/* ---------- The Dream seal (signature) ---------- */
.seal {
  --seal: 48px;
  position: relative; width: var(--seal); height: var(--seal); border-radius: 50%; flex-shrink: 0;
  display: inline-grid; place-items: center; padding: 0;
  font-family: var(--font-display); font-weight: 600; font-size: calc(var(--seal) * .32); color: #A3A5AA;
  border: 1.5px dashed var(--line-strong); background: var(--surface);
}
.seal.is-filled {
  border: 0; color: var(--charcoal);
  background:
    radial-gradient(circle at 50% 50%, #EAD9B5 0 36%, transparent 37%),
    repeating-conic-gradient(from 3deg, #C9A66B 0deg 7.5deg, #B08D57 7.5deg 15deg);
  box-shadow: inset 0 0 0 2.5px #F6EEDC, inset 0 0 0 4px #9C7A43, 0 1px 2px rgba(27, 28, 31, .2);
}
.seal .icon { --icon: calc(var(--seal) * .4); stroke-width: 2.4; }
.seal.is-filled .icon { color: var(--charcoal); }
.seal.is-voided { border-style: solid; border-color: var(--danger-soft); color: var(--danger); }
button.seal { cursor: pointer; transition: transform var(--dur-2) var(--ease); }
button.seal:hover { transform: rotate(-8deg) scale(1.04); }
button.seal:focus-visible { outline-offset: 3px; border-radius: 50%; }
.seal.is-new { animation: seal-press 700ms var(--ease) both; }
.seal.is-new::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--brass); opacity: 0; animation: seal-ring 900ms 260ms var(--ease) both; }
@keyframes seal-press { 0% { transform: scale(1.6) rotate(-24deg); opacity: 0; } 55% { transform: scale(.9) rotate(5deg); opacity: 1; } 100% { transform: none; } }
@keyframes seal-ring { 0% { opacity: .9; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.4); } }
.seal-row { display: flex; gap: 6px; flex-wrap: wrap; }
.seal-row .seal { --seal: 30px; }
.seal-row .seal.is-filled { box-shadow: inset 0 0 0 2px #F6EEDC, inset 0 0 0 3px #9C7A43; }

/* Countdown ring */
.ring { --ring: 116px; position: relative; width: var(--ring); height: var(--ring); display: grid; place-items: center; flex-shrink: 0; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__track { stroke: var(--surface-3); }
.ring__bar { stroke: var(--brass-mark); transition: stroke-dashoffset 1s linear, stroke var(--dur-2) var(--ease); }
.ring.is-low .ring__bar { stroke: var(--warning); }
.ring.is-done .ring__bar { stroke: var(--line-strong); }
.ring__center { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.ring__value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; direction: ltr; font-variant-numeric: tabular-nums; }
.ring__label { font-size: 11.5px; color: var(--muted); }
.ring--sm { --ring: 40px; }
.ring--sm .ring__value { font-size: 11px; }

/* QR frame with brass corner marks */
.qr-frame { position: relative; background: #fff; padding: 12px; border-radius: var(--r-lg); width: 100%; max-width: var(--qr, 300px); margin-inline: auto; }
.qr-frame svg { width: 100%; height: auto; }
.qr-frame::before, .qr-frame::after { content: ""; position: absolute; width: 26px; height: 26px; border: 3px solid var(--brass); pointer-events: none; }
.qr-frame::before { top: 0; inset-inline-start: 0; border-inline-end: 0; border-bottom: 0; border-start-start-radius: var(--r-lg); }
.qr-frame::after { bottom: 0; inset-inline-end: 0; border-inline-start: 0; border-top: 0; border-end-end-radius: var(--r-lg); }

/* ---------- Reception ---------- */
.patient-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.patient-head .avatar { width: 44px; height: 44px; font-size: 17px; background: var(--charcoal); }
.patient-head__name { font-size: 17px; font-weight: 600; line-height: 1.35; }
.patient-head__meta { display: flex; gap: 4px 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); align-items: center; }
.patient-head__meta span { display: inline-flex; align-items: center; gap: 5px; }
.patient-head__meta .icon { --icon: 14px; }
.cycle { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.cycle__count { font-size: 13px; color: var(--muted); }
.cycle__count strong { font-size: 18px; color: var(--ink); }
.qr-live { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); }
.qr-live:last-child { border-bottom: 0; }
.qr-live:hover { background: #FAFAF8; }
.qr-live.is-attention { background: var(--warning-soft); }
.qr-live.is-attention:hover { background: #F8EACF; }
.qr-live__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.search-results .list__item { padding-block: 8px; }
.today-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

/* ---------- Public and patient screens (mobile first) ---------- */
body.public-body { font-size: 15px; background: var(--page); }
.p-shell { width: min(100%, 540px); margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 0 16px; padding-bottom: max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.p-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 10px; }
.p-header__brand { display: flex; align-items: center; gap: 10px; border-radius: var(--r); }
.p-header__logo { width: 54px; height: 40px; object-fit: contain; border-radius: 8px; background: #000; }
.p-header__name { font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.2; display: flex; flex-direction: column; }
.p-header__name small { font-family: var(--font); font-size: 11.5px; font-weight: 400; color: var(--muted); }
.p-main { flex: 1; display: flex; flex-direction: column; gap: 14px; padding-bottom: 20px; }
.p-footer { font-size: 12px; color: var(--muted); text-align: center; padding: 10px 0 4px; }
.p-title { font-family: var(--font-display); font-weight: 600; font-size: 25px; line-height: 1.35; }
.p-lead { color: var(--muted); font-size: 15px; line-height: 1.75; }
.p-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px; box-shadow: var(--shadow-1); }
.p-card--flush { padding: 0; overflow: hidden; }
.p-card__title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 16px; font-weight: 600; }
.p-section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 16px; font-weight: 600; padding: 4px 2px 0; }
.touch .input, .touch .select { min-height: 48px; font-size: 16px; border-radius: var(--r-md); padding-inline: 14px; }
.touch .input-icon > .input { padding-inline-start: 40px; }
.touch .btn { --btn-h: 46px; font-size: 15px; border-radius: var(--r-md); }
.touch .btn--sm { --btn-h: 36px; font-size: 13.5px; }
.touch .btn--icon { width: 42px; --btn-h: 42px; }
.touch .field__label { font-size: 14px; }
.touch .field { gap: 6px; }
.otp-input { font-family: var(--font-mono); font-size: 26px !important; letter-spacing: .5em; text-align: center; direction: ltr; padding-inline-start: .5em !important; }
.pin-input { font-family: var(--font-mono); font-size: 22px !important; letter-spacing: .45em; text-align: center; direction: ltr; padding-inline-start: .45em !important; }
.steps { display: flex; gap: 6px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--surface-3); }
.steps span.is-done { background: var(--brass); }
.steps span.is-current { background: var(--charcoal); }
.steps__label { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.p-links { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); text-align: center; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Hero on home and join */
.hero { position: relative; overflow: hidden; background: var(--charcoal); color: var(--on-charcoal); border-radius: var(--r-xl); padding: 24px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.hero::after { content: ""; position: absolute; inset-inline-end: -70px; bottom: -80px; width: 220px; height: 220px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(201, 166, 107, .18) 0deg 7.5deg, transparent 7.5deg 15deg); pointer-events: none; }
.hero h1 { font-family: var(--font-display); font-weight: 600; font-size: 26px; line-height: 1.4; color: var(--on-charcoal); max-width: 17ch; }
.hero p { color: var(--on-charcoal-muted); line-height: 1.75; max-width: 34ch; position: relative; z-index: 1; }
.hero__seals { display: flex; gap: 6px; margin-top: 4px; position: relative; z-index: 1; }
.hero__seals .seal { --seal: 26px; background: transparent; border-color: rgba(201, 166, 107, .45); }
.hero__seals .seal.is-filled { box-shadow: inset 0 0 0 2px #2A2B2F, inset 0 0 0 3px #9C7A43; }
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.how li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.65; }
.how__icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brass-soft); color: var(--brass-text); flex-shrink: 0; }
.how__icon .icon { --icon: 17px; }
.how strong { display: block; }
.how span { color: var(--muted); font-size: 14px; }

/* Member card */
.member-card { position: relative; overflow: hidden; background: var(--charcoal); color: var(--on-charcoal); border-radius: var(--r-xl); padding: 16px 18px; box-shadow: var(--shadow-2); }
.member-card::after { content: ""; position: absolute; inset-inline-end: -64px; top: -64px; width: 190px; height: 190px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(201, 166, 107, .16) 0deg 7.5deg, transparent 7.5deg 15deg); pointer-events: none; }
.member-card > * { position: relative; z-index: 1; }
.member-card__hello { font-size: 13px; color: var(--on-charcoal-muted); }
.member-card__name { font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1.35; color: var(--on-charcoal); }
.member-card__code { margin-top: 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.member-card__code span { font-size: 12px; color: var(--on-charcoal-muted); }
.member-card__code strong { font-family: var(--font-mono); font-size: 19px; letter-spacing: .1em; color: var(--brass-light); direction: ltr; unicode-bidi: isolate; }
.member-card__note { margin-top: 8px; font-size: 12.5px; color: var(--on-charcoal-muted); line-height: 1.65; }
.stamp-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 6px; justify-items: center; padding: 6px 0 2px; }
.stamp-grid .seal { --seal: min(54px, 14.5vw); }
.progress-line { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress-line > span { display: block; height: 100%; background: var(--brass-mark); border-radius: 6px; }
.visit-row { display: flex; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.visit-row:last-child { border-bottom: 0; }
.visit-row__date { width: 50px; flex-shrink: 0; text-align: center; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); padding: 4px 0; line-height: 1.2; }
.visit-row__date strong { display: block; font-size: 17px; }
.visit-row__date span { font-size: 11px; color: var(--muted); }
.visit-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.visit-row__body strong { font-size: 14.5px; }
.visit-row__body span { font-size: 12.5px; color: var(--muted); }
.visit-row.is-today { background: rgba(244, 237, 224, .6); }
dialog.bottom-sheet { position: fixed; inset: auto 0 0 0; margin: 0 auto; width: min(540px, 100vw); max-width: 100vw; border: 0; padding: 0 0 max(12px, env(safe-area-inset-bottom)); border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--surface); box-shadow: var(--shadow-3); }
dialog.bottom-sheet::backdrop { background: rgba(27, 28, 31, .42); }
dialog.bottom-sheet[open] { animation: sheet-up var(--dur-3) var(--ease) both; }
@keyframes sheet-up { from { opacity: 0; transform: translateY(26px); } }
.bottom-sheet__grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 10px auto 2px; }
.bottom-sheet__body { padding: 8px 18px 8px; display: flex; flex-direction: column; gap: 12px; }

/* Gift */
.gift-card { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 16px; background: linear-gradient(160deg, #FFFDF8 0%, var(--brass-soft) 100%); border: 1px solid #E6D5B5; display: flex; gap: 14px; align-items: center; }
.gift-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.gift-card__title { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.gift { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.gift__box { position: absolute; inset-inline: 10px; bottom: 6px; height: 36px; border-radius: 5px; background: var(--charcoal); }
.gift__lid { position: absolute; inset-inline: 6px; top: 24px; height: 13px; border-radius: 4px; background: var(--charcoal-3); transform-origin: 15% 100%; }
.gift__ribbon { position: absolute; top: 24px; bottom: 6px; left: 50%; width: 9px; margin-left: -4.5px; background: var(--brass); }
.gift__bow { position: absolute; top: 9px; left: 50%; width: 32px; height: 16px; margin-left: -16px; transform-origin: 50% 100%; }
.gift__bow::before, .gift__bow::after { content: ""; position: absolute; bottom: 0; width: 15px; height: 13px; border: 3px solid var(--brass); border-radius: 60% 60% 10% 60%; }
.gift__bow::before { left: 0; transform: rotate(-12deg); }
.gift__bow::after { right: 0; transform: scaleX(-1) rotate(-12deg); }
.gift.is-waiting { animation: gift-wiggle 3s var(--ease) infinite; }
.gift.is-opening .gift__lid { animation: lid-open 650ms var(--ease) both; }
.gift.is-opening .gift__bow { animation: bow-off 650ms var(--ease) both; }
.gift.is-opening::after { content: ""; position: absolute; inset: -16px; border-radius: 50%; background: radial-gradient(circle, rgba(201, 166, 107, .6), transparent 62%); animation: gift-glow 1s var(--ease) both; }
@keyframes gift-wiggle { 0%, 80%, 100% { transform: none; } 84% { transform: rotate(-7deg); } 88% { transform: rotate(6deg); } 92% { transform: rotate(-3deg); } 96% { transform: rotate(2deg); } }
@keyframes lid-open { to { transform: translateY(-14px) rotate(-22deg); } }
@keyframes bow-off { to { transform: translateY(-22px) rotate(-18deg); opacity: 0; } }
@keyframes gift-glow { from { opacity: 0; transform: scale(.5); } 40% { opacity: 1; } to { opacity: 0; transform: scale(1.3); } }
.reward-code { font-family: var(--font-mono); font-size: 21px; font-weight: 600; letter-spacing: .14em; direction: ltr; unicode-bidi: isolate; background: var(--surface); border: 1px dashed var(--brass); border-radius: var(--r); padding: 4px 12px; display: inline-block; }
.reward-item { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.reward-item:last-child { border-bottom: 0; }
.reward-item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; opacity: 0; animation: confetti-fall 1400ms var(--ease) forwards; }
@keyframes confetti-fall { 0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); } 100% { opacity: 0; transform: translate3d(var(--dx, 0), 70vh, 0) rotate(540deg); } }

/* ---------- Center poster ---------- */
.poster { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 30px 26px; text-align: center; max-width: 560px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.poster__logo { width: 140px; height: 104px; object-fit: contain; border-radius: 12px; background: #000; }
.poster__title { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1.4; }
.poster__steps { text-align: start; display: flex; flex-direction: column; gap: 6px; margin: 0; padding-inline-start: 22px; line-height: 1.75; }
.poster__url { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; direction: ltr; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .toasts, .skip-link { display: none !important; }
  .app-shell { display: block; }
  .page { padding: 0; max-width: none; }
  .poster { border: 0; max-width: none; padding: 8mm 0; }
  .poster .qr-frame { --qr: 118mm; }
  .poster__title { font-size: 28pt; }
  .poster__steps { font-size: 14pt; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .gift.is-waiting, .badge--live::before { animation: none !important; }
  .confetti { display: none; }
}

/* ---------- Small utilities used by several screens ---------- */
.search-row { display: flex; flex-wrap: wrap; gap: 8px; }
.search-row > .input-icon { flex: 1 1 260px; }
.list--boxed { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.stats--pairs { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.qr-stage__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 250px); gap: 20px; align-items: center; }
.qr-stage__side { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: start; }
.qr-steps { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 4px; line-height: 1.7; font-size: 13.5px; align-self: stretch; }
@media (max-width: 720px) { .qr-stage__grid { grid-template-columns: minmax(0, 1fr); } }
.dl--compact { gap: 3px 12px; font-size: 12.5px; }
.dl--compact dt { white-space: nowrap; }
.dl > div { display: contents; }
.notice-link { align-items: center; text-decoration: none; transition: filter var(--dur-1) var(--ease); }
.notice-link:hover { filter: brightness(.97); }
.notice-link > div { flex: 1; }
.notice-link > .icon:last-child { margin-top: 0; }
.signup-fields { display: flex; flex-direction: column; gap: 12px; }
.signup-form:has(input[name="mode"][value="phone"]:checked) .field--phone { order: -1; }
.signup-form:has(input[name="mode"][value="phone"]:checked) .signup-when-email,
.signup-form:has(input[name="mode"][value="email"]:checked) .signup-when-phone { display: none; }
.reward-item.is-revealed { animation: reward-reveal 900ms var(--ease) both; }
@keyframes reward-reveal { 0% { background: var(--brass-soft); transform: scale(.98); } 60% { background: var(--brass-soft); transform: none; } 100% { background: transparent; } }
.audit-details > summary { cursor: pointer; color: var(--brass-text); font-weight: 600; font-size: 12.5px; }
.audit-details[open] > summary { margin-bottom: 6px; }
.more-visits { display: flex; flex-direction: column; gap: 8px; }
.more-visits > summary { list-style: none; }
.more-visits > summary::-webkit-details-marker { display: none; }
.more-visits[open] > summary { display: none; }
.dl dd.ltr { display: block; text-align: end; }
@media (max-width: 640px) { .chart__axis text { font-size: 21px; } }
@media (max-width: 600px) {
  /* On phones messages sit at the bottom, clear of the header and its back button. */
  .toasts { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); flex-direction: column-reverse; }
  .toast { animation-name: toast-in-up; }
  @keyframes toast-in-up { from { opacity: 0; transform: translateY(8px); } }
}
