/*
 * Ghost Tech
 * Palette: night slate-violet surfaces, pale "specter" lilac for actions,
 * and warm "candle" amber reserved for the things people come here for: codes and credentials.
 * Layout uses logical properties (inline-start/end) so Arabic (RTL) mirrors without extra rules.
 *
 * Themes: this file is the "Ghost" theme and the base of every other one. A theme is a small file
 * (assets/css/theme-<name>.css, loaded after this one) that mostly gives the variables below new values.
 * Every colour in this file therefore comes from a variable.
 */
:root {
  --night: #191b2a;
  --fog-1: #212438;
  --fog-2: #2b2f48;
  --line: #3a3f5e;
  --ink: #ecebf7;
  --mute: #a4a7c4;
  --specter: #b9abff;
  --specter-ink: #1c1740;
  --candle: #ffc56e;
  --ok: #7fddb3;
  --bad: #ff8c96;
  --sans: "Readex Pro", system-ui, "Segoe UI", Tahoma, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r-card: 14px;
  --r-ctl: 8px;
  /* values a theme may also change */
  --head: var(--sans);        /* headings */
  --weight: 300;              /* weight of running text */
  --link: var(--specter);     /* links and other text in the action colour */
  --specter-hi: #d0c6ff;      /* main button under the pointer */
  --candle-ink: #3a2a08;      /* text on a candle background */
  --side: var(--fog-1);       /* menu column */
  --field: var(--night);      /* text boxes */
  --well: var(--night);       /* sunken areas: photos, code blocks */
  --placeholder: #6f7394;
  --ok-bg: #1c3230;  --ok-line: #2f6b57;
  --bad-bg: #33212c; --bad-line: #6b3d4c; --bad-edge: #9a4a5c;
  --warn-bg: #2a2622; --warn-line: #6f5a36; --warn-edge: #8a6f3c;
  --info-line: #57528f;
  --backdrop: rgba(12, 13, 22, 0.72);
  --shadow: none;             /* under cards */
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: var(--weight) 0.9375rem/1.55 var(--sans);
}
h1, h2, h3, h4 { margin: 0; font-family: var(--head); font-weight: 500; line-height: 1.2; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
small { font-size: 0.8125rem; color: var(--mute); }
strong, b { font-weight: 500; }
code, pre { font-family: var(--mono); font-size: 0.875rem; }
code { overflow-wrap: anywhere; }
pre {
  margin: 0 0 0.75rem; padding: 0.75rem; overflow-x: auto;
  background: var(--well); border: 1px solid var(--line); border-radius: var(--r-ctl);
}
blockquote { margin: 0 0 0.75rem; padding-inline-start: 0.75rem; border-inline-start: 2px solid var(--line); color: var(--mute); }
:focus-visible { outline: 2px solid var(--specter); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- brand, buttons, form controls ---------- */
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink); text-decoration: none; font-weight: 500; font-size: 1.0625rem; }
.mark { width: 1.5rem; height: 1.5rem; color: var(--specter); flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.5rem; padding: 0 1rem;
  border: 1px solid transparent; border-radius: var(--r-ctl);
  font: 500 0.9375rem/1 var(--sans); text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn-sm { min-height: 2rem; padding: 0 0.7rem; font-size: 0.8125rem; }
.btn-primary { background: var(--specter); color: var(--specter-ink); }
.btn-primary:hover { background: var(--specter-hi); color: var(--specter-ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--specter); color: var(--ink); }
.btn-danger { background: transparent; border-color: var(--bad-line); color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); color: var(--bad); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

label { display: grid; gap: 0.3rem; font-size: 0.8125rem; color: var(--mute); }
input, select, textarea {
  width: 100%; min-height: 2.5rem; padding: 0.45rem 0.7rem;
  background: var(--field); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  font: var(--weight) 0.9375rem/1.4 var(--sans);
}
textarea { font-family: var(--mono); font-size: 0.875rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; min-height: 0; height: 1.05rem; padding: 0; flex: none; accent-color: var(--specter); }
input.narrow { max-width: 8rem; }
/* A labelled control that is not a single input (the days stepper on the Stock page): looks like a label. */
.field { display: grid; gap: 0.3rem; justify-items: start; font-size: 0.8125rem; color: var(--mute); }
/* Suggestions under a text box while typing ("Give accounts": the user). */
.suggest { position: relative; display: block; }
.suggest-list { position: absolute; z-index: 5; inset-inline: 0; top: calc(100% + 4px); margin: 0; padding: 0.3rem; list-style: none; background: var(--fog-1); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35); max-height: 16rem; overflow-y: auto; }
.suggest-list li { display: flex; align-items: baseline; gap: 0.6rem; padding: 0.5rem 0.7rem; border-radius: 8px; cursor: pointer; color: var(--ink); font-size: 0.9375rem; }
.suggest-list li[aria-selected="true"], .suggest-list li:hover { background: var(--fog-2); }
.suggest-list li small { color: var(--mute); }
.suggest-list li code { margin-inline-start: auto; color: var(--candle); direction: ltr; }
/* The admin's invite link on the Users page: closed until he opens it. */
.invite-box { margin-bottom: 1rem; }
.invite-box summary { cursor: pointer; color: var(--mute); font-size: 0.875rem; }
.invite-box .cred { display: flex; margin-top: 0.4rem; }
/* "My catalog": a category, subcategory or product that is not ticked is dimmed; ticking it brings it back. */
.catalog .is-off > .card-head, .catalog .is-off > h3, .catalog tr.is-off > td { opacity: 0.55; }
.catalog .is-off > .card-head label, .catalog .is-off > h3 label, .catalog tr.is-off label { opacity: 1; }
.catalog-sub { margin-top: 1rem; }
.catalog-sub > h3 { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 1rem 0 0.5rem; }
.catalog .card-head h2 { margin: 0; }
label.check-big { font-size: inherit; font-weight: inherit; }
label.check-end { justify-content: flex-end; }
label.check { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); font-size: 0.9375rem; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.8rem; max-width: 30rem; }
.stack.wide { max-width: 44rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; align-items: end; }
tfoot th { text-align: start; border-top: 1px solid var(--line); font-weight: 600; }
tfoot th.num { text-align: end; }
.inline-form { margin-top: 0.8rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin-bottom: 1rem; }
.filters label { min-width: 11rem; }
#results[aria-busy="true"] { opacity: 0.55; }

