/*
 * Service Manager UI system
 * Tabler provides the Bootstrap 5 component foundation. This file owns the
 * product identity, application shell and compatibility styles used while
 * legacy templates are migrated to shared Jinja components.
 */

:root {
  --sm-bg: #f8fafc;
  --sm-surface: #ffffff;
  --sm-surface-muted: #f1f5f9;
  --sm-surface-raised: #ffffff;
  --sm-border: #e2e8f0;
  --sm-border-strong: #cbd5e1;
  --sm-text: #0f172a;
  --sm-text-muted: #475569;
  --sm-primary: #2563eb;
  --sm-primary-hover: #1d4ed8;
  --sm-primary-contrast: #ffffff;
  --sm-primary-soft: #eff6ff;
  --sm-success: #1d4ed8;
  --sm-success-soft: #eff6ff;
  --sm-warning-accent: #d97706;
  --sm-warning: #b45309;
  --sm-warning-soft: #fff7ed;
  --sm-danger: #dc2626;
  --sm-danger-text: #b91c1c;
  --sm-danger-contrast: #ffffff;
  --sm-danger-soft: #fef2f2;
  --sm-info: #1d4ed8;
  --sm-info-soft: #eff6ff;
  --sm-sidebar-bg: #111827;
  --sm-sidebar-border: #374151;
  --sm-sidebar-text: #f1f5f9;
  --sm-sidebar-muted: #cbd5e1;
  --sm-sidebar-active: #1e3a8a;
  --sm-sidebar-hover: #1f2937;
  --sm-topbar-bg: rgba(255, 255, 255, .94);
  --sm-radius-sm: .5rem;
  --sm-radius: .625rem;
  --sm-radius-lg: .75rem;
  --sm-shadow-sm: 0 1px 2px rgba(20, 35, 45, .04), 0 5px 16px rgba(20, 35, 45, .035);
  --sm-shadow-lg: 0 18px 50px rgba(20, 35, 45, .16);
  --sm-sidebar-width: 272px;
  --sm-sidebar-collapsed: 76px;
  --sm-topbar-height: 64px;
  --sm-content-width: 1600px;
  --sm-space-1: .25rem;
  --sm-space-2: .5rem;
  --sm-space-3: .75rem;
  --sm-space-4: 1rem;
  --sm-space-5: 1.25rem;
  --sm-space-6: 1.5rem;
  --sm-space-8: 2rem;
  --sm-space-10: 2.5rem;
  --tblr-primary: var(--sm-primary);
  --tblr-primary-rgb: 37, 99, 235;
  --tblr-success: var(--sm-success);
  --tblr-success-rgb: 29, 78, 216;
  --tblr-success-lt: var(--sm-success-soft);
  --tblr-success-fg: var(--sm-primary-contrast);
  --tblr-success-darken: var(--sm-primary-hover);
  --tblr-danger: var(--sm-danger);
  --tblr-danger-fg: var(--sm-danger-contrast);
  --tblr-green: var(--sm-success);
  --tblr-green-lt: var(--sm-success-soft);
  --tblr-teal: var(--sm-info);
  --tblr-teal-lt: var(--sm-info-soft);
  --tblr-body-bg: var(--sm-bg);
  --tblr-body-color: var(--sm-text);
  --tblr-border-color: var(--sm-border);
  --tblr-card-bg: var(--sm-surface);
}

html[data-bs-theme="dark"] {
  --sm-bg: #0b1220;
  --sm-surface: #111c2e;
  --sm-surface-muted: #17253a;
  --sm-surface-raised: #1c2b40;
  --sm-border: #334155;
  --sm-border-strong: #475569;
  --sm-text: #f1f5f9;
  --sm-text-muted: #cbd5e1;
  --sm-primary: #93c5fd;
  --sm-primary-hover: #bfdbfe;
  --sm-primary-contrast: #0f172a;
  --sm-primary-soft: #1e3a5f;
  --sm-success: #93c5fd;
  --sm-success-soft: #1e3a5f;
  --sm-warning-accent: #fdba74;
  --sm-warning: #fdba74;
  --sm-warning-soft: #422d1b;
  --sm-danger: #fca5a5;
  --sm-danger-text: #fca5a5;
  --sm-danger-contrast: #0f172a;
  --sm-danger-soft: #452328;
  --sm-info: #93c5fd;
  --sm-info-soft: #1e3a5f;
  --sm-sidebar-bg: #0b1220;
  --sm-sidebar-border: #334155;
  --sm-sidebar-text: #f1f5f9;
  --sm-sidebar-muted: #cbd5e1;
  --sm-sidebar-active: #1e3a8a;
  --sm-sidebar-hover: #1f2937;
  --sm-topbar-bg: rgba(17, 28, 46, .96);
  --sm-shadow-sm: 0 1px 2px rgba(0, 0, 0, .16), 0 8px 22px rgba(0, 0, 0, .11);
  --sm-shadow-lg: 0 22px 60px rgba(0, 0, 0, .38);
  --tblr-body-bg: var(--sm-bg);
  --tblr-body-color: var(--sm-text);
  --tblr-border-color: var(--sm-border);
  --tblr-card-bg: var(--sm-surface);
  --tblr-success-rgb: 147, 197, 253;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--sm-bg); }
