/* Enterprise design system - tokens in tokens.css */

@import url("fonts.cb601920c250.css");
@import url("tokens.adf1f0dabf01.css");

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-1);
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--ink-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--space-2);
  z-index: 9999;
  padding: var(--space-2) var(--space-3);
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 500;
}

.skip-link:focus {
  left: var(--space-2);
}

code,
kbd {
  color: var(--ink-1);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

/* ----- App shell ----- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1040;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink-0);
}

.sidebar-brand-mark {
  width: 36px;
  height: 28px;
  border-radius: var(--radius-md);
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
  flex-shrink: 0;
}

.brand-mark-img {
  display: block;
  width: 44px;
  height: auto;
}

.brand-mark-img--sm {
  width: 36px;
}

.sidebar-brand-text {
  min-width: 0;
}

.sidebar-brand-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink-0);
}

.sidebar-brand-sub {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.3;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-2);
}

.sidebar-section {
  margin-bottom: var(--space-4);
}

.sidebar-section-label {
  display: block;
  padding: var(--space-1) var(--space-3);
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  color: var(--ink-1);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar .nav-link i {
  font-size: 1rem;
  opacity: 0.75;
  width: 18px;
  text-align: center;
}

.sidebar .nav-link:hover {
  background: var(--bg-2);
  color: var(--ink-0);
}

.sidebar .nav-link.active {
  background: var(--brand-soft);
  color: var(--brand-700);
  border-color: transparent;
  border-left: 3px solid var(--brand-600);
  padding-left: calc(var(--space-3) - 3px);
  font-weight: 600;
}

.sidebar .nav-link.active i {
  opacity: 1;
}

.sidebar-badge {
  margin-left: auto;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--muted);
}

.sidebar-badge--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.sidebar-badge--danger {
  background: var(--err-soft);
  color: var(--err);
}

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--line);
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  background: var(--bg-0);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.topbar-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--bg-0);
  border-radius: var(--radius-md);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  color: var(--ink-1);
  cursor: pointer;
}

.topbar-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.topbar-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.topbar-search i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: var(--text-sm);
  pointer-events: none;
}

.topbar-search .form-control {
  padding-left: 32px;
  height: 36px;
  font-size: var(--text-sm);
}

.topbar-spacer {
  flex: 1;
}

.topbar-user .dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-0);
  color: var(--ink-1);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
}

.topbar-user .dropdown-toggle:hover,
.topbar-user .dropdown-toggle.show {
  background: var(--bg-2);
  color: var(--ink-0);
}

.user-dropdown {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
  background: var(--bg-0);
  min-width: 200px;
}

.user-dropdown .dropdown-item {
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-1);
  padding: 8px 10px;
}

.user-dropdown .dropdown-item:hover {
  background: var(--bg-2);
  color: var(--ink-0);
}

/* App-wide dropdown menus - keep action labels readable */
.dropdown-menu {
  border: 1px solid var(--line, #e4e4e7);
  border-radius: var(--radius-lg, 8px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.06));
  padding: var(--space-1, 4px);
  background: var(--bg-0, #fff);
}

.dropdown-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  border-radius: var(--radius-md, 6px);
  font-size: var(--text-sm, 0.8125rem);
  font-weight: 500;
  color: var(--ink-1, #27272a);
  padding: 8px 10px;
}

.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus,
.dropdown-menu .dropdown-item:focus-visible {
  background: var(--bg-2, #f4f4f5);
  color: var(--ink-0, #18181b);
}

.dropdown-menu .dropdown-item:disabled,
.dropdown-menu .dropdown-item.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.dropdown-menu .dropdown-item i {
  width: 1rem;
  text-align: center;
  color: var(--muted, #71717a);
  flex-shrink: 0;
}

.app-content {
  flex: 1;
  padding: var(--space-6) var(--space-7);
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.app-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-xs);
  text-align: center;
}

.app-footer p {
  margin: 0;
}

/* Minimal layout (handover signing) */
body.layout-minimal .app-sidebar {
  display: none;
}

body.layout-minimal .topbar-toggle {
  display: none;
}

body.layout-minimal .app-topbar {
  justify-content: space-between;
}

body.layout-minimal .topbar-search {
  display: none;
}

body.layout-minimal .topbar-brand-mini {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-0);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1035;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .app-sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-overlay.is-visible {
    display: block;
  }

  .topbar-toggle {
    display: inline-flex;
  }

  .app-content {
    padding: var(--space-4) var(--space-3);
  }

  .app-topbar {
    padding: 0 var(--space-3);
  }
}

/* ----- Page structure ----- */

.page-header {
  margin-bottom: var(--space-6);
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  color: var(--muted);
}

.page-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.page-breadcrumb a:hover {
  color: var(--brand);
}

.page-breadcrumb-sep {
  color: var(--muted-2);
}

.page-title,
.z-title,
.wp-title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--ink-0);
  line-height: 1.2;
  letter-spacing: var(--tracking-tight);
}

.page-subtitle,
.z-subtitle,
.wp-subtitle {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
  font-weight: 400;
  line-height: 1.45;
}

.page-actions,
.head-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

/* Legacy hero → flat header */
.wp-hero {
  padding: 0;
  margin-bottom: var(--space-5) !important;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  position: static;
  overflow: visible;
}

.wp-hero::before,
.wp-hero::after {
  display: none !important;
}

.dashboard-wp {
  background: transparent;
  padding: 0;
  border-radius: 0;
}

/* ----- Stats / KPI ----- */

.stat-row,
.wp-kpi-grid {
  margin-bottom: var(--space-4);
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.stat-card,
.wp-stat,
.kpi-card {
  flex: 1 1 140px;
  min-width: 140px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.stat-card:hover,
.wp-stat:hover,
.kpi-card:hover {
  border-color: var(--brand-100);
  box-shadow: var(--shadow-md);
}

.wp-stat-accent,
.kpi-accent {
  display: none !important;
}

.wp-stat-label,
.kpi-label,
.stat-card-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.wp-stat-value,
.kpi-value,
.stat-card-value {
  margin-top: var(--space-1);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink-0);
  line-height: 1.2;
}

.wp-stat-note,
.stat-card-note {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--muted);
}

.wp-stat {
  min-height: auto;
}

.wp-section-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink-0);
  margin: 0 0 var(--space-1);
}

