/*
 * ui/css/components.css - Windows 11 style components on top of Bootstrap 5
 * (docs/DESIGN.md). Everything is scoped to body.ui-native so Bootstrap
 * pages that don't opt in are untouched. Needs tokens.css first.
 *
 * Page types (body classes, set by lib/ui.php):
 *   nv-app     desktop layout: title bar (in shell), nav pane, scrolling content layer
 *   nv-auth    sign-in / setup / error pages, centred card, page scrolls
 *   nv-mobile  customer site: app bar, touch sizes, sticky bottom command bar
 */

/* ---------------------------------------------------------------- base */
body.ui-native {
  --bs-body-font-family: var(--nv-font);
  --bs-body-font-size: 14px;
  --bs-body-line-height: 20px;
  --bs-body-color: var(--nv-text);
  --bs-body-bg: var(--nv-bg);
  --bs-border-color: var(--nv-stroke);
  --bs-border-radius: var(--nv-radius);
  --bs-border-radius-lg: var(--nv-radius-lg);
  --bs-link-color: var(--app-accent-ink);
  --bs-link-color-rgb: var(--app-accent-rgb);
  --bs-link-hover-color: var(--nv-text);
  --bs-secondary-color: var(--nv-text-2);
  --bs-emphasis-color: var(--nv-text);
  margin: 0;
  font-family: var(--nv-font);
  font-size: 14px;
  line-height: 20px;
  color: var(--nv-text);
  background: var(--nv-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.ui-native.in-shell { padding-top: var(--nv-titlebar-h); }

/* Page changes (Phase 4): the old page stays until the new one is ready, then the content
   cross-fades; the title bar and nav pane keep their place. No white flash between pages. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .12s; }
::view-transition-group(nv-pane), ::view-transition-group(nv-titlebar) { animation-duration: 0s; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

body.ui-native h1, body.ui-native h2, body.ui-native h3,
body.ui-native .nv-display { font-family: var(--nv-font-display); font-weight: 600; color: var(--nv-text); }
body.ui-native h1 { font-size: 28px; line-height: 36px; }
body.ui-native h2 { font-size: 20px; line-height: 28px; }
body.ui-native h3 { font-size: 16px; line-height: 22px; }
body.ui-native code, body.ui-native kbd, body.ui-native pre, body.ui-native .font-monospace { font-family: var(--nv-font-mono); }
body.ui-native code { color: var(--nv-text); font-size: 13px; }
body.ui-native a { color: var(--app-accent-ink); text-underline-offset: 2px; }
body.ui-native a:hover { color: var(--nv-text); }
body.ui-native .text-secondary, body.ui-native .text-muted { color: var(--nv-text-2) !important; }
body.ui-native .small, body.ui-native small { font-size: 12px; line-height: 16px; }

/* Desktop conventions (B6 last bullet) */
/* Everything that can be clicked shows the hand (owner decision 2026-10-25, all three surfaces). */
body.ui-native :is(a[href], button, .btn, [role="button"], [data-copy], summary, select, .form-select,
  input[type="checkbox"], input[type="radio"], input[type="range"], input[type="file"], input[type="color"],
  .form-check-input + .form-check-label, label.form-check-label, .nv-pivot a) { cursor: pointer; }
body.ui-native :is(button, .btn, select, input):disabled, body.ui-native .btn.disabled { cursor: default; }
body.ui-native summary > .bi:first-child { margin: 0 6px 0 4px; }
body.ui-native .nv-pane, body.ui-native .btn, body.ui-native .nv-titlebar, body.ui-native .nv-page-header,
body.ui-native .table thead, body.ui-native .nv-chip, body.ui-native .nv-toast { user-select: none; -webkit-user-select: none; }
body.ui-native img, body.ui-native a { -webkit-user-drag: none; }
body.ui-native :focus { outline: none; }
body.ui-native :focus-visible { outline: 2px solid #000; outline-offset: 1px; box-shadow: none !important; }

/* Scroll bars (B6): thin rounded thumb, no arrows. Don't use scrollbar-width. */
body.ui-native ::-webkit-scrollbar { width: 12px; height: 12px; background: transparent; }
body.ui-native ::-webkit-scrollbar-track { background: transparent; }
body.ui-native ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .28); border-radius: 12px;
  border: 4px solid transparent; background-clip: content-box;
}
body.ui-native ::-webkit-scrollbar-thumb:hover { background-color: rgba(0, 0, 0, .45); border-width: 3px; }
body.ui-native ::-webkit-scrollbar-button { display: none; }
body.ui-native ::-webkit-scrollbar-corner { background: transparent; }

/* ---------------------------------------------------------------- title bar (client app only) */
.nv-titlebar {
  position: fixed; inset: 0 0 auto 0; z-index: 1080; height: var(--nv-titlebar-h);
  padding: 0 150px 0 12px; display: flex; align-items: center; gap: 6px;
  font: 12px/16px var(--nv-font); color: #1b1b1b; background: var(--nv-bg);
  -webkit-app-region: drag; app-region: drag; view-transition-name: nv-titlebar;
}
.nv-titlebar-app {
  display: inline-flex; align-items: center; gap: 8px; padding: 2px 6px; margin-left: -6px;
  border-radius: 4px; -webkit-app-region: no-drag; app-region: no-drag;
  border: 0; background: none; font: inherit; color: inherit;
}
.nv-titlebar-app:hover { background: rgba(0, 0, 0, .06); }
.nv-titlebar-app img { width: 16px; height: 16px; }
.nv-titlebar-sep, .nv-titlebar-doc { color: var(--nv-text-2); }
.nv-badge-tb {
  font-size: 10px; font-weight: 700; line-height: 14px; padding: 0 5px; border-radius: 3px;
  color: var(--st-warning); background: var(--st-warning-bg); letter-spacing: .02em;
}
.nv-badge-tb.is-info { color: var(--st-info); background: var(--st-info-bg); }

/* ---------------------------------------------------------------- app layout (nav pane + content) */
body.nv-app { height: 100vh; overflow: hidden; }
.nv-shell { display: flex; height: 100%; }
body.in-shell .nv-shell { height: calc(100vh - var(--nv-titlebar-h)); }

.nv-pane {
  width: var(--nv-pane-w); flex: 0 0 var(--nv-pane-w);
  display: flex; flex-direction: column; background: transparent; view-transition-name: nv-pane;
}
.nv-pane-scroll { flex: 1 1 auto; overflow-y: auto; padding: 8px 4px 8px 8px; }
.nv-account {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; margin-bottom: 8px;
  border: 0; border-radius: var(--nv-radius); background: transparent; text-align: left; color: var(--nv-text);
}
.nv-account:hover { background: var(--nv-subtle-hover); }
.nv-account:active { background: var(--nv-subtle-press); }
.nv-avatar {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 15px;
  background: var(--app-accent); color: var(--app-on-accent);
}
.nv-account-text { flex: 1 1 auto; min-width: 0; line-height: 18px; }
.nv-account-name { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-account-role { font-size: 12px; color: var(--nv-text-2); display: block; }
.nv-account .bi-chevron-down { font-size: 10px; color: var(--nv-text-2); }

.nv-nav-heading { font-size: 12px; font-weight: 600; color: var(--nv-text-2); padding: 14px 12px 6px; }
.nv-nav { list-style: none; margin: 0; padding: 0; }
.nv-nav-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  height: 36px; padding: 0 12px; margin: 2px 0; border-radius: var(--nv-radius);
  color: var(--nv-text); text-decoration: none; font-size: 14px;
}
body.ui-native .nv-nav-item { color: var(--nv-text); text-decoration: none; }
.nv-nav-item:hover { background: var(--nv-subtle-hover); color: var(--nv-text); }
.nv-nav-item:active { background: var(--nv-subtle-press); }
.nv-nav-item .bi { font-size: 16px; width: 16px; line-height: 1; }
.nv-nav-item.active { background: var(--nv-selected); font-weight: 600; }
.nv-nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 10px; width: 3px; height: 16px;
  border-radius: 2px; background: var(--app-accent-strong);
}
.nv-nav-item .nv-nav-count { margin-left: auto; font-size: 12px; font-weight: 600; }

