:root {
  --bg: #f3f4f7; --panel: #ffffff; --panel-2: #f8f9fb; --text: #1c2230; --muted: #667085;
  --border: #dde1e8; --accent: #2457c5; --accent-weak: #e7eefc; --accent-text: #ffffff;
  --danger: #b42318; --danger-weak: #fdecea; --ok: #067647; --ok-weak: #e6f4ea; --warn: #b54708; --warn-weak: #fef3e2;
  --sidebar: #1d2433; --sidebar-text: #c9d1e0; --sidebar-active: #2e3a52; --sidebar-muted: #7d889e;
  --row-hover: #f1f4fa; --row-selected: #e3ebfb;
  --radius: 8px; --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b1f27; --panel-2: #20252f; --text: #e5e8ee; --muted: #98a2b3;
    --border: #2f3542; --accent: #6b97ff; --accent-weak: #22304d; --accent-text: #0d1220;
    --danger: #ff8a80; --danger-weak: #3a1f1f; --ok: #6fcf97; --ok-weak: #18311f; --warn: #f5b971; --warn-weak: #3a2b15;
    --sidebar: #0e1117; --sidebar-text: #c2cad8; --sidebar-active: #222a3a; --sidebar-muted: #6b7486;
    --row-hover: #232936; --row-selected: #26324a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); background: var(--bg); color: var(--text); }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); overflow-y: auto; padding: 12px 8px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 16px; font-weight: 600; font-size: 16px; color: #fff; }
.brand small { color: var(--sidebar-muted); font-weight: 400; font-size: 11px; margin-left: auto; }
/* Bovrie logo: lowercase b in Abel on Bovrie blue (as the desktop app icon). */
@font-face { font-family: "Abel"; src: url("fonts/Abel-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 5px; background: #006088; color: #fff;
  font: 400 22px/1 "Abel", var(--font); padding-bottom: 2px;
}
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); padding: 14px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 6px 30px 6px 10px; border-radius: 6px; color: var(--sidebar-text); text-decoration: none; white-space: nowrap; }
.nav-icon { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-row { position: relative; }
.nav-star {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 5px; background: none; color: var(--sidebar-muted); cursor: pointer; opacity: 0;
}
.nav-star-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.nav-row:hover .nav-star, .nav-star:focus-visible { opacity: 1; }
.nav-star:hover { color: #fff; background: var(--sidebar-active); }
.nav-star.on { opacity: 1; color: #f5c542; }
.nav-star.on .nav-star-icon { fill: currentColor; }
.nav-toggle {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--sidebar-muted); cursor: pointer;
}
.nav-toggle:hover { background: var(--sidebar-active); color: #fff; }
.nav-toggle-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-user { display: none; }
.user-name { color: #fff; font-weight: 600; }

/* Computers: the sidebar collapses to a 60 px bar with icons (only the starred items when there are any). */
@media (min-width: 761px) {
  .shell { transition: grid-template-columns .2s ease; }
  .shell.nav-collapsed, html.nav-collapsed-pref .shell { grid-template-columns: 60px 1fr; }
  :is(.shell.nav-collapsed, html.nav-collapsed-pref .shell) .sidebar { padding: 12px 6px; overflow-x: hidden; }
  :is(.shell.nav-collapsed, html.nav-collapsed-pref .shell) .brand { flex-direction: column; gap: 10px; padding: 2px 0 12px; }
  :is(.shell.nav-collapsed, html.nav-collapsed-pref .shell) :is(.brand-name, .brand small, .nav-group, .nav-label, .nav-star, .user-box) { display: none; }
  :is(.shell.nav-collapsed, html.nav-collapsed-pref .shell) .nav-item { justify-content: center; padding: 9px 0; }
  :is(.shell.nav-collapsed, html.nav-collapsed-pref .shell) .nav-icon { width: 20px; height: 20px; }
  :is(.shell.nav-collapsed, html.nav-collapsed-pref .shell) .nav-row + .nav-row { margin-top: 2px; }
  :is(.shell.nav-collapsed, html.nav-collapsed-pref .shell) .nav-user {
    display: grid; place-items: center; width: 100%; margin-top: 14px; padding: 9px 0; border: 0; border-top: 1px solid var(--sidebar-active);
    background: none; color: var(--sidebar-muted); cursor: pointer;
  }
  .nav-user .nav-icon { width: 20px; height: 20px; }
}
/* Global search under the logo; suggestions drop down within the sidebar. */
.gsearch { position: relative; margin: 0 2px 6px; }
.gsearch-icon { position: absolute; left: 9px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); fill: none; stroke: var(--sidebar-muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
/* input[type=search] here: must outrank the generic input rule further down. */
.gsearch input[type=search] {
  width: 100%; height: 34px; padding: 0 10px 0 32px; border: 1px solid var(--sidebar-active); border-radius: 8px;
  background: rgba(255, 255, 255, .06); color: #fff; font: inherit; font-size: 13px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.gsearch input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.gsearch input[type=search]::placeholder { color: var(--sidebar-muted); }
.gsearch input[type=search]:hover { border-color: #3c4a66; }
.gsearch input[type=search]:focus { outline: none; border-color: var(--accent); background: rgba(255, 255, 255, .1); }
.gsearch:focus-within .gsearch-icon { stroke: #fff; }
.gsearch-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 70; max-height: 65vh; overflow-y: auto;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28); padding: 4px 0;
}
.gsearch-group { padding: 8px 10px 3px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.gsearch-hit { display: block; padding: 5px 10px; color: var(--text); text-decoration: none; line-height: 1.3; }
.gsearch-hit.active { background: var(--panel-2); }
.gsearch-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; overflow: hidden; white-space: nowrap; }
.gsearch-sub { display: block; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsearch-empty { padding: 6px 10px; font-size: 12px; color: var(--muted); }
.nav-search { display: none; }
@media (min-width: 761px) {
  html.nav-collapsed-pref .gsearch { display: none; }
  :is(.shell.nav-collapsed, html.nav-collapsed-pref .shell) .nav-search {
    display: grid; place-items: center; width: 100%; padding: 9px 0; border: 0; border-radius: 6px;
    background: none; color: var(--sidebar-text); cursor: pointer;
  }
  .nav-search:hover { background: var(--sidebar-active); }
  .nav-search svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
}
.search-groups { display: grid; gap: 14px; }
/* Order line opened from the global search. */
tr.line-hit > td, .line-item.line-hit { background: var(--accent-weak); }
tr.line-hit > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.search-jump { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.search-group { scroll-margin-top: 12px; }
.search-groups .panel + .panel { margin-top: 0; }

.nav-item:hover { background: var(--sidebar-active); }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.content { overflow: auto; padding: 18px 22px; min-width: 0; }

/* Page layout */
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head .spacer { flex: 1; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.split.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .split, .split.wide-left { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.panel + .panel { margin-top: 14px; }
.panel.sticky { position: sticky; top: 0; }

/* Controls */
input[type=text], input[type=search], input[type=number], input[type=password], input:not([type]), select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 9px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
/* Blazor focuses the page title after navigating (screen readers); no visible box around it. */
h1:focus, h1:focus-visible { outline: none; }

/* Planning: three equal columns; the week bar uses the same columns; list headers equally tall so tables line up. */
.planning-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.planning-weekbar { margin-bottom: 14px; }
.planning-grid > .panel > .toolbar:first-child { min-height: 34px; align-items: center; }
.planning-grid > .panel { margin-top: 0; }
.planning-weekbar { align-items: stretch; }
/* Lists: each panel spans two shared rows (header, content) so the tables start at the same height even when a header wraps. */
.planning-lists > .panel { display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: 10px; align-content: start; }
.planning-lists > .panel > .toolbar:first-child { margin-bottom: 0; }
.planning-weeknav { display: flex; align-items: center; justify-content: center; gap: 12px; }
.planning-weektitle { display: flex; flex-direction: column; align-items: center; min-width: 150px; line-height: 1.25; }
.planning-weektitle .muted { font-size: 12px; }
.planning-totals { display: flex; align-items: center; justify-content: flex-end; gap: 18px; flex-wrap: wrap; }
@media (max-width: 1100px) {
  .planning-grid { grid-template-columns: minmax(0, 1fr); }
  .planning-weekbar-left { display: none; }
  .planning-totals { justify-content: center; }
}
textarea { width: 100%; min-height: 70px; resize: vertical; }
.search { width: 260px; }
.btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.tabs button { font: inherit; border: 0; background: var(--panel); color: var(--text); padding: 6px 12px; cursor: pointer; }
.tabs button + button { border-left: 1px solid var(--border); }
.tabs button.on { background: var(--accent); color: var(--accent-text); }
label.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field > span { font-size: 12px; color: var(--muted); }
.field.full { grid-column: 1 / -1; }

/* Key/value header */
dl.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 16px; margin: 0 0 12px; }
dl.kv dt { color: var(--muted); font-size: 12px; }
dl.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
dl.kv.order-head { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 20px; }
dl.kv.order-head > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
dl.kv.order-head dd { font-size: 15px; }
/* PC: order lines open their characteristics in a row below (Orders.razor). */
tr.line-row td { vertical-align: top; }
.line-desc-cell { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.line-chevron { flex: none; color: var(--muted); font-weight: 700; transition: transform .15s; display: inline-block; }
tr.line-row.open .line-chevron { transform: rotate(90deg); color: var(--accent); }
.line-desc-text { min-width: 0; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.line-row.open .line-desc-text { white-space: normal; }
/* Lines without characteristics: no arrow, nothing to open, the whole description shown. */
tr.line-row.no-more .line-desc-text, .line-item.no-more .line-desc { white-space: normal; }
.line-item.no-more .line-head { cursor: default; }
.line-chevron { min-width: 8px; }
tr.line-row.open td { background: var(--row-selected); }
tr.line-detail > td { background: var(--panel-2); border-bottom: 2px solid var(--accent); padding-top: 8px; padding-bottom: 10px; }
dl.kv.line-chars { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 18px; margin: 0; }
dl.kv.line-chars > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
dl.kv.line-chars dd { font-weight: 500; }

/* Tables (QuickGrid + plain) */
.grid-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.grid-wrap.tall { max-height: calc(100vh - 210px); }
.grid-wrap.mid { max-height: 420px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 9px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
thead th { position: sticky; top: 0; z-index: 1; background: var(--panel-2); font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.selected, tbody tr.selected:hover { background: var(--row-selected); }
tbody tr.clickable { cursor: pointer; }
td input, td select { width: 100%; padding: 3px 6px; }
.col-sort-button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; }
.quickgrid th .col-title-text { font-weight: 600; }
.quickgrid th.col-justify-end .col-title, .quickgrid td.col-justify-end { text-align: right; }
.chars { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* Badges & alerts */
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.badge.keukens { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.badge.stollen { background: var(--ok-weak); color: var(--ok); border-color: transparent; }
.badge.service { background: var(--danger-weak); color: var(--danger); border-color: transparent; }
td.pills .badge + .badge { margin-left: 4px; }
.badge.ok { background: var(--ok-weak); color: var(--ok); border-color: transparent; }
.badge.err { background: var(--danger-weak); color: var(--danger); border-color: transparent; }
.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.alert.error { background: var(--danger-weak); color: var(--danger); }
.alert.ok { background: var(--ok-weak); color: var(--ok); }
.alert.info { background: var(--accent-weak); color: var(--accent); }

/* Upload */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 12px 14px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dropzone.over { border-color: var(--accent); background: var(--accent-weak); color: var(--text); }
.pdf-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

/* Sign-in */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px 16px;
  background: radial-gradient(900px 520px at 50% -8%, var(--accent-weak), transparent 70%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 26px; box-shadow: 0 12px 32px rgba(16, 24, 40, .10), 0 2px 6px rgba(16, 24, 40, .06);
}
.auth-card h1 { font-size: 22px; margin: 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 46px; height: 46px; border-radius: 8px; font-size: 36px; padding-bottom: 4px; }
.auth-brand strong { display: block; font-size: 18px; line-height: 1.2; }
.auth-brand small { color: var(--muted); font-size: 12px; }
.auth-sub { color: var(--muted); margin: 4px 0 18px; }
.auth-form { display: grid; gap: 14px; margin-top: 10px; }
.auth-form .field > span { font-size: 13px; font-weight: 500; color: var(--text); }
.auth-form input:not([type=checkbox]) {
  width: 100%; height: 46px; padding: 0 12px; font: 16px var(--font); /* 16px: no zoom on iPhone */
  color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px;
}
.auth-form input:not([type=checkbox]):focus { outline: 3px solid var(--accent-weak); border-color: var(--accent); background: var(--panel); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 46px !important; }
.pw-toggle {
  position: absolute; top: 0; right: 0; width: 46px; height: 46px; display: grid; place-items: center;
  border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 9px;
}
.pw-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-toggle[aria-pressed=true] { color: var(--accent); }
.auth-remember { font-size: 14px; user-select: none; }
.auth-remember input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.auth-form .btn.primary { height: 48px; justify-content: center; font-size: 16px; font-weight: 600; border-radius: 9px; margin-top: 4px; }
.auth-form .btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.auth-card .alert { margin: 0 0 14px; }
.auth-foot { color: var(--muted); font-size: 12px; }
@media (max-width: 440px) { .auth-card { padding: 24px 20px; } }
.user-box { margin-top: 18px; padding: 10px; border-top: 1px solid var(--sidebar-active); font-size: 13px; }
.user-box form { display: inline; }
.user-box button, .user-box a { font: inherit; color: var(--sidebar-text); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

/* Kast 3D */
.kast3d { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; height: calc(100vh - 110px); }
.kast3d-view { width: 100%; height: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: #eef1f5; }
.kast3d-side { overflow: auto; }
/* Options one below the other (two columns ran off the panel with long colour names). */
.kast3d-side { overflow-x: hidden; }
.kast3d-side .form-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.kast3d-side .form-grid select, .kast3d-side .toolbar select { width: 100%; min-width: 0; max-width: 100%; }
.kast3d-side .toolbar { flex-wrap: wrap; }
.kast3d-parts { max-height: calc(100vh - 470px); }
.kast3d-bar, .kast3d-sheet-handle, .mobile-only { display: none; }
@media (max-width: 1000px) { .kast3d { grid-template-columns: 1fr; height: auto; } .kast3d-view { height: 70vh; } }

/* Phones: Kast 3D as a full-screen pop-up with an "Opties" sheet. */
@media (max-width: 760px) {
  .mobile-only { display: inline-flex; }
  .kast3d.full { position: fixed; inset: 0; z-index: 80; display: block; height: auto; background: #eef1f5; overscroll-behavior: contain; }
  /* No page scrolling behind the full-screen 3D view (touch gestures go to the viewer). */
  html:has(.kast3d.full), body:has(.kast3d.full) { overflow: hidden; height: 100%; overscroll-behavior: none; }
  .kast3d.full .kast3d-bar { touch-action: none; }
  /* Solid bar on top; the 3D view starts below it so the viewer's own buttons and view cube stay free. */
  .kast3d.full .kast3d-view {
    position: absolute; left: 0; right: 0; bottom: 0; top: calc(58px + env(safe-area-inset-top));
    width: 100%; height: calc(100% - 58px - env(safe-area-inset-top)); border: 0; border-radius: 0;
  }
  .kast3d.full .kast3d-bar {
    display: flex; align-items: center; gap: 8px; position: absolute; top: 0; left: 0; right: 0; z-index: 2;
    height: calc(58px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0; background: var(--sidebar);
  }
  .kast3d-bar-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 42px; height: 42px; padding: 0 10px; border: 0; border-radius: 21px;
    background: var(--sidebar-active); color: #fff; font: 600 14px var(--font); cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .kast3d-bar-btn.wide { padding: 0 14px; }
  .kast3d-bar-btn.on { background: var(--accent); color: var(--accent-text); }
  .kast3d-bar-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .kast3d-bar-title { flex: 1; min-width: 0; color: #fff; line-height: 1.2; }
  .kast3d-bar-title strong, .kast3d-bar-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .kast3d-bar-title span { font-size: 12px; opacity: .9; }

  .kast3d.full .kast3d-side { display: none; }
  .kast3d.full.sheet-open .kast3d-side {
    display: block; position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; max-height: 62vh; overflow-y: auto;
    border: 0; border-radius: 16px 16px 0 0; padding: 0 14px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .25);
  }
  .kast3d.full .kast3d-sheet-handle { display: flex; justify-content: center; padding: 10px 0 12px; position: sticky; top: 0; background: var(--panel); cursor: pointer; z-index: 1; }
  .kast3d-sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--border); }
  .kast3d.full .kast3d-parts { max-height: none; }
}

/* Phone: an order opens under its row in the list (Orders.razor). */
.row-detail > td { padding: 0 !important; background: var(--panel-2); border-bottom: 2px solid var(--accent); }
.row-detail-body {
  position: sticky; left: 0; width: calc(100vw - 34px); max-width: 100%; box-sizing: border-box;
  padding: 12px; white-space: normal; cursor: default;
}
.row-detail-body .grid-wrap.mid { max-height: none; }
.row-detail-body .pdf-frame { height: 60vh; }
/* Phone: order lines as a list; a line opens its details on tap. */
.line-list { display: grid; gap: 6px; }
.line-item { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.line-head {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.line-head { align-items: flex-start; }
.line-pos {
  flex: none; min-width: 28px; padding: 1px 6px; border-radius: 6px; background: var(--panel-2); color: var(--muted);
  font-size: 12px; font-variant-numeric: tabular-nums; text-align: center;
}
.line-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.line-top { display: flex; align-items: baseline; gap: 8px; }
.line-art { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-3d { flex: none; padding: 2px 8px; font-weight: 700; text-decoration: none; }
.line-top .line-qty { margin-left: auto; }
.line-qty { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.line-desc { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-prices { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; font-variant-numeric: tabular-nums; }
.line-prices small { color: var(--muted); font-size: 11px; margin-right: 2px; }
.line-head svg { flex: none; width: 18px; height: 18px; margin-top: 2px; fill: none; stroke: var(--muted); stroke-width: 2; transition: transform .15s; }
.line-item.open { border-color: var(--accent); }
.line-item.open .line-head svg { transform: rotate(180deg); }
.line-body { padding: 8px 12px 10px; border-top: 1px solid var(--border); display: grid; gap: 8px; justify-items: start; }
.line-item.open .line-desc { white-space: normal; } /* opened: the whole description, not repeated below */
.line-body dl.kv { margin: 0; justify-self: stretch; grid-template-columns: minmax(90px, max-content) 1fr; gap: 4px 12px; align-items: baseline; }
.line-body dl.kv dd { font-weight: 500; }
@media (max-width: 760px) {
  .grid-wrap.tall { max-height: none; } /* phones: the page scrolls, not a box inside it */
}

/* Sortable tables (GridHead). */
.col-sort-button .sort-arrow { margin-left: 4px; font-size: 9px; color: var(--accent); }
.col-sort-button.sorted { color: var(--accent); }
tr.grid-head th[draggable=true] { cursor: grab; }
th.col-dragging { opacity: .45; }
th.col-drop { box-shadow: inset 3px 0 0 var(--accent); }
.grid-menu-backdrop { position: fixed; inset: 0; z-index: 95; cursor: default; }
.grid-menu {
  position: fixed; z-index: 96; min-width: 200px; max-height: 70vh; overflow-y: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 28px rgba(16, 24, 40, .18);
  color: var(--text); font-size: 13px; font-weight: 400; white-space: nowrap; text-transform: none; letter-spacing: 0; cursor: default;
}
.grid-menu-title { padding: 4px 8px 6px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.grid-menu-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 5px; cursor: pointer; }
.grid-menu-item:hover { background: var(--row-hover); }
.grid-menu-item input { accent-color: var(--accent); }
.grid-menu-reset { display: block; width: 100%; margin-top: 6px; padding: 6px 8px; border: 0; border-top: 1px solid var(--border); background: none; color: var(--accent); text-align: left; cursor: pointer; font: inherit; }

/* Resizable columns (app.js): a line on the header edge under the mouse; sized tables clip long cells. */
th.col-resize-hover { cursor: col-resize; }
th.col-resize-hover, th.col-resize-hover * { cursor: col-resize !important; } /* also over the title button (not the hand) */
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }
table.cols-sized th, table.cols-sized td { overflow: hidden; text-overflow: ellipsis; }

/* Divider between two sections (app.js): cursor and a line on the left section's edge. */
.split.split-hover { cursor: col-resize; }
.split.split-hover > :first-child, body.split-resizing .split-sized > :first-child { box-shadow: 4px 0 0 -1px var(--accent); }
body.split-resizing, body.split-resizing * { cursor: col-resize !important; user-select: none; }
body.split-resizing iframe { pointer-events: none; } /* the PDF frame must not swallow the drag */

/* Catalog hover preview of a cabinet (app.js). */
.kast-preview {
  position: fixed; z-index: 90; width: 420px; height: 360px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .22); pointer-events: none;
}
.kast-preview[hidden] { display: none; }
.kast-preview-title { padding: 6px 10px; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kast-preview iframe { flex: 1; width: 100%; border: 0; background: #eef1f5; }

/* Phone outside Planning: view only (DeviceAccess). */
.ro .edit-only { display: none !important; }
.ro-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.ro-fieldset:disabled input, .ro-fieldset:disabled select, .ro-fieldset:disabled textarea { opacity: 1; color: var(--text); background: var(--panel-2); }

/* Mobile bottom tab bar (hidden on desktop) */
.tabbar, .more-backdrop { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; height: auto; }
  .content { padding: 14px 16px calc(78px + env(safe-area-inset-bottom)); }
  .search { width: 100%; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--sidebar); border-top: 1px solid var(--sidebar-active);
    padding: 4px 4px env(safe-area-inset-bottom);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-width: 0; height: 56px; padding: 0 2px; border: 0; border-radius: 8px; background: none;
    color: var(--sidebar-muted); font: 500 10.5px/1.2 var(--font); text-decoration: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .tab svg circle { fill: currentColor; stroke: none; }
  .tab.active { color: #fff; }
  .tab.active svg { stroke: #8fb0ff; }
  .tab.active svg circle { fill: #8fb0ff; }

  /* "Meer": the sidebar becomes a sheet above the tab bar, without the items already in the bar. */
  .sidebar { display: none; }
  .shell.more-open .sidebar {
    display: block; position: fixed; left: 0; right: 0; z-index: 55;
    bottom: calc(64px + env(safe-area-inset-bottom)); max-height: 72vh; overflow-y: auto;
    border-radius: 14px 14px 0 0; padding: 10px 10px 14px; box-shadow: 0 -8px 24px rgba(0, 0, 0, .3);
  }
  .sidebar .in-tabbar { display: none; }
  .sidebar .nav-item { padding: 10px 12px; }
  .sidebar :is(.nav-star, .nav-toggle) { display: none; } /* phones: no collapse, so no stars */
  .more-backdrop { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .35); }
}
@media print {
  .tabbar, .more-backdrop { display: none !important; }
  .sidebar, .toolbar, .page-head .btn, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; overflow: visible; }
  .grid-wrap { max-height: none !important; border: 0; }
}
