/* commerce-platform design foundation.
   Tokens first: every colour, size and radius below comes from these, so a
   theme or a business accent is one change here, not a hunt through files. */
:root {
  --bg: #f7f6f3;          /* page */
  --surface: #ffffff;     /* panes, cards */
  --surface-2: #f3f1ec;   /* hover, chips, quiet fills */
  --surface-3: #ebe8e0;   /* pressed, tracks */
  --border: #e9e6de;
  --border-strong: #d8d3c7;
  --text: #17171a;
  --text-2: #5f5d57;      /* secondary words */
  --text-3: #8e8b83;      /* timestamps, hints */
  --accent: #a8822a;      /* business accent (Mine Credit gold) */
  --accent-hi: #c8a04a;   /* top of the gold gradient */
  --accent-soft: #f7efda;
  --accent-ring: rgba(184, 145, 47, .30);
  --on-accent: #ffffff;
  --danger: #b42318;      /* only for a waiting customer or an error */
  --danger-soft: #fdeceb;
  --warn: #93650a;
  --warn-soft: #fdf3d7;
  --good: #1a7a3e;
  --good-soft: #e5f4ea;
  --info: #2a5bb8;
  --info-soft: #eaf1fd;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --gap: 8px;
  --rail: 68px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow-sm: 0 1px 2px rgba(23, 23, 26, .06);
  --shadow: 0 1px 2px rgba(23, 23, 26, .04), 0 8px 24px rgba(23, 23, 26, .08);
  --shadow-lg: 0 2px 6px rgba(23, 23, 26, .06), 0 20px 48px rgba(23, 23, 26, .14);
  --av-l: 92%; --av-t: 32%; --av-s: 48%;   /* avatar tint: lightness, text lightness, saturation */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e10; --surface: #17171a; --surface-2: #1f1f23; --surface-3: #2a2a2f; --border: #26262b; --border-strong: #37373d;
    --text: #ededee; --text-2: #a3a3aa; --text-3: #6f6f77; --accent: #d4b062; --accent-hi: #e2c27a; --accent-soft: #2a2314;
    --accent-ring: rgba(212, 176, 98, .30); --on-accent: #1a1406;
    --danger: #f2877e; --danger-soft: #3a1c1a; --warn: #e5b84f; --warn-soft: #352a12; --good: #7fcb96; --good-soft: #17301f;
    --info: #8db4f5; --info-soft: #1a2538;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 20px 48px rgba(0, 0, 0, .6);
    --av-l: 22%; --av-t: 78%; --av-s: 30%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e10; --surface: #17171a; --surface-2: #1f1f23; --surface-3: #2a2a2f; --border: #26262b; --border-strong: #37373d;
  --text: #ededee; --text-2: #a3a3aa; --text-3: #6f6f77; --accent: #d4b062; --accent-hi: #e2c27a; --accent-soft: #2a2314;
  --accent-ring: rgba(212, 176, 98, .30); --on-accent: #1a1406;
  --danger: #f2877e; --danger-soft: #3a1c1a; --warn: #e5b84f; --warn-soft: #352a12; --good: #7fcb96; --good-soft: #17301f;
  --info: #8db4f5; --info-soft: #1a2538;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 20px 48px rgba(0, 0, 0, .6);
  --av-l: 22%; --av-t: 78%; --av-s: 30%;
  color-scheme: dark;
}