/* ---------- messages, badges ---------- */
.flash { margin-bottom: 1rem; padding: 0.7rem 0.9rem; border-radius: var(--r-ctl); border: 1px solid; }
.flash.ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok); }
.flash.err { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad); }
.hint { color: var(--mute); font-size: 0.875rem; max-width: 70ch; }
.empty { color: var(--mute); padding: 1.25rem 0; }
.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 400; border: 1px solid var(--line); color: var(--mute); white-space: nowrap; }
.b-ok { color: var(--ok); border-color: var(--ok-line); }
.b-warn { color: var(--candle); border-color: var(--warn-line); }
.b-bad { color: var(--bad); border-color: var(--bad-line); }
.warn { color: var(--candle); }

/* ---------- small dialog ("How many tokens?") and the list of links ---------- */
.dialog { width: min(24rem, calc(100vw - 2rem)); padding: 1.25rem; background: var(--fog-1); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-card); }
/* the fallback is for browsers whose ::backdrop does not see the page's variables */
.dialog::backdrop { background: var(--backdrop, rgba(12, 13, 22, 0.72)); }
.dialog h2 { font-size: 1.25rem; }
.dialog .hint { margin: 0; }
.dialog-actions { display: flex; gap: 0.6rem; }
.dialog-actions .btn-primary { flex: 1; }
.dialog-actions .btn-danger { flex: 1; }
#confirm-text { margin: 0 0 1rem; font-size: 1rem; overflow-wrap: anywhere; }
.token-list { margin: 0 0 0.9rem; padding-inline-start: 1.6rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.45rem; max-height: 22rem; overflow-y: auto; }
.token-list li { min-width: 0; }
.token-list li::marker { color: var(--mute); font-size: 0.8125rem; }
.token-list small { margin-inline: 0.5rem; white-space: nowrap; }