.wp-section-sub {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 0 var(--space-4);
}

.wp-kpi-divider {
  height: 1px;
  background: var(--line);
  margin: var(--space-4) 0;
}

.kpi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ----- Toolbar & filters ----- */

.page-toolbar,
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.filter-card .card-header,
.devices-card .card-header {
  font-size: var(--text-sm);
  font-weight: 600;
}

/* ----- Cards ----- */

.card,
.wp-box {
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  overflow: hidden;
  background: var(--bg-0);
  transition: none;
}

.card:hover,
.wp-box:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--line);
}

.card-header {
  background: var(--bg-1);
  color: var(--ink-0);
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  font-size: var(--text-sm);
}

.card-body {
  background: var(--bg-0);
  padding: var(--space-4);
}

.quick-intake-view .card {
  overflow: visible;
}

/* ----- Buttons ----- */

.btn {
  font-weight: 500;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.btn-primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
  box-shadow: none;
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}

.btn-primary:active {
  background: var(--brand-700);
  border-color: var(--brand-700);
  transform: scale(0.98);
}

.btn-primary:focus-visible,
.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--ring);
}

.btn-outline-secondary,
.btn-outline-primary {
  color: var(--ink-1);
  border: 1px solid var(--line);
  background: var(--bg-0);
}

.btn-outline-secondary:hover,
.btn-outline-primary:hover {
  background: var(--bg-2);
  border-color: var(--line-strong);
  color: var(--ink-0);
}

.head-actions .btn,
.quick-action-btn {
  min-height: 36px;
  font-weight: 500;
  border-radius: var(--radius-md);
}

.qa-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.qa-secondary {
  background: var(--bg-0);
  border: 1px solid var(--line);
  color: var(--ink-1);
}

.qa-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}

.qa-ghost:hover {
  background: var(--bg-2);
  color: var(--ink-0);
}

/* ----- Forms ----- */

.form-control,
.form-select {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  padding: 8px 10px;
  background: var(--bg-0);
  color: var(--ink-1);
  font-size: var(--text-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}

.form-control::placeholder {
  color: var(--muted);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-1);
  margin-bottom: var(--space-1);
}

