/*
 * SIG Inventory — Global Styles (v1.1)
 *
 * Loaded after Tailwind. Defines:
 *   - body / typography defaults
 *   - focus ring (emerald, always visible on keyboard)
 *   - scrollbar styling (subtle, on-surface)
 *   - reusable component classes that complement Tailwind utilities:
 *       .card, .card--inset, .panel, .input, .input--sm, .select,
 *       .btn / .btn--<variant>, .icon-btn, .nav-item / .nav-item--active,
 *       .pill / .pill--<status>, .role / .role--<role>, .kbd, .skel,
 *       .data-table (sticky header, hover, sort markers),
 *       .filter-chip, .metric-card, .bar
 *
 * All visual decisions are token-driven. No raw hex values appear here.
 */

/* ───────────────────────────── Base reset ───────────────────────────── */

html {
  background: rgb(var(--canvas-deep));
  /* Respect browser zoom and user font-size preferences — do not pin a px root. */
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgb(var(--brand-500) / 0.06), transparent 50%),
    radial-gradient(ellipse 80% 50% at 100% 0%, rgb(var(--info) / 0.04), transparent 45%),
    linear-gradient(180deg, rgb(var(--canvas-deep)) 0%, rgb(var(--canvas)) 40%, rgb(var(--canvas)) 100%);
  color: rgb(var(--text-secondary));
  min-height: 100vh;
  font-family:
    'Inter',
    ui-sans-serif,
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  color: rgb(var(--text-primary));
  letter-spacing: -0.01em;
}

::selection {
  background: rgb(var(--brand-500) / 0.35);
  color: rgb(var(--text-primary));
}

hr {
  border: 0;
  border-top: 1px solid rgb(var(--border-subtle));
}

/* ─────────────────────────── Focus visibility ──────────────────────── */

*:focus { outline: none; }

*:focus-visible {
  outline: 2px solid rgb(var(--brand-500));
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.input:focus-visible {
  outline: none;
  border-color: rgb(var(--brand-500));
  box-shadow: 0 0 0 3px rgb(var(--brand-500) / 0.18);
}

/* ────────────────────────────── Scrollbar ──────────────────────────── */

* {
  scrollbar-width: thin;
  scrollbar-color: rgb(var(--border)) transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgb(var(--border));
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: var(--radius-full);
}
*::-webkit-scrollbar-thumb:hover {
  background: rgb(var(--border-strong));
  background-clip: padding-box;
}

/* ───────────────────────────── Typography helpers ───────────────────── */

.font-mono,
code, kbd, .mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-feature-settings: 'zero', 'ss01';
}

.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum', 'cv11';
}

.overline {
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgb(var(--text-muted));
}

/* ───────────────────────────── Surfaces ────────────────────────────── */

.card {
  /* min-width:0 lets a card shrink inside a grid/flex column instead of
     forcing the column (and its siblings) wider than the viewport. Overflow
     stays default (visible) so popovers/dropdowns anchored inside a card
     aren't clipped; components that need edge-to-edge clipping (e.g. the
     companies table card) opt in explicitly via `overflow-hidden`. */
  min-width: 0;
  background: linear-gradient(
    165deg,
    rgb(var(--surface-1-top) / 0.55) 0%,
    rgb(var(--surface-1)) 38%,
    rgb(var(--surface-1)) 100%
  );
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.card--lg { border-radius: var(--radius-card); }
.card--padded { padding: var(--space-6); }

/* Inset section inside a card: subtler bg, no border. */
.card-inset {
  background: rgb(var(--surface-2));
  border-radius: var(--radius-sm);
}

.divider { height: 1px; width: 100%; background: rgb(var(--border)); }
.divider--subtle { background: rgb(var(--border-subtle)); }

/* ───────────────────────────── Buttons ─────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: rgb(var(--text-primary));
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition:
    background-color var(--motion-fast) var(--ease-out),
    border-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--xs { height: 24px; padding: 0 8px;  font-size: 12px; }
.btn--sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn--lg { height: 40px; padding: 0 16px; font-size: 14px; }
.btn--xl { height: 44px; padding: 0 18px; font-size: 14px; }

.btn--primary {
  background: linear-gradient(180deg, rgb(var(--brand-500)) 0%, rgb(var(--brand-600)) 100%);
  color: rgb(var(--text-on-brand));
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgb(255 255 255 / 0.08);
}
.btn--primary:hover  {
  background: linear-gradient(180deg, rgb(var(--brand-400)) 0%, rgb(var(--brand-500)) 100%);
}
.btn--primary:active {
  background: linear-gradient(180deg, rgb(var(--brand-600)) 0%, rgb(var(--brand-700)) 100%);
}

.btn--secondary {
  background: rgb(var(--surface-2));
  border-color: rgb(var(--border));
  color: rgb(var(--text-primary));
}
.btn--secondary:hover {
  background: rgb(var(--surface-1));
  border-color: rgb(var(--border-strong));
}

.btn--outline {
  border-color: rgb(var(--border));
  color: rgb(var(--text-primary));
}
.btn--outline:hover {
  background: rgb(var(--surface-2));
  border-color: rgb(var(--border-strong));
}

.btn--ghost { color: rgb(var(--text-secondary)); }
.btn--ghost:hover {
  background: rgb(var(--surface-2));
  color: rgb(var(--text-primary));
}

.btn--danger {
  background: rgb(var(--danger));
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn--danger:hover { background: rgb(var(--danger) / 0.9); }

.btn--link {
  background: transparent;
  color: rgb(var(--brand-400));
  height: auto;
  padding: 0;
}
.btn--link:hover { color: rgb(var(--brand-500)); text-decoration: underline; text-underline-offset: 3px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: rgb(var(--text-secondary));
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out),
    border-color var(--motion-fast) var(--ease-out);
}
.icon-btn:hover {
  background: rgb(var(--surface-2));
  color: rgb(var(--text-primary));
  border-color: rgb(var(--border));
}
.icon-btn--sm { width: 32px; height: 32px; }

/* ───────────────────────────── Inputs ──────────────────────────────── */

.input,
.select,
input.input,
select.select,
textarea.input {
  display: block;
  width: 100%;
  height: var(--input-height);
  padding: 0 14px;
  background: rgb(var(--surface-input));
  color: rgb(var(--text-primary));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 20px;
  appearance: none;
  -webkit-appearance: none;
  transition:
    border-color var(--motion-fast) var(--ease-out),
    background-color var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out);
}

.input::placeholder,
.select::placeholder,
textarea.input::placeholder { color: rgb(var(--text-muted)); }

.input:hover,
.select:hover { border-color: rgb(var(--border-strong)); }

.input--sm { height: var(--input-height-sm); font-size: 13px; padding: 0 12px; }
.input--lg { height: var(--input-height-lg); font-size: 14px; }

textarea.input {
  height: auto;
  min-height: 80px;
  padding: 8px 12px;
  resize: vertical;
  line-height: 22px;
}

/* Custom chevron for <select class="select"> using a CSS background SVG. */
.select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
}
/* Native select options inherit the page color-scheme: dark on supported browsers. */
.select option { background: rgb(var(--surface-1)); color: rgb(var(--text-primary)); }

/* Calendar / date picker iconography (Chromium) — match secondary text */
input[type='date'].input::-webkit-calendar-picker-indicator {
  filter: invert(58%) sepia(11%) saturate(420%) hue-rotate(180deg) brightness(90%);
  cursor: pointer;
}

