:root {
  /* Kaia Creations brand, from kaiacreates.com: cream ground, ink type and buttons, caramel from the logo's heart */
  --bg: #f6e7ce; --surface: #ffffff; --surface-2: #fbf3e6; --ink: #121212; --ink-2: #5f564c; --line: #e6d3b3;
  --sidebar: #f6e7ce; --sidebar-line: #e2cda8;
  --accent: #121212; --accent-ink: #ffffff;               /* primary buttons, like the shop's */
  --brand: #c69a74; --brand-ink: #121212; --brand-soft: #f3e1cb; --brand-deep: #8a5d3b; /* caramel heart */
  --blue: #3e6fd8; --blue-soft: #e5edfb; --ok: #2f7d55; --ok-soft: #e2f1e7; --warn: #9a6512; --warn-soft: #fbedd2;
  --neg: #b8323f; --neg-soft: #fbe3e3;
  --radius: 10px; --radius-ctl: 4px; --shadow: 0 1px 2px rgba(18,18,18,.05), 0 4px 14px rgba(18,18,18,.04);
  --head: 'Assistant', system-ui, -apple-system, sans-serif; --body: 'Assistant', system-ui, -apple-system, sans-serif;
  --tab-h: 64px;
  --logo-filter: none;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121212; --surface: #1c1a18; --surface-2: #24211e; --ink: #f6e7ce; --ink-2: #b8a991; --line: #3a342d;
    --sidebar: #171513; --sidebar-line: #2c2823;
    --accent: #f6e7ce; --accent-ink: #121212;
    --brand: #d4ab86; --brand-ink: #121212; --brand-soft: #3a2c20; --brand-deep: #e3c09f;
    --blue-soft: #22304d; --blue: #8fb0f2; --ok: #7fcfa0; --ok-soft: #1f3a2c; --warn: #e9b65c; --warn-soft: #3e3220;
    --neg: #ff8a8a; --neg-soft: #3f2224; --shadow: none;
    --logo-filter: invert(1) hue-rotate(180deg) brightness(1.05); color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; margin: 0 0 .5rem; line-height: 1.2; letter-spacing: .01em; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
a { color: var(--ink); text-underline-offset: 3px; }
small { display: block; font-size: .8rem; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: .85em; word-break: break-all; }
.muted { color: var(--ink-2); } .small { font-size: .85rem; } .block { display: block; } .nowrap { white-space: nowrap; }
.neg { color: var(--neg); font-weight: 600; } .pos { color: var(--ok); font-weight: 600; } .low { color: var(--warn); font-weight: 600; }
.lead { color: var(--ink-2); max-width: 70ch; margin: 0 0 1rem; }
.pad { padding: 1rem 1.25rem; }

/* Layout */
#app { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; background: var(--sidebar); color: var(--ink); border-right: 1px solid var(--sidebar-line); display: flex; flex-direction: column; padding: 1rem .75rem; }
.brand { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .25rem .5rem 1.1rem; margin-bottom: .5rem; border-bottom: 1px solid var(--sidebar-line); }
.brand small { font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-2); }
.logo { display: block; height: 58px; width: auto; filter: var(--logo-filter); }
.logo-lg { height: 92px; margin: 0 auto; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: .65rem; color: var(--ink-2); text-decoration: none; padding: .6rem .75rem; border-radius: var(--radius-ctl); font-weight: 600; }
.sidebar nav a:hover { background: rgba(18,18,18,.06); color: var(--ink); }
.sidebar nav a.active { background: var(--accent); color: var(--accent-ink); }
.sidebar-foot { margin-top: auto; padding: .75rem; display: flex; flex-direction: column; gap: .25rem; }
.sidebar-foot .link { color: var(--ink); text-align: left; text-decoration: underline; }
.ico { width: 1.25rem; text-align: center; font-size: 1.05rem; }
.badge { margin-left: auto; background: var(--brand); color: var(--brand-ink); border-radius: 99px; font-size: .72rem; font-weight: 600; padding: 1px 7px; min-width: 20px; text-align: center; }
.sidebar nav a.active .badge { background: var(--brand); color: var(--brand-ink); }
.main { margin-left: 232px; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem .5rem; }
.topbar h1 { margin: 0; }
#view { padding: .5rem 1.5rem 2rem; max-width: 1280px; outline: none; }
.tabbar, .mobile-only { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: .9rem 1rem .6rem; }
  #view { padding: .25rem 1rem 1.5rem; }
  .mobile-only { display: inline-flex; }
  .tabbar { display: flex; position: fixed; inset: auto 0 0 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line); z-index: 10; }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; font-weight: 500;
    color: var(--ink-2); text-decoration: none; background: none; border: 0; position: relative; font-family: var(--body); }
  .tabbar .ico { font-size: 1.3rem; }
  .tabbar a.active { color: var(--ink); font-weight: 700; }
  .tabbar a.active::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; background: var(--brand); border-radius: 0 0 3px 3px; }
  .tabbar .badge { position: absolute; top: 6px; right: calc(50% - 22px); margin: 0; }
  .hide-sm { display: none; }
}

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.flush { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.center-card { max-width: 380px; margin: 12vh auto 0; text-align: center; padding: 2rem 1.5rem; }
.auth { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-align: left; display: flex; flex-direction: column; gap: .8rem; }
.auth h1, .auth > .muted { text-align: center; margin: 0; }
.eyebrow { text-align: center; margin: -.4rem 0 .4rem; font-size: .74rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-2); }
.notice { background: var(--warn-soft); border-radius: 10px; padding: .65rem .85rem; margin: 0 0 1rem; }
.notice.error { background: var(--neg-soft); color: var(--neg); }
.empty { color: var(--ink-2); padding: 1rem 0; margin: 0; }
.card.empty { padding: 1.5rem; }
.loading { padding: 3rem; text-align: center; }