/* ----- Status badges ----- */

.badge-status,
.status-pill,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: var(--text-xs);
  border: 1px solid transparent;
  line-height: 1.4;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted-2);
}

.status-dot--planned,
.status-dot--status-planned { background: var(--info); }
.status-dot--in_progress,
.status-dot--status-in_progress { background: var(--warn); }
.status-dot--completed,
.status-dot--status-completed { background: var(--ok); }
.status-dot--failed,
.status-dot--status-failed { background: var(--err); }
.status-dot--on_hold,
.status-dot--status-on_hold { background: var(--warn); }
.status-dot--delivered,
.status-dot--status-delivered { background: #0e7490; }
.status-dot--hand_in,
.status-dot--status-hand_in { background: var(--muted); }

.status-planned {
  background: var(--info-soft);
  color: var(--info);
  border-color: var(--info-line);
}

.status-in_progress,
.status-pill-progress {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-line);
}

.status-completed,
.status-pill-completed {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-line);
}

.status-delivered {
  background: #ecfeff;
  color: #0e7490;
  border-color: #a5f3fc;
}

.status-hand_in,
.status-pill-neutral {
  background: var(--bg-2);
  color: var(--muted);
  border-color: var(--line);
}

.status-failed,
.status-pill-failed {
  background: var(--err-soft);
  color: var(--err);
  border-color: var(--err-line);
}

.status-on_hold,
.status-pill-hold {
  background: var(--bg-2);
  color: var(--ink-1);
  border-color: var(--line);
}

.status-cancelled {
  background: var(--bg-2);
  color: var(--muted);
  border-color: var(--line);
}

.pill-neutral {
  background: var(--bg-2);
  border-color: var(--line);
  color: var(--ink-1);
}

/* ----- Tables (Linear-style) ----- */

.table-responsive {
  border-radius: var(--radius-lg);
  overflow: auto;
  border: 1px solid var(--line);
}

.table {
  margin-bottom: 0;
  font-size: var(--text-sm);
  --bs-table-bg: transparent;
  --bs-table-hover-bg: var(--bg-1);
}

.table th {
  background: var(--surface-elevated);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  vertical-align: middle;
  color: var(--ink-1);
  border: none;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-0);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--bg-1);
}

.table tbody tr.is-selected td {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}

.clean-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(8px);
  background: rgba(250, 251, 252, 0.95);
}

[data-theme="dark"] .clean-table thead th {
  background: rgba(26, 34, 45, 0.95);
}

.clean-table tbody tr:nth-child(even) td {
  background: var(--bg-0);
}

.data-table--compact .table th,
.data-table--compact .table td {
  padding: 8px 12px;
}

.group-link,
.status-link {
  color: var(--ink-0);
  font-weight: 500;
  text-decoration: none;
}

.group-link:hover,
.status-link:hover {
  color: var(--brand);
  text-decoration: underline;
}

.group-link:focus-visible,
.status-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ----- Pagination ----- */

.pagination .page-link {
  border-radius: var(--radius-md);
  border-color: var(--line);
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--ink-1);
  background: var(--bg-0);
}

.pagination .page-item:not(:first-child) .page-link {
  margin-left: var(--space-1);
}

.pagination .page-item.active .page-link {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ----- Alerts ----- */

.alert {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  box-shadow: none;
  font-size: var(--text-sm);
}

/* ----- Charts ----- */

.chart-wrap {
  position: relative;
  min-height: 240px;
}

.chart-tall {
  min-height: 280px;
}

.chart-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-1) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  z-index: 1;
  pointer-events: none;
}

.chart-loading.loaded::before {
  display: none;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.progress-track {
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 6px;
}

.progress-bar {
  background: var(--brand-gradient);
}

/* ----- Next steps / quick filters ----- */

.next-steps-grid,
.wp-quick-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
}

.next-step,
.wp-quick-filter {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg-0);
  text-decoration: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.next-step:hover,
.wp-quick-filter:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: none;
}

.next-step-title,
.wp-quick-filter-title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--ink-0);
}