.input--error,
.input[aria-invalid='true'] { border-color: rgb(var(--danger)); }
.input--error:focus-visible,
.input[aria-invalid='true']:focus-visible {
  box-shadow: 0 0 0 3px rgb(var(--danger) / 0.18);
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgb(var(--text-muted));
  margin-bottom: 6px;
}

.field-help {
  display: block;
  font-size: 12px;
  line-height: 18px;
  color: rgb(var(--text-muted));
  margin-top: 6px;
}

.field-error {
  display: block;
  font-size: 12px;
  line-height: 18px;
  color: rgb(var(--danger));
  margin-top: 6px;
}

/* ──────────────────────── Form-level inline alert ──────────────────── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 13px;
  line-height: 20px;
}
.alert--danger {
  background: rgb(var(--danger) / 0.08);
  border-color: rgb(var(--danger) / 0.30);
  color: rgb(var(--danger));
}
.alert--success {
  background: rgb(var(--success) / 0.08);
  border-color: rgb(var(--success) / 0.30);
  color: rgb(var(--success));
}
.alert--warning {
  background: rgb(var(--warning) / 0.08);
  border-color: rgb(var(--warning) / 0.30);
  color: rgb(var(--warning));
}
.alert--compact {
  padding: 10px 12px;
  gap: 8px;
  font-size: 12px;
  line-height: 18px;
}

/* ───────────────────────────── Status pills ────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill__dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex-shrink: 0;
}

.pill--active,
.pill--success    { background: rgb(var(--success) / 0.12); border-color: rgb(var(--success) / 0.30); color: rgb(var(--success)); }
.pill--available,
.pill--info       { background: rgb(var(--info)    / 0.12); border-color: rgb(var(--info)    / 0.30); color: rgb(var(--info)); }
.pill--assigned   { background: rgb(var(--brand-500) / 0.12); border-color: rgb(var(--brand-500) / 0.30); color: rgb(var(--brand-400)); }
.pill--repair     { background: rgb(var(--repair)  / 0.12); border-color: rgb(var(--repair)  / 0.30); color: rgb(var(--repair)); }
.pill--retired,
.pill--neutral,
.pill--returned   { background: rgb(var(--neutral) / 0.14); border-color: rgb(var(--neutral) / 0.30); color: rgb(var(--text-secondary)); }
.pill--lost,
.pill--danger     { background: rgb(var(--danger)  / 0.12); border-color: rgb(var(--danger)  / 0.30); color: rgb(var(--danger)); }
.pill--pending    { background: rgb(var(--pending) / 0.12); border-color: rgb(var(--pending) / 0.30); color: rgb(var(--pending)); }
.pill--warning    { background: rgb(var(--warning) / 0.12); border-color: rgb(var(--warning) / 0.30); color: rgb(var(--warning)); }

/* Pill variant: tonal — solid quiet background, no border. Used in dense lists. */
.pill--tonal {
  background: rgb(var(--surface-2));
  border-color: rgb(var(--border));
  color: rgb(var(--text-secondary));
}

/* ───────────────────────── Role badge (square) ─────────────────────── */

.role {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-xs);
  background: rgb(var(--surface-2));
  border: 1px solid rgb(var(--border));
  color: rgb(var(--text-secondary));
}
.role--admin    { color: rgb(var(--danger));    background: rgb(var(--danger)    / 0.12); border-color: rgb(var(--danger) / 0.30); }
.role--it_staff { color: rgb(var(--brand-400)); background: rgb(var(--brand-500) / 0.12); border-color: rgb(var(--brand-500) / 0.30); }
.role--viewer   { color: rgb(var(--text-secondary)); }

/* ───────────────────────────── Keyboard hint ───────────────────────── */

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  color: rgb(var(--text-secondary));
  background: rgb(var(--surface-2));
  border: 1px solid rgb(var(--border));
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  line-height: 1;
}

/* ───────────────────────── Filter chip / quick filter ──────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: rgb(var(--text-secondary));
  background: rgb(var(--surface-2));
  border: 1px solid rgb(var(--border));
  cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
  white-space: nowrap;
}
.chip:hover { color: rgb(var(--text-primary)); border-color: rgb(var(--border-strong)); }

.chip--active {
  background: rgb(var(--brand-500) / 0.14);
  color: rgb(var(--brand-400));
  border-color: rgb(var(--brand-500) / 0.40);
}

/* ───────────────────────── Sidebar nav items ───────────────────────── */

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 100%;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: rgb(var(--text-secondary));
  transition:
    background-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out);
  cursor: pointer;
  user-select: none;
}
.nav-item:hover {
  background: rgb(var(--surface-2));
  color: rgb(var(--text-primary));
}
.nav-item__icon {
  width: 16px; height: 16px;
  color: rgb(var(--text-muted));
  flex-shrink: 0;
}
.nav-item:hover .nav-item__icon { color: rgb(var(--text-primary)); }

.nav-item--active {
  background: rgb(var(--brand-500) / 0.10);
  color: rgb(var(--brand-400));
}
.nav-item--active::before {
  /* Positioned inside the sidebar's own padding gutter (.app-sidebar__nav
     has 12px horizontal padding) — never escapes the sidebar's box, so it
     can never bleed into main content regardless of viewport size. */
  content: '';
  position: absolute;
  left: -8px;
  top: 5px;
  bottom: 5px;
  width: 3px;
  border-radius: var(--radius-full);
  background: rgb(var(--brand-500));
  box-shadow: 0 0 8px rgb(var(--brand-500) / 0.45);
}
.nav-item--active .nav-item__icon { color: rgb(var(--brand-400)); }

/* ───────────────────────── App shell (structural) ──────────────────────
 *
 * Grid, not flex-with-JS-offsets: the sidebar is a fixed-width grid track
 * and main content is `minmax(0, 1fr)`. This means the sidebar can never
 * overlap or be overlapped — there is no computed padding, no JS-bound
 * inline style, and no position:fixed/absolute anywhere in the base shell.
 * If Alpine.js fails to load entirely, the grid still renders correctly;
 * JS only adds the optional collapse *animation* on top.
 *
 * Scroll: the document grows naturally with content and browser zoom.
 * The sidebar is sticky with its own overflow when nav is long; main
 * content is not locked to a fixed 100dvh cage (which made zoom/resize
 * feel "stuck" because dvh shrinks as the layout viewport zooms).
 * ------------------------------------------------------------------------ */

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

/* Only when authenticated (sidebar present) does the shell become 2 columns.
   Server-rendered class (not CSS :has()) so it works on every browser. */