/* base */
*, *::before, *::after { box-sizing: border-box; }
body { font: 14.5px/1.45 var(--font); margin: 0; color: var(--text); background: var(--bg); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 9px; max-width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
table { width: 100%; max-width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; }
td.n, th.n { text-align: right; }
.muted { color: var(--text-2); font-size: 13px; }
.small { font-size: 13px; }

/* buttons: primary (accent), ghost (outlined), quiet (no border) */
button, .btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--accent); color: var(--on-accent); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 7px 13px; cursor: pointer; text-decoration: none; line-height: 1.2; }
button:hover, .btn:hover { filter: brightness(1.05); }
button.ghost, .btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
button.ghost:hover { background: var(--surface-2); filter: none; }
button.quiet { background: transparent; color: var(--text-2); border-color: transparent; }
button.quiet:hover { background: var(--surface-2); color: var(--text); }
button:disabled { opacity: .55; cursor: default; }
button.is-loading { position: relative; color: transparent !important; pointer-events: none; }
button.is-loading::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--text-2) transparent var(--text-2) transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* icons: <svg class="i"><use href="#i-inbox"/></svg> */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* cards, chips, notices */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.chip { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.msg { padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; background: var(--good-soft); }
.err { background: var(--danger-soft); color: var(--danger); }
.late { color: var(--danger); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.steps { display: flex; gap: 8px; margin-bottom: 14px; font-size: 13px; }
.steps span { padding: 4px 10px; border-radius: 12px; background: var(--surface-2); }
.steps .on { background: var(--accent); color: var(--on-accent); }
img.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-sm); }

/* app frame: left rail + content */
.app { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0; background: var(--surface); border-right: 1px solid var(--border); }
.rail .brand { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 10px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; text-decoration: none; }
.rail a.item, .rail button.item { position: relative; width: 48px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0; border-radius: 10px; color: var(--text-2); text-decoration: none; font-size: 10.5px; background: transparent; border: 0; }
.rail a.item:hover, .rail button.item:hover { background: var(--surface-2); color: var(--text); filter: none; }
.rail a.item.on { background: var(--accent-soft); color: var(--text); }
.rail .badge { position: absolute; top: 2px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.rail .spacer { flex: 1; }
.content { min-width: 0; }
main { max-width: 980px; margin: 20px auto; padding: 0 16px; overflow-wrap: anywhere; }
main.wide { max-width: none; margin: 0; padding: 0; }
.signin main { max-width: 380px; margin-top: 12vh; }

/* toasts */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 13.5px; animation: toast-in .18s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* phone: rail becomes a bottom tab bar */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: 58px; flex-direction: row; justify-content: space-around;
    padding: 4px 8px; border-right: 0; border-top: 1px solid var(--border); z-index: 40; }
  .rail > a.brand, .rail .spacer, .rail .desk { display: none !important; }
  .content { padding-bottom: 58px; }
  .toasts { bottom: 70px; }
}

/* phone polish: safe areas, no iOS zoom on focus, keyboard-aware layout */
@media (max-width: 820px) {
  .rail { height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .content { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px; }            /* below 16px iOS zooms the page on focus */
  button, .btn, .chipbtn, .q-tabs a { min-height: 40px; }  /* thumb-sized targets */
  body.kb .rail { display: none; }                       /* keyboard open: give the space to the chat */
  body.kb .content { padding-bottom: 0; }
}

/* public legal pages */
.legal { max-width: 720px; margin: 24px auto; line-height: 1.6; }
.legal h1 { margin-top: 0; }
.legal h2 { font-size: 17px; margin-top: 24px; }

.rail .badge[hidden] { display: none; }

/* ===== Premium pass: type, controls, rail ===== */
body { font-size: 14px; letter-spacing: -0.006em; font-feature-settings: "cv11", "ss01", "ss03"; -webkit-font-smoothing: antialiased; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { letter-spacing: -0.018em; font-weight: 650; }
.muted { color: var(--text-2); }
::selection { background: var(--accent-ring); }

input, select, textarea { border-color: var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px;
  transition: border-color .12s, box-shadow .12s, background .12s; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
button:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
select { appearance: none; padding-right: 28px; background-repeat: no-repeat; background-position: right 9px center; background-size: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8b83' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }

button, .btn { font-weight: 550; border-radius: var(--radius-sm); padding: 8px 14px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent)); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .18);
  transition: transform .08s, filter .12s, background .12s, box-shadow .12s; }
button:hover, .btn:hover { filter: brightness(1.04); }
button:active, .btn:active { transform: translateY(.5px); }
button.ghost, .btn.ghost { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
button.ghost:hover { background: var(--surface-2); }
button.quiet { background: transparent; box-shadow: none; font-weight: 500; }
.btn.big { padding: 11px 18px; font-size: 14.5px; border-radius: var(--radius); }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; font: 600 11px/1 var(--font);
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; }

.chip { font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 999px; line-height: 1.5; }
.card { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }

/* avatars: a steady tint per person (style="--h: <hue>") */
.avatar { --h: 40; background: hsl(var(--h) var(--av-s) var(--av-l)) !important; color: hsl(var(--h) 45% var(--av-t)) !important;
  font-weight: 650; letter-spacing: .01em; }

/* rail */
.rail { gap: 2px; padding: 12px 0; }
.rail .brand { width: 40px; height: 40px; border-radius: 12px; margin-bottom: 14px; font-size: 17px;
  background: linear-gradient(145deg, var(--accent-hi), var(--accent)); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .25); }