.nv-pane-footer {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-top: 1px solid var(--nv-stroke); font-size: 12px; line-height: 16px;
}
.nv-pane-footer img { width: 28px; height: 28px; }
.nv-pane-footer strong { display: block; font-weight: 600; font-size: 13px; color: var(--nv-text); }
.nv-pane-footer span { color: var(--nv-text-3); }

.nv-content {
  flex: 1 1 auto; min-width: 0; overflow-y: auto; position: relative;
  background: var(--nv-layer); border-top: 1px solid var(--nv-stroke); border-left: 1px solid var(--nv-stroke);
  border-top-left-radius: var(--nv-radius-lg);
}
.nv-page { padding: 28px 36px 36px; max-width: 1440px; }

/* .btn.nv-hamburger: must beat "body.ui-native .btn { display: inline-flex }" further down. */
body.ui-native .btn.nv-hamburger { display: none; }
@media (max-width: 991.98px) {
  .nv-pane.offcanvas-lg { background: var(--nv-bg); width: var(--nv-pane-w); }
  .nv-content { border-left: 0; border-top-left-radius: 0; }
  .nv-page { padding: 20px 16px 28px; }
  body.ui-native .btn.nv-hamburger { display: inline-flex; }
}
@media (min-width: 992px) {
  .nv-pane.offcanvas-lg { position: static; visibility: visible; transform: none; background: transparent; }
}
/* Narrow desktop windows (Phase 4): the pane shrinks to icons, like Windows 11's compact
   NavigationView, so tables keep their columns. Labels show as tooltips (title). */
@media (min-width: 992px) and (max-width: 1199.98px) {
  body.nv-app { --nv-pane-w: 60px; }
  body.nv-app .nv-pane-scroll { padding: 8px 6px; }
  body.nv-app .nv-nav-item { justify-content: center; gap: 0; padding: 0; }
  body.nv-app .nv-nav-item > span:not(.nv-nav-count) { display: none; }
  body.nv-app .nv-nav-item .nv-nav-count { position: absolute; top: 1px; right: 1px; margin: 0; padding: 0 4px; font-size: 10px; line-height: 14px; }
  body.nv-app .nv-nav-heading { font-size: 0; line-height: 0; padding: 0; margin: 10px 6px 8px; border-top: 1px solid var(--nv-stroke); }
  body.nv-app .nv-account { justify-content: center; padding: 4px 0; }
  body.nv-app .nv-account-text, body.nv-app .nv-account .bi-chevron-down { display: none; }
  body.nv-app .nv-pane-footer { justify-content: center; padding: 12px 0; }
  body.nv-app .nv-pane-footer > div { display: none; }
}