.app-shell.has-sidebar {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

/* Rail (icon-only) mode is for genuinely narrow/tablet windows only — normal
   desktop widths (>=900px) always get the full 260px labeled sidebar. */
@media (max-width: 900px) {
  .app-shell.has-sidebar {
    grid-template-columns: var(--sidebar-rail) minmax(0, 1fr);
  }
}

.app-sidebar {
  width: 100%;
  min-width: 0;
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgb(var(--border));
  background: linear-gradient(180deg, rgb(var(--sidebar)) 0%, rgb(var(--canvas-deep)) 100%);
}

.app-sidebar__brand {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid rgb(var(--border));
}

.app-sidebar__nav {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 12px;
}
.app-sidebar__nav > * + * { margin-top: 24px; }

@media (max-width: 900px) {
  .sidebar-label,
  .sidebar-brand-text { display: none !important; }
  .app-sidebar__brand { justify-content: center; padding: 0; }
}

.app-main {
  position: relative; /* containing block for #hx-progress only */
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page {
  width: 100%;
  max-width: min(1480px, 100%);
  margin: 0;
  padding: 28px 32px 40px 32px;
  flex: 1;
  box-sizing: border-box;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-header__text { min-width: 0; }
.page-header__title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: rgb(var(--text-primary));
  line-height: 1.2;
}
/* Any subtitle paragraph rendered via the page_subtitle block — overrides
   whatever ad-hoc Tailwind text size a page template used, so every page
   gets a consistent, readable subtitle without touching each template. */
.page-header__text > p {
  font-size: 14px !important;
  line-height: 20px;
  margin-top: 4px;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.page-header-actions__divider {
  width: 1px;
  height: 24px;
  background: rgb(var(--border));
  margin: 0 2px;
}

.page-footer {
  flex-shrink: 0;
  padding: 16px 32px;
  border-top: 1px solid rgb(var(--border));
  font-size: 11px;
  letter-spacing: 0.03em;
  color: rgb(var(--text-muted));
}

/* ───────────────────────── Search input ────────────────────────────── */

.search-input-wrap {
  position: relative;
}
.search-input-wrap__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: rgb(var(--text-muted));
  pointer-events: none;
}
.search-input-wrap .input,
.search-input-wrap .input--sm {
  padding-left: 38px;
}

/* ───────────────────────── Toggle switch ─────────────────────────── */

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.toggle__track {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  background: rgb(var(--surface-2));
  border: 1px solid rgb(var(--border));
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
}
.toggle__thumb {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: rgb(var(--text-muted));
  transition: transform var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out);
}
.toggle input:checked ~ .toggle__track {
  background: rgb(var(--brand-500) / 0.25);
  border-color: rgb(var(--brand-500) / 0.50);
}
.toggle input:checked ~ .toggle__thumb {
  transform: translateX(18px);
  background: rgb(var(--brand-400));
}
.toggle input:focus-visible ~ .toggle__track {
  outline: 2px solid rgb(var(--brand-500));
  outline-offset: 2px;
}

/* ───────────────────────── Empty state ───────────────────────────── */

.empty-state {
  padding: var(--space-10) var(--space-6);
  text-align: center;
}
.empty-state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgb(var(--surface-2));
  border: 1px solid rgb(var(--border));
  color: rgb(var(--text-muted));
  margin-bottom: var(--space-3);
}
.empty-state__title {
  font-size: 14px;
  font-weight: 600;
  color: rgb(var(--text-primary));
}
.empty-state__desc {
  font-size: 12px;
  color: rgb(var(--text-muted));
  margin-top: var(--space-1);
  line-height: 1.5;
}

/* ───────────────────────── Pagination ────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid rgb(var(--border-subtle));
}
.pagination__meta {
  font-size: 12px;
  color: rgb(var(--text-muted));
  font-variant-numeric: tabular-nums;
}
.pagination__controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ───────────────────────── Table card header ─────────────────────── */

.table-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 20px 24px;
  border-bottom: 1px solid rgb(var(--border-subtle));
}
.table-card-header__title {
  font-size: 18px;
  font-weight: 600;
  color: rgb(var(--text-primary));
  line-height: 1.3;
}
.table-card-header__meta {
  font-size: 14px;
  color: rgb(var(--text-muted));
  margin-top: 3px;
}

/* ───────────────────────── Header user chip ──────────────────────── */

.header-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: rgb(var(--text-secondary));
  background: transparent;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
}
.header-user-btn:hover {
  background: rgb(var(--surface-2));
  border-color: rgb(var(--border-subtle));
  color: rgb(var(--text-primary));
}

.nav-item__soon {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(var(--text-muted));
}
.nav-item--disabled { cursor: not-allowed; opacity: 0.55; }
.nav-item--disabled:hover { background: transparent; color: rgb(var(--text-secondary)); }
.nav-item--disabled:hover .nav-item__icon { color: rgb(var(--text-muted)); }

/* ───────────────────────────── Data table ──────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  color: rgb(var(--text-secondary));
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgb(var(--surface-table-head));
  color: rgb(var(--text-muted));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  padding: 12px 16px;
  line-height: 20px;
  border-bottom: 1px solid rgb(var(--border));
  white-space: nowrap;
}

.data-table thead th:first-child { border-top-left-radius:  var(--radius-md); }
.data-table thead th:last-child  { border-top-right-radius: var(--radius-md); }

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.data-table th.sortable:hover { color: rgb(var(--text-primary)); }
.data-table th .sort-indicator {
  display: inline-block;
  margin-left: 6px;
  width: 10px;
  text-align: center;
  color: rgb(var(--text-muted));
  font-size: 10px;
  opacity: 0.5;
}
.data-table th[aria-sort='ascending']  .sort-indicator,
.data-table th[aria-sort='descending'] .sort-indicator { color: rgb(var(--brand-400)); opacity: 1; }

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid rgb(var(--border-subtle));
  vertical-align: middle;
  color: rgb(var(--text-secondary));
}
.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table tbody tr {
  transition: background-color var(--motion-fast) var(--ease-out);
}
.data-table tbody tr:hover { background: rgb(var(--surface-2)); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.selected   { background: rgb(var(--brand-500) / 0.08); }
.data-table tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 rgb(var(--brand-500)); }

.data-table .cell-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; color: rgb(var(--text-secondary)); }
.data-table .cell-primary { color: rgb(var(--text-primary)); font-weight: 500; }

/* Density variants */
.data-table--compact tbody td  { padding: 8px 16px; }
.data-table--relaxed tbody td  { padding: 16px 16px; }

/* Empty-state row inside a table */
.table-empty {
  padding: 56px 16px;
  text-align: center;
  color: rgb(var(--text-muted));
}

/* ───────────────────────────── Metric card ─────────────────────────── */

.metric {
  background: rgb(var(--surface-1));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.metric__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(var(--text-muted));
}
.metric__value {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1;
  font-weight: 600;
  color: rgb(var(--text-primary));
  font-variant-numeric: tabular-nums;
}
.metric__hint {
  margin-top: 6px;
  font-size: 12px;
  color: rgb(var(--text-muted));
}

/* ──────────────────────── Horizontal bar row ───────────────────────── */

.bar-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 8px 0; }
.bar-row + .bar-row { border-top: 1px solid rgb(var(--border-subtle)); }
.bar-row__label { font-size: 13px; color: rgb(var(--text-secondary)); display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-row__label-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__count { font-size: 12px; color: rgb(var(--text-muted)); font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }
.bar-row__track { grid-column: 1 / -1; height: 4px; border-radius: var(--radius-full); background: rgb(var(--surface-2)); overflow: hidden; }
.bar-row__fill { height: 100%; border-radius: var(--radius-full); background: rgb(var(--brand-500)); transition: width var(--motion-emphasis) var(--ease-emphasis); }
.bar-row__fill--info     { background: rgb(var(--info)); }
.bar-row__fill--warning  { background: rgb(var(--warning)); }
.bar-row__fill--danger   { background: rgb(var(--danger)); }
.bar-row__fill--repair   { background: rgb(var(--repair)); }
.bar-row__fill--neutral  { background: rgb(var(--neutral)); }

/* ─────────────────────────── Skeleton loader ───────────────────────── */

@keyframes skel-pulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }
.skel {
  display: block;
  background: rgb(var(--surface-2));
  border-radius: var(--radius-sm);
  animation: skel-pulse 1.2s ease-in-out infinite;
}

/* ──────────────────── HTMX progress / request indicator ────────────── */

.htmx-indicator { opacity: 0; transition: opacity var(--motion-base) var(--ease-out); }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* Scoped to .app-main (position:relative) rather than position:fixed on the
   viewport, so this can never overlay the sidebar column. */