body.sm-body {
  min-height: 100vh;
  margin: 0;
  background: var(--sm-bg);
  color: var(--sm-text);
  font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--sm-primary); text-underline-offset: 2px; }
a:hover { color: var(--sm-primary-hover); }
:focus-visible { outline: 2px solid var(--sm-primary); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted, .text-muted { color: var(--sm-text-muted) !important; }

/* Application shell */
.sm-app-shell { min-height: 100vh; }
.sm-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  width: var(--sm-sidebar-width);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 0;
  overflow: hidden;
  background: var(--sm-sidebar-bg);
  border: 0;
  border-right: 1px solid var(--sm-sidebar-border);
  color: var(--sm-sidebar-text);
  transition: width .18s ease, transform .18s ease;
}
.sm-sidebar-brand {
  min-height: var(--sm-topbar-height);
  display: flex;
  align-items: center;
  gap: var(--sm-space-2);
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--sm-sidebar-border);
}
.sm-brand {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sm-sidebar-text);
  text-decoration: none;
}
.sm-brand:hover { color: #fff; }
.sm-brand-mark {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--sm-primary) 82%, #fff 18%);
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.sm-brand-copy, .sm-auth-brand > span:last-child, .sm-public-brand > span:last-child { display: grid; line-height: 1.15; min-width: 0; }
.sm-brand-copy strong, .sm-auth-brand strong, .sm-public-brand strong { font-size: .92rem; font-weight: 700; white-space: nowrap; }
.sm-brand-copy small, .sm-auth-brand small, .sm-public-brand small { margin-top: 3px; color: var(--sm-sidebar-muted); font-size: .69rem; white-space: nowrap; }
.sm-sidebar-collapse, .sm-sidebar-close { flex: 0 0 auto; color: var(--sm-sidebar-muted); }
.sm-sidebar-collapse:hover, .sm-sidebar-close:hover { color: #fff; background: rgba(255,255,255,.07); }
.sm-sidebar-close { display: none; }
.sm-sidebar-scroll { min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 10px 18px; scrollbar-width: thin; scrollbar-color: #38505d transparent; }
.sm-nav { display: grid; gap: 14px; }
.sm-nav-group { min-width: 0; }
.sm-nav-group-title {
  padding: 0 10px 6px;
  color: var(--sm-sidebar-muted);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .095em;
  text-transform: uppercase;
}
.sm-nav-items { display: grid; gap: 3px; }
.sm-nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--sm-radius-sm);
  color: var(--sm-sidebar-text);
  text-decoration: none;
  font-size: .86rem;
  font-weight: 520;
  transition: background-color .12s ease, color .12s ease;
}
.sm-nav-item:hover { background: rgba(255,255,255,.055); color: #fff; }
.sm-nav-item.active { background: var(--sm-sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--sm-primary); }
.sm-nav-icon { width: 22px; flex: 0 0 22px; display: grid; place-items: center; color: var(--sm-sidebar-muted); font-size: 1.18rem; }
.sm-nav-item.active .sm-nav-icon, .sm-nav-item:hover .sm-nav-icon { color: currentColor; }
.sm-nav-text { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sm-nav-badge {
  min-width: 22px;
  height: 20px;
  margin-left: auto;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: #eaf2f6;
  font-size: .68rem;
  font-weight: 700;
}
.sm-nav-badge-warning { background: color-mix(in srgb, var(--sm-warning) 28%, transparent); color: #ffd99e; }
.sm-sidebar-footer { padding: 10px; border-top: 1px solid var(--sm-sidebar-border); background: color-mix(in srgb, var(--sm-sidebar-bg) 94%, #fff 6%); }
.sm-account { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--sm-radius-sm); color: var(--sm-sidebar-text); text-decoration: none; }
.sm-account:hover { color: #fff; background: rgba(255,255,255,.055); }
.sm-account-avatar { flex: 0 0 auto; background: #2b4554; color: #fff; }
.sm-account-copy { min-width: 0; display: grid; line-height: 1.2; }
.sm-account-copy strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .82rem; }
.sm-account-copy small { margin-top: 2px; color: var(--sm-sidebar-muted); font-size: .69rem; }
.sm-account-chevron { margin-left: auto; color: var(--sm-sidebar-muted); font-size: .95rem; }
.sm-footer-actions { display: grid; gap: 3px; margin-top: 5px; }
.sm-footer-actions form { margin: 0; }
.sm-footer-action {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--sm-radius-sm);
  background: transparent;
  color: var(--sm-sidebar-muted);
  font: inherit;
  font-size: .77rem;
  text-align: left;
}
.sm-footer-action .ti { width: 20px; text-align: center; font-size: 1.05rem; }
.sm-footer-action:hover { background: rgba(255,255,255,.055); color: #fff; }
.sm-footer-danger:hover { color: #ffd0d0; background: rgba(192,59,59,.12); }
.sm-sidebar-meta { display: flex; justify-content: space-between; gap: 8px; padding: 8px 9px 0; color: var(--sm-sidebar-muted); font-size: .63rem; }
.sm-sidebar-meta a { color: inherit; }

.sm-workspace { min-height: 100vh; margin-left: var(--sm-sidebar-width); transition: margin-left .18s ease; }
.sm-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  min-height: var(--sm-topbar-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 20px;
  background: var(--sm-topbar-bg);
  border-bottom: 1px solid var(--sm-border);
  backdrop-filter: blur(12px);
}
.sm-mobile-menu { display: none; }
.sm-global-search { position: relative; flex: 1 1 480px; max-width: 720px; margin: 0; }
.sm-global-search > .ti { position: absolute; left: 13px; top: 50%; translate: 0 -50%; z-index: 2; color: var(--sm-text-muted); font-size: 1.05rem; }
.sm-global-search input {
  width: 100%;
  height: 42px;
  padding: 0 82px 0 40px;
  border: 1px solid var(--sm-border);
  border-radius: var(--sm-radius);
  background: var(--sm-surface-muted);
  color: var(--sm-text);
  box-shadow: none;
}
.sm-global-search input:focus { border-color: color-mix(in srgb, var(--sm-primary) 55%, var(--sm-border)); background: var(--sm-surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sm-primary) 12%, transparent); outline: 0; }
.sm-search-hint { position: absolute; right: 10px; top: 50%; translate: 0 -50%; border: 1px solid var(--sm-border); background: var(--sm-surface); color: var(--sm-text-muted); font-size: .65rem; }
.sm-topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.sm-work-indicator {
  min-width: 54px;
  height: 42px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  padding: 4px 8px;
  border-radius: var(--sm-radius-sm);
  color: var(--sm-text-muted);
  text-decoration: none;
  line-height: 1.05;
}
.sm-work-indicator:hover { background: var(--sm-surface-muted); color: var(--sm-text); }
.sm-work-indicator > span, .sm-work-indicator > .ti { color: var(--sm-text); font-size: .9rem; font-weight: 700; }
.sm-work-indicator small { font-size: .62rem; }
.sm-work-indicator.has-warning > span { color: var(--sm-warning); }
.sm-qr-action { min-height: 42px; display: inline-flex; align-items: center; gap: 7px; }
.sm-main { min-height: calc(100vh - var(--sm-topbar-height)); background: var(--sm-bg); }
.sm-content { width: 100%; max-width: var(--sm-content-width); padding: 24px 24px 48px; }

body.sm-sidebar-collapsed .sm-sidebar { width: var(--sm-sidebar-collapsed); }
body.sm-sidebar-collapsed .sm-workspace { margin-left: var(--sm-sidebar-collapsed); }
body.sm-sidebar-collapsed .sm-brand-copy,
body.sm-sidebar-collapsed .sm-nav-group-title,
body.sm-sidebar-collapsed .sm-nav-text,
body.sm-sidebar-collapsed .sm-nav-badge,
body.sm-sidebar-collapsed .sm-account-copy,
body.sm-sidebar-collapsed .sm-account-chevron,
body.sm-sidebar-collapsed .sm-footer-action span,
body.sm-sidebar-collapsed .sm-sidebar-meta { display: none; }
body.sm-sidebar-collapsed .sm-sidebar-brand { padding-inline: 12px; justify-content: center; flex-wrap: wrap; }
body.sm-sidebar-collapsed .sm-brand { flex: 0 0 auto; }
body.sm-sidebar-collapsed .sm-brand-mark { width: 38px; flex-basis: 38px; }
body.sm-sidebar-collapsed .sm-sidebar-collapse { width: 38px; order: 2; }
body.sm-sidebar-collapsed .sm-sidebar-scroll { padding-inline: 10px; }
body.sm-sidebar-collapsed .sm-nav { gap: 6px; }
body.sm-sidebar-collapsed .sm-nav-item { justify-content: center; padding-inline: 8px; }
body.sm-sidebar-collapsed .sm-nav-icon { flex-basis: 24px; width: 24px; }
body.sm-sidebar-collapsed .sm-account { justify-content: center; }
body.sm-sidebar-collapsed .sm-footer-action { justify-content: center; padding-inline: 6px; }

.sm-sidebar-backdrop { display: none; }

/* Page hierarchy */
.sm-page-header, .page-header {
  margin: 0 0 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.sm-page-heading, .page-header > div:first-child { min-width: 0; }
.sm-kicker, .page-kicker, .eyebrow {
  margin-bottom: 4px;
  color: var(--sm-text-muted);
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.sm-page-title-row { display: flex; align-items: baseline; gap: 10px; }
.sm-page-title, .page-header h1 { margin: 0; color: var(--sm-text); font-size: clamp(1.45rem, 2vw, 1.85rem); font-weight: 720; letter-spacing: -.025em; }
.sm-page-description, .page-header p { max-width: 780px; margin: 5px 0 0; color: var(--sm-text-muted); line-height: 1.45; }
.sm-count { color: var(--sm-text-muted); font-size: .86rem; font-weight: 650; }
.sm-page-actions, .page-actions, .actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }

/* Core components */
.card, .sm-card, .dashboard-section, .panel {
  border: 1px solid var(--sm-border);
  border-radius: var(--sm-radius);
  background: var(--sm-surface);
  color: var(--sm-text);
  box-shadow: var(--sm-shadow-sm);
}
.card-header, .sm-card-header { min-height: 52px; padding: 14px 16px; border-bottom: 1px solid var(--sm-border); background: transparent; }
.card-title, .sm-card-title { margin: 0; color: var(--sm-text); font-size: .95rem; font-weight: 690; }
.sm-card-subtitle { margin: 3px 0 0; color: var(--sm-text-muted); font-size: .78rem; }
.card-body, .sm-card-body { padding: 16px; }
.card-grid, .dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.dashboard-section { margin-bottom: 18px; padding: 18px; }
.dashboard-section > h2, .section-heading h2 { margin: 0 0 14px; font-size: 1rem; font-weight: 700; }

.btn, button, .navbutton, .button-link, .menu-action, .quick-action, .footer-action {
  font-family: inherit;
}
.btn { border-radius: var(--sm-radius-sm); font-weight: 620; }
.btn-primary, .sm-btn-primary, :where(button:not(.btn):not(.sm-footer-action):not(.sm-sidebar-backdrop):not(.iconbutton)) {
  border-color: var(--sm-primary);
  background: var(--sm-primary);
  color: var(--sm-primary-contrast);
}
.btn-primary:hover, .sm-btn-primary:hover { border-color: var(--sm-primary-hover); background: var(--sm-primary-hover); color: var(--sm-primary-contrast); }
:where(button:not(.btn):not(.btn-icon):not(.sm-footer-action):not(.sm-sidebar-backdrop):not(.iconbutton):not(.sm-nav-group-toggle):not(.sm-search-hint)) {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--sm-primary);
  border-radius: var(--sm-control-radius, var(--sm-radius-sm));
  font: inherit;
  font-size: .82rem;
  font-weight: 620;
  cursor: pointer;
}
.sm-btn-secondary { border-color: var(--sm-border-strong); background: var(--sm-surface); color: var(--sm-text); }
.sm-btn-ghost { border-color: transparent; background: transparent; color: var(--sm-text); }
.sm-btn-danger { border-color: var(--sm-danger); background: var(--sm-danger); color: var(--sm-danger-contrast); }
.navbutton, .button-link, .menu-action, .quick-action {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--sm-border-strong);
  border-radius: var(--sm-radius-sm);
  background: var(--sm-surface);
  color: var(--sm-text);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 620;
}
.navbutton:hover, .button-link:hover, .menu-action:hover, .quick-action:hover { border-color: color-mix(in srgb, var(--sm-primary) 45%, var(--sm-border)); background: var(--sm-primary-soft); color: var(--sm-primary); }

/* Forms */
form { min-width: 0; }
label { color: var(--sm-text); font-weight: 600; }
.form-label, form > label, .field > label { margin-bottom: 6px; font-size: .78rem; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea, .form-control, .form-select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--sm-border-strong);
  border-radius: var(--sm-radius-sm);
  background: var(--sm-surface);
  color: var(--sm-text);
  box-shadow: none;
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--sm-text-muted) 72%, transparent); }
input:focus, select:focus, textarea:focus, .form-control:focus, .form-select:focus { border-color: var(--sm-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sm-primary) 13%, transparent); outline: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--sm-primary); outline-offset: 2px; }
input:disabled, select:disabled, textarea:disabled { background: var(--sm-surface-muted); color: var(--sm-text-muted); opacity: .8; }
.sm-required { margin-left: 2px; color: var(--sm-danger-text); }
.sm-field-help, .form-hint { margin-top: 5px; color: var(--sm-text-muted); font-size: .72rem; }
.form-grid, .sm-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full, .sm-form-grid .full, .span-2 { grid-column: 1 / -1; }
.sm-form-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--sm-border); }
.sm-form-section:last-child { border-bottom: 0; }
.sm-form-section-title { margin: 0 0 12px; font-size: .95rem; }
.sm-form-actions { position: sticky; bottom: 0; z-index: 8; display: flex; justify-content: flex-end; gap: 8px; margin: 20px -16px -16px; padding: 12px 16px; border-top: 1px solid var(--sm-border); background: color-mix(in srgb, var(--sm-surface) 94%, transparent); backdrop-filter: blur(8px); }
.filters, .filterbar, .search-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.filters > *, .filterbar > * { flex: 1 1 180px; }
.filters button, .filterbar button { flex: 0 0 auto; }

