:root {
  --font-sans: 'Inter Tight', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --color-bg: #f6f8fb;
  --color-surface: #ffffff;
  --color-surface-muted: #f0f3f8;
  --color-border: #d9e1ec;
  --color-border-strong: #c3cedd;
  --color-text: #1c2430;
  --color-text-muted: #5a6b82;
  --color-primary: #1f5eff;
  --color-primary-strong: #1748c7;
  --color-accent: #f08a24;
  --color-success: #18a957;
  --color-warning: #d97706;
  --color-danger: #d14343;
  --shadow-sm: 0 4px 12px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 10px 30px rgba(16, 24, 40, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --max-width: 1200px;
}

html[data-theme='dark'] {
  --color-bg: #0b1220;
  --color-surface: #111a2b;
  --color-surface-muted: #192438;
  --color-border: #2b3b57;
  --color-border-strong: #3a4d70;
  --color-text: #e6edf8;
  --color-text-muted: #9db0cf;
  --color-primary: #6ea8ff;
  --color-primary-strong: #94beff;
  --shadow-sm: 0 4px 12px rgba(2, 8, 18, 0.5);
  --shadow-md: 0 10px 30px rgba(2, 8, 18, 0.65);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.5;
}
.global-progress {
  position: fixed;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  z-index: 1300;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(90deg, transparent 0%, transparent 18%, #5b8dff 42%, #9ec0ff 58%, transparent 82%, transparent 100%);
  background-size: 220% 100%;
  transition: opacity 120ms ease;
}
.global-progress.is-active {
  opacity: 1;
  animation: progress-slide 1s linear infinite;
}
@keyframes progress-slide {
  0% { background-position: 180% 0; }
  100% { background-position: -40% 0; }
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-strong); }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid color-mix(in srgb, var(--color-primary) 70%, white);
  outline-offset: 2px;
}

.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 var(--space-5); }
.skip-link {
  position: absolute;
  top: -48px;
  left: 12px;
  background: #0f1729;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 1200;
}
.skip-link:focus {
  top: 10px;
}

header.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #0f1729;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
header .topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 12px var(--space-5);
  gap: 10px;
}