/* ---------- notices published by admins ---------- */
.notice { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.15rem 1rem; align-items: start; margin-bottom: 1rem; padding: 0.8rem 1rem; background: var(--fog-1); border: 1px solid var(--line); border-inline-start-width: 4px; border-radius: var(--r-ctl); }
.notice strong { grid-column: 1; font-size: 0.8125rem; color: var(--link); }
.notice p { grid-column: 1; margin: 0; overflow-wrap: anywhere; }
.notice form { grid-column: 2; grid-row: 1 / span 2; }
.notice-info { border-color: var(--info-line); }
.notice-warning { border-color: var(--warn-edge); background: var(--warn-bg); }
.notice-warning strong { color: var(--candle); }
.notice-alert { border-color: var(--bad-edge); background: var(--bad-bg); }
.notice-alert strong { color: var(--bad); }
.checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0; padding: 0; border: 0; }
.checks legend { padding: 0; margin-bottom: 0.4rem; font-size: 0.8125rem; color: var(--mute); }
textarea.prose { font-family: var(--sans); font-size: 0.9375rem; }

/* ---------- reviews ---------- */
.stars { color: var(--candle); letter-spacing: 0.1em; font-size: 1.125rem; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
/* five radio buttons drawn as stars; every star up to the chosen one lights up */
.star-pick { display: flex; gap: 0.15rem; margin: 0; padding: 0; border: 0; }
.star-pick legend { padding: 0; margin-bottom: 0.3rem; font-size: 0.8125rem; color: var(--mute); }
.star-pick label { display: block; position: relative; font-size: 2rem; line-height: 1; color: var(--line); cursor: pointer; }
.star-pick input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.star-pick label:has(input:checked), .star-pick label:has(~ label input:checked) { color: var(--candle); }
.star-pick label:has(input:focus-visible) { outline: 2px solid var(--specter); outline-offset: 2px; border-radius: 4px; }
.reviews { padding: 2.5rem 0; border-top: 1px solid var(--fog-2); }
.reviews h2 { font-size: 1.375rem; }
.reviews > .hint { margin: 0.4rem 0 1.5rem; }
.reviews ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1.75rem 2.5rem; }
.reviews li p { margin: 0.4rem 0; overflow-wrap: anywhere; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 1rem 0; }
.support-line { margin: 0; padding: 0 clamp(1rem, 3vw, 2rem) 1.5rem; font-size: 0.8125rem; color: var(--mute); }
.guest-foot .support-line { padding: 0; margin-inline-start: 1rem; }
.hold-actions > form, .hold-actions > details { flex: 0 0 auto; }
.hold-actions .btn { flex: 0 0 auto; }
.btn[aria-pressed="false"] { color: var(--mute); }
dd.pos, dd .pos { color: var(--ok); }
dd.neg, dd .neg { color: var(--bad); }