.next-step-note,
.wp-quick-filter-value {
  font-size: var(--text-xs);
  color: var(--muted);
}

.next-step-primary {
  border-color: rgba(var(--brand-rgb), 0.25);
  background: var(--brand-soft);
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.recent-list li {
  display: flex;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.recent-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 7px;
  background: var(--brand);
  flex-shrink: 0;
}

/* ----- Empty state ----- */

.empty-state {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ----- Handover (minimal) ----- */

.handover-shell {
  max-width: 720px;
  margin: 0 auto;
}

.handover-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.sig-wrap {
  background: var(--bg-0);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2);
}

#sigCanvas {
  width: 100%;
  height: 200px;
  display: block;
  touch-action: none;
}

/* ----- Legacy compat ----- */

.main-content {
  padding: 0;
  width: 100%;
}

.container-xxl {
  max-width: none;
  padding: 0;
}

.footer {
  display: none;
}

.fade-in-up,
.fade-in-row,
.device-list-view {
  animation: none;
}

.issues-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--line);
  cursor: help;
}

.wp-scope-pill {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
  .page-title,
  .z-title,
  .wp-title {
    font-size: var(--text-lg);
  }

  .stat-card,
  .wp-stat,
  .kpi-card {
    flex: 1 1 100%;
  }

  .table th,
  .table td {
    font-size: var(--text-xs);
    padding: 8px;
  }

  .group-overview-table th:first-child,
  .group-overview-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-0);
  }

  .group-overview-table thead th:first-child {
    z-index: 3;
    background: var(--bg-1);
  }

  .stat-row-scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: var(--space-2);
    -webkit-overflow-scrolling: touch;
  }

  .stat-row-scroll .stat-card {
    flex: 0 0 160px;
  }
}

/* ----- Extended components ----- */

.topbar-breadcrumb {
  display: none;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--muted);
  margin-right: var(--space-3);
}

@media (min-width: 992px) {
  .topbar-breadcrumb {
    display: flex;
  }
}

.topbar-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.topbar-breadcrumb a:hover {
  color: var(--brand);
}

.stat-row-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stat-card--link {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.stat-card--link:hover {
  border-color: var(--brand-100);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.page-badge {
  display: inline-block;
  margin-bottom: var(--space-2);
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
}

.page-badge--warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-line);
}

.page-badge--readonly {
  background: var(--info-soft);
  color: var(--info);
  border-color: var(--info-line);
}

.inline-summary {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.inline-summary strong {
  color: var(--ink-0);
  font-weight: 600;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.filter-chip,
.chip-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 6px 12px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-1);
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.filter-chip:hover,
.chip-filter:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--ink-0);
}

.chip-filter.is-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-700);
}

.chip-filter .chip-count {
  font-weight: 600;
  color: var(--ink-0);
}

.filter-toolbar--inline {
  margin-bottom: var(--space-4);
}

.filter-toolbar--inline .form-control,
.filter-toolbar--inline .form-select {
  min-width: 140px;
}

.filter-field--search {
  max-width: 280px;
}

.filter-field--group {
  max-width: 200px;
}

.filter-field--wave {
  max-width: 220px;
}

.filter-field--status {
  max-width: 180px;
}

.filter-field--actor,
.filter-field--device {
  max-width: 140px;
}

.scope-toolbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 1020;
  margin: calc(-1 * var(--space-2)) 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--space-2);
}

.tab-bar .tab-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 12px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
}

.tab-bar .tab-link:hover {
  color: var(--ink-0);
  background: var(--bg-1);
}

.tab-bar .tab-link.is-active {
  color: var(--brand-700);
  background: var(--bg-0);
  border-color: var(--line);
  font-weight: 600;
}

.tab-bar .tab-count {
  font-size: var(--text-xs);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--muted);
}

.tab-bar .tab-link.is-active .tab-count {
  background: var(--brand-soft);
  color: var(--brand-700);
}

.wizard-steps {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--muted);
}

.wizard-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--bg-2);
  border: 1px solid var(--line);
}

.wizard-step.is-active {
  color: var(--ink-0);
  font-weight: 500;
}

