/* BuggyBricks Order Tracker — styles */
:root, html[data-theme="light"] {
  color-scheme: light;
  --primary: #2563eb;
  --accent: #f59e0b;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface2: #eef0f3;
  --text: #1c2330;
  --muted: #68707e;
  --border: #d9dde3;
  --danger: #c0392b;
  --ok: #1e8449;
  --warn: #b7950b;
  --shadow: 0 8px 30px rgba(0,0,0,.18);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c;
  --surface: #1e232b;
  --surface2: #262c36;
  --text: #e8ebef;
  --muted: #9aa3b0;
  --border: #39404c;
  --shadow: 0 8px 30px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #14171c; --surface: #1e232b; --surface2: #262c36;
    --text: #e8ebef; --muted: #9aa3b0; --border: #39404c;
    --shadow: 0 8px 30px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0 0 .5rem; }
a { color: var(--primary); }

/* ---------- buttons & forms ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .45rem .8rem; border-radius: 8px; cursor: pointer; font-size: .92rem; }
.btn:hover { border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1c2330; font-weight: 600; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: .7rem; font-size: 1rem; }
.btn.small { padding: .25rem .55rem; font-size: .85rem; }
label { display: block; font-size: .8rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); margin: .6rem 0 .25rem; text-transform: uppercase; }
input, select, textarea { width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: .95rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; }
.form-error { color: var(--danger); min-height: 1.2em; font-size: .9rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; }
.row > * { flex: 1; }
.checkline { display: flex; align-items: center; gap: .5rem; text-transform: none; font-size: .95rem; color: var(--text); }
.checkline input { width: auto; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; width: 100%; max-width: 380px; text-align: center; box-shadow: var(--shadow); }
.auth-card form { text-align: left; margin-top: 1rem; }
.auth-logo { font-size: 2.6rem; }
.auth-switch { font-size: .9rem; margin-top: .8rem; }

/* ---------- layout ---------- */
#app-view { display: flex; min-height: 100vh; }
#sidebar { width: 230px; flex: 0 0 230px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 1rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; }
.shop-brand { display: flex; gap: .6rem; align-items: center; }
.brand-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.brand-sub { color: var(--muted); font-size: .8rem; word-break: break-all; }
#sidebar nav { display: flex; flex-direction: column; gap: .3rem; }
.nav-btn { text-align: left; border: none; background: transparent; color: var(--text); padding: .6rem .7rem;
  border-radius: 8px; cursor: pointer; font-size: .98rem; display: flex; align-items: center; gap: .55rem; }