/* Breadcrumb + page header (B4) */
.nv-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 14px; color: var(--nv-text-2); }
.nv-breadcrumb a { color: var(--nv-text-2); text-decoration: none; }
.nv-breadcrumb a:hover { color: var(--nv-text); text-decoration: underline; }
.nv-breadcrumb .bi { font-size: 10px; }
.nv-breadcrumb .current { color: var(--nv-text); }
.nv-page-header { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 24px; margin-bottom: 24px; }
.nv-page-header-text { flex: 1 1 auto; min-width: 0; }
.nv-page-title { margin: 0; font: 600 28px/36px var(--nv-font-display); }
.nv-page-subtitle { margin: 2px 0 0; color: var(--nv-text-2); }
.nv-page-commands { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- buttons (B6) */
body.ui-native .btn {
  --bs-btn-padding-x: 12px; --bs-btn-padding-y: 0; --bs-btn-font-size: 14px; --bs-btn-font-weight: 400;
  --bs-btn-line-height: 20px; --bs-btn-border-radius: var(--nv-radius); --bs-btn-box-shadow: none;
  --bs-btn-focus-box-shadow: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 32px; white-space: nowrap; box-shadow: none; transition: background-color .08s, color .08s;
}
body.ui-native .btn .bi { font-size: 16px; line-height: 1; }
body.ui-native .btn-sm { height: 28px; --bs-btn-padding-x: 10px; --bs-btn-font-size: 13px; }
body.ui-native .btn-lg { height: 40px; --bs-btn-padding-x: 16px; --bs-btn-font-size: 15px; }

/* Standard */
body.ui-native .btn-default, body.ui-native .btn-secondary, body.ui-native .btn-outline-secondary {
  color: var(--nv-text); background: var(--nv-control);
  border: 1px solid var(--nv-control-border); border-bottom-color: var(--nv-control-border-bottom);
}
body.ui-native .btn-default:hover, body.ui-native .btn-secondary:hover, body.ui-native .btn-outline-secondary:hover {
  color: var(--nv-text); background: var(--nv-control-hover); border-color: var(--nv-control-border); border-bottom-color: var(--nv-control-border-bottom);
}
body.ui-native .btn-default:active, body.ui-native .btn-secondary:active, body.ui-native .btn-outline-secondary:active,
body.ui-native .btn-default.active, body.ui-native .btn-secondary.active {
  color: var(--nv-text-2); background: var(--nv-control-press); border-color: var(--nv-control-border);
}

/* Primary = accent. Text colour comes from --app-on-accent (never white on yellow). */
body.ui-native .btn-primary {
  color: var(--app-on-accent); background: var(--app-accent);
  border: 1px solid rgba(255, 255, 255, .08); border-bottom-color: rgba(0, 0, 0, .25);
}
body.ui-native .btn-primary:hover { color: var(--app-on-accent); background: var(--app-accent-hover); border-color: rgba(255, 255, 255, .08); border-bottom-color: rgba(0, 0, 0, .25); }
body.ui-native .btn-primary:active, body.ui-native .btn-primary.active { color: var(--app-on-accent); background: var(--app-accent-active); border-color: transparent; }

/* Brand green call to action (customer site) */
body.ui-native .btn-green {
  color: #fff; background: var(--brand-green);
  border: 1px solid rgba(255, 255, 255, .08); border-bottom-color: rgba(0, 0, 0, .4);
}
body.ui-native .btn-green:hover { color: #fff; background: var(--brand-green-hover); }
body.ui-native .btn-green:active { color: rgba(255, 255, 255, .8); background: #085d14; }

body.ui-native .btn-danger {
  color: #fff; background: var(--st-danger);
  border: 1px solid rgba(255, 255, 255, .08); border-bottom-color: rgba(0, 0, 0, .4);
}
body.ui-native .btn-danger:hover { color: #fff; background: #b02417; }
body.ui-native .btn-danger:active { color: rgba(255, 255, 255, .8); background: #9b2014; }

/* Subtle: transparent until hover */
body.ui-native .btn-subtle, body.ui-native .btn-light, body.ui-native .btn-link {
  color: var(--nv-text); background: transparent; border: 1px solid transparent; text-decoration: none;
}
body.ui-native .btn-subtle:hover, body.ui-native .btn-light:hover { background: var(--nv-subtle-hover); color: var(--nv-text); }
body.ui-native .btn-subtle:active, body.ui-native .btn-light:active { background: var(--nv-subtle-press); color: var(--nv-text-2); }
body.ui-native .btn-link { color: var(--app-accent-ink); }
body.ui-native .btn-icon { width: 32px; padding: 0; }
body.ui-native .btn-sm.btn-icon { width: 28px; }

body.ui-native .btn:disabled, body.ui-native .btn.disabled {
  color: var(--nv-disabled-text); background: var(--nv-control-press);
  border-color: var(--nv-control-border); opacity: 1;
}
body.ui-native .btn-subtle:disabled, body.ui-native .btn-light:disabled { background: transparent; border-color: transparent; }
/* Busy button: same size and colours, label replaced by a spinner, no more clicks. */
body.ui-native .btn.nv-busy { justify-content: center; pointer-events: none; cursor: progress; }
body.ui-native .btn.nv-busy .nv-spinner { margin: 0; }
body.ui-native .btn.nv-busy:disabled { color: inherit; }

/* Toggle-button groups (selected = accent) */
body.ui-native .btn-check:checked + .btn, body.ui-native .btn-check + .btn.active {
  color: var(--app-on-accent); background: var(--app-accent); border-color: rgba(0, 0, 0, .08); border-bottom-color: rgba(0, 0, 0, .25);
}
body.ui-native .btn-check:focus-visible + .btn { outline: 2px solid #000; outline-offset: 1px; }

/* ---------------------------------------------------------------- inputs (B6) */
body.ui-native .form-control, body.ui-native .form-select {
  height: 32px; padding: 5px 10px; font-size: 14px; line-height: 20px; color: var(--nv-text);
  background-color: var(--nv-input-bg); border: 1px solid var(--nv-control-border);
  border-bottom-color: var(--nv-input-border-bottom); border-radius: var(--nv-radius); box-shadow: none;
}
body.ui-native .form-select { padding-right: 32px; background-position: right 10px center; }
body.ui-native textarea.form-control { height: auto; min-height: 64px; }
body.ui-native .form-control:hover, body.ui-native .form-select:hover { background-color: var(--nv-control-hover); }
body.ui-native .form-control:focus, body.ui-native .form-select:focus {
  background-color: #fff; border-color: var(--nv-control-border);
  border-bottom: 2px solid var(--app-accent-strong); padding-bottom: 4px; box-shadow: none; outline: none;
}
body.ui-native .form-control::placeholder { color: var(--nv-text-3); }
body.ui-native .form-control:disabled, body.ui-native .form-select:disabled {
  color: var(--nv-disabled-text); background-color: rgba(249, 249, 249, .3); border-bottom-color: var(--nv-control-border);
}
body.ui-native .form-control.is-invalid, body.ui-native .was-validated .form-control:invalid,
body.ui-native .form-select.is-invalid {
  border-color: var(--nv-control-border); border-bottom: 2px solid var(--st-danger); padding-bottom: 4px; background-image: none;
}
body.ui-native .invalid-feedback { font-size: 12px; color: var(--st-danger); margin-top: 4px; }
body.ui-native .form-label { font-size: 14px; font-weight: 400; margin-bottom: 6px; color: var(--nv-text); }
body.ui-native .form-text { font-size: 12px; line-height: 16px; color: var(--nv-text-2); margin-top: 4px; }
body.ui-native .input-group-text { background: var(--nv-control-press); border-color: var(--nv-control-border); color: var(--nv-text-2); font-size: 14px; }

/* File input: grey "Choose file" segment */
body.ui-native .form-control[type="file"] { padding: 0 10px 0 0; line-height: 30px; }
body.ui-native .form-control[type="file"]::file-selector-button {
  height: 30px; margin: 0 10px 0 0; padding: 0 12px; border: 0; border-right: 1px solid var(--nv-control-border);
  background: #f6f6f6; color: var(--nv-text);
}

/* Checkboxes, radios (20px), toggle switches (40x20) */
body.ui-native .form-check { min-height: 20px; padding-left: 28px; margin-bottom: 8px; }
body.ui-native .form-check-input {
  width: 20px; height: 20px; margin-top: 0; margin-left: -28px;
  background-color: rgba(0, 0, 0, .0241); border: 1px solid rgba(0, 0, 0, .4466); box-shadow: none;
}
body.ui-native .form-check-input[type="checkbox"] { border-radius: 4px; }
body.ui-native .form-check-input:hover { background-color: rgba(0, 0, 0, .0578); }
body.ui-native .form-check-input:checked { background-color: var(--app-accent-strong); border-color: var(--app-accent-strong); }
body.ui-native .form-check-label { line-height: 20px; }
body.ui-native .form-switch { padding-left: 52px; }
body.ui-native .form-switch .form-check-input {
  width: 40px; height: 20px; margin-left: -52px; border-radius: 10px;
  background-color: transparent; border-color: rgba(0, 0, 0, .6);
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2.4' fill='rgba(0,0,0,.62)'/%3e%3c/svg%3e");
}
body.ui-native .form-switch .form-check-input:checked {
  background-color: var(--app-accent-strong); border-color: var(--app-accent-strong);
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2.8' fill='%23fff'/%3e%3c/svg%3e");
}

/* Password field with an eye button (app.js wires [data-password-toggle]) */
.nv-password { position: relative; }
.nv-password .form-control { padding-right: 40px; }
.nv-password [data-password-toggle] {
  position: absolute; right: 2px; top: 2px; width: 28px; height: 28px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: var(--nv-radius); background: transparent; color: var(--nv-text-2);
}
body.nv-mobile .nv-password [data-password-toggle] { top: 8px; }
.nv-password [data-password-toggle]:hover { background: var(--nv-subtle-hover); }

/* OTP: 6 separate 40px boxes (app.js [data-otp]) */
.nv-otp { display: flex; gap: 8px; justify-content: center; }
body.ui-native .nv-otp input {
  width: 40px; height: 48px; padding: 0; text-align: center;
  font: 600 20px/1 var(--nv-font-display); font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- dropdowns / flyouts */
body.ui-native .dropdown-menu {
  --bs-dropdown-bg: var(--nv-layer); --bs-dropdown-border-color: var(--nv-stroke-strong);
  --bs-dropdown-border-radius: var(--nv-radius-lg); --bs-dropdown-padding-y: 4px; --bs-dropdown-padding-x: 4px;
  --bs-dropdown-font-size: 14px; --bs-dropdown-link-color: var(--nv-text);
  --bs-dropdown-link-hover-bg: var(--nv-subtle-hover); --bs-dropdown-link-active-bg: var(--nv-subtle-press);
  --bs-dropdown-link-active-color: var(--nv-text); --bs-dropdown-item-padding-x: 10px; --bs-dropdown-item-padding-y: 6px;
  box-shadow: var(--nv-shadow-flyout); min-width: 200px;
}
body.ui-native .dropdown-item { display: flex; align-items: center; gap: 12px; border-radius: var(--nv-radius); }
body.ui-native .dropdown-item .bi { font-size: 16px; width: 16px; }
body.ui-native .dropdown-item.text-danger:hover { color: var(--st-danger); }
body.ui-native .dropdown-divider { margin: 4px -4px; border-color: var(--nv-stroke); }
body.ui-native .dropdown-header { font-size: 12px; color: var(--nv-text-2); padding: 6px 10px; }

/* ---------------------------------------------------------------- cards */
body.ui-native .card {
  --bs-card-bg: var(--nv-card); --bs-card-border-color: var(--nv-stroke); --bs-card-border-radius: var(--nv-radius-lg);
  --bs-card-inner-border-radius: 7px; --bs-card-cap-bg: transparent; --bs-card-cap-padding-y: 12px; --bs-card-cap-padding-x: 16px;
  --bs-card-spacer-y: 16px; --bs-card-spacer-x: 16px; box-shadow: none;
}
body.ui-native .card-header { font-weight: 600; border-bottom: 1px solid var(--nv-stroke); display: flex; align-items: center; gap: 8px; }
body.ui-native .card-header .nv-card-commands { margin-left: auto; display: flex; gap: 8px; }
body.ui-native .card-footer { background: transparent; border-top: 1px solid var(--nv-stroke); }

/* Form cards: sections + sticky command bar */
.nv-form-card { background: var(--nv-card); border: 1px solid var(--nv-stroke); border-radius: var(--nv-radius-lg); }
.nv-form-section { padding: 20px 24px; border-top: 1px solid var(--nv-stroke); }
.nv-form-section:first-child { border-top: 0; }
.nv-section-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.nv-section-icon {
  flex: 0 0 32px; width: 32px; height: 32px; border-radius: var(--nv-radius);
  display: grid; place-items: center; background: var(--app-accent-soft); color: var(--app-accent-ink); font-size: 16px;
}
.nv-section-title { font-size: 16px; line-height: 22px; font-weight: 600; margin: 0; }
.nv-section-desc { font-size: 12px; line-height: 16px; color: var(--nv-text-2); margin: 2px 0 0; }
.nv-command-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; align-items: center;
  padding: 12px 24px; border-top: 1px solid var(--nv-stroke);
  border-bottom-left-radius: var(--nv-radius-lg); border-bottom-right-radius: var(--nv-radius-lg);
  background: rgba(243, 243, 243, .92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.nv-command-bar .nv-command-end { margin-left: auto; display: flex; gap: 8px; }

/* ---------------------------------------------------------------- tables */
body.ui-native .table {
  --bs-table-bg: transparent; --bs-table-color: var(--nv-text); --bs-table-border-color: var(--nv-stroke);
  --bs-table-hover-bg: rgba(0, 0, 0, .024); --bs-table-hover-color: var(--nv-text);
  --bs-table-striped-bg: #fafafa; font-size: 14px; margin-bottom: 0;
}
body.ui-native .table > :not(caption) > * > * { padding: 9px 12px; border-bottom-color: var(--nv-stroke); }
body.ui-native .table thead th {
  position: sticky; top: 0; z-index: 1; background: #fbfbfb;
  font-size: 12px; font-weight: 600; color: var(--nv-text-2); text-transform: none; white-space: nowrap;
}
body.ui-native .table tbody tr:last-child > * { border-bottom: 0; }
body.ui-native .table .nv-num { text-align: right; font-variant-numeric: tabular-nums; }
body.ui-native .table .nv-empty { color: var(--nv-text-3); }
.nv-table-card { overflow: auto; }

/* Width helpers (pages run under a CSP that forbids style="" attributes) */
.nv-w-search { width: 100%; max-width: 280px; }
.nv-w-xs { width: 100%; max-width: 120px; }
.nv-w-sm { width: 100%; max-width: 200px; }
.nv-w-md { width: 100%; max-width: 360px; }
/* nv-w-* are for form fields: on a table cell "width: 100%" makes that column eat the table.
   For long text in a cell use <div class="nv-ellipsis"> (one line, "…", full text in title). */
td[class*="nv-w-"], th[class*="nv-w-"] { width: auto; }
.nv-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.nv-ellipsis.is-sm { max-width: 220px; }
.nv-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 420px; }
.nv-mw-720 { max-width: 720px; }
.nv-prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.nv-hours input[type="time"] { min-width: 112px; }
/* A checkbox alone in a table cell (Opening hours "Closed"): centred on the row, no form-check offset. */
body.ui-native td > .form-check-input:only-child { float: none; margin: 0; vertical-align: middle; }
.nv-hours th:last-child, .nv-hours td:last-child { width: 1%; text-align: center; white-space: nowrap; }
.nv-qr { width: 100%; max-width: 220px; aspect-ratio: 1; display: block; }
.nv-qr svg { width: 100%; height: 100%; display: block; }
.nv-secret {
  font-family: var(--nv-font-mono); font-size: 13px; word-break: break-all; padding: 8px 10px;
  background: var(--nv-control-press); border: 1px solid var(--nv-stroke); border-radius: var(--nv-radius);
}
.nv-kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px 16px; margin: 0; }
.nv-kv dt { font-weight: 400; color: var(--nv-text-2); }
.nv-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.nv-timeline { list-style: none; margin: 0; padding: 0; }
.nv-timeline li { position: relative; padding: 0 0 14px 22px; }
.nv-timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--nv-text-3); }
.nv-timeline li::after { content: ""; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--nv-stroke-strong); }
.nv-timeline li:last-child::after { display: none; }

/* ---------------------------------------------------------------- status chips (InfoBadge) */
.nv-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: var(--nv-radius);
  font-size: 12px; line-height: 16px; font-weight: 600; white-space: nowrap;
  color: var(--st-muted); background: var(--st-muted-bg);
}
.nv-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 6px; }
.nv-chip.no-dot::before { display: none; }
.nv-chip.is-success { color: var(--st-success); background: var(--st-success-bg); }
.nv-chip.is-warning { color: var(--st-warning); background: var(--st-warning-bg); }
.nv-chip.is-danger  { color: var(--st-danger);  background: var(--st-danger-bg); }
.nv-chip.is-info    { color: var(--st-info);    background: var(--st-info-bg); }
.nv-chip.is-purple  { color: var(--st-purple);  background: var(--st-purple-bg); }
.nv-chip.is-accent  { color: var(--app-accent-ink); background: var(--app-accent-soft); }

/* ---------------------------------------------------------------- stat tiles */
.nv-stat {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px;
  background: var(--nv-card); border: 1px solid var(--nv-stroke); border-radius: var(--nv-radius-lg);
}
.nv-stat-icon {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: var(--nv-radius);
  display: grid; place-items: center; font-size: 20px; background: var(--app-accent-soft); color: var(--app-accent-ink);
}
.nv-stat-icon.is-success { background: var(--st-success-bg); color: var(--st-success); }
.nv-stat-icon.is-danger  { background: var(--st-danger-bg);  color: var(--st-danger); }
.nv-stat-icon.is-info    { background: var(--st-info-bg);    color: var(--st-info); }
.nv-stat-icon.is-warning { background: var(--st-warning-bg); color: var(--st-warning); }
.nv-stat-label { font-size: 12px; line-height: 16px; color: var(--nv-text-2); }
.nv-stat-value { font: 600 28px/36px var(--nv-font-display); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- InfoBars */
.nv-infobar {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 16px;
  border: 1px solid var(--nv-stroke); border-radius: var(--nv-radius);
  background: var(--st-info-bg); color: var(--nv-text);
}
.nv-infobar > .bi { font-size: 16px; line-height: 20px; color: var(--st-info); flex: 0 0 16px; }
.nv-infobar-body { flex: 1 1 auto; min-width: 0; }
.nv-infobar-title { font-weight: 600; margin-right: 6px; }
.nv-infobar-actions { display: flex; gap: 8px; margin-left: auto; align-self: center; }
.nv-infobar.is-success { background: var(--st-success-bg); } .nv-infobar.is-success > .bi { color: var(--st-success); }
.nv-infobar.is-warning { background: var(--st-warning-bg); } .nv-infobar.is-warning > .bi { color: var(--st-warning); }
.nv-infobar.is-danger  { background: var(--st-danger-bg); }  .nv-infobar.is-danger > .bi  { color: var(--st-danger); }

/* ---------------------------------------------------------------- dialogs (ContentDialog) */
.nv-dialog-backdrop {
  position: fixed; inset: 0; z-index: 1090; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .3); animation: nv-fade .15s ease-out;
}
.nv-dialog {
  width: min(448px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--nv-layer); border: 1px solid var(--nv-stroke-strong); border-radius: var(--nv-radius-lg);
  box-shadow: var(--nv-shadow-dialog); overflow: hidden; animation: nv-dialog-in .2s cubic-bezier(.1, .9, .2, 1);
}
.nv-dialog-body { padding: 24px; overflow-y: auto; background: var(--nv-card); }
.nv-dialog-title { margin: 0 0 12px; font: 600 20px/28px var(--nv-font-display); }
.nv-dialog-message { color: var(--nv-text); white-space: pre-line; }
.nv-dialog-footer { display: flex; gap: 8px; padding: 24px; background: var(--nv-bg); border-top: 1px solid var(--nv-stroke); }
.nv-dialog-footer .btn { flex: 1 1 0; min-width: 120px; }
.nv-sheet-handle { display: none; }
@keyframes nv-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nv-dialog-in { from { opacity: 0; transform: scale(1.05); } to { opacity: 1; transform: none; } }
@keyframes nv-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@media (max-width: 575.98px) {
  /* Dialogs become bottom sheets on phones (A4) */
  .nv-dialog-backdrop { place-items: end stretch; padding: 0; }
  .nv-dialog {
    width: 100%; border-radius: var(--nv-radius-lg) var(--nv-radius-lg) 0 0; border-bottom: 0;
    animation: nv-sheet-in .24s cubic-bezier(.1, .9, .2, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nv-sheet-handle { display: block; width: 36px; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, .2); margin: 8px auto 0; }
  .nv-dialog-body { padding: 16px 20px 20px; }
  .nv-dialog-footer { padding: 16px 20px; flex-direction: column-reverse; }
  .nv-dialog-footer .btn { width: 100%; height: var(--touch-h); }
}

/* ---------------------------------------------------------------- toasts */
.nv-toasts {
  position: fixed; top: 12px; right: 12px; z-index: 1100; width: min(380px, calc(100vw - 2rem));
  display: flex; flex-direction: column; gap: .6rem; pointer-events: none;
}
body.in-shell .nv-toasts { top: 44px; }
.nv-toast {
  position: relative; overflow: hidden; pointer-events: auto; display: flex; gap: 12px; padding: 14px 12px 14px 16px;
  background: var(--nv-layer); border: 1px solid var(--nv-stroke-strong); border-radius: var(--nv-radius-lg);
  box-shadow: var(--nv-shadow-flyout); animation: nv-toast-in .28s cubic-bezier(.1, .9, .2, 1);
}
.nv-toast.is-leaving { animation: nv-toast-out .2s ease-in forwards; }
.nv-toast > .bi { font-size: 16px; line-height: 20px; flex: 0 0 16px; }
.nv-toast.is-success > .bi { color: var(--st-success); }
.nv-toast.is-danger > .bi  { color: var(--st-danger); }
.nv-toast.is-warning > .bi { color: var(--st-warning); }
.nv-toast.is-info > .bi    { color: var(--st-info); }
.nv-toast-body { flex: 1 1 auto; min-width: 0; }
.nv-toast-title { font-weight: 600; }
.nv-toast-message { color: var(--nv-text-2); overflow-wrap: anywhere; }
.nv-toast-actions { display: flex; gap: 8px; margin-top: 10px; }
.nv-toast-close {
  flex: 0 0 28px; width: 28px; height: 28px; margin: -4px -2px 0 0; border: 0; border-radius: var(--nv-radius);
  background: transparent; color: var(--nv-text-2); display: grid; place-items: center;
}
.nv-toast-close:hover { background: var(--nv-subtle-hover); }
.nv-toast-progress {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; transform-origin: left;
  background: currentColor; opacity: .55;
}
.nv-toast.is-success .nv-toast-progress { color: var(--st-success); }
.nv-toast.is-danger .nv-toast-progress  { color: var(--st-danger); }
.nv-toast.is-warning .nv-toast-progress { color: var(--st-warning); }
.nv-toast.is-info .nv-toast-progress    { color: var(--st-info); }
@keyframes nv-toast-in { from { opacity: 0; transform: translateX(110%); } to { opacity: 1; transform: none; } }
@keyframes nv-toast-out { to { opacity: 0; transform: translateX(110%); } }

/* ---------------------------------------------------------------- busy feedback (B7) */
.nv-spinner {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, .15); border-top-color: currentColor; animation: nv-spin .8s linear infinite;
}
.nv-ring {
  display: inline-block; width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, .08); border-top-color: var(--app-accent-strong); animation: nv-spin .8s linear infinite;
}
.nv-ring.is-24 { width: 24px; height: 24px; }
@keyframes nv-spin { to { transform: rotate(360deg); } }