/* Tables */
.sm-table-wrap, .table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--sm-border); border-radius: var(--sm-radius); background: var(--sm-surface); box-shadow: var(--sm-shadow-sm); }
table, .table { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; color: var(--sm-text); }
thead th, .table > thead > tr > th { padding: 10px 12px; border-bottom: 1px solid var(--sm-border); background: var(--sm-surface-muted); color: var(--sm-text-muted); font-size: .68rem; font-weight: 750; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
tbody td, .table > tbody > tr > td { padding: 11px 12px; border-bottom: 1px solid var(--sm-border); vertical-align: middle; font-size: .82rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--sm-primary-soft) 35%, transparent); }
.sm-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.compact-table td, .compact-table th { padding-block: 8px; }

/* Status */
.sm-badge, .badge, .status-badge, .status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.1;
}
.sm-badge-neutral { background: var(--sm-surface-muted); border-color: var(--sm-border); color: var(--sm-text-muted); }
.sm-badge-muted { background: var(--sm-surface-muted); border-color: var(--sm-border); color: var(--sm-text-muted); }
.sm-badge-info { background: var(--sm-info-soft); border-color: color-mix(in srgb, var(--sm-info) 24%, transparent); color: var(--sm-info); }
.sm-badge-success, .status-ok, .status-active, .status-done { background: var(--sm-success-soft); border-color: color-mix(in srgb, var(--sm-success) 24%, transparent); color: var(--sm-success); }
.sm-badge-warning, .status-warning, .status-due { background: var(--sm-warning-soft); border-color: color-mix(in srgb, var(--sm-warning) 25%, transparent); color: var(--sm-warning); }
.sm-badge-danger, .status-danger, .status-overdue, .status-error { background: var(--sm-danger-soft); border-color: color-mix(in srgb, var(--sm-danger) 24%, transparent); color: var(--sm-danger-text); }
.bg-green-lt, .bg-success-lt { background: var(--sm-success-soft) !important; color: var(--sm-success) !important; }
.text-bg-success { background: var(--sm-success) !important; color: var(--sm-primary-contrast) !important; }
.text-green, .text-success { color: var(--sm-success) !important; }
.btn-success { --tblr-btn-bg: var(--sm-success); --tblr-btn-border-color: var(--sm-success); --tblr-btn-hover-bg: var(--sm-primary-hover); --tblr-btn-hover-border-color: var(--sm-primary-hover); --tblr-btn-color: var(--sm-primary-contrast); }

