/* 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: #f6f5f1;          /* page */
  --surface: #ffffff;     /* panes, cards */
  --surface-2: #f0efea;   /* hover, chips, quiet fills */
  --border: #e4e2da;
  --text: #1d1d1f;
  --text-2: #6b6a65;      /* secondary words */
  --accent: #b8912f;      /* business accent (Mine Credit gold) */
  --accent-soft: #f6eed6;
  --on-accent: #ffffff;
  --danger: #b3261e;      /* only for a waiting customer or an error */
  --danger-soft: #fdecec;
  --warn: #9a6700;
  --warn-soft: #fff4ce;
  --good: #1e7a3c;
  --good-soft: #e6f4ea;
  --info-soft: #e8f0fe;
  --radius: 8px;
  --radius-sm: 6px;
  --gap: 8px;
  --rail: 64px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 6px 24px rgba(0, 0, 0, .10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131312; --surface: #1c1c1a; --surface-2: #262623; --border: #33332f;
    --text: #ecebe6; --text-2: #a3a29b; --accent: #d1ab4c; --accent-soft: #3a3220; --on-accent: #1b1606;
    --danger: #f2827a; --danger-soft: #3d1f1d; --warn: #e7b84a; --warn-soft: #3a3016;
    --good: #7cc792; --good-soft: #1d3324; --info-soft: #1f2a3d; --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131312; --surface: #1c1c1a; --surface-2: #262623; --border: #33332f;
  --text: #ecebe6; --text-2: #a3a29b; --accent: #d1ab4c; --accent-soft: #3a3220; --on-accent: #1b1606;
  --danger: #f2827a; --danger-soft: #3d1f1d; --warn: #e7b84a; --warn-soft: #3a3016;
  --good: #7cc792; --good-soft: #1d3324; --info-soft: #1f2a3d; --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  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 .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; }