#hx-progress {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: rgb(var(--brand-500));
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 100;
  pointer-events: none;
  transition: transform 200ms ease-out, opacity 200ms ease-out;
  opacity: 0;
}
.htmx-request #hx-progress {
  opacity: 1;
  transform: scaleX(0.7);
}

/* ───────────────────────── Reduced motion ──────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ───────────────────────── Misc utilities ──────────────────────────── */

[x-cloak] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Definition list helper used on detail pages */
.dl-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 12px 16px; font-size: 13px; }
.dl-grid dt { color: rgb(var(--text-muted)); font-size: 12px; }
.dl-grid dd { color: rgb(var(--text-primary)); }
@media (max-width: 640px) { .dl-grid { grid-template-columns: 1fr; gap: 6px 16px; } .dl-grid dd { margin-bottom: 6px; } }

/* ───────────────────── Inventory registration form ─────────────────── */

.reg-card {
  background: linear-gradient(
    165deg,
    rgb(var(--surface-1-top) / 0.55) 0%,
    rgb(var(--surface-1)) 38%,
    rgb(var(--surface-1)) 100%
  );
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}

.reg-section-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.reg-section-header--compact { margin-bottom: 14px; }

.reg-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: rgb(var(--surface-2));
  border: 1px solid rgb(var(--border-subtle));
  color: rgb(var(--brand-400));
  flex-shrink: 0;
}

.reg-section-title {
  font-size: 15px;
  font-weight: 600;
  color: rgb(var(--text-primary));
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.reg-section-desc {
  font-size: 12px;
  color: rgb(var(--text-muted));
  margin-top: 2px;
  line-height: 1.45;
}

.input-icon-wrap {
  position: relative;
}
.input-icon-wrap__icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: rgb(var(--text-muted));
  pointer-events: none;
  z-index: 1;
}
.input-icon-wrap__input {
  padding-left: 34px !important;
}
textarea.input-icon-wrap__input {
  padding-left: 12px !important;
}

.reg-summary-card {
  position: sticky;
  /* Nothing else is sticky/fixed above this inside .app-main's own scroll
     container, so a plain offset is safe (matches .companies-side-panel). */
  top: 24px;
  background: linear-gradient(
    165deg,
    rgb(var(--surface-1)) 0%,
    rgb(var(--surface-1) / 0.92) 100%
  );
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px 18px 16px;
}
.reg-summary-card__header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgb(var(--border-subtle));
}
.reg-summary-card__title {
  font-size: 14px;
  font-weight: 600;
  color: rgb(var(--text-primary));
}
.reg-summary-card__subtitle {
  font-size: 11px;
  color: rgb(var(--text-muted));
  margin-top: 2px;
}
.reg-summary-card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgb(var(--border-subtle));
}

.inv-summary-list--premium > div {
  padding: 6px 0;
  border-bottom: 1px solid rgb(var(--border-subtle) / 0.55);
}
.inv-summary-list--premium > div:last-child {
  border-bottom: 0;
}

.reg-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  background: rgb(var(--surface-1));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}
.reg-suggest__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 13px;
  color: rgb(var(--text-primary));
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-out);
}
.reg-suggest__row:hover {
  background: rgb(var(--surface-2));
}
.reg-suggest__row--new {
  color: rgb(var(--brand-400));
}
.reg-suggest__meta {
  font-size: 11px;
  color: rgb(var(--text-muted));
  flex-shrink: 0;
}

.inv-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: rgb(var(--brand-500) / 0.15);
  color: rgb(var(--brand-400));
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.inv-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 640px) {
  .inv-template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.inv-template-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(var(--border-subtle));
  background: rgb(var(--surface-1));
  text-align: left;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.inv-template-card--arrow {
  align-items: center;
  padding: 14px 16px;
  min-height: 72px;
}
.inv-template-card__icon {
  width: 22px;
  height: 22px;
  color: rgb(var(--brand-400));
  flex-shrink: 0;
}
.inv-template-card__body {
  flex: 1;
  min-width: 0;
}
.inv-template-card__title {
  font-size: 14px;
  font-weight: 600;
  color: rgb(var(--text-primary));
  line-height: 1.25;
}
.inv-template-card__desc {
  font-size: 11px;
  color: rgb(var(--text-muted));
  margin-top: 3px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.inv-template-card__arrow {
  width: 16px;
  height: 16px;
  color: rgb(var(--text-muted));
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-out);
}
.inv-template-card:hover {
  border-color: rgb(var(--border-strong));
  background: rgb(var(--surface-2));
}
.inv-template-card:hover .inv-template-card__arrow {
  opacity: 1;
  color: rgb(var(--text-secondary));
  transform: translateX(2px);
}
.inv-template-card.is-selected {
  border-color: rgb(var(--brand-500));
  background: rgb(var(--brand-500) / 0.08);
  box-shadow: 0 0 0 1px rgb(var(--brand-500) / 0.35);
}
.inv-template-card.is-selected .inv-template-card__icon {
  color: rgb(var(--brand-500));
}
.inv-template-card.is-selected .inv-template-card__arrow {
  opacity: 1;
  color: rgb(var(--brand-400));
}

.inv-template-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(var(--border-subtle));
  background: rgb(var(--surface-2) / 0.6);
}

/* Iconify-backed icon picker (admin template forms) — compact, integrated
   look: a small selected-icon chip, a dark search-input-wrap search box,
   and a tight icon-only grid (no oversized scroll area, no per-icon name
   label). Icons render via the <iconify-icon> web component so any set in
   the Iconify catalog (Lucide, MDI, Tabler, Phosphor, …) works, not just
   a small hardcoded list. */
.icon-picker__selected {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--border-subtle));
  background: rgb(var(--surface-2) / 0.5);
  margin-bottom: 8px;
}
.icon-picker__selected-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-xs);
  background: rgb(var(--brand-500) / 0.14);
  color: rgb(var(--brand-400));
  flex-shrink: 0;
}
.icon-picker__search { margin-bottom: 8px; }
.icon-picker__grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  max-height: 176px;
  overflow-y: auto;
  padding: 2px;
}
.icon-picker__item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: rgb(var(--surface-1));
  color: rgb(var(--text-muted));
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.icon-picker__item:hover {
  border-color: rgb(var(--border-strong));
  background: rgb(var(--surface-2));
  color: rgb(var(--text-secondary));
}
.icon-picker__item.is-selected {
  border-color: rgb(var(--brand-500) / 0.60);
  background: rgb(var(--brand-500) / 0.12);
  color: rgb(var(--brand-400));
}
.icon-picker__item.is-focused {
  outline: 2px solid rgb(var(--brand-500) / 0.5);
  outline-offset: 1px;
}
.icon-picker__empty {
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: rgb(var(--text-muted));
  border: 1px dashed rgb(var(--border-subtle));
  border-radius: var(--radius-sm);
}
.icon-picker__status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 2px;
  font-size: 12px;
  color: rgb(var(--text-muted));
}
.icon-picker__status--warn { color: rgb(var(--warning)); }
.icon-picker__spinner {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  border: 2px solid rgb(var(--border));
  border-top-color: rgb(var(--brand-400));
  animation: icon-picker-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes icon-picker-spin { to { transform: rotate(360deg); } }

.inv-summary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12px;
}
.inv-summary-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.inv-summary-list dt {
  color: rgb(var(--text-muted));
  flex-shrink: 0;
}
.inv-summary-list dd {
  color: rgb(var(--text-primary));
  text-align: right;
  word-break: break-word;
}