/* Tabs */
.tabs, .sm-tabs { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 22px; padding: 5px; border: 1px solid var(--sm-border); border-radius: var(--sm-radius); background: var(--sm-surface-muted); }
.tabs .tab-link, .sm-tabs .nav-link { flex: 0 0 auto; min-height: 38px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border: 0; border-radius: var(--sm-radius-sm); color: var(--sm-text-muted); text-decoration: none; font-size: .77rem; font-weight: 650; white-space: nowrap; }
.tabs .tab-link:hover, .sm-tabs .nav-link:hover { color: var(--sm-text); background: var(--sm-surface); }
.tabs .tab-link.active, .sm-tabs .nav-link.active { color: var(--sm-primary); background: var(--sm-surface); box-shadow: var(--sm-shadow-sm), inset 0 -2px 0 var(--sm-primary); }

/* Alerts, empty states, pagination */
.sm-alert, .alert { border-radius: var(--sm-radius); border: 1px solid var(--sm-border); }
.alert:not(.alert-danger):not(.alert-warning):not(.alert-success) { background: var(--sm-info-soft); color: var(--sm-text); }
.alert-danger { background: var(--sm-danger-soft); color: var(--sm-text); border-color: color-mix(in srgb, var(--sm-danger) 25%, var(--sm-border)); }
.alert-warning { background: var(--sm-warning-soft); color: var(--sm-text); border-color: color-mix(in srgb, var(--sm-warning) 25%, var(--sm-border)); }
.alert-success { background: var(--sm-success-soft); color: var(--sm-text); border-color: color-mix(in srgb, var(--sm-success) 25%, var(--sm-border)); }
.sm-alert-title { margin-bottom: 3px; font-weight: 700; }
.sm-empty-state, .empty-state { min-height: 0; display: grid; place-items: center; align-content: center; gap: 7px; padding: 22px; border: 1px dashed var(--sm-border-strong); border-radius: var(--sm-radius); background: var(--sm-surface-muted); color: var(--sm-text-muted); text-align: center; }
.sm-empty-state strong { color: var(--sm-text); }
.sm-empty-state p { max-width: 520px; margin: 0; }
.sm-empty-icon { font-size: 1.7rem; }
.sm-empty-actions { margin-top: 6px; }
.sm-pagination { display: flex; justify-content: center; margin-top: 18px; }
.sm-pagination-label { pointer-events: none; color: var(--sm-text-muted); background: var(--sm-surface-muted); }