.nv-progress {
  position: fixed; left: 0; right: 0; top: 0; z-index: 1110; height: 3px; overflow: hidden; pointer-events: none;
  opacity: 0; transition: opacity .15s;
}
body.in-shell .nv-progress { top: var(--nv-titlebar-h); }
.nv-progress.is-on { opacity: 1; transition: none; }
/* Next page after a busy click: the bar sweeps to the end, then fades (app.js busyFinish). */
.nv-progress.is-finishing { transition: opacity .3s; }
.nv-progress.is-finishing::before { animation: nv-progress-finish .3s ease-out forwards; }
@keyframes nv-progress-finish { from { left: 0; width: 40%; } to { left: 0; width: 100%; } }
.nv-progress::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -40%;
  background: var(--app-accent-strong); animation: nv-progress 1.1s ease-in-out infinite;
}
@keyframes nv-progress { from { left: -40%; } to { left: 100%; } }
body.nv-busy, body.nv-busy * { cursor: progress !important; }

/* Live print progress (app.js): width set from data-done/total/rate, never from style="". */
.nv-live-progress { position: relative; height: 6px; margin-top: 6px; border-radius: 3px; background: rgba(0, 0, 0, .08); overflow: hidden; max-width: 320px; }
.nv-live-progress-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: var(--app-accent-strong); }
@media (prefers-reduced-motion: reduce) { .nv-live-progress-fill { transition: none !important; } }