/* ---------- themes: the "Theme" menu and the cards in Settings ---------- */
/* The five colours of each theme, for the small previews only (the page itself never uses these). */
.tp-ghost    { --tp-bg: #191b2a; --tp-card: #212438; --tp-ink: #ecebf7; --tp-act: #b9abff; --tp-code: #ffc56e; }
.tp-daylight { --tp-bg: #f3f4fa; --tp-card: #ffffff; --tp-ink: #1b1d33; --tp-act: #5b46e0; --tp-code: #b45309; }
.tp-market   { --tp-bg: #0f1c1e; --tp-card: #16292c; --tp-ink: #f3ead7; --tp-act: #f2a93b; --tp-code: #ffd98a; }
.tp-receipt  { --tp-bg: #26272b; --tp-card: #f6f1e4; --tp-ink: #1c1b19; --tp-act: #c8372d; --tp-code: #8a8474; }
.tp-console  { --tp-bg: #14161a; --tp-card: #1b1e23; --tp-ink: #e6e9ee; --tp-act: #5aa9ff; --tp-code: #8b93a1; }
.sw { display: inline-block; flex: none; width: 0.9rem; height: 0.9rem; border-radius: 50%; border: 1px solid var(--line); background: linear-gradient(135deg, var(--tp-card) 50%, var(--tp-act) 50%); }
.theme-pick { position: relative; font-size: 0.875rem; }
.theme-pick > summary { display: inline-flex; align-items: center; gap: 0.4rem; list-style: none; color: var(--mute); cursor: pointer; border-radius: 4px; }
.theme-pick > summary::-webkit-details-marker { display: none; }
.theme-pick > summary:hover, .theme-pick[open] > summary { color: var(--ink); }
.theme-menu { position: absolute; z-index: 30; inset-block-start: calc(100% + 0.5rem); inset-inline-end: 0; display: grid; gap: 2px; min-width: 11.5rem; padding: 0.35rem; background: var(--fog-1); border: 1px solid var(--line); border-radius: var(--r-ctl); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28); }
.theme-menu a { display: flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.6rem; border-radius: 6px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.theme-menu a:hover { background: var(--fog-2); color: var(--ink); }
.theme-menu a[aria-current] { background: var(--fog-2); font-weight: 500; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 0.9rem; margin: 0 0 1rem; padding: 0; border: 0; }
.theme-grid legend { padding: 0; margin-bottom: 0.5rem; font-size: 0.8125rem; color: var(--mute); }
.theme-card { display: grid; gap: 0.5rem; align-content: start; padding: 0.7rem; border: 1px solid var(--line); border-radius: var(--r-ctl); color: var(--ink); font-size: 0.9375rem; cursor: pointer; }
.theme-card:has(input:checked) { border-color: var(--specter); }
.theme-card > span:not(.tp) { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.tp { display: block; height: 4.75rem; padding: 0.6rem 0.6rem 0; border-radius: 6px; background: var(--tp-bg); overflow: hidden; }
.tp-in { display: block; height: 100%; padding: 0.55rem 0.6rem; border-radius: 5px 5px 0 0; background: var(--tp-card); }
.tp-l { display: block; width: 55%; height: 0.35rem; margin-bottom: 0.5rem; border-radius: 2px; background: var(--tp-ink); }
.tp-row { display: flex; justify-content: space-between; align-items: center; }
.tp-c { width: 38%; height: 0.55rem; border-radius: 2px; background: var(--tp-code); }
.tp-b { width: 2.4rem; height: 0.95rem; border-radius: 4px; background: var(--tp-act); }

/* ---------- photos ---------- */
.thumb { flex: none; width: 3rem; height: 3rem; object-fit: cover; border-radius: var(--r-ctl); background: var(--well); }
.thumb-lg { width: 4.5rem; height: 4.5rem; border-radius: 10px; }
.with-thumb { display: flex; align-items: center; gap: 0.6rem; }
.current-photo { display: flex; align-items: center; gap: 0.75rem; }
input[type="file"] { padding: 0.4rem; font-size: 0.875rem; }

/* ---------- copyable codes and credentials ---------- */
.copy {
  flex: none; min-height: 1.75rem; padding: 0 0.6rem;
  background: transparent; color: var(--mute);
  border: 1px solid var(--line); border-radius: 999px;
  font: 400 0.75rem/1 var(--sans); cursor: pointer;
}
.copy:hover, .copy.done { color: var(--candle); border-color: var(--candle); }
.cred { display: inline-flex; align-items: center; gap: 0.5rem; max-width: 100%; }
.cred code { color: var(--candle); overflow-wrap: anywhere; direction: ltr; unicode-bidi: isolate; }
.cred-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }

/* ---------- guest pages ---------- */
.guest-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem clamp(1rem, 4vw, 3rem); }
.top-tools { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.lang { color: var(--mute); text-decoration: none; font-size: 0.875rem; }
.lang:hover { color: var(--ink); }
.guest-main { max-width: 68rem; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 3rem) 3rem; }
.guest-foot { padding: 1.5rem; text-align: center; color: var(--mute); font-size: 0.8125rem; border-top: 1px solid var(--fog-2); }

.hero { padding: clamp(2.5rem, 10vw, 7rem) 0 clamp(2.5rem, 8vw, 5rem); }
.hero h1 { max-width: 17ch; font-size: clamp(2.2rem, 7vw, 4.2rem); font-weight: 500; line-height: 1.06; letter-spacing: -0.02em; text-wrap: balance; }
.hero-copy p { margin: 1.25rem 0 1.75rem; max-width: 36rem; font-size: 1.0625rem; color: var(--mute); }
@keyframes materialize { from { opacity: 0; filter: blur(8px); } to { opacity: 1; filter: none; } }

.steps { padding: 2.5rem 0; border-top: 1px solid var(--fog-2); }
.steps h2 { font-size: 1.375rem; margin-bottom: 1.5rem; }
.steps ol { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.steps li { counter-increment: step; }
.steps li::before { content: counter(step); display: block; margin-bottom: 0.6rem; font-size: 2rem; font-weight: 300; line-height: 1; color: var(--link); }
.steps li p { margin: 0.35rem 0 0; color: var(--mute); }

.login { max-width: 52rem; margin: 0 auto; padding-top: clamp(1.5rem, 6vw, 4rem); }
.login h1 { font-size: 2rem; }
.login .lead { margin: 0.6rem 0 1.5rem; color: var(--mute); }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.plain-steps { margin: 0.75rem 0 1rem; padding-inline-start: 1.2rem; color: var(--mute); }
.plain-steps li { margin-bottom: 0.3rem; }
.token-form { display: grid; gap: 0.6rem; }
.wait { max-width: 34rem; }
.token-page { max-width: 34rem; margin: 0 auto; padding-top: clamp(1.5rem, 6vw, 4rem); }
.token-page h1 { font-size: 1.75rem; overflow-wrap: anywhere; }
.token-page .lead { margin: 0.5rem 0 1.25rem; color: var(--mute); }
.token-clock { font: 500 1.5rem/1 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.token-page .live i { animation: pulse 1.6s ease-in-out infinite; }
.wait .live i { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; margin: 1rem 0; }
.facts dt { color: var(--mute); font-size: 0.8125rem; }
.facts dd { margin: 0; }
.wait-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.token-form input { font: 500 1.375rem/1.2 var(--mono); letter-spacing: 0.18em; text-align: center; text-transform: uppercase; color: var(--candle); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 14.5rem minmax(0, 1fr); min-height: 100vh; }
.side { padding: 1.25rem 0.9rem; background: var(--side); border-inline-end: 1px solid var(--fog-2); }
.side .brand { padding: 0 0.6rem 1.1rem; }
.menu-btn, .menu-toggle { display: none; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.6rem; border-radius: var(--r-ctl); color: var(--mute); text-decoration: none; }
.nav a:hover { color: var(--ink); background: var(--fog-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--fog-2); font-weight: 400; box-shadow: inset 2px 0 0 var(--specter); }
[dir="rtl"] .nav a[aria-current="page"] { box-shadow: inset -2px 0 0 var(--specter); }
.count { min-width: 1.3rem; padding: 0 0.35rem; border-radius: 999px; background: var(--candle); color: var(--candle-ink); font-size: 0.75rem; font-weight: 500; text-align: center; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1.1rem clamp(1rem, 3vw, 2rem); border-bottom: 1px solid var(--fog-2); }
.top h1 { font-size: 1.375rem; }
.balance { display: inline-flex; gap: 0.4rem; align-items: baseline; padding: 0.3rem 0.75rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--mute); font-size: 0.8125rem; }
.balance strong { color: var(--ink); font-size: 0.9375rem; }
.who { font-size: 0.875rem; }
.content { padding: 1.5rem clamp(1rem, 3vw, 2rem) 3rem; max-width: 76rem; }

.card { background: var(--fog-1); border: 1px solid var(--fog-2); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card > h2, .card-head { margin-bottom: 0.75rem; }
.card h3 { margin: 1.25rem 0 0.75rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.card-head time { color: var(--mute); font-size: 0.8125rem; }
.head-tools { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.head-tools small { color: var(--mute); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.two > *, .dash > * { min-width: 0; }
.two h3 { margin-top: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: 0.9rem; margin-bottom: 1.25rem; }
.stat { display: grid; gap: 0.2rem; padding: 0.9rem 1rem; background: var(--fog-1); border: 1px solid var(--fog-2); border-radius: var(--r-card); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
a.stat:hover { border-color: var(--line); color: var(--ink); }
.stat span { color: var(--mute); font-size: 0.8125rem; }
.stat strong { font-size: 1.5rem; font-weight: 400; overflow-wrap: anywhere; }

/* ---------- dashboard: notification log ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.dash > .card:only-child { grid-column: 1 / -1; }
.live { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8125rem; color: var(--mute); }
.live i { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--ok); }
.feed { list-style: none; margin: 0; padding: 0; max-height: 42rem; overflow-y: auto; }
.feed-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 1rem; padding: 0.8rem 0; border-top: 1px solid var(--fog-2); }
.feed-item:first-child { border-top: 0; }
.feed-item.is-new { animation: materialize 0.8s both; }
.feed-text p { margin: 0.15rem 0 0; color: var(--mute); font-size: 0.875rem; overflow-wrap: anywhere; }
.feed-item time { grid-column: 2; grid-row: 1; color: var(--mute); font-size: 0.75rem; white-space: nowrap; }
.feed-code { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 0.6rem; }
.feed-code code { color: var(--candle); white-space: pre-wrap; overflow-wrap: anywhere; direction: ltr; unicode-bidi: isolate; text-align: start; }
.feed-link { align-items: center; }
.click-here { font-size: 1.125rem; font-weight: 500; color: var(--candle); text-underline-offset: 4px; }
.click-here:hover { color: var(--ink); }
.toast .click-here { display: inline-block; margin-top: 0.3rem; }
.feed-item.is-code .feed-code code { font-size: 1.5rem; font-weight: 500; letter-spacing: 0.14em; line-height: 1.2; }
.soon { list-style: none; margin: 0; padding: 0; }
.soon li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.7rem 0; border-top: 1px solid var(--fog-2); }
.soon li:first-child { border-top: 0; }
.soon strong { display: block; overflow-wrap: anywhere; font-weight: 400; }
.soon-text { flex: 1; min-width: 0; }
.soon small { display: block; }

#toasts { position: fixed; inset-block-end: 1rem; inset-inline-end: 1rem; z-index: 20; display: grid; gap: 0.5rem; width: min(22rem, calc(100vw - 2rem)); }
.toast { position: relative; padding: 0.8rem 1rem; padding-inline-end: 2.75rem; background: var(--fog-2); border: 1px solid var(--line); border-radius: var(--r-card); animation: materialize 0.6s both; }
.toast strong { display: block; }
.toast small { display: block; overflow-wrap: anywhere; }
.toast-email { color: var(--ink); direction: ltr; text-align: start; }
.toast-close { position: absolute; inset-block-start: 0.35rem; inset-inline-end: 0.35rem; width: 2rem; height: 2rem; border: 0; border-radius: 50%; background: transparent; color: var(--mute); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.toast-close:hover { color: var(--ink); background: var(--fog-1); }
.toast code { display: block; margin-top: 0.25rem; color: var(--candle); font-size: 1.25rem; font-weight: 500; letter-spacing: 0.12em; white-space: pre-wrap; overflow-wrap: anywhere; direction: ltr; text-align: start; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.65rem 0.7rem; text-align: start; vertical-align: top; border-bottom: 1px solid var(--fog-2); }
th { font-weight: 400; font-size: 0.8125rem; color: var(--mute); white-space: nowrap; }
/* Settings > Who can pay online: three group columns in a narrow card, so their headings may wrap */
#pay-who th { white-space: normal; line-height: 1.3; vertical-align: bottom; }
#pay-who th, #pay-who td { padding-inline: 0.45rem; }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }
.actions { text-align: end; }
.actions > form, .actions > a, .actions > details { display: inline-block; vertical-align: top; margin: 0 0 0.3rem; margin-inline-start: 0.3rem; }
.actions > a.btn { display: inline-flex; }
.pop > summary { list-style: none; }
.pop > summary::-webkit-details-marker { display: none; }
.actions > .pop[open] { display: block; }
.pop-body { display: grid; gap: 0.6rem; margin-top: 0.6rem; padding: 0.8rem; min-width: 15rem; text-align: start; background: var(--well); border: 1px solid var(--line); border-radius: var(--r-ctl); }
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid var(--fog-2); }
.tabs a { padding: 0.55rem 0.9rem; color: var(--mute); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--specter); }
.bulk { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.bulk .hint { margin: 0; }
.pager { display: flex; align-items: center; gap: 0.75rem; color: var(--mute); font-size: 0.875rem; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; padding: 0; }
.chips li { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.3rem 0.2rem 0.75rem; border: 1px solid var(--line); border-radius: 999px; }
[dir="rtl"] .chips li { padding: 0.2rem 0.75rem 0.2rem 0.3rem; }
.x { width: 1.5rem; height: 1.5rem; border: 0; border-radius: 50%; background: transparent; color: var(--mute); font-size: 1rem; line-height: 1; cursor: pointer; }
.x:hover { color: var(--bad); background: var(--fog-2); }

/* ---------- shop ---------- */
.cat { margin-bottom: 2rem; }
.cat > h2 { font-size: 1.375rem; margin-bottom: 0.9rem; }
.cat > h3 { margin: 1.25rem 0 0.75rem; color: var(--link); font-weight: 400; }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; }
.product { display: grid; gap: 0.6rem; align-content: start; padding: 1.1rem; background: var(--fog-1); border: 1px solid var(--fog-2); border-radius: var(--r-card); box-shadow: var(--shadow); }
.product p { margin: 0; color: var(--mute); font-size: 0.875rem; }
/* Photos are shown whole, never cropped: most are logos. */
.product-img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--well); border-radius: var(--r-ctl); }

/* Shop steps: category and subcategory tiles, and the path back */
.crumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.1rem; color: var(--mute); }
.crumbs [aria-current] { color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.tile { display: grid; gap: 0.25rem; padding: 0.9rem; background: var(--fog-1); border: 1px solid var(--fog-2); border-radius: var(--r-card); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--specter); color: var(--ink); }
.tile strong { margin-top: 0.5rem; font-size: 1.125rem; }
.tile-img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--well); border-radius: var(--r-ctl); }
.tile-blank { display: grid; place-items: center; font-size: 3rem; font-weight: 300; color: var(--line); }
.section-title { margin: 0 0 0.9rem; }
.product.is-out { opacity: 0.6; }
.product-meta { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.product-meta strong { font-size: 1.375rem; font-weight: 400; }
.buy { display: grid; gap: 0.6rem; }
.buy .hint { margin: 0; font-size: 0.8125rem; }
.buy-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.buy-row > .btn { flex: 1; }
/* quantity:  -  1  + */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r-ctl); overflow: hidden; }
.stepper button { width: 2.5rem; min-height: 2.5rem; border: 0; background: var(--fog-2); color: var(--ink); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.stepper button:hover { background: var(--line); }
.stepper input { width: 3.25rem; min-height: 2.5rem; padding: 0; border: 0; border-radius: 0; text-align: center; font-weight: 500; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper:focus-within { border-color: var(--specter); }
.delivered { border-color: var(--warn-line); }

/* ---------- tablets and phones: one column, menu folded behind a button ---------- */
@media (max-width: 860px) {
  .app { display: block; }
  .side { position: sticky; top: 0; z-index: 10; padding: 0.55rem 1rem; border-inline-end: 0; border-bottom: 1px solid var(--fog-2); }
  .side-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
  .side .brand { padding: 0; }
  .menu-btn { display: inline-flex; align-items: center; gap: 0.55rem; min-height: 2.5rem; padding: 0 0.85rem; border: 1px solid var(--line); border-radius: var(--r-ctl); font-size: 0.9375rem; cursor: pointer; user-select: none; }
  .menu-btn i { width: 1rem; height: 2px; background: currentColor; box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor; }
  .menu-toggle { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
  .menu-toggle:focus-visible + .side-head .menu-btn { outline: 2px solid var(--specter); outline-offset: 2px; }
  .menu-toggle:checked + .side-head .menu-btn { background: var(--fog-2); border-color: var(--specter); }
  .nav { display: none; max-height: calc(100vh - 4.5rem); overflow-y: auto; padding-top: 0.6rem; }
  .menu-toggle:checked ~ .nav { display: grid; }
  .nav a { padding: 0.75rem 0.6rem; }
  .top { padding: 0.8rem 1rem; }
  .top h1 { font-size: 1.25rem; }
  .content { padding: 1rem 1rem 3rem; }
  .card { padding: 1rem; }
  /* the Theme menu opens as a row of its own instead of floating */
  .theme-pick[open] { flex-basis: 100%; }
  .theme-menu { position: static; display: flex; flex-wrap: wrap; margin-top: 0.5rem; box-shadow: none; }
  .theme-menu a { padding: 0.6rem 0.7rem; }
  .login-grid, .two, .dash { grid-template-columns: minmax(0, 1fr); }
  .steps ol { grid-template-columns: 1fr; gap: 1.5rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
  .stat strong { font-size: 1.25rem; }
  .feed { max-height: none; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; }
  .filters label { flex: 1 1 9rem; min-width: 0; }
  pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  /* 16px text in fields stops iPhones from zooming the page when a field is tapped; larger targets for fingers */
  input, select, textarea { font-size: 1rem; }
  .btn-sm { min-height: 2.25rem; }
  .copy { min-height: 2rem; padding: 0 0.75rem; }
  .actions { text-align: start; }
  .actions > form, .actions > a, .actions > details { margin-inline-start: 0; margin-inline-end: 0.3rem; }
}

/* ---------- phones: every table row becomes a small card, each value under its column name ---------- */
@media (max-width: 720px) {
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem 1rem; padding: 0.9rem 0; border-bottom: 1px solid var(--fog-2); }
  td, td.actions { min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; }
  /* the column name is copied into data-label by assets/js/app.js */
  td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 0.1rem; font-size: 0.75rem; color: var(--mute); }
  td.num { text-align: start; white-space: normal; }
  td:first-child, td.actions, td:has(.cred), td:has(code), td:has(input:not([type="checkbox"])) { grid-column: 1 / -1; }
  .pop-body { min-width: 0; }
  td .badge { white-space: normal; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
  .tile { padding: 0.7rem; }
  .tile strong { font-size: 1rem; }
  .products { grid-template-columns: minmax(0, 1fr); }
  .token-list { padding-inline-start: 1.4rem; }
  /* The address is cut with "..." so that Copy stays in view; status and "Open the link" go on the next line. */
  .token-list .cred { display: flex; width: 100%; }
  .token-list .cred code { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .token-list .cred .copy { flex: none; }
  .token-list small { margin-inline-start: 0; }
  .soon li { flex-wrap: wrap; }
  .notice { padding: 0.7rem 0.8rem; gap: 0.15rem 0.6rem; }
  .guest-top { padding: 0.8rem 1rem; }
  .guest-main { padding: 0 1rem 2.5rem; }
}
@media (max-width: 480px) {
  .pair { grid-template-columns: minmax(0, 1fr); }
  .who small { display: none; }
}

/* Arabic: letter-spacing breaks joined letters, so it is switched off for running text. */
:lang(ar) h1, :lang(ar) .hero h1 { letter-spacing: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