/* Controls */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .88rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.input { font: inherit; font-weight: 400; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-ctl); padding: .6rem .75rem; min-height: 42px; width: 100%; }
.input:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: transparent; }
select.input { width: auto; min-width: 10rem; }
label select.input { width: 100%; min-width: 0; }
.btn { font: 600 .9rem var(--body); display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px; padding: .5rem 1.1rem; border-radius: var(--radius-ctl); letter-spacing: .02em;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: none; opacity: .88; border-color: var(--accent); }
.btn:focus-visible, .chip:focus-visible, .icon-btn:focus-visible, .link:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-danger { color: var(--neg); border-color: var(--neg); background: transparent; }
.btn-block { width: 100%; } .btn-lg { min-height: 52px; font-size: 1rem; }
.btn.sm { min-height: 34px; padding: .3rem .7rem; font-size: .82rem; }
.icon-btn { background: none; border: 0; font-size: 1.15rem; color: var(--ink-2); cursor: pointer; min-width: 40px; min-height: 40px; border-radius: 10px; }
.icon-btn:hover { background: var(--surface-2); }
.link { background: none; border: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font: 600 .9rem var(--body); cursor: pointer; padding: .4rem 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.toolbar .grow, .grow { flex: 1 1 200px; width: auto; }
.row-end { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row-between h2 { margin: 0; }
.form { display: flex; flex-direction: column; gap: .9rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; align-items: end; }
.field-inline { margin-bottom: .9rem; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-ctl); padding: 3px; gap: 2px; margin-bottom: 1rem; flex-wrap: wrap; }
.segmented button { border: 0; background: none; font: 600 .85rem var(--body); color: var(--ink-2); padding: .5rem .95rem; border-radius: 3px; cursor: pointer; min-height: 38px; }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 99px; padding: .35rem .8rem; font: 500 .82rem var(--body); cursor: pointer; min-height: 34px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: .74rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.blue { background: var(--blue-soft); color: var(--blue); } .pill.pink { background: var(--brand-soft); color: var(--brand-deep); }
.spin { width: 18px; height: 18px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
.spin.dark { border-color: var(--line); border-top-color: var(--brand); width: 28px; height: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); font-weight: 600; padding: .6rem .75rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.table td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.card:not(.flush) .table th:first-child, .card:not(.flush) .table td:first-child { padding-left: 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll.short { max-height: 300px; overflow-y: auto; }
.stock-table tr.group-start td { border-top: 1px solid var(--line); }
.stock-table thead th { position: sticky; top: 0; z-index: 1; }
.item-cell { display: flex; align-items: center; gap: .65rem; }
.item-cell > div { display: flex; flex-direction: column; }
.qty-in { width: 84px; text-align: right; min-height: 38px; padding: .35rem .5rem; }
tr.archived, .archived { opacity: .5; }
.variants-edit td { padding: .35rem .3rem; } .variants-edit .input { min-width: 90px; min-height: 38px; padding: .4rem .55rem; }
.variants-edit .narrow { min-width: 64px; width: 72px; }

/* Thumbs */
.thumb { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.thumb-empty { display: grid; place-items: center; font: 700 1.05rem var(--head); color: var(--brand-deep); background: var(--brand-soft); }
.thumb-space { width: 40px; flex: none; }

/* Dashboard */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.stat span { font-size: .74rem; color: var(--ink-2); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.stat b { display: block; font: 700 1.9rem var(--head); margin: .15rem 0; }
.stat small { color: var(--ink-2); }
.stat.warn b { color: var(--warn); }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1rem; }
.loc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; margin-bottom: .25rem; }
.loc-card { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: .15rem; }
.loc-card .big { font: 700 2.2rem var(--head); }
.loc-card .pill { align-self: flex-start; margin-top: .4rem; }
.setup .steps li { margin: .5rem 0; } .steps li.done { text-decoration: line-through; color: var(--ink-2); }
.steps { padding-left: 1.2rem; }

/* Quick Sale + transfers */
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.cart { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .8rem; }
.cart h2 { margin: 0; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } .cart { position: static; order: -1; } }
.picker-bar { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .75rem; }
.picker-list { display: flex; flex-direction: column; gap: .4rem; }
.pk-product { border: 1px solid var(--line); border-radius: var(--radius-ctl); overflow: hidden; }
.pk-product.open { border-color: var(--ink); }
.pk-head { display: flex; align-items: center; gap: .75rem; width: 100%; background: var(--surface); border: 0; padding: .6rem .75rem; cursor: pointer; text-align: left; font: inherit; color: var(--ink); min-height: 56px; }
.pk-name { flex: 1; font-weight: 600; } .pk-name small { font-weight: 400; color: var(--ink-2); }
.pk-caret { font-size: 1.3rem; color: var(--ink-2); width: 24px; text-align: center; }
.pk-variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .45rem; padding: .25rem .75rem .8rem; background: var(--surface); }
.variant-chip { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); padding: .55rem .4rem; cursor: pointer; font: inherit; color: var(--ink); min-height: 54px; }
.variant-chip b { display: block; font-size: .9rem; } .variant-chip small { color: var(--ink-2); }
.variant-chip:hover { border-color: var(--ink); }
.variant-chip.out { opacity: .55; } .variant-chip.out small { color: var(--neg); }
.cart-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cart-lines li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.cl-name { font-weight: 600; } .cl-name small { font-weight: 400; color: var(--ink-2); }
.cl-ctrl { display: flex; align-items: center; gap: .4rem; } .cl-ctrl b { min-width: 1.5rem; text-align: center; }
.price { width: 84px; min-height: 34px; padding: .3rem .5rem; text-align: right; }
.cart-total { display: flex; justify-content: space-between; font: 600 1.1rem var(--head); }
.stepper { display: flex; gap: .5rem; align-items: center; margin: .5rem 0 1rem; }
.step { min-width: 52px; font-size: 1.3rem; } .step.sm { min-width: 34px; font-size: 1rem; }
.step-input { text-align: center; font-size: 1.3rem; font-weight: 600; }
.from-to { display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: end; margin-bottom: .9rem; }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .8rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.mini { margin: .3rem 0 0; padding-left: 1rem; font-size: .88rem; }