/* Dashboard compatibility */
.dashboard-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { min-height: 112px; display: grid; align-content: center; gap: 4px; padding: 16px; border: 1px solid var(--sm-border); border-radius: var(--sm-radius); background: var(--sm-surface); color: var(--sm-text); text-decoration: none; box-shadow: var(--sm-shadow-sm); }
.metric-card:hover { border-color: color-mix(in srgb, var(--sm-primary) 35%, var(--sm-border)); color: var(--sm-text); }
.metric-label { color: var(--sm-text-muted); font-size: .72rem; font-weight: 650; }
.metric-value { font-size: 1.75rem; font-weight: 760; letter-spacing: -.035em; }
.metric-card.danger .metric-value, .metric-card.warning .metric-value { color: var(--sm-warning); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sm-search-summary { margin: 14px 0 10px; color: var(--sm-text-muted); }
.sm-search-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sm-search-metrics .metric-card { min-height: 88px; padding: 12px 14px; }
.sm-search-metrics .metric-value { margin-top: 2px; font-size: 1.55rem; }
.sm-search-metrics .metric-sub { margin-top: 0; }
.sm-search-metrics + .row { margin-bottom: 18px; }
@media (max-width: 767.98px) {
  .sm-search-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-search-metrics .metric-card { min-height: 78px; padding: 10px 12px; }
}

/* Dialogs / QR scanner */
dialog.sm-dialog, dialog.sm-qr-dialog, .qr-scanner-dialog { width: min(620px, calc(100vw - 30px)); max-height: min(88vh, 760px); padding: 0; overflow: hidden; border: 1px solid var(--sm-border); border-radius: var(--sm-radius-lg); background: var(--sm-surface); color: var(--sm-text); box-shadow: var(--sm-shadow-lg); }
dialog::backdrop { background: rgba(5, 12, 17, .62); backdrop-filter: blur(3px); }
.sm-dialog-header, .qr-scanner-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--sm-border); }
.sm-dialog-header h2 { margin: 0; font-size: 1rem; }
.sm-dialog-body, .qr-scanner-body { padding: 16px; overflow-y: auto; }
.qr-scanner-view { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border-radius: var(--sm-radius); background: #071015; }
.qr-scanner-view video { width: 100%; height: 100%; object-fit: cover; }
.qr-scanner-frame { position: absolute; inset: 18%; border: 2px solid rgba(255,255,255,.85); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.18); }
.qr-scanner-status { min-height: 22px; margin: 10px 0; color: var(--sm-text-muted); font-size: .8rem; }
.qr-scanner-status[data-kind="error"] { color: var(--sm-danger-text); }
.qr-scanner-status[data-kind="ok"] { color: var(--sm-success); }
.qr-inline-scan { margin-top: 6px; }

