/* netpit — mobile-first, photo-led B2B catalogue. One file, no framework.
   Theme: Brändäämö Tec — clean light surfaces, bold orange accents. */
:root {
  --bg: #f6f6f6;        /* page background */
  --panel: #ffffff;     /* cards / header / tiles */
  --panel-2: #f6f6f6;   /* subtle fills (inputs, stepper buttons) */
  --card: #ffffff;      /* popovers / dropdowns */
  --ink: #272727;       /* primary text */
  --heading: #0e0e0e;   /* headings / deepest ink */
  --muted: #4a5464;     /* secondary text */
  --line: #e7e7e7;      /* borders / dividers */
  --accent: #f0523d;    /* vivid orange-red — primary (white-label: overridden inline in <head>) */
  --accent-dark: #d8432f; /* hover-darken — static fallback for old browsers */
  /* Derive the hover-darken from whatever --accent is, so recolouring the brand
     keeps the hover in step. Browsers without color-mix keep the fallback above. */
  --accent-dark: color-mix(in srgb, var(--accent) 88%, black);
  --accent-ink: #ffffff;
  --ok: #1b7a4b;
  --err: #b3261e;
  --radius: 12px;
  --font-head: 'Manrope', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-body: 'Nunito Sans', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4, .page-title, .sub, .brand {
  font-family: var(--font-head);
  color: var(--heading);
  font-weight: 700;
}

/* White-label text wordmark: two spans, no gap, one lowercase word.
   .bm-1 is ink, .bm-2 is the (configurable) accent. */
.brandmark {
  display: inline-flex; align-items: baseline; line-height: 1;
  font-family: var(--font-head); font-weight: 700;
  font-size: 1.35rem; letter-spacing: -.01em; text-transform: lowercase;
  text-decoration: none;
}
.brandmark:hover { text-decoration: none; }
.brandmark .bm-1 { color: var(--ink); }
.brandmark .bm-2 { color: var(--accent); }
.bm-1 + .bm-2 { margin-left: 0; }   /* no gap — reads as one word */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent-dark); }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: inline-flex; align-items: center; line-height: 0; }
.brand img { height: 32px; width: auto; display: block; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav a { color: var(--ink); font-weight: 700; }
.nav a:hover { color: var(--accent); text-decoration: none; }
.who { color: var(--muted); font-size: .85rem; display: flex; flex-direction: column; line-height: 1.2; }
.who .role { font-size: .72rem; color: var(--accent); }
.logout { margin: 0; }
.logout button, .nav button {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; font-size: .85rem;
  font-family: var(--font-head); font-weight: 600;
  min-height: 40px;
}
.logout button:hover, .nav button:hover { color: var(--accent); border-color: var(--accent); }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }
.foot { color: var(--muted); text-align: center; padding: 24px; font-size: .8rem; }
.page-title { font-size: 1.4rem; margin: 8px 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card.auth { max-width: 380px; margin: 8vh auto 0; }
.card h1 { margin-top: 0; }

/* Forms */
label { display: block; margin: 10px 0; font-size: .9rem; color: var(--muted); }
input, select {
  display: block; width: 100%; margin-top: 4px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 1rem; font-family: var(--font-body);
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }

/* Primary action — solid orange fill (buttons + link-buttons) */
.primary, button.primary {
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 11px 16px; font-size: 1rem; font-weight: 700;
  font-family: var(--font-head);
  cursor: pointer; margin-top: 8px;
  display: inline-block; text-align: center; min-height: 44px;
  transition: background .15s ease, border-color .15s ease;
}
a.primary { line-height: 1.45; }
.primary:hover, button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--accent-ink); text-decoration: none; }
button.primary:disabled { opacity: .5; cursor: not-allowed; }
.inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.stack > * { margin-bottom: 6px; }