.field-error {
  margin-top: 4px;
  font-size: 11px;
  color: rgb(var(--danger));
}

/* ───────────────────────── Companies page ──────────────────────────── */

.companies-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.companies-toolbar .search-input-wrap {
  width: 240px;
}
@media (min-width: 640px) {
  .companies-toolbar .search-input-wrap { width: 300px; }
}

.search-input-wrap--kbd {
  position: relative;
}
.search-input-wrap--kbd .input--sm {
  padding-right: 44px;
}
.search-input-wrap__kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgb(var(--text-muted));
  pointer-events: none;
  user-select: none;
}

.companies-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
@media (min-width: 1100px) {
  .companies-layout {
    grid-template-columns: minmax(720px, 1fr) 380px;
    gap: 24px;
  }
}

.companies-side-panel {
  order: 2;
  width: 100%;
}
@media (min-width: 1100px) {
  .companies-side-panel {
    order: 0;
    position: sticky;
    /* Nothing else is position:sticky/fixed above this panel inside
       .app-main's own scroll container, so a plain 24px offset is safe
       and can never tuck under another bar. */
    top: 24px;
  }
}

.companies-side-panel__card {
  overflow: hidden;
}
.companies-side-panel__header {
  padding: 24px 24px 0;
}
.companies-side-panel__header h2 {
  font-size: 18px !important;
}
.companies-side-panel__body {
  padding: 20px 24px 24px;
}

.companies-table-card__tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.table-card-header__meta .text-status-success {
  color: rgb(var(--brand-400));
}

.code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.code-badge--emerald { background: rgb(var(--brand-500) / 0.18); color: rgb(var(--brand-400)); }
.code-badge--blue    { background: rgb(var(--info) / 0.18);       color: rgb(96 165 250); }
.code-badge--purple  { background: rgb(var(--pending) / 0.18);    color: rgb(var(--pending)); }
.code-badge--orange  { background: rgb(var(--repair) / 0.18);     color: rgb(var(--repair)); }
.code-badge--teal    { background: rgb(20 184 166 / 0.18);       color: rgb(45 212 191); }
.code-badge--amber   { background: rgb(var(--warning) / 0.18);    color: rgb(var(--warning)); }
.code-badge--slate   { background: rgb(var(--surface-2));         color: rgb(var(--text-muted)); border: 1px solid rgb(var(--border-subtle)); }
.code-badge--rose    { background: rgb(var(--danger) / 0.14);      color: rgb(248 113 113); }

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  flex-wrap: nowrap;
}
.companies-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.icon-btn--danger {
  color: rgb(var(--danger));
}
.icon-btn--danger:hover {
  color: rgb(248 113 113);
  background: rgb(var(--danger) / 0.10);
  border-color: rgb(var(--danger) / 0.25);
}

.toggle--row {
  margin: 0 2px;
}

.field-label--caps {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}
.field-help--above {
  margin-top: 0;
  margin-bottom: 6px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid rgb(var(--border-subtle));
}
.table-footer__per-page {
  display: flex;
  align-items: center;
  gap: 8px;
}
.select--inline {
  width: auto;
  height: 32px;
  padding: 0 28px 0 10px;
  font-size: 12px;
}
.table-footer__nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.table-footer__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--border));
  background: rgb(var(--surface-2));
  font-size: 12px;
  font-weight: 500;
  color: rgb(var(--text-primary));
  font-variant-numeric: tabular-nums;
}

/* ───────────────────────── Device templates page ───────────────────── *
 * Mirrors .companies-layout / .companies-side-panel exactly: a fluid table
 * column plus a fixed 380px side panel, stacking to one column below the
 * same 1100px breakpoint (side panel becomes static instead of sticky).  */

.device-templates-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
@media (min-width: 1100px) {
  .device-templates-layout {
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
  }
}

/* Right column holds both the sticky "Add template" panel and the static
   "How customization works" info card below it. */
.device-templates-side {
  order: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (min-width: 1100px) {
  .device-templates-side { order: 0; }
}

.device-templates-panel { width: 100%; }
@media (min-width: 1100px) {
  .device-templates-panel {
    position: sticky;
    /* Nothing else is position:sticky/fixed above this panel inside
       .app-main's own scroll container, so a plain 24px offset is safe
       (matches .companies-side-panel). */
    top: 24px;
  }
}

.device-templates-panel__card { overflow: hidden; }
.device-templates-panel__header { padding: 20px 20px 0; }
.device-templates-panel__header h2 { font-size: 17px !important; }
.device-templates-panel__body { padding: 16px 20px 20px; }

.device-templates-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.device-templates-subtitle {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  max-width: 220px;
}

/* Row actions: just Edit + Delete, both plain 32px ghost icon buttons
   (.icon-btn--sm's own default size/styling — transparent by default,
   subtle bordered surface on hover, muted icon that brightens on hover).
   No text buttons, no filled backgrounds. */
.device-templates-table .row-actions { gap: 4px; }

/* Minimal icon chip — low-weight container for the row's icon glyph.
   Small, subtly bordered, no color emphasis so it doesn't compete with the
   Label column for attention. Icon glyph itself defaults to a muted
   blue-gray and only picks up an emerald tint when the row is hovered. */
.device-templates-icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: rgb(var(--surface-2) / 0.55);
  border: 1px solid rgb(var(--border-subtle));
  color: rgb(var(--text-secondary));
  flex-shrink: 0;
  transition: color 120ms ease, border-color 120ms ease;
}
.device-templates-icon-chip svg,
.device-templates-icon-chip iconify-icon {
  color: inherit;
}
.device-templates-table tbody tr:hover .device-templates-icon-chip {
  color: rgb(var(--brand-500));
  border-color: rgb(var(--brand-500) / 0.35);
}
.device-templates-icon-name {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: rgb(var(--text-muted));
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ───────────────────── Edit Template drawer ────────────────────────── *
 * Right-side drawer opened from the table's Edit action. Two tabs:
 * Details (same field/icon-picker styling as the Add Template panel) and
 * Fields (an <iframe> embedding the existing fields-management page via
 * _shell/embed_base.html, so field CRUD keeps using its own routes/forms
 * unchanged — the drawer only supplies a frame around it). */

/* Handover asset picker modal — professional dark enterprise selector */
.ho-asset-picker {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.ho-asset-picker__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(var(--canvas-deep) / 0.78);
  backdrop-filter: blur(4px);
}

.ho-asset-picker__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(1320px, calc(100vw - 64px));
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
  border-radius: 16px;
  border: 1px solid rgb(var(--border));
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgb(var(--brand-500) / 0.06), transparent 55%),
    rgb(var(--surface-1));
  box-shadow:
    0 0 0 1px rgb(var(--border-subtle) / 0.5),
    0 24px 48px -12px rgb(0 0 0 / 0.55),
    0 8px 24px -8px rgb(0 0 0 / 0.35);
  overflow: hidden;
}

/* ── Header ── */
.ho-asset-picker__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgb(var(--border-subtle));
  flex-shrink: 0;
  background: rgb(var(--surface-1) / 0.96);
}

.ho-asset-picker__header-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.ho-asset-picker__icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: rgb(var(--brand-500) / 0.12);
  border: 1px solid rgb(var(--brand-500) / 0.28);
  color: rgb(var(--brand-400));
  flex-shrink: 0;
}