/* Authentication / public */
.sm-auth-body, .sm-public-body { display: grid; grid-template-rows: 1fr auto; background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--sm-primary) 8%, transparent), transparent 35%), var(--sm-bg); }
.sm-auth-main, .sm-public-main { width: min(100%, 1080px); margin: 0 auto; padding: 44px 22px 30px; }
.sm-auth-main { display: grid; justify-items: center; align-content: center; gap: 22px; }
.sm-auth-brand, .sm-public-brand { display: flex; align-items: center; gap: 10px; color: var(--sm-text); text-decoration: none; }
.sm-auth-brand small, .sm-public-brand small { color: var(--sm-text-muted); }
.login-scene { display: none; }
.login-wrap { width: min(100%, 430px); }
.login-card { padding: 26px; border: 1px solid var(--sm-border); border-radius: var(--sm-radius-lg); background: var(--sm-surface); box-shadow: var(--sm-shadow-lg); }
.login-brandline { display: none; }
.login-card h1 { margin: 0 0 7px; font-size: 1.55rem; }
.login-card form { display: grid; gap: 13px; margin-top: 14px; }
.login-card form label { display: grid; gap: 6px; font-size: .78rem; }
.login-card button[type="submit"], .login-card form button { min-height: 42px; border: 0; border-radius: var(--sm-radius-sm); background: var(--sm-primary); color: #fff; font-weight: 700; }
.passkey-login-button { width: 100%; min-height: 42px; margin-top: 18px; border: 1px solid var(--sm-border-strong) !important; border-radius: var(--sm-radius-sm); background: var(--sm-surface-muted) !important; color: var(--sm-text) !important; font-weight: 650; }
.login-divider { display: flex; align-items: center; gap: 9px; margin: 16px 0 2px; color: var(--sm-text-muted); font-size: .7rem; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--sm-border); }
.login-security-note { display: flex; gap: 9px; margin-top: 17px; padding: 11px; border-radius: var(--sm-radius-sm); background: var(--sm-surface-muted); color: var(--sm-text-muted); font-size: .72rem; }
.login-security-note strong { color: var(--sm-text); }
.login-legal-links { display: flex; gap: 12px; margin-top: 14px; font-size: .7rem; }
.sm-public-main { align-self: start; }
.sm-public-brand { margin-bottom: 20px; }
.sm-public-footer, .public-footer { display: flex; justify-content: space-between; gap: 16px; padding: 16px 22px; border-top: 1px solid var(--sm-border); color: var(--sm-text-muted); font-size: .68rem; }
.sm-public-footer span:last-child { display: flex; gap: 12px; }