.rail a.item, .rail button.item { width: 52px; padding: 8px 0 6px; border-radius: 12px; font-weight: 500; font-size: 10.5px; box-shadow: none; }
.rail a.item.on { background: var(--accent-soft); color: var(--text); }
.rail a.item.on::before { content: ""; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.rail a.item.on .i { color: var(--accent); }
.rail .badge { top: 1px; right: 3px; box-shadow: 0 0 0 2px var(--surface); font-variant-numeric: tabular-nums; }
.toast { border-radius: var(--radius); font-weight: 500; }
@media (max-width: 820px) { .rail a.item.on::before { display: none; } }

/* ===== Brand: per-business accent, display font, mark (values come from apps/core/branding.py) ===== */
:root { --font-display: var(--font); }
.display, .q-title h1, .board-head h1, .empty h2, .auth-card h1 { font-family: var(--font-display); }
.rail .brand.has-mark { background: #fbf7f0; box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(0, 0, 0, .06); padding: 4px; overflow: hidden; }
.rail .brand.has-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* business switcher: brand mark opens a menu when staff belong to 2+ shops */
.biz-switch { position: relative; margin-bottom: 14px; }
.biz-switch > summary.brand { list-style: none; cursor: pointer; margin-bottom: 0; }
.biz-switch > summary.brand::-webkit-details-marker { display: none; }
.biz-switch > summary.brand::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 1.5px var(--accent); }
.biz-menu { position: absolute; left: calc(100% + 10px); top: 0; min-width: 180px; padding: 8px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 60; }
.biz-menu-label { margin: 0 8px 6px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase;
  letter-spacing: .04em; }
.biz-opt { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; font-weight: 500; box-shadow: none; cursor: pointer; }
.biz-opt:hover { background: var(--surface-2); filter: none; transform: none; }
.biz-opt.on { background: var(--accent-soft); color: var(--text); font-weight: 600; cursor: default; }
.biz-switch form { margin: 0; }
@media (max-width: 820px) {
  .biz-switch { margin: 0; flex: 0 0 auto; }
  .biz-switch > summary.brand { width: 36px; height: 36px; border-radius: 10px; font-size: 14px; }
  .biz-menu { left: 0; right: auto; top: auto; bottom: calc(100% + 8px); min-width: 200px; }
}

/* sign-in */
main.auth { max-width: none; margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 28px 28px 30px; text-align: center; }
.auth-logo { display: block; width: 100%; max-width: 260px; margin: -4px auto 14px; border-radius: 14px; }
.auth-mark { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; font: 700 24px var(--font);
  color: var(--on-accent); background: linear-gradient(145deg, var(--accent-hi), var(--accent)); }
.auth-card h1 { margin: 0; font-size: 26px; }
.auth-card > p { margin: 4px 0 18px; }
.auth-form { display: grid; gap: 12px; text-align: left; }
.auth-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--text-2); }
.auth-form input { width: 100%; padding: 10px 12px; }
.auth-form .btn { width: 100%; margin-top: 6px; }
.signin main.auth { margin-top: 0; }