.wizard-step.is-active .wizard-step-num {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.wizard-step.is-done {
  color: var(--ok);
}

.wizard-step.is-done .wizard-step-num {
  background: var(--ok-soft);
  border-color: var(--ok-line);
  color: var(--ok);
}

.workflow-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.workflow-step.is-current {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-700);
}

.workflow-step.is-done {
  background: var(--ok-soft);
  border-color: var(--ok-line);
  color: var(--ok);
}

.form-section {
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line-soft);
}

.form-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.form-section-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink-0);
  margin: 0 0 var(--space-1);
}

.form-section-desc {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 0 var(--space-3);
}

.table-meta {
  font-size: var(--text-xs);
  color: var(--muted);
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--err);
  background-color: var(--err-soft);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
  border-color: var(--err);
  box-shadow: 0 0 0 3px var(--err-line);
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-3);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-1);
  color: var(--muted);
  font-size: 1.35rem;
}

.bulk-action-bar,
.bulk-toolbar {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 1045;
  padding: var(--space-3) var(--space-5);
  background: var(--bg-0);
  color: var(--ink-0);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
}

.bulk-action-bar[hidden],
.bulk-toolbar[hidden] {
  display: none !important;
}

.bulk-action-bar .btn,
.bulk-toolbar .btn {
  font-size: var(--text-sm);
}

@media (max-width: 991.98px) {
  .bulk-action-bar,
  .bulk-toolbar {
    left: 0;
  }
}

.density-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.density-toggle button {
  border: none;
  background: var(--bg-0);
  padding: 6px 10px;
  font-size: var(--text-xs);
  color: var(--muted);
  cursor: pointer;
}

.density-toggle button.is-active {
  background: var(--brand-soft);
  color: var(--brand-700);
  font-weight: 600;
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.75;
}

.btn.is-loading::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-content {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.modal-header {
  border-bottom: 1px solid var(--line);
  padding: var(--space-3) var(--space-4);
}

.modal-footer {
  border-top: 1px solid var(--line);
  padding: var(--space-3) var(--space-4);
}

.expandable-row details {
  font-size: var(--text-xs);
}

.expandable-row summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 500;
}

.expandable-row pre {
  margin: var(--space-2) 0 0;
  padding: var(--space-2);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow: auto;
  font-size: var(--text-xs);
}

.audit-ts {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: var(--text-xs);
}

.alert-strip {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: var(--text-sm);
}

.alert-strip--config {
  border-color: #f5c2c7;
  background: #f8d7da;
  color: #842029;
  font-weight: 500;
}

.section-divider {
  margin: var(--space-8) 0 var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}

.app-footer-version {
  display: none;
}

/* Modal polish */
.modal-content {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--bg-0);
}

.modal-body {
  padding: var(--space-5);
}

.modal-footer {
  padding: var(--space-3) var(--space-5) var(--space-4);
  border-top: 1px solid var(--line);
  background: var(--bg-1);
}

.collapse-section .collapse-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-1);
  border: none;
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-0);
  cursor: pointer;
  text-align: left;
}

.collapse-section .collapse-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.handover-actions-sticky {
  position: sticky;
  bottom: 0;
  padding: var(--space-3) 0;
  background: linear-gradient(transparent, var(--bg-1) 20%);
}

.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.auth-split-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-6);
  background: var(--brand-solid);
  color: #fff;
}

.auth-split-brand h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  margin: 0 0 var(--space-3);
}

.auth-split-brand p {
  color: rgba(255, 255, 255, 0.75);
  font-size: var(--text-sm);
  max-width: 360px;
}

.auth-split-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--bg-1);
}

@media (max-width: 768px) {
  .auth-split {
    grid-template-columns: 1fr;
  }
  .auth-split-brand {
    padding: var(--space-5);
    min-height: auto;
  }
}

.field-error {
  font-size: var(--text-xs);
  color: var(--err);
  margin-top: var(--space-1);
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.summary-chip {
  padding: 4px 10px;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.summary-chip--ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-line);
}

.summary-chip--warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-line);
}

.summary-chip--err {
  background: var(--err-soft);
  color: var(--err);
  border-color: var(--err-line);
}

.row-stale td {
  background: var(--warn-soft) !important;
}

.table-head-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.table-head-count {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
}