.nv-working {
  position: fixed; left: 50%; bottom: 24px; z-index: 1105; transform: translateX(-50%);
  display: flex; gap: 14px; align-items: center; width: min(440px, calc(100vw - 32px)); padding: 14px 18px;
  background: var(--nv-layer); border: 1px solid var(--nv-stroke-strong); border-radius: var(--nv-radius-lg);
  box-shadow: var(--nv-shadow-flyout); animation: nv-fade .2s ease-out;
}
.nv-working-title { font-weight: 600; }
.nv-working-detail { font-size: 12px; line-height: 16px; color: var(--nv-text-2); }

/* ---------------------------------------------------------------- sign-in / setup / error pages (B12) */
body.nv-auth { min-height: 100vh; overflow-y: auto; }
.nv-auth-wrap { max-width: 440px; margin: 0 auto; padding: 56px 16px 32px; }
.nv-auth-wrap.is-wide { max-width: 780px; }
.nv-auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.nv-auth-brand img { width: 48px; height: 48px; }
.nv-auth-brand-name { font: 600 20px/26px var(--nv-font-display); }
.nv-auth-brand-sub { font-size: 12px; color: var(--nv-text-2); }
.nv-auth-card {
  padding: 28px; background: var(--nv-card); border: 1px solid var(--nv-stroke);
  border-radius: var(--nv-radius-lg); box-shadow: 0 8px 16px rgba(0, 0, 0, .06);
}
.nv-auth-title { margin: 0 0 6px; font: 600 24px/32px var(--nv-font-display); }
.nv-auth-lead { color: var(--nv-text-2); margin-bottom: 20px; }
.nv-auth-footer { margin-top: 20px; text-align: center; font-size: 12px; color: var(--nv-text-3); }