/* Products */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .75rem; }
.product-card { display: flex; gap: .8rem; align-items: center; text-align: left; cursor: pointer; font: inherit; color: var(--ink); margin: 0; }
.product-card:hover { border-color: var(--ink); }
.product-card .thumb { width: 52px; height: 52px; }

/* Stock save bar */
.savebar { position: sticky; bottom: 0; display: flex; gap: .5rem; padding: .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -4px 20px rgba(0,0,0,.08); flex-wrap: wrap; }
@media (max-width: 860px) { .savebar { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 8px); } }

/* Settings */
.copy-row { display: flex; gap: .5rem; align-items: center; margin: .5rem 0 1rem; flex-wrap: wrap; }

/* Modals, sheets, toasts */
.modal-backdrop, .sheet-backdrop { position: fixed; inset: 0; background: rgba(20,15,22,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(480px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-wide { width: min(860px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem .5rem; }
.modal header h2 { margin: 0; }
.modal-body { padding: .5rem 1.25rem 1.25rem; overflow-y: auto; }
.modal-actions { margin-top: .5rem; }
@media (max-width: 600px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal-wide { width: 100%; border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); }
}
.sheet-backdrop { align-items: flex-end; padding: 0; }
.sheet { background: var(--surface); width: 100%; border-radius: 18px 18px 0 0; padding: .75rem 1rem calc(1rem + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.sheet a { display: flex; align-items: center; gap: .75rem; padding: .9rem .5rem; color: var(--ink); text-decoration: none; font-weight: 500; border-bottom: 1px solid var(--line); }
.sheet .link { padding: .9rem .5rem; text-align: left; }
#toasts { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
@media (max-width: 860px) { #toasts { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); } }
.toast { background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: var(--radius-ctl); font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: 0; transform: translateY(8px); transition: .25s; max-width: 90vw; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--neg); color: var(--surface); }

/* Phone tightening */
@media (max-width: 600px) {
  .stat-row { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .stat { padding: .7rem .75rem; }
  .stat b { font-size: 1.35rem; }
  .stat span, .stat small { font-size: .72rem; }
  .loc-grid { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .loc-card { padding: .8rem .75rem; }
  .loc-card h3 { font-size: .85rem; }
  .loc-card .big { font-size: 1.5rem; }
  .loc-card .muted { font-size: .72rem; }
  .cart.is-empty { display: none; }
}

/* "New updates" button in the top bar */
.topbar { gap: .75rem; }
.fresh-btn { border-color: var(--brand); color: var(--brand-deep); background: var(--brand-soft); }
@media (max-width: 860px) { .fresh-btn { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 10px); z-index: 20; box-shadow: var(--shadow); } }

.topbar-logo { height: 36px; margin-left: auto; }