/* Loader */
.sm-loader, #loader { position: fixed; inset: 0 0 auto; height: 3px; z-index: 2000; display: none; background: var(--sm-primary); pointer-events: none; }
.sm-loader .spinner-border { display: none; }
body.loading .sm-loader, body.loading #loader, body.soft-navigating .sm-loader { display: block; animation: sm-loading 1.2s ease-in-out infinite alternate; transform-origin: left; }
@keyframes sm-loading { from { transform: scaleX(.15); } to { transform: scaleX(.9); } }

/* Fast, keyboard-accessible navigation across desktop and field devices. */
.sm-skip-link { position: fixed; top: 8px; left: 12px; z-index: 2100; padding: 12px 18px; border-radius: var(--sm-radius); background: var(--sm-surface); color: var(--sm-primary); transform: translateY(-150%); }
.sm-skip-link:focus { transform: translateY(0); }
.sm-menu-search { padding: 0 6px 14px; margin-bottom: 10px; border-bottom: 1px solid var(--sm-sidebar-border); }
.sm-menu-search label { display: block; margin-bottom: 7px; color: var(--sm-sidebar-muted); font-size: .72rem; }
#sm-menu-filter { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--sm-sidebar-border); border-radius: var(--sm-radius-sm); color: var(--sm-sidebar-text); background: var(--sm-sidebar-active); }
.sm-menu-search input::placeholder { color: var(--sm-sidebar-muted); }
.sm-menu-empty { padding: 16px; color: var(--sm-sidebar-text); }
.sm-nav [hidden], .sm-menu-empty[hidden] { display: none !important; }
.sm-nav-filtering .sm-nav-group .sm-nav-items { display: grid !important; }
body.sm-sidebar-collapsed .sm-menu-search { display: none; }
.sm-global-search button.sm-search-hint { pointer-events: auto; cursor: pointer; border: 0; background: var(--sm-surface-muted); color: var(--sm-text-muted); border-radius: var(--sm-radius-sm); }
.sm-global-search button.sm-search-hint kbd { margin-left: 6px; font-size: .65rem; }
:where(a, button, input, select, textarea):focus-visible { outline: 3px solid var(--sm-primary); outline-offset: 3px; }