/* ---------------------------------------------------------------- customer site (A4, mobile first) */
body.nv-mobile { min-height: 100vh; overflow-y: auto; }
body.nv-mobile .btn { height: var(--touch-h); --bs-btn-padding-x: 16px; --bs-btn-font-size: 15px; }
body.nv-mobile .btn-primary, body.nv-mobile .btn-green { height: var(--touch-h-primary); font-weight: 600; }
body.nv-mobile .btn-sm { height: 36px; }
body.nv-mobile .form-control, body.nv-mobile .form-select { height: var(--touch-h); font-size: 16px; } /* 16px: no iOS zoom */
/* Toasts sit below the app bar (and the TEST MODE banner); same 380 px card as on desktop,
   only phones get the full width minus a gutter, sliding down instead of in from the side. */
body.nv-mobile .nv-toasts { top: calc(var(--nv-appbar-h) + 8px); }
body.nv-mobile:has(.nv-test-banner) .nv-toasts { top: calc(var(--nv-appbar-h) + 36px); }
@media (max-width: 575.98px) {
  body.nv-mobile .nv-toasts { left: 8px; right: 8px; width: auto; }
  body.nv-mobile .nv-toast { animation-name: nv-toast-drop; }
  body.nv-mobile .nv-toast.is-leaving { animation-name: nv-toast-lift; }
}
@keyframes nv-toast-drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes nv-toast-lift { to { opacity: 0; transform: translateY(-12px); } }