header.site-header.shrink .topbar {
  padding: var(--space-3) var(--space-5);
}
header.site-header.shrink {
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}
.breadcrumb-bar.shrink {
  padding-top: 2px;
  padding-bottom: 2px;
}
header .topbar nav { display: flex; align-items: center; gap: var(--space-4); }
header .brand { display: flex; align-items: center; gap: var(--space-3); font-weight: 700; letter-spacing: 0.2px; color: #fff; text-decoration: none; min-height: 32px; }
header .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-accent); }
header .brand .brand-label { line-height: 1; }
.brand-logo { display:block; height:32px; width:auto; max-width:min(220px, 42vw); object-fit:contain; }
.brand-logo-drawer { height:28px; max-width:180px; }
.topbar-row { display:flex; align-items:center; justify-content: space-between; gap: var(--space-3); width:100%; }
.brand-wrap { display:flex; align-items:center; gap: var(--space-3); justify-content: flex-start; width:auto; flex:0 0 auto; }
.brand-actions { display:flex; align-items:center; gap: var(--space-2); }
.login-brand-lockup { display:flex; align-items:center; gap:12px; margin-bottom: var(--space-3); }
.login-brand-logo { display:block; height:52px; width:auto; max-width:240px; object-fit:contain; }
.login-brand-name { font-size:1.35rem; font-weight:800; letter-spacing:0.02em; color: var(--color-text); }
.quick-deviation { display:none; align-items:center; justify-content:center; width:40px; height:40px; border-radius:12px; background: rgba(255,255,255,0.14); color:#e5edff; font-size:22px; font-weight:800; text-decoration:none; border:1px solid rgba(255,255,255,0.22); }
.quick-deviation:hover { background: rgba(255,255,255,0.22); }
.quick-action { display:none !important; }
header nav a { color: #dce6ff; font-weight: 600; }
header nav a:hover { color: #fff; }
.nav-links a.active { color: #fff; border-bottom: 2px solid var(--color-accent); padding-bottom: 4px; }
.action-bar { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.sticky-action-form { position: relative; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: 10px 0; border-top: 1px solid var(--color-border); }
.tooltip-pop { position:absolute; background:#0f172a; color:#fff; padding:8px 10px; border-radius:6px; font-size:12px; max-width:260px; box-shadow:0 10px 30px rgba(0,0,0,0.2); z-index:9999;}
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid rgba(255,255,255,0.18); border-radius: 999px; color: #e5edff; }
.user-chip .avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.18); display: grid; place-items: center; font-weight: 800; }
.nav-toggle { display: none; background: none; color: #fff; border: 1px solid rgba(255,255,255,0.3); border-radius: var(--radius-sm); padding: 8px 10px; }
.nav-links { display: flex; align-items: center; gap: var(--space-3); flex-wrap: nowrap; flex: 0 1 auto; }
.nav-links .nav-group { display: flex; align-items: center; gap: var(--space-2); flex-wrap: nowrap; }
.nav-links .nav-group.primary { gap: var(--space-1); }
.nav-links .nav-item { padding: 6px 10px; border-radius: 8px; color: #dce6ff; font-weight: 600; font-size: 14px; border: 1px solid transparent; }
.nav-links .nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-links .nav-item.active {
  border-color: rgba(255,255,255,0.18);
  color: #fff;
  background: rgba(255,255,255,0.08);
}
.nav-dropdown .caret { font-size: 11px; margin-left: 4px; }

.nav-dropdown { position: relative; }
.nav-dropdown button {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #e5edff;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}
.nav-dropdown.active button {
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.14);
  color: #fff;
}
.nav-dropdown-menu {
  position: absolute;
  top: 110%;
  left: 0;
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  border-radius: 10px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  z-index: 30;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}
.nav-dropdown-menu a {
  color: var(--color-text);
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  background: #fff;
}
.nav-dropdown-menu a:last-child { border-bottom: none; }
.nav-dropdown-menu a:hover,
.nav-dropdown-menu a:focus {
  background: var(--color-surface-muted);
  color: var(--color-primary);
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.nav-more button { background: rgba(255,255,255,0.05); }
.nav-theme-toggle {
  position: relative;
  width: 64px;
  height: 32px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #dce6ff;
  border-radius: 999px;
  cursor: pointer;
}
.nav-theme-toggle:hover { background: rgba(255,255,255,0.14); }
.nav-theme-toggle .theme-icon {
  position: relative;
  z-index: 2;
  font-size: 13px;
  line-height: 1;
}
.nav-theme-toggle .theme-icon-sun { color: #fef08a; }
.nav-theme-toggle .theme-icon-moon { color: #bfdbfe; opacity: 0.6; }
.nav-theme-toggle .theme-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #f8fafc;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}
.nav-theme-toggle[data-theme='dark'] .theme-knob {
  transform: translateX(32px);
  background: #0f172a;
  border: 1px solid #334155;
}
.nav-theme-toggle[data-theme='dark'] .theme-icon-sun { opacity: 0.55; }
.nav-theme-toggle[data-theme='dark'] .theme-icon-moon { opacity: 1; }

.main-content { padding: var(--space-6) 0 var(--space-8); }
.breadcrumb-bar { background: #0b1220; color: #dce6ff; border-bottom: 1px solid rgba(255,255,255,0.08); }
.breadcrumb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  font-size: 14px;
}
.breadcrumb-trail { display: flex; align-items: center; gap: 8px; min-width: 0; }
.breadcrumb a { color: #dce6ff; }
.breadcrumb span.sep { opacity: 0.5; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-4); }
.grid > .card { margin-top: 0; }

.table-wrapper { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; min-height: 120px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
.table th { text-align: left; background: var(--color-surface-muted); font-weight: 700; color: var(--color-text); position: sticky; top: 0; z-index: 1; }
.table tr[data-open-url] { cursor: pointer; }
.table tr:hover td { background: color-mix(in srgb, var(--color-surface-muted) 65%, var(--color-surface)); }
.table tr[data-open-url]:focus-visible td {
  background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface));
  box-shadow: inset 0 2px 0 rgba(37, 99, 235, 0.45), inset 0 -2px 0 rgba(37, 99, 235, 0.45);
}
.table .pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.pill.success { background: rgba(24,169,87,0.12); color: #0f7b3c; }
.pill.warn { background: rgba(217,119,6,0.12); color: #8b4b02; }
.pill.danger { background: rgba(220, 38, 38, 0.14); color: #991b1b; }
.pill.info { background: rgba(37, 99, 235, 0.12); color: #1d4ed8; }
.pill.neutral { background: rgba(148, 163, 184, 0.16); color: #334155; }
.pill.muted { background: rgba(92,104,120,0.14); color: #344054; }

.button, button, input[type=submit] {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.button.primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-sm); }
.button.primary:hover { background: var(--color-primary-strong); transform: translateY(-1px); }
.button.secondary { background: var(--color-surface-muted); color: var(--color-text); border: 1px solid var(--color-border); }
.button.danger { background: var(--color-danger); color: #fff; }
.button.is-loading,
button.is-loading,
input[type=submit].is-loading {
  opacity: 0.78;
  cursor: wait;
}

form .field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
form label { font-weight: 600; color: var(--color-text); }
form input, form select, form textarea { padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: #fff; font-family: var(--font-sans); }
form input:focus, form select:focus, form textarea:focus { outline: 2px solid rgba(31,94,255,0.25); border-color: var(--color-primary); }

.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); margin-bottom: var(--space-4); font-weight: 600; }
.alert.success { background: rgba(24,169,87,0.12); color: #0f7b3c; }
.alert.warning { background: rgba(217,119,6,0.12); color: #8b4b02; }
.alert.error { background: rgba(209,67,67,0.15); color: #8c1f1f; }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: var(--color-surface-muted); color: var(--color-text-muted); font-size: 12px; font-weight: 700; }

.footer { margin-top: var(--space-8); padding: var(--space-5); color: var(--color-text-muted); text-align: center; font-size: 14px; }

/* Layout helpers */
.grid { display: grid; gap: var(--space-5); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); grid-auto-rows: 1fr; gap: var(--space-3); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }

.header-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.page-title { margin: 0 0 var(--space-3); font-size: 26px; font-weight: 800; letter-spacing: -0.3px; }
.subtitle { color: var(--color-text-muted); margin-bottom: var(--space-4); }
.hero { background: linear-gradient(120deg, #0f1729 0%, #1f5eff 80%); color: #fff; border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-md); margin-bottom: var(--space-6); }
.hero h1 { margin: 0 0 var(--space-3); font-size: 32px; }
.hero p { margin: 0; color: #e3ebff; }
.stat-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  row-gap: 8px;
  min-height: 140px;
  height: 100%;
  align-items: start;
}
.stat-card h3 { margin: 0; color: var(--color-text-muted); font-size: 14px; letter-spacing: 0.2px; text-transform: uppercase; }
.stat-card .metric { font-size: 28px; font-weight: 800; margin: 0; display: flex; align-items: center; }
.stat-card .badge { align-self: flex-start; }
.stat-card .summary-row,
.stat-card .action-links,
.stat-card > .badge { margin-top: auto; align-self: end; }
.stat-card .action-links { margin: 0; padding: 0; width: 100%; }
.action-links summary { cursor: pointer; list-style: none; }
.action-links summary::-webkit-details-marker { display: none; }
.action-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.action-list a { color: var(--color-primary); text-decoration: none; font-weight: 700; }
.action-list a:hover { text-decoration: underline; }
.action-list.bullets { padding-left: 16px; }
.action-list.bullets li { font-size: 13px; color: var(--color-text-muted); }
.filter-bar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.filter-bar input[type=\"search\"] { min-width: 240px; }
.table-pagination { display: flex; align-items: center; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-4); color: var(--color-text-muted); }
.table-pagination a { color: var(--color-primary); font-weight: 700; }
.empty-state { text-align: center; padding: var(--space-6); color: var(--color-text-muted); border: 1px dashed var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.empty-state strong { display: block; margin-bottom: var(--space-2); color: var(--color-text); }
.filter-row { background: var(--color-surface-muted); }
.filter-row th { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); }
.filter-input, .filter-select { width: 100%; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 14px; }
.filter-input:focus, .filter-select:focus { outline: 2px solid rgba(31,94,255,0.25); border-color: var(--color-primary); background: #fff; }
.filter-form { display: grid; gap: var(--space-3); }
.filter-bar .button { height: 38px; }
.filter-actions { text-align: right; padding: var(--space-2) var(--space-3); }

/* CV module UX polish */
.cv-page { display: grid; gap: var(--space-4); }
.cv-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.cv-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cv-card-tight { padding: var(--space-4); }
.cv-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
.cv-field-full { grid-column: 1 / -1; }
.cv-visibility-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}
.cv-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
}
.cv-check input[type="checkbox"] { margin: 0; width: 16px; height: 16px; }
.cv-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.cv-inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cv-inline-form select { min-width: 180px; }
.cv-inline-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cv-inline-actions form { margin: 0; }
.cv-item-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.cv-item-title {
  display: grid;
  gap: 4px;
  min-width: 220px;
  flex: 1;
}
.cv-item-meta { color: var(--color-text-muted); font-size: 13px; }
.cv-item-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.cv-item-form-grid .cv-field-full { grid-column: 1 / -1; }
.cv-helper {
  color: var(--color-text-muted);
  font-size: 13px;
}
.cv-snapshot-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.cv-control-stack {
  display: grid;
  gap: var(--space-2);
}
.cv-control-row {
  display: flex;
  align-items: end;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.cv-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
}
.cv-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
.cv-table td, .cv-table th { vertical-align: top; }

@media (max-width: 980px) {
  .cv-profile-grid,
  .cv-snapshot-controls,
  .cv-grid-two,
  .cv-item-form-grid,
  .cv-visibility-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .cv-inline-form { width: 100%; }
  .cv-inline-form select,
  .cv-inline-form input[type="text"],
  .cv-inline-form button,
  .cv-control-row > * {
    width: 100%;
  }
  .cv-table-responsive thead { display: none; }
  .cv-table-responsive,
  .cv-table-responsive tbody,
  .cv-table-responsive tr,
  .cv-table-responsive td {
    display: block;
    width: 100%;
  }
  .cv-table-responsive tr {
    border-bottom: 1px solid var(--color-border);
    padding: 10px 0;
  }
  .cv-table-responsive td {
    border: none !important;
    padding: 4px 0 !important;
  }
  .cv-table-responsive td::before {
    content: attr(data-label);
    display: block;
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 2px;
  }
}

/* Toast messages (flash messages) */
.flash-stack { position: fixed; top: var(--space-5); right: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); z-index: 40; }
.flash {
  min-width: 260px;
  max-width: 460px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: #fff;
  box-shadow: var(--shadow-md);
  font-weight: 700;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.flash-text { flex: 1; min-width: 0; }
.flash .flash-text,
.flash .flash-text * {
  color: inherit !important;
}
.flash a,
.flash a:visited {
  color: inherit !important;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.flash-close {
  border: none;
  background: transparent;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0.9;
}
.flash-close:hover { opacity: 1; }
.flash.info { background: var(--color-primary); }
.flash.success { background: var(--color-success); }
.flash.warning { background: var(--color-warning); }
.flash.error { background: var(--color-danger); }
.flash.info,
.flash.success,
.flash.error {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff;
}
.flash.warning,
.flash.warning .flash-close {
  color: #111827 !important;
  -webkit-text-fill-color: #111827;
}
.flash.fade-out { opacity: 0; transition: opacity 220ms ease; }
.shortcut-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(15, 23, 42, 0.56);
}
.shortcut-modal.open { display: flex; }
.shortcut-modal-panel {
  width: min(680px, 96vw);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.shortcut-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
}
.shortcut-modal-header h3 { margin: 0; font-size: 18px; }
.shortcut-modal-close {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.shortcut-grid {
  display: grid;
  grid-template-columns: minmax(170px, auto) 1fr;
  gap: 10px 14px;
  padding: 14px;
  font-size: 14px;
}
.shortcut-grid kbd {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  font-family: inherit;
  font-size: 12px;
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-bottom-color: color-mix(in srgb, var(--color-border-strong) 78%, #000);
  background: var(--color-surface-muted);
  border-radius: 6px;
  padding: 2px 6px;
  margin-right: 2px;
}
.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  z-index: 39;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}
.back-to-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Global search bar style */
.search-box { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.12); border-radius: var(--radius-md); padding: 6px 10px; width: 100%; }
.search-box input { border: none; background: transparent; color: #fff; width: 100%; min-height: 38px; }
.search-box input:focus { outline: none; }

@media (max-width: 768px) {
  header .topbar { flex-direction: column; align-items: stretch; padding: var(--space-3) var(--space-4); gap: var(--space-3); }
  .brand-wrap { width: 100%; justify-content: space-between; }
  header nav { width: 100%; flex-direction: column; align-items: flex-start; }
  .nav-links { display: none; flex-direction: column; width: 100vw; max-width: 360px; position: fixed; top: 0; left: -110%; height: 100vh; background: #0f1729; padding: var(--space-5); gap: var(--space-2); box-shadow: var(--shadow-md); z-index: 50; overflow-y: auto; transition: left 160ms ease; }
  .nav-links.open { display: flex; left: 0; }
  .nav-toggle { display: inline-flex; }
  .container { padding: 0 var(--space-4); }
  .main-content { padding-top: var(--space-5); }
  .shortcut-grid { grid-template-columns: 1fr; }

  .search-box { width: 100%; flex: 0 0 auto; max-width: 100%; }
  .search-box input { width: 100%; }
  .nav-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40; opacity: 0; visibility: hidden; transition: opacity 150ms ease; }
  .nav-overlay.show { opacity: 1; visibility: visible; }

  /* Mobile: force single-column grids even when templates set custom column widths inline. */
  .grid.two { grid-template-columns: 1fr !important; }
  .grid.three { grid-template-columns: 1fr !important; }
  .grid.four { grid-template-columns: 1fr !important; }

  /* Drawer items */
  .nav-links .nav-group { flex-direction: column; gap: var(--space-1); width: 100%; }
  .nav-links .nav-item { width: 100%; text-align: left; padding: 12px 0; border: none; border-radius: 0; display: block; font-size: 16px; }
  .nav-links .nav-item.active { border: none; }
  .nav-links .nav-item + .nav-item { border-top: 1px solid rgba(255,255,255,0.08); }
  .nav-links .quick-action { font-weight: 800; color: #90e0ff; display:block !important; }
  .nav-dropdown, .nav-more { width: 100%; }
  .nav-dropdown button { width: 100%; justify-content: space-between; text-align: left; background: rgba(255,255,255,0.06); padding: 12px 0; border: none; color: #e5edff; }
  .nav-dropdown-menu { position: relative; top: 0; left: 0; box-shadow: none; border: none; background: transparent; padding-left: var(--space-2); }
  .nav-dropdown-menu a { padding: 8px 0; border: none; background: transparent; color: #dce6ff; border-top: 1px solid rgba(255,255,255,0.05); }
  .nav-links .user-chip { width: 100%; justify-content: flex-start; margin-top: var(--space-3); }
  .quick-deviation { display:inline-flex; }
  .nav-drawer-header { display:flex; }
  .nav-close { display:inline-flex; }

  /* Mobile action bar for key screens */
  .action-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 12px;
    box-shadow: 0 -6px 18px rgba(0,0,0,0.12);
    z-index: 30;
    gap: 10px;
    flex-wrap: wrap;
  }
  .action-bar .btn { flex: 1 1 auto; min-width: 45%; }
}

@media (min-width: 769px) {
  .quick-deviation { display: none !important; }
  .quick-action { display: none !important; }
}

.nav-drawer-header { display:flex; align-items:center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-3); color:#e5edff; }
.nav-close { background:none; border:1px solid rgba(255,255,255,0.2); color:#fff; padding:6px 10px; border-radius:8px; cursor:pointer; display:none; }
.brand-inline { font-weight:800; letter-spacing:0.3px; }
.nav-drawer-header { display:none; }

@media (max-width: 768px) {
  .brand-logo { height:26px; max-width:160px; }
  .login-brand-logo { height:44px; max-width:200px; }
}

/* Permission chips */
.permissions-cloud { display:flex; flex-wrap:wrap; gap:8px; }
.permission-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 12px;
  background: #eef2ff;
  color: #1f2937;
  font-size: 13px;
  line-height: 1.3;
  word-break: break-all;
  max-width: 100%;
}

html[data-theme='dark'] .hero {
  background: linear-gradient(120deg, #111a2b 0%, #1b3057 80%);
}
html[data-theme='dark'] .search-box {
  background: rgba(255,255,255,0.08);
}
html[data-theme='dark'] .search-box input {
  color: #f1f5ff;
}
html[data-theme='dark'] form input,
html[data-theme='dark'] form select,
html[data-theme='dark'] form textarea {
  background: #121d30;
  color: #e6edf8;
  border-color: #2b3b57;
}
html[data-theme='dark'] .nav-dropdown-menu,
html[data-theme='dark'] .nav-dropdown-menu a {
  background: #111a2b;
  color: #e6edf8;
  border-color: #2b3b57;
}
html[data-theme='dark'] .nav-dropdown-menu a:hover,
html[data-theme='dark'] .nav-dropdown-menu a:focus {
  background: #1b2a44;
  color: #d6e5ff;
}
html[data-theme='dark'] .empty-state {
  background: #111a2b;
}
html[data-theme='dark'] .shortcut-modal {
  background: rgba(2, 8, 18, 0.74);
}
html[data-theme='dark'] .shortcut-modal-panel {
  background: #111a2b;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