/* Alerts */
.alert { padding: 10px 12px; border-radius: 8px; margin: 8px 0; font-size: .9rem; }
.alert.error { background: #fdecea; color: var(--err); border: 1px solid #f5c6c2; }
.alert.ok { background: #e7f6ee; color: var(--ok); border: 1px solid #bfe6d0; }

/* Catalogue photo grid (mobile-first: 2 cols, grows on wider screens) */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.tile a { color: var(--ink); display: block; }
.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.tile:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.06); }
.tile a:hover { text-decoration: none; }
.photo { aspect-ratio: 1 / 1; background: var(--panel-2); display: flex; align-items: center; justify-content: center; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder {
  color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em;
}
.placeholder.big { width: 100%; aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center; }
.meta { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.meta .name { font-weight: 700; font-size: .92rem; color: var(--heading); }
.meta .unit { color: var(--muted); font-size: .8rem; }

/* Product detail */
.product-detail { display: grid; gap: 20px; }
@media (min-width: 700px) { .product-detail { grid-template-columns: 1fr 1fr; } }
.hero img { width: 100%; border-radius: var(--radius); display: block; }
.product-detail h1 { margin-top: 0; }
.unit-line { color: var(--muted); }

/* Accounts */
.op-results { list-style: none; padding: 0; margin: 6px 0; }
.op-results li { margin: 4px 0; }
.op-results button {
  width: 100%; text-align: left; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--ink);
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.op-results button:hover { border-color: var(--accent); }
.operator-pick { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 10px 0; }
.operator-pick legend { color: var(--muted); padding: 0 6px; }
.chosen { font-size: .9rem; }
.users { width: 100%; border-collapse: collapse; font-size: .9rem; }
.users th, .users td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.users th { color: var(--muted); font-weight: 700; }
.preview-bar .small { margin-top: 8px; }

/* Per-row account actions (Take role / Delete) */
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.row-actions button {
  font-size: .78rem; padding: 4px 10px; border-radius: 6px; cursor: pointer;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
}
.row-actions .take-role:hover { border-color: var(--accent); color: var(--accent); }
.row-actions .delete { color: var(--err); }
.row-actions .delete:hover { background: var(--err); color: #fff; border-color: var(--err); }

/* Impersonation banner — shown on every page while an admin acts as someone */
.impersonation-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; max-width: 1080px; margin: 12px auto 0; padding: 8px 14px;
  background: color-mix(in srgb, var(--accent) 14%, white);
  border: 1px solid var(--accent); border-left: 4px solid var(--accent);
  border-radius: 8px; font-size: .88rem;
}
.impersonation-banner .imp-msg { color: var(--ink); }
.impersonation-banner form { margin: 0; }
.impersonation-banner button {
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: 6px; padding: 4px 12px; font-size: .8rem; font-weight: 700; cursor: pointer;
}
.impersonation-banner button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* Cart link + count badge in the top bar */
.cart-link { display: inline-flex; align-items: center; gap: 6px; }
.cart-count {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 1px 8px; font-size: .72rem; font-weight: 700;
}

/* Add-to-cart button on tiles + product detail */
.add-form { padding: 0 12px 12px; }
.add-form .small-btn { width: 100%; margin-top: 0; padding: 10px 10px; font-size: .85rem; }
.add-form.detail { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.add-form.detail .qty { width: 120px; margin: 0; }
/* Brief inline feedback after an AJAX add (orange, like the brand). */
button.primary.added { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* Quantity stepper (− [n] +) — shared by tiles, product detail, and cart.
   Big tap targets for mobile; the number field stays writable in the middle. */
.qty-stepper { display: inline-flex; align-items: stretch; gap: 0; margin: 6px 0; }
.qty-stepper .step {
  flex: 0 0 auto; width: 44px; min-height: 44px;
  background: var(--panel-2); color: var(--accent);
  border: 1px solid var(--line); cursor: pointer;
  font-size: 1.25rem; line-height: 1; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.qty-stepper .step:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); }
.qty-stepper .step:active { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.qty-stepper .step-dec { border-radius: 8px 0 0 8px; }
.qty-stepper .step-inc { border-radius: 0 8px 8px 0; }
.qty-stepper .qty-input {
  width: 56px; min-height: 44px; margin: 0; text-align: center;
  border-radius: 0; border-left: none; border-right: none;
  padding: 8px 4px; -moz-appearance: textfield; appearance: textfield;
}
.qty-stepper .qty-input::-webkit-outer-spin-button,
.qty-stepper .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-stepper .qty-input:focus { outline: none; border-color: var(--accent); box-shadow: none; }
/* On a catalogue tile the stepper centres above the full-width Add button. */
.add-form .qty-stepper { display: flex; justify-content: center; }
/* Product detail: a small "Quantity" label sits above the stepper. */
.add-form.detail .qty { margin: 0; width: auto; }
.add-form.detail .qty-label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }

/* Admin operator picker (searchable) — catalogue dropdown only.
   Scoped to .op-picker so these absolute/dropdown rules don't leak onto the
   accounts page, which reuses .op-results as a plain inline list. */
.op-picker { position: relative; margin: 8px 0; max-width: 420px; }
.op-picker input { width: 100%; }
.op-picker .op-results {
  list-style: none; margin: 4px 0 0; padding: 4px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  position: absolute; left: 0; right: 0; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.op-picker .op-results li { padding: 0; }
.op-picker .op-results li a { display: block; padding: 8px 10px; border-radius: 6px; }
.op-picker .op-results li a:hover { background: var(--panel-2); text-decoration: none; }
.op-picker .op-results li.op-empty { padding: 8px 10px; }
.op-quick-label { margin-top: 12px; }
.op-quicklist { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.op-quicklist a {
  display: inline-block; padding: 6px 12px; font-size: .85rem;
  border: 1px solid var(--line); border-radius: 999px; color: var(--ink);
}
.op-quicklist a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Cart + checkout lists */
.cart-list { list-style: none; margin: 0; padding: 0; }
.cart-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.cart-row:last-child { border-bottom: none; }
/* Cart line thumbnail — same photo-first look as the catalogue, sized small (64px)
   so it never dominates the row. Reuses .photo/.photo img/.placeholder. */
.cart-thumb {
  flex: 0 0 auto; width: 64px; height: 64px;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--line);
}
.cart-thumb .placeholder { font-size: .6rem; text-align: center; line-height: 1.1; }
.cart-name { flex: 1 1 200px; display: flex; flex-direction: column; gap: 2px; }
.cart-list.compact .cart-row { padding: 6px 0; }
.cart-qty { display: flex; align-items: center; gap: 6px; margin: 0; }
.cart-qty input { width: 80px; margin: 0; }
.cart-qty button, .cart-remove button {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; font-size: .85rem;
  font-family: var(--font-head); font-weight: 600; min-height: 44px;
}
.cart-qty button:hover, .cart-remove button:hover { color: var(--accent); border-color: var(--accent); }
.cart-remove { margin: 0; }

/* Calls to action */
a.cta, .cta { display: inline-block; text-decoration: none; }
.cta { margin-top: 8px; }
.sub { font-size: 1.05rem; margin: 4px 0 12px; }

/* Picture Loader */
.rb-hero img { max-width: 320px; width: 100%; border-radius: var(--radius); display: block; }
.drop-zone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 16px; margin: 10px 0; transition: border-color .15s ease, background .15s ease;
}
.drop-zone.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.dz-hint { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }
.camera-controls { margin: 10px 0; }
.camera-controls video { width: 100%; max-width: 360px; border-radius: var(--radius); margin: 8px 0; background: #000; }
.cam-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ghost-btn {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; font-size: .85rem; margin-top: 6px;
  font-family: var(--font-head); font-weight: 600; min-height: 44px;
}
.ghost-btn:hover { color: var(--accent); border-color: var(--accent); }
.ghost-btn.danger:hover { color: var(--err); border-color: var(--err); }
.staged { list-style: none; padding: 0; margin: 10px 0 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.staged li { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; color: var(--muted); }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.rule { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.loader-gallery .tile.is-hero { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.tile-actions form { margin: 0; }
.push-form { margin-top: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.push-form button { margin: 0; }

/* Picture Loader landing — show-all grid + instant filter */
.loader-filter-bar input { width: 100%; box-sizing: border-box; }
.loader-group { margin-top: 18px; }
.group-title { font-size: 1.05rem; margin: 0 0 10px; }
.loader-cta { margin-top: 4px; font-weight: 700; color: var(--accent); font-size: .82rem; }
.tile[hidden], .loader-group[hidden] { display: none; }

/* Catalogue mini-gallery (extra netpit angles under the hero) */
.angles { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.angles img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* Delivery address picker */
.addr-pick {
  display: flex; align-items: flex-start; gap: 10px; margin: 8px 0;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  color: var(--ink); cursor: pointer;
}
.addr-pick:hover { border-color: var(--accent); }
.addr-pick input { width: auto; margin: 4px 0 0; }
.addr-body { font-size: .92rem; line-height: 1.4; }
.ship-to { font-style: normal; line-height: 1.5; color: var(--ink); }

/* Areas (admin org-chart / area tree, GET /areas) -------------------------- */
/* Two conscience indicators in the brand's orange-warning style. */
.warn-line {
  margin: 8px 0; padding: 8px 12px; font-size: .9rem;
  background: color-mix(in srgb, var(--accent) 12%, white);
  border: 1px solid var(--accent); border-left: 4px solid var(--accent); border-radius: 8px;
}
.callout-warn {
  margin: 10px 0; padding: 10px 14px; font-size: .9rem;
  background: color-mix(in srgb, var(--accent) 12%, white);
  border: 1px solid var(--accent); border-left: 4px solid var(--accent); border-radius: 8px;
}
.callout-warn .warn-list { margin: 6px 0 0; padding-left: 18px; }

/* Mobile-first: panes stack; side-by-side from 760px up. */
.area-layout { display: grid; gap: 18px; }
@media (min-width: 760px) { .area-layout { grid-template-columns: minmax(260px, 360px) 1fr; align-items: start; } }

/* The tree (permanent left org chart) */
.area-tree .tree-root, .area-tree .node-children { list-style: none; margin: 0; padding: 0; }
.area-tree .node-children { margin-left: 16px; border-left: 1px solid var(--line); padding-left: 6px; }
.tree-node { margin: 2px 0; }
.node-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 8px; flex-wrap: wrap; }
.node-row.is-selected { background: color-mix(in srgb, var(--accent) 12%, white); box-shadow: inset 0 0 0 1px var(--accent); }
.node-toggle, .node-toggle-spacer {
  width: 22px; min-height: 22px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
}
.node-toggle {
  background: var(--panel-2); color: var(--accent); border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer; font-size: .8rem; padding: 0;
}
.node-toggle:hover { border-color: var(--accent); }
.node-name { color: var(--ink); font-weight: 700; }
.node-name:hover { color: var(--accent); text-decoration: none; }
.node-badge { flex: 0 0 auto; }
.node-sys { font-size: .68rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
.node-mgr { font-size: .78rem; color: var(--muted); }
.node-mgr.none { color: var(--accent); font-style: italic; }
.level-labels { margin-top: 14px; }
.level-labels summary { cursor: pointer; color: var(--muted); font-size: .85rem; }

/* Detail pane */
.area-detail h3 { margin: 14px 0 6px; font-size: 1rem; }
.chip-list { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: .82rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px;
}
.chip form { margin: 0; }
.chip-x {
  background: var(--panel); color: var(--err); border: 1px solid var(--line);
  border-radius: 999px; width: 22px; height: 22px; line-height: 1; cursor: pointer; padding: 0; font-size: 1rem;
}
.chip-x:hover { background: var(--err); color: #fff; border-color: var(--err); }
.shop-list { list-style: none; margin: 6px 0; padding: 0; }
.shop-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.shop-row .shop-name { font-weight: 600; }
.shop-row form { margin: 0 0 0 auto; }
.add-shops { margin-top: 8px; }
.add-shops summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: .85rem; }
.shop-pick-row label { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); }
.shop-pick-row input[type=checkbox] { width: auto; margin: 0; }
.shop-pick-row[hidden] { display: none; }

/* Audit log (admin activity viewer, GET /audit) */
.audit-filter { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.audit-filter label { display: flex; flex-direction: column; font-size: .82rem; gap: 4px; }
.audit-filter select, .audit-filter input { min-width: 160px; }
.audit-table code { font-size: .82rem; }
.audit-details .kv { display: inline-block; margin-right: 10px; white-space: nowrap; }
.audit-details .k { color: var(--muted); }
.audit-details .v { font-weight: 600; }
.role.acting-as { color: var(--accent); }
.audit-pager { display: flex; gap: 10px; margin-top: 12px; }