.nv-appbar {
  position: sticky; top: 0; z-index: 1030; height: var(--nv-appbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: rgba(243, 243, 243, .92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--nv-stroke);
}
.nv-appbar img { width: 32px; height: 32px; }
.nv-appbar-text { min-width: 0; line-height: 18px; }
.nv-appbar-org { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nv-appbar-atm { font-size: 12px; color: var(--nv-text-2); display: flex; align-items: center; gap: 6px; }
.nv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--nv-text-3); display: inline-block; }
.nv-dot.is-success { background: var(--st-success); }
.nv-dot.is-danger { background: var(--st-danger); }
.nv-dot.is-warning { background: #d89a00; }

.nv-mobile-page { max-width: 600px; margin: 0 auto; padding: 16px 16px 120px; }
@media (min-width: 768px) { .nv-mobile-page { max-width: 720px; padding-top: 24px; } }
.nv-list-row { min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 8px 0; }

.nv-bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(243, 243, 243, .92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid var(--nv-stroke);
}
.nv-bottom-bar-price { flex: 1 1 auto; min-width: 0; line-height: 18px; }
.nv-bottom-bar-price strong { display: block; font: 600 20px/26px var(--nv-font-display); }
.nv-bottom-bar-price span { font-size: 12px; color: var(--nv-text-2); }
.nv-bottom-bar .btn { flex: 0 0 auto; min-width: 140px; }

.nv-test-banner {
  background: var(--st-warning-bg); color: var(--st-warning); text-align: center;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; padding: 4px 8px;
}

@media (prefers-reduced-motion: reduce) {
  .nv-toast, .nv-dialog, .nv-dialog-backdrop, .nv-working { animation: none; }
  .nv-progress::before { animation-duration: 2.4s; }
}

/* Selector bar (Windows 11 SelectorBar): a page's tabs as plain links, the current one underlined. */
.nv-pivot { display: flex; gap: 4px; margin: 0 0 20px; border-bottom: 1px solid var(--nv-stroke-strong); overflow-x: auto; scrollbar-width: none; }
body.ui-native .nv-pivot a { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px 10px; color: var(--nv-text-2); text-decoration: none;
  font-weight: 600; white-space: nowrap; border-radius: var(--nv-radius) var(--nv-radius) 0 0; }
body.ui-native .nv-pivot a .bi { font-size: 16px; width: 16px; line-height: 1; text-align: center; }
body.ui-native .nv-pivot a:hover { color: var(--nv-text); background: var(--nv-subtle-hover); }
body.ui-native .nv-pivot a[aria-current="page"] { color: var(--nv-text); }
body.ui-native .nv-pivot a[aria-current="page"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 2px; background: var(--app-accent); }

@media print {
  .nv-pane, .nv-titlebar, .nv-toasts, .nv-progress, .nv-working, .nv-command-bar, .nv-bottom-bar, .nv-appbar { display: none !important; }
  body.nv-app { height: auto; overflow: visible; }
  .nv-content { overflow: visible; border: 0; background: #fff; }
}