.ho-asset-picker__title {
  font-size: 17px;
  font-weight: 600;
  color: rgb(var(--text-primary));
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.ho-asset-picker__subtitle {
  margin-top: 3px;
  font-size: 12.5px;
  color: rgb(var(--text-muted));
  line-height: 1.45;
}

.ho-asset-picker__header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ho-asset-picker__sel-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: rgb(var(--brand-500) / 0.12);
  border: 1px solid rgb(var(--brand-500) / 0.30);
  color: rgb(var(--brand-400));
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ho-asset-picker__close {
  color: rgb(var(--text-muted));
}
.ho-asset-picker__close:hover {
  color: rgb(var(--text-primary));
}

/* ── Toolbar (search + filters) ── */
.ho-asset-picker__toolbar {
  padding: 16px 24px;
  border-bottom: 1px solid rgb(var(--border-subtle));
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgb(var(--surface-1) / 0.92);
}

.ho-asset-picker__search {
  position: relative;
  display: flex;
  align-items: center;
}

.ho-asset-picker__search-icon {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  color: rgb(var(--text-muted));
  pointer-events: none;
}

.ho-asset-picker__search-input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 40px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(var(--border));
  background: rgb(var(--surface-input));
  color: rgb(var(--text-primary));
  font-size: 13.5px;
  transition: border-color var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-fast) var(--ease-out);
}
.ho-asset-picker__search-input::placeholder {
  color: rgb(var(--text-muted));
}
.ho-asset-picker__search-input:focus {
  outline: none;
  border-color: rgb(var(--brand-500));
  box-shadow: 0 0 0 3px rgb(var(--brand-500) / 0.16);
}

.ho-asset-picker__search-clear {
  position: absolute;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgb(var(--text-muted));
  cursor: pointer;
  transition: color var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out);
}
.ho-asset-picker__search-clear:hover {
  color: rgb(var(--text-primary));
  background: rgb(var(--surface-2));
}

.ho-asset-picker__filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 768px) {
  .ho-asset-picker__filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 1100px) {
  .ho-asset-picker__filter-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.ho-asset-picker__filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ho-asset-picker__filter-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(var(--text-muted));
}

.ho-asset-picker__select {
  appearance: none;
  width: 100%;
  height: 34px;
  padding: 0 28px 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--border));
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 10px center / 12px,
    rgb(var(--surface-input));
  color: rgb(var(--text-secondary));
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease-out);
}
.ho-asset-picker__select:hover {
  border-color: rgb(var(--border-strong));
}
.ho-asset-picker__select:focus {
  outline: none;
  border-color: rgb(var(--brand-500));
  box-shadow: 0 0 0 3px rgb(var(--brand-500) / 0.14);
}

.ho-asset-picker__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: end;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--border-subtle));
  background: rgb(var(--surface-2) / 0.35);
  font-size: 12.5px;
  color: rgb(var(--text-secondary));
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.ho-asset-picker__toggle:hover {
  border-color: rgb(var(--border));
  background: rgb(var(--surface-2) / 0.55);
}

.ho-asset-picker__loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgb(var(--text-muted));
}

/* ── Custom checkboxes ── */
.ho-asset-picker__check-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ho-asset-picker__checkbox {
  appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border-radius: 4px;
  border: 1px solid rgb(var(--border-strong));
  background: rgb(var(--surface-input));
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-fast) var(--ease-out);
  flex-shrink: 0;
}
.ho-asset-picker__checkbox:checked {
  border-color: rgb(var(--brand-500));
  background: rgb(var(--brand-500))
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")
    no-repeat center / 10px;
}
.ho-asset-picker__checkbox:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ho-asset-picker__checkbox:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgb(var(--brand-500) / 0.2);
}

/* ── Two-column body ── */
.ho-asset-picker__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
@media (min-width: 1000px) {
  .ho-asset-picker__body {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

.ho-asset-picker__table-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgb(var(--border-subtle));
}

.ho-asset-picker__table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.ho-asset-picker__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.ho-asset-picker__table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 14px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgb(var(--text-muted));
  background: rgb(var(--surface-2) / 0.95);
  border-bottom: 1px solid rgb(var(--border-subtle));
  backdrop-filter: blur(6px);
}

.ho-asset-picker__col-check {
  width: 44px;
  padding-left: 16px !important;
}

.ho-asset-picker__table tbody td {
  padding: 14px;
  vertical-align: middle;
  border-bottom: 1px solid rgb(var(--border-subtle) / 0.7);
  font-size: 12.5px;
  color: rgb(var(--text-secondary));
}

.ho-asset-picker__row {
  transition: background var(--motion-fast) var(--ease-out);
}
.ho-asset-picker__row:hover:not(.ho-asset-picker__row--disabled) {
  background: rgb(var(--surface-2) / 0.45);
}
.ho-asset-picker__row--selected td {
  background: rgb(var(--brand-500) / 0.07);
}
.ho-asset-picker__row--selected td:first-child {
  box-shadow: inset 3px 0 0 rgb(var(--brand-500));
}
.ho-asset-picker__row--disabled {
  opacity: 0.48;
}
.ho-asset-picker__row--disabled:hover {
  background: transparent;
}

.ho-asset-picker__inv-id {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  color: rgb(var(--text-primary));
}

.ho-asset-picker__type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgb(var(--surface-2) / 0.55);
  border: 1px solid rgb(var(--border-subtle));
  color: rgb(var(--text-secondary));
  font-size: 11.5px;
  white-space: nowrap;
}
.ho-asset-picker__type-chip i,
.ho-asset-picker__type-chip svg {
  color: rgb(var(--brand-400));
  flex-shrink: 0;
}

.ho-asset-picker__model,
.ho-asset-picker__org {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ho-asset-picker__serial {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px;
  color: rgb(var(--text-muted));
}

.ho-asset-picker__employee {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ho-asset-picker__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: rgb(var(--brand-500) / 0.14);
  border: 1px solid rgb(var(--brand-500) / 0.22);
  color: rgb(var(--brand-400));
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.ho-asset-picker__empty {
  text-align: center;
  padding: 48px 24px !important;
  color: rgb(var(--text-muted));
  font-size: 13px;
}

/* ── Selection summary panel ── */
.ho-asset-picker__summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  min-height: 0;
  overflow-y: auto;
  background: rgb(var(--surface-2) / 0.22);
}
@media (max-width: 999px) {
  .ho-asset-picker__summary {
    border-top: 1px solid rgb(var(--border-subtle));
    max-height: 240px;
  }
  .ho-asset-picker__table-pane {
    border-right: 0;
  }
}

.ho-asset-picker__summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ho-asset-picker__summary-title {
  font-size: 13.5px;
  font-weight: 600;
  color: rgb(var(--text-primary));
}

.ho-asset-picker__clear-all {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 11.5px;
  font-weight: 500;
  color: rgb(var(--danger));
  cursor: pointer;
  transition: opacity var(--motion-fast) var(--ease-out);
}
.ho-asset-picker__clear-all:hover {
  opacity: 0.85;
}

.ho-asset-picker__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ho-asset-picker__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(var(--border-subtle));
  background: rgb(var(--surface-1) / 0.6);
  text-align: center;
}
.ho-asset-picker__stat--primary {
  border-color: rgb(var(--brand-500) / 0.28);
  background: rgb(var(--brand-500) / 0.08);
}
.ho-asset-picker__stat-value {
  font-size: 16px;
  font-weight: 700;
  color: rgb(var(--text-primary));
  line-height: 1.2;
}
.ho-asset-picker__stat--primary .ho-asset-picker__stat-value {
  color: rgb(var(--brand-400));
}
.ho-asset-picker__stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgb(var(--text-muted));
}