.nav-ic { display: inline-flex; flex: 0 0 auto; }
.nav-ic svg { width: 21px; height: 21px; display: block; }
.auth-logo svg { width: 54px; height: 54px; display: block; margin: 0 auto; }
.nav-btn:hover { background: var(--surface2); }
.nav-btn.active { background: var(--primary); color: #fff; font-weight: 600; }
.logout { margin-top: auto; }
#main { flex: 1; padding: 1.2rem; max-width: 1100px; margin: 0 auto; width: 100%; }

/* ---------- generic UI ---------- */
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .spacer { flex: 1; }
.toolbar input[type="search"] { max-width: 260px; }
.toolbar select { width: auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; margin-bottom: .8rem; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.paid { background: #d5f5e3; color: var(--ok); }
.badge.partial { background: #fcf3cf; color: var(--warn); }
.badge.unpaid { background: #fadbd8; color: var(--danger); }
.badge.cancelled { background: var(--surface2); color: var(--muted); }
html[data-theme="dark"] .badge.paid, html[data-theme="dark"] .badge.partial, html[data-theme="dark"] .badge.unpaid { filter: brightness(.85); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 110%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); min-width: 170px; z-index: 40; padding: .3rem; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text);
  padding: .5rem .6rem; border-radius: 6px; cursor: pointer; font-size: .92rem; }
.menu button:hover { background: var(--surface2); }
.menu button.danger { color: var(--danger); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-top: .6rem; }
.kv .k { background: var(--surface2); border-radius: 8px; padding: .5rem .6rem; }
.kv .k .lab { font-size: .72rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.kv .k .val { font-size: 1.05rem; font-weight: 700; margin-top: .15rem; }
table.plain { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.plain th, table.plain td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); }
table.plain th { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; }
.stat .lab { color: var(--muted); font-size: .78rem; text-transform: uppercase; font-weight: 700; }
.stat .val { font-size: 1.5rem; font-weight: 800; margin-top: .2rem; }
.stat.hot { border-color: var(--accent, #d97706); box-shadow: inset 3px 0 0 var(--accent, #d97706); }
.bar-row { display: flex; align-items: center; gap: .6rem; margin: .35rem 0; font-size: .9rem; }
.bar-row .bar-lab { width: 110px; color: var(--muted); }
.bar-track { flex: 1; background: var(--surface2); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.feed-item { padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .93rem; }
.feed-item:last-child { border-bottom: none; }
.part-img { width: 44px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.part-img.mini { width: 28px; height: 28px; vertical-align: middle; }
.line-row { display: grid; grid-template-columns: 52px minmax(105px, 1fr) minmax(135px, 1.2fr) 68px minmax(95px, .8fr) auto; gap: .55rem; align-items: start;
  border: 1px solid var(--border); border-radius: 10px; padding: .55rem .6rem; margin-bottom: .55rem; background: var(--surface2); }
.line-row label { margin-top: 0; }
.line-row .line-img { width: 52px; height: 52px; margin-top: 1.05rem; }
.line-note { font-size: .8rem; margin-top: .25rem; min-height: 1em; }
.line-variants { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.variant-chip { font-size: .78rem; padding: .18rem .55rem; }
.line-x { margin-top: 1.05rem; }
.set-card { display: flex; gap: 1rem; align-items: flex-start; }
.set-img { width: 110px; height: 110px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 8px; flex: 0 0 auto; }
.set-main { flex: 1; min-width: 0; }
.detail-panel { border-left: 3px solid var(--accent); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: .7rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow); z-index: 200; max-width: 90vw; font-size: .95rem;
  display: flex; align-items: center; gap: .8rem; }
.toast-btn { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: .35rem .85rem;
  font-weight: 700; font-size: .9rem; cursor: pointer; flex: 0 0 auto; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 1rem; z-index: 100; }
.modal { background: var(--surface); color: var(--text); border-radius: 14px; padding: 1.2rem; width: 100%; max-width: 640px; box-shadow: var(--shadow); margin: auto 0; }
.modal.wide { max-width: 780px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.x-btn { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); }

/* ---------- confirm dialog ---------- */
.confirm-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 300; }
.confirm-card { background: var(--surface); color: var(--text); border-radius: 14px; padding: 1.3rem; width: 100%; max-width: 400px;
  box-shadow: var(--shadow); text-align: center; }
.confirm-card p { margin: 0 0 1.1rem; font-size: 1.02rem; line-height: 1.45; }
.confirm-actions { display: flex; gap: .6rem; }
.confirm-actions .btn { flex: 1; }

/* ---------- order sheet ---------- */
.sheet { background: #fff; color: #111; padding: 1.2rem 1.3rem; font-size: 14px; line-height: 1.35; }
.sheet-head { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .7rem; border-bottom: 2px solid #111; }
.sheet-logo { max-width: 110px; max-height: 64px; object-fit: contain; }
.sheet-shop { font-size: 1.3rem; font-weight: 800; }
.sheet-title { margin: .8rem 0 .25rem; font-size: 1.12rem; }
.sheet-meta { display: flex; gap: 1.1rem; flex-wrap: wrap; color: #333; font-size: .92rem; }
.sheet table.items { width: 100%; border-collapse: collapse; table-layout: fixed; margin: .9rem 0 0; }
.sheet table.items th, .sheet table.items td { padding: .28rem .5rem; text-align: left; vertical-align: middle; border-bottom: 1px solid #ddd; overflow-wrap: break-word; }
.sheet table.items th { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: #666; border-bottom: 2px solid #111; }
.sheet table.items col.c-pic { width: 52px; }
.sheet table.items col.c-colour { width: 128px; }
.sheet table.items col.c-qty { width: 46px; }
.sheet table.items col.c-money { width: 86px; }
.sheet td.c, .sheet th.c { text-align: center; }
.sheet td.r, .sheet th.r { text-align: right; }
.sheet-sub { color: #555; font-size: .85em; margin-top: .1rem; }
.sheet-pic { width: 38px; height: 38px; object-fit: contain; display: block; }
.sheet .totals { margin: .6rem 0 0 auto; width: 264px; border-collapse: collapse; }
.sheet .totals td { padding: .28rem .5rem; }
.sheet .totals td.r { text-align: right; }
.sheet .totals .grand td { font-weight: 800; border-top: 2px solid #111; }
.sheet .totals .status td { text-align: right; font-weight: 800; letter-spacing: .05em; padding-top: .55rem; }
.sheet-notes { color: #444; font-size: .9rem; margin-top: .8rem; }

/* Customer name autocomplete (order forms) */
.picker-wrap { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.suggest button { display: flex; justify-content: space-between; gap: .6rem; width: 100%; padding: .55rem .7rem; background: none; border: none; border-bottom: 1px solid var(--border); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.suggest button:last-child { border-bottom: none; }
.suggest button:hover { background: var(--surface2); }
/* Consignment tracked-set rows */
.cons-item { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.cons-item:last-of-type { border-bottom: none; }
.print-only { display: none; }

@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; inset: 0; }
  .no-print { display: none !important; }
}

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  #app-view { flex-direction: column; }
  #sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  #sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .logout { margin-top: 0; margin-left: auto; }
  #main { padding: .8rem; }
  .line-row { grid-template-columns: 48px 1fr 1fr; }
  .line-row .line-img { width: 48px; height: 48px; }
  .set-card { flex-direction: column; }
  .set-img { width: 90px; height: 90px; }
}

/* Customization: bold text + compact spacing (Settings → Appearance).
   Text size is applied as the root font-size by applySettings; printing
   always uses the standard size so the sheets never change. */
@media print { html { font-size: 16px !important; } }
/* Bold text is a display preference, so it wins over per-component weights
   (buttons, inputs, badges and menus each set their own). The printable
   sheet keeps its own weights. */
html[data-textbold="true"] * { font-weight: 600 !important; }
html[data-textbold="true"] strong, html[data-textbold="true"] b,
html[data-textbold="true"] h1, html[data-textbold="true"] h2, html[data-textbold="true"] h3,
html[data-textbold="true"] th { font-weight: 800 !important; }
html[data-textbold="true"] .sheet, html[data-textbold="true"] .sheet * { font-weight: 400 !important; }
html[data-textbold="true"] .sheet strong, html[data-textbold="true"] .sheet b,
html[data-textbold="true"] .sheet th { font-weight: 700 !important; }
html[data-density="compact"] .card { padding: .65rem .75rem; }
html[data-density="compact"] .btn { padding: .34rem .62rem; }
html[data-density="compact"] .stat { padding: .6rem .7rem; }
html[data-density="compact"] .feed-item { padding: .32rem 0; }
html[data-density="compact"] .cons-item { padding: .3rem 0; }
html[data-density="compact"] .kv .k { padding: .45rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }

/* Paywall + access */
.paywall-prices { display: grid; gap: .35rem; margin: .8rem 0; text-align: left; }
.paywall-prices div { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .5rem .7rem; }
#access-banner { background: #fef3c7; color: #92400e; padding: .55rem .9rem; border-radius: 10px; margin-bottom: .8rem; font-size: .92rem; }
html[data-theme="dark"] #access-banner { background: #453309; color: #fcd34d; }

/* Interaction feedback — hover, press, and focus you can actually see.
   (The old .btn hover only tinted the border; on touch screens there
   was effectively nothing.) */
.btn, .nav-btn, .menu button, .suggest button, .variant-chip, .x-btn {
  transition: background-color .12s ease, border-color .12s ease, filter .12s ease, transform .06s ease, box-shadow .12s ease, color .12s ease;
}
.btn:hover { background: var(--surface2); border-color: var(--primary); box-shadow: 0 1px 5px rgba(0,0,0,.16); }
.btn.primary:hover { background: var(--primary); border-color: var(--primary); filter: brightness(1.13); }
.btn.accent:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.07); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost:hover { background: var(--surface2); }
.btn:active, .nav-btn:active, .menu button:active, .suggest button:active, .variant-chip:active { transform: scale(.95); }
.btn.primary:active, .btn.accent:active { filter: brightness(.9); }
.nav-btn:hover { box-shadow: inset 3px 0 0 var(--primary); }
.nav-btn.active:hover { filter: brightness(1.12); box-shadow: none; }
.variant-chip:hover { border-color: var(--primary); background: var(--surface2); box-shadow: 0 1px 4px rgba(0,0,0,.14); }
.x-btn:hover { color: var(--danger); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 1px;
}
* { -webkit-tap-highlight-color: rgba(0,0,0,.10); }

/* Landing page (the logged-out front page) */
.auth-wrap.landing-mode { align-items: flex-start; }
.landing { width: 100%; max-width: 600px; text-align: center; padding: 2.2rem 0 3rem; }
.landing h1 { font-size: 2.4rem; margin: .4rem 0 .2rem; }
.landing-tag { font-size: 1.15rem; font-weight: 600; margin: 0 0 .4rem; }
.landing-sub { max-width: 46ch; margin: 0 auto; }
.landing-cta { display: grid; gap: .5rem; max-width: 320px; margin: 1.2rem auto; }
.landing-features { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; text-align: left; margin: 1.4rem 0; }
.landing-features > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; display: grid; gap: .25rem; }
.landing-features span { color: var(--muted); font-size: .9rem; }
.landing-prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 0 0 1rem; }
.landing-prices > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .7rem; display: grid; }
.landing-prices strong { font-size: 1.3rem; }
.landing-prices span { color: var(--muted); font-size: .88rem; }
@media (max-width: 560px) { .landing-features { grid-template-columns: 1fr; } }

/* Order-card side actions: the old menu's contents as three buttons in
   the same style as the rest, centred vertically on the card's right
   side — no dots button. */
.card:has(.card-side) { position: relative; padding-right: 9.5rem; }
.card-side { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: .4rem; }
.card-side .btn { white-space: nowrap; }