/* Legacy utility compatibility during migration */
.content-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.stack { display: grid; gap: 12px; }
.row { min-width: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.summary-grid, .detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.summary-item, .detail-item { padding: 11px; border: 1px solid var(--sm-border); border-radius: var(--sm-radius-sm); background: var(--sm-surface-muted); }
.summary-item small, .detail-item small { display: block; margin-bottom: 3px; color: var(--sm-text-muted); font-size: .68rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; }
.pagination a { min-height: 36px; display: inline-flex; align-items: center; padding: 6px 10px; border: 1px solid var(--sm-border); border-radius: var(--sm-radius-sm); background: var(--sm-surface); text-decoration: none; }

@media (max-width: 1199.98px) {
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-work-indicator { display: none; }
}

@media (max-width: 991.98px) {
  :root { --sm-topbar-height: 58px; }
  .sm-sidebar { width: min(310px, calc(100vw - 42px)); transform: translateX(-102%); box-shadow: var(--sm-shadow-lg); }
  .sm-sidebar-close { display: inline-grid; }
  .sm-sidebar-collapse { display: none; }
  .sm-workspace { margin-left: 0; }
  .sm-mobile-menu { display: inline-grid; flex: 0 0 auto; }
  .sm-sidebar-backdrop { position: fixed; inset: 0; z-index: 1035; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(5,12,17,.48); }
  body.sm-sidebar-open { overflow: hidden; }
  body.sm-sidebar-open .sm-sidebar { transform: translateX(0); }
  body.sm-sidebar-open .sm-sidebar-backdrop { display: block; }
  .sm-content { padding: 20px 18px 42px; }
  .content-columns { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
  .sm-topbar { gap: 8px; padding: 8px 12px; }
  .sm-global-search { flex-basis: auto; }
  .sm-search-hint { display: none; }
  .sm-global-search input { height: 40px; padding-right: 12px; }
  .sm-qr-action { width: 40px; min-width: 40px; height: 40px; padding: 0; justify-content: center; }
  .sm-qr-action span { display: none; }
  .sm-content { padding: 18px 12px 36px; }
  .sm-page-header, .page-header { align-items: stretch; flex-direction: column; gap: 12px; }
  .sm-page-actions, .page-actions { justify-content: flex-start; }
  .sm-page-actions .btn, .page-actions .btn, .page-actions .navbutton { min-height: 42px; }
  .form-grid, .sm-form-grid { grid-template-columns: 1fr; }
  .form-grid .full, .sm-form-grid .full, .span-2 { grid-column: auto; }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric-card { min-height: 96px; padding: 12px; }
  .metric-value { font-size: 1.45rem; }
  .card-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .filters, .filterbar, .search-row { align-items: stretch; flex-direction: column; }
  .filters > *, .filterbar > * { width: 100%; flex-basis: auto; }
  .filters button, .filterbar button, .filters .btn, .filterbar .btn { min-height: 42px; }
  table.sm-mobile-cards, .sm-mobile-cards thead, .sm-mobile-cards tbody, .sm-mobile-cards tr, .sm-mobile-cards td { display: block; width: 100%; }
  .sm-mobile-cards thead { display: none; }
  .sm-mobile-cards tr { padding: 10px; border-bottom: 1px solid var(--sm-border); }
  .sm-mobile-cards td { padding: 5px 0; border: 0; }
  .sm-public-footer, .public-footer { flex-direction: column; }
}

@media (max-width: 430px) {
  .sm-global-search input { font-size: .78rem; }
  .dashboard-metrics { grid-template-columns: 1fr 1fr; }
  .sm-content { padding-inline: 10px; }
  .login-card { padding: 20px; }
}

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