.ho-asset-picker__summary-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.ho-asset-picker__summary-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(var(--text-muted));
}

.ho-asset-picker__summary-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.ho-asset-picker__summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(var(--border-subtle));
  background: rgb(var(--surface-1) / 0.65);
}

.ho-asset-picker__summary-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: rgb(var(--surface-2));
  border: 1px solid rgb(var(--border-subtle));
  color: rgb(var(--brand-400));
  flex-shrink: 0;
}

.ho-asset-picker__summary-item-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.ho-asset-picker__summary-item-id {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: rgb(var(--text-primary));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ho-asset-picker__summary-item-sub {
  font-size: 10.5px;
  color: rgb(var(--text-muted));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ho-asset-picker__summary-remove {
  color: rgb(var(--text-muted));
  flex-shrink: 0;
}
.ho-asset-picker__summary-remove:hover {
  color: rgb(var(--danger));
}

.ho-asset-picker__summary-empty {
  font-size: 12px;
  color: rgb(var(--text-muted));
  padding: 8px 0;
}

.ho-asset-picker__info-card {
  margin-top: auto;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(var(--info) / 0.22);
  background: rgb(var(--info) / 0.06);
}

.ho-asset-picker__info-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: rgb(var(--text-primary));
  margin-bottom: 8px;
}
.ho-asset-picker__info-title i,
.ho-asset-picker__info-title svg {
  color: rgb(var(--info));
}

.ho-asset-picker__info-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ho-asset-picker__info-list li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  color: rgb(var(--text-muted));
  line-height: 1.45;
}
.ho-asset-picker__info-list i,
.ho-asset-picker__info-list svg {
  color: rgb(var(--brand-400));
  margin-top: 2px;
  flex-shrink: 0;
}

/* ── Sticky footer ── */
.ho-asset-picker__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 14px 24px;
  border-top: 1px solid rgb(var(--border-subtle));
  background: rgb(var(--surface-1) / 0.98);
  flex-shrink: 0;
}

.ho-asset-picker__footer-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.ho-asset-picker__footer-count {
  font-size: 13px;
  font-weight: 600;
  color: rgb(var(--text-primary));
}

.ho-asset-picker__footer-results {
  font-size: 11.5px;
  color: rgb(var(--text-muted));
}

.ho-asset-picker__pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.ho-asset-picker__page-label {
  font-size: 12px;
  color: rgb(var(--text-muted));
  white-space: nowrap;
}

.ho-asset-picker__footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.ho-asset-picker__btn-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .ho-asset-picker {
    padding: 0;
    align-items: stretch;
  }
  .ho-asset-picker__panel {
    max-width: 100%;
    max-height: 100%;
    max-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .ho-asset-picker__footer {
    flex-direction: column;
    align-items: stretch;
  }
  .ho-asset-picker__pagination {
    order: 2;
    justify-content: space-between;
  }
  .ho-asset-picker__footer-actions {
    order: 3;
    margin-left: 0;
    justify-content: stretch;
  }
  .ho-asset-picker__footer-actions .btn {
    flex: 1;
    justify-content: center;
  }
}


.edit-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(var(--canvas-deep) / 0.72);
  backdrop-filter: blur(2px);
}

.edit-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  width: 100%;
  max-width: 600px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: rgb(var(--surface-1));
  border-left: 1px solid rgb(var(--border));
  box-shadow: -24px 0 48px -12px rgb(0 0 0 / 0.45);
}
@media (min-width: 640px) {
  .edit-drawer__panel { width: 600px; }
}

.edit-drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgb(var(--border-subtle));
  flex-shrink: 0;
}
.edit-drawer__title {
  font-size: 17px;
  font-weight: 600;
  color: rgb(var(--text-primary));
  line-height: 1.3;
}
.edit-drawer__subtitle {
  font-size: 12.5px;
  color: rgb(var(--text-muted));
  margin-top: 2px;
  line-height: 1.4;
}

.edit-drawer__tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid rgb(var(--border-subtle));
  flex-shrink: 0;
}
.edit-drawer__tab {
  appearance: none;
  background: transparent;
  border: none;
  padding: 8px 4px 10px;
  margin-right: 16px;
  font-size: 13px;
  font-weight: 500;
  color: rgb(var(--text-muted));
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.edit-drawer__tab:hover { color: rgb(var(--text-secondary)); }
.edit-drawer__tab.is-active {
  color: rgb(var(--text-primary));
  border-bottom-color: rgb(var(--brand-500));
}

.edit-drawer__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 20px;
}

.edit-drawer__status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgb(var(--border-subtle));
}

.edit-drawer__fields {
  height: 100%;
  min-height: 480px;
}
.edit-drawer__fields-frame {
  width: 100%;
  height: 100%;
  min-height: 480px;
  border: 0;
  border-radius: var(--radius-sm);
}

.edit-drawer__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid rgb(var(--border-subtle));
  flex-shrink: 0;
}

/* Embedded page shell (see _shell/embed_base.html) — no sidebar, tighter
   page padding so the fields table/aside fit comfortably inside the
   drawer's iframe. */
.app-shell--embed { grid-template-columns: minmax(0, 1fr); }
.page--embed { padding: 4px; max-width: none; }

/* ───────────────────────── Manufacturers page ──────────────────────── *
 * Mirrors .device-templates-layout / .device-templates-side exactly: a
 * fluid hierarchy table column plus a fixed 380px side panel (Add
 * manufacturer + How it works), stacking to one column below 1100px. */

.manufacturers-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
@media (min-width: 1100px) {
  .manufacturers-layout {
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
  }
}

.manufacturers-side {
  order: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (min-width: 1100px) {
  .manufacturers-side { order: 0; }
}

.manufacturers-panel { width: 100%; }
@media (min-width: 1100px) {
  .manufacturers-panel {
    position: sticky;
    /* Nothing else is position:sticky/fixed above this panel inside
       .app-main's own scroll container, so a plain 24px offset is safe
       (matches .companies-side-panel / .device-templates-panel). */
    top: 24px;
  }
}

.manufacturers-panel__card { overflow: hidden; }
.manufacturers-panel__header { padding: 20px 20px 0; }
.manufacturers-panel__header h2 { font-size: 17px !important; }
.manufacturers-panel__body { padding: 16px 20px 20px; }

.manufacturers-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

/* Row actions match the compact 28px icon-only group used on
   Companies/Templates row actions. */
.manufacturers-table .row-actions { gap: 4px; }
.manufacturers-table .row-actions .icon-btn {
  width: 28px;
  height: 28px;
}

/* ── Hierarchy rows ── */

.mfr-row td {
  padding-top: 15px;
  padding-bottom: 15px;
  background: rgb(var(--surface-2) / 0.32);
}
.mfr-row:hover td { background: rgb(var(--surface-2) / 0.55); }

.mfr-row__lead {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mfr-row__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: rgb(var(--text-muted));
  background: transparent;
  border: 0;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: color var(--motion-fast) var(--ease-out),
              transform var(--motion-base) var(--ease-out),
              background-color var(--motion-fast) var(--ease-out);
}
.mfr-row__toggle:hover { color: rgb(var(--text-primary)); background: rgb(var(--surface-2)); }
.mfr-row__toggle.is-open { transform: rotate(90deg); }
.mfr-row__toggle:disabled { opacity: 0.3; cursor: default; pointer-events: none; }

.mfr-row__name {
  font-size: 14px;
  font-weight: 600;
  color: rgb(var(--text-primary));
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mfr-child-row td {
  padding-top: 10px;
  padding-bottom: 10px;
}
.mfr-child-row:not(.mfr-more-row) td:first-child {
  padding-left: 16px;
}

.mfr-child-row__lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-left: 34px;
  position: relative;
}
.mfr-child-row__connector {
  width: 14px;
  height: 14px;
  color: rgb(var(--text-muted) / 0.7);
  flex-shrink: 0;
}
.mfr-child-row__name {
  font-size: 13px;
  color: rgb(var(--text-secondary));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--motion-fast) var(--ease-out);
}
.mfr-child-row__name:hover { color: rgb(var(--brand-400)); }