.review-action-panel {
  position: sticky;
  top: calc(var(--topbar-h) + var(--space-4));
}

.client-progress-bar {
  height: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  overflow: hidden;
  margin: var(--space-2) 0;
}

.client-progress-bar .progress-bar {
  height: 100%;
  background: var(--brand-gradient);
}

/* Preserve user-entered line breaks in read-only comment blocks */
.text-preserve-breaks {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Vertical application list (one per row) */
.app-install-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.app-install-list__item {
  font-size: var(--text-sm);
  color: var(--ink-0);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
}

/* Semantic badges (replace Bootstrap text-bg-*) */
.badge-semantic {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  line-height: 1.4;
}

.badge-semantic--ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-line);
}

.badge-semantic--warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-line);
}

.badge-semantic--err {
  background: var(--err-soft);
  color: var(--err);
  border-color: var(--err-line);
}

.badge-semantic--info {
  background: var(--info-soft);
  color: var(--info);
  border-color: var(--info-line);
}

.badge-semantic--neutral {
  background: var(--bg-2);
  color: var(--muted);
  border-color: var(--line);
}

/* --- Toast notifications --- */
.dms-toast-stack {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(420px, calc(100vw - 2rem));
  pointer-events: none;
}

.dms-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  color: var(--ink-0);
  pointer-events: auto;
  animation: dms-toast-in var(--transition-base) ease;
}

.dms-toast.is-leaving {
  animation: dms-toast-out var(--transition-fast) ease forwards;
}

.dms-toast--success { border-left: 3px solid var(--ok); }
.dms-toast--success > .bi { color: var(--ok); }
.dms-toast--danger { border-left: 3px solid var(--err); }
.dms-toast--danger > .bi { color: var(--err); }
.dms-toast--warning { border-left: 3px solid var(--warn); }
.dms-toast--warning > .bi { color: var(--warn); }
.dms-toast--info { border-left: 3px solid var(--info); }
.dms-toast--info > .bi { color: var(--info); }

.dms-toast__text { flex: 1; line-height: var(--leading-normal); }
.dms-toast__close {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

@keyframes dms-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dms-toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

/* --- Command palette --- */
.dms-cmd-palette {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.dms-cmd-palette__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.dms-cmd-palette__panel {
  position: relative;
  width: min(560px, calc(100vw - 2rem));
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.dms-cmd-palette__input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: var(--space-4);
  font-size: var(--text-base);
  background: transparent;
  color: var(--ink-0);
}

.dms-cmd-palette__input:focus { outline: none; }

.dms-cmd-palette__results {
  list-style: none;
  margin: 0;
  padding: var(--space-2);
  max-height: 320px;
  overflow-y: auto;
}

.dms-cmd-palette__item,
.dms-cmd-palette__empty {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--ink-0);
}

.dms-cmd-palette__item.is-active,
.dms-cmd-palette__item:hover {
  background: var(--bg-1);
}

.dms-cmd-palette__meta {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--text-xs);
}

body.dms-cmd-open { overflow: hidden; }

.topbar-cmd-btn {
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-1);
  color: var(--muted);
  font-size: var(--text-sm);
  cursor: pointer;
  max-width: 280px;
}

.topbar-cmd-btn:hover { border-color: var(--line-strong); color: var(--ink-0); }

.topbar-cmd-kbd {
  margin-left: auto;
  font-size: var(--text-xs);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  color: var(--muted);
}

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-0);
  color: var(--muted);
  cursor: pointer;
  margin-right: var(--space-2);
}

.topbar-icon-btn:hover { color: var(--ink-0); border-color: var(--line-strong); }

.dms-onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 1080;
}

.dms-onboarding-tooltip {
  position: fixed;
  z-index: 1085;
  width: min(300px, calc(100vw - 2rem));
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
}

.dms-onboarding-tooltip__footer {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-4);
}

.dms-onboarding-highlight {
  position: relative;
  z-index: 1081;
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.btn-modern.quick-action-btn,
.qa-btn {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-modern.quick-action-btn:active:not(:disabled),
.qa-btn:active:not(:disabled) {
  transform: scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
  .dms-toast { animation: none; }
  .btn-modern.quick-action-btn:active,
  .qa-btn:active { transform: none; }
}