.mfr-more-row td {
  padding-top: 8px;
  padding-bottom: 8px;
}
.mfr-more-row__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 34px;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 500;
  color: rgb(var(--text-muted));
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color var(--motion-fast) var(--ease-out);
}
.mfr-more-row__btn:hover { color: rgb(var(--brand-400)); }

.mfr-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: rgb(var(--text-secondary));
  tabular-nums: normal;
}
.mfr-count--muted { color: rgb(var(--text-muted)); }
.mfr-count svg,
.mfr-count i { flex-shrink: 0; }

.mfr-empty-dash {
  color: rgb(var(--text-muted));
  font-size: 13px;
}

.manufacturers-table tbody tr[hidden] { display: none; }

/* ───────────────────── Register & Assign Devices ───────────────────── *
 * One shared Assignment section, a repeater of device entry cards, and a
 * sticky Assignment Summary panel on the right. Reuses .reg-card /
 * .reg-summary-card / .inv-step-badge from the single-register form so
 * both flows stay visually identical.                                    */

.register-assign-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (min-width: 1100px) {
  .register-assign-layout {
    grid-template-columns: minmax(0, 1fr) 400px;
  }
}

.ra-side {
  order: 2;
  width: 100%;
  min-width: 0;
}
@media (min-width: 1100px) {
  .ra-side {
    order: 0;
    position: sticky;
    /* Nothing else is position:sticky/fixed above this panel inside
       .app-main's own scroll container, so a plain 24px offset is safe
       (matches .reg-summary-card / .companies-side-panel). */
    top: 24px;
  }
}

.reg-section-header--devices {
  align-items: center;
}

.ra-count-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: rgb(var(--brand-500) / 0.12);
  border: 1px solid rgb(var(--brand-500) / 0.30);
  color: rgb(var(--brand-400));
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ── Device entry card (repeater item) ── */

.ra-device {
  border: 1px solid rgb(var(--border-subtle));
  border-radius: var(--radius-lg);
  background: rgb(var(--surface-2) / 0.35);
  overflow: visible;
  transition: border-color var(--motion-fast) var(--ease-out);
}
.ra-device:hover { border-color: rgb(var(--border)); }
.ra-device.has-errors { border-color: rgb(var(--danger) / 0.45); }

.ra-device__header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}
.ra-device.is-collapsed .ra-device__header { padding: 12px 14px; }
.ra-device:not(.is-collapsed) .ra-device__header {
  border-bottom: 1px solid rgb(var(--border-subtle));
}

.ra-device__num {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-full);
  background: rgb(var(--brand-500) / 0.14);
  color: rgb(var(--brand-400));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}

.ra-device__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: rgb(var(--surface-2) / 0.6);
  border: 1px solid rgb(var(--border-subtle));
  color: rgb(var(--brand-400));
  flex-shrink: 0;
}

.ra-device__title {
  font-size: 13.5px;
  font-weight: 600;
  color: rgb(var(--text-primary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ra-device__title--empty {
  color: rgb(var(--text-muted));
  font-weight: 500;
}

.ra-device__summary {
  font-size: 12.5px;
  color: rgb(var(--text-muted));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ra-device__chevron i,
.ra-device__chevron svg {
  transition: transform var(--motion-base) var(--ease-out);
}
.ra-device__chevron.is-open i,
.ra-device__chevron.is-open svg {
  transform: rotate(180deg);
}

.ra-device__body {
  padding: 16px 16px 18px;
}

.ra-device .row-actions .icon-btn {
  width: 28px;
  height: 28px;
}
.ra-device .row-actions .icon-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ── Template picker tiles ── */

.ra-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}
@media (min-width: 640px)  { .ra-template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .ra-template-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.ra-template-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 66px;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(var(--border-subtle));
  background: rgb(var(--surface-1));
  cursor: pointer;
  text-align: center;
  transition: border-color var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-fast) var(--ease-out);
}
.ra-template-tile:hover {
  border-color: rgb(var(--border-strong));
  background: rgb(var(--surface-2));
}
.ra-template-tile__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgb(var(--text-secondary));
  transition: color var(--motion-fast) var(--ease-out);
}
.ra-template-tile__label {
  font-size: 12px;
  font-weight: 500;
  color: rgb(var(--text-secondary));
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  transition: color var(--motion-fast) var(--ease-out);
}
.ra-template-tile__check {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: rgb(var(--brand-500));
  color: rgb(var(--text-on-brand));
}
.ra-template-tile.is-selected {
  border-color: rgb(var(--brand-500));
  background: rgb(var(--brand-500) / 0.08);
  box-shadow: 0 0 0 1px rgb(var(--brand-500) / 0.35);
}
.ra-template-tile.is-selected .ra-template-tile__icon,
.ra-template-tile.is-selected .ra-template-tile__label {
  color: rgb(var(--brand-400));
}

.ra-empty-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 14px;
  border: 1px dashed rgb(var(--border-subtle));
  border-radius: var(--radius-md);
  color: rgb(var(--text-muted));
  font-size: 12.5px;
}

.ra-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--input-height);
  padding: 0 14px;
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius-sm);
  background: rgb(var(--surface-input));
  cursor: pointer;
}
.ra-checkbox input[type='checkbox'] {
  width: 15px;
  height: 15px;
  accent-color: rgb(var(--brand-500));
  cursor: pointer;
}

.ra-radio {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: rgb(var(--text-secondary));
  cursor: pointer;
}
.ra-radio input[type='radio'] {
  margin-top: 2px;
  accent-color: rgb(var(--brand-500));
  cursor: pointer;
}

.ra-gap-panel {
  padding: 12px;
  border: 1px solid rgb(var(--border-subtle));
  border-radius: var(--radius-sm);
  background: rgb(var(--surface-2) / 0.5);
}

.ra-add-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgb(var(--border-subtle));
}

/* ── Summary panel devices list + badges ── */

.ra-summary-devices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 264px;
  overflow-y: auto;
}

.ra-summary-device {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(var(--border-subtle));
  background: rgb(var(--surface-2) / 0.4);
}
.ra-summary-device__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: rgb(var(--surface-2) / 0.7);
  border: 1px solid rgb(var(--border-subtle));
  color: rgb(var(--brand-400));
  flex-shrink: 0;
}
.ra-summary-device__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.ra-summary-device__name {
  font-size: 12.5px;
  font-weight: 500;
  color: rgb(var(--text-primary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ra-summary-device__model {
  font-size: 11px;
  color: rgb(var(--text-muted));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ra-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid transparent;
}
.ra-badge--serialized {
  background: rgb(var(--brand-500) / 0.12);
  border-color: rgb(var(--brand-500) / 0.30);
  color: rgb(var(--brand-400));
}
.ra-badge--accessory {
  background: rgb(var(--info) / 0.12);
  border-color: rgb(var(--info) / 0.30);
  color: rgb(var(--info));
}

.ra-draft-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 11px;
  color: rgb(var(--text-muted));
}
