/* Dolutech Cybersecurity Ecosystem - shared UI components (design system v2).
   Consumes the semantic tokens declared at the top of style.css; no colour
   literal lives here except pure white/black on brand surfaces. Loaded after
   style.css on every page. */

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

.sidebar-group {
  padding: 14px 14px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-group);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-group:first-child {
  padding-top: 4px;
}

.sidebar-nav a .nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: var(--accent-400);
  color: var(--brand-900);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--r-full);
}

.sidebar-collapse-btn {
  display: none;
  width: 100%;
  background: none;
  border: 1px solid var(--sidebar-divider);
  color: var(--sidebar-fg);
  border-radius: var(--r-md);
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sidebar-collapse-btn:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-fg-strong);
}

.sidebar-footer a {
  color: var(--sidebar-fg);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r-md);
}

.sidebar-footer a:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-fg-strong);
}

/* Collapsed rail (desktop only; state in localStorage, applied by theme-early.js) */
@media (min-width: 992px) {
  .sidebar-collapse-btn {
    display: flex;
  }

  html[data-sidebar="collapsed"] .sidebar {
    width: var(--sidebar-width-collapsed);
  }

  html[data-sidebar="collapsed"] .main-content {
    margin-left: var(--sidebar-width-collapsed);
  }

  html[data-sidebar="collapsed"] .sidebar-brand {
    height: 64px;
    padding: 0;
  }

  html[data-sidebar="collapsed"] .sidebar-brand .sidebar-brand-full {
    display: none;
  }

  html[data-sidebar="collapsed"] .sidebar-brand .sidebar-brand-mark {
    display: block;
    height: 36px;
  }

  html[data-sidebar="collapsed"] .sidebar-group {
    height: 1px;
    padding: 0;
    margin: 8px 12px;
    background: var(--sidebar-divider);
    overflow: hidden;
    color: transparent;
  }

  html[data-sidebar="collapsed"] .sidebar-nav a {
    justify-content: center;
    padding: 12px 0;
  }

  html[data-sidebar="collapsed"] .sidebar-nav a .nav-label,
  html[data-sidebar="collapsed"] .sidebar-nav a .nav-badge,
  html[data-sidebar="collapsed"] .sidebar-footer .nav-label,
  html[data-sidebar="collapsed"] .sidebar-collapse-btn .nav-label {
    display: none;
  }

  html[data-sidebar="collapsed"] .sidebar-nav a i {
    width: auto;
    font-size: 1.15rem;
  }

  html[data-sidebar="collapsed"] .sidebar-collapse-btn i {
    transform: rotate(180deg);
  }
}

.topbar {
  gap: 16px;
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: var(--r-sm);
}

.breadcrumbs a:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

.breadcrumbs .crumb-sep {
  opacity: 0.6;
}

.breadcrumbs .crumb-current {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  min-width: 0;
}

.topbar-search-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.topbar-search-btn kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-muted);
}

.topbar-actions .btn.theme-toggle,
.topbar-actions .notif-bell-btn.btn,
.topbar-actions .btn-icon-topbar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  margin: 0;
}

.topbar-actions .btn.theme-toggle:hover,
.topbar-actions .notif-bell-btn.btn:hover,
.topbar-actions .btn-icon-topbar:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

.user-menu-wrap {
  position: relative;
}

.user-menu {
  border: 1px solid transparent;
}

.user-menu:hover,
.user-menu[aria-expanded="true"] {
  background: var(--surface-sunken);
  border-color: var(--border);
}

.user-menu .user-caret {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: 2px;
}

.ui-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: var(--z-dropdown);
}

.ui-menu[hidden] {
  display: none;
}

.ui-menu-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.ui-menu-head .ui-menu-name {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ui-menu-head .ui-menu-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.ui-menu-label {
  padding: 8px 10px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ui-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--r-md);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.ui-menu-item:hover,
.ui-menu-item:focus-visible {
  background: var(--surface-sunken);
  outline: none;
}

.ui-menu-item i {
  width: 18px;
  text-align: center;
  color: var(--text-muted);
}

.ui-menu-item[aria-checked="true"] {
  color: var(--text-link);
  font-weight: 600;
}

.ui-menu-item[aria-checked="true"]::after {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-left: auto;
  font-size: 0.75rem;
}

.ui-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

.ui-menu-item.danger {
  color: var(--danger-fg);
}

.ui-menu-item.danger i {
  color: var(--danger-fg);
}

.ui-menu-inline {
  display: flex;
  gap: 4px;
  padding: 2px 6px 6px;
}

.ui-menu-inline .ui-menu-item {
  width: auto;
  flex: 1;
  justify-content: center;
  padding: 6px 8px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

.ui-menu-inline .ui-menu-item[aria-checked="true"] {
  border-color: var(--accent-500);
  background: var(--brand-subtle-bg);
  color: var(--brand-subtle-fg);
}

.ui-menu-inline .ui-menu-item[aria-checked="true"]::after {
  content: none;
}

/* ---------------------------------------------------------- page header */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header-text {
  min-width: 0;
}

.page-header h1,
.page-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.page-meta strong {
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 767px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-actions .btn {
    flex: 1 1 auto;
  }
}

/* -------------------------------------------------------------- hero */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  padding: 28px 32px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-900) 0%, var(--brand-700) 55%, var(--brand-800) 100%);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.hero > * {
  position: relative;
}

.hero h1,
.hero h2 {
  color: #fff;
  font-size: 1.5rem;
  margin: 0 0 6px;
}

.hero p {
  color: rgba(255,255,255,0.8);
  margin: 0;
}

.hero .badge {
  background: rgba(255,255,255,0.16);
  color: #fff;
}

.hero[data-severity="critical"] { box-shadow: inset 6px 0 0 var(--sev-critical), var(--shadow); }
.hero[data-severity="high"] { box-shadow: inset 6px 0 0 var(--sev-high), var(--shadow); }
.hero[data-severity="medium"] { box-shadow: inset 6px 0 0 var(--sev-medium), var(--shadow); }
.hero[data-severity="low"] { box-shadow: inset 6px 0 0 var(--sev-low), var(--shadow); }

/* ------------------------------------------------------------- KPI tile */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  min-width: 0;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

a.kpi:hover,
button.kpi:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: var(--brand-subtle-bg);
  color: var(--brand-subtle-fg);
}

.kpi[data-tone="danger"] .kpi-icon { background: var(--danger-bg); color: var(--danger-fg); }
.kpi[data-tone="warn"] .kpi-icon { background: var(--warn-bg); color: var(--warn-fg); }
.kpi[data-tone="ok"] .kpi-icon { background: var(--ok-bg); color: var(--ok-fg); }
.kpi[data-tone="info"] .kpi-icon { background: var(--info-bg); color: var(--info-fg); }
.kpi[data-tone="neutral"] .kpi-icon { background: var(--surface-sunken); color: var(--text-secondary); }
.kpi[data-tone="accent"] .kpi-icon { background: var(--accent-400); color: var(--brand-900); }

.kpi-body {
  min-width: 0;
  flex: 1;
}

.kpi-label {
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--text-muted);
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-delta.up { color: var(--danger-fg); }
.kpi-delta.down { color: var(--ok-fg); }
.kpi-delta.up.good { color: var(--ok-fg); }
.kpi-delta.down.bad { color: var(--danger-fg); }

.kpi-spark {
  width: 72px;
  height: 28px;
  flex-shrink: 0;
  align-self: center;
}

.kpi.kpi-attention {
  border-left: 4px solid var(--sev-critical);
}

.kpi.kpi-attention[data-tone="warn"] { border-left-color: var(--sev-medium); }
.kpi.kpi-attention[data-tone="ok"] { border-left-color: var(--ok-500); }

.stat-card,
.stats-grid .stat-card {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- status dot */

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--slate-400);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 2px var(--surface-card);
}

.status-dot.online, .status-dot.ok { background: var(--ok-500); }
.status-dot.warn, .status-dot.degraded { background: var(--warn-500); }
.status-dot.offline, .status-dot.danger { background: var(--danger-500); }
.status-dot.pulse { animation: dotPulse 1.6s ease-in-out infinite; }

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--surface-card); }
  50% { box-shadow: 0 0 0 5px var(--surface-card), 0 0 0 7px var(--ok-bg); }
}

/* ------------------------------------------------------------------ tabs */

.ui-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.ui-tabs [role="tab"] {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 16px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.ui-tabs [role="tab"]:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

.ui-tabs [role="tab"][aria-selected="true"],
.ui-tabs [role="tab"].active {
  color: var(--text-link);
  border-bottom-color: var(--brand-700);
}

html[data-theme="dark"] .ui-tabs [role="tab"][aria-selected="true"],
html[data-theme="dark"] .ui-tabs [role="tab"].active {
  border-bottom-color: var(--accent-400);
}

.ui-tabs [role="tab"] .tab-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.ui-tabs [role="tab"][aria-selected="true"] .tab-count {
  background: var(--brand-subtle-bg);
  color: var(--brand-subtle-fg);
}

.ui-tabs.ui-tabs-pills {
  border-bottom: none;
  gap: 6px;
  padding: 4px;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  width: fit-content;
  max-width: 100%;
}

.ui-tabs.ui-tabs-pills [role="tab"] {
  border-radius: var(--r-sm);
  border-bottom: none;
  margin: 0;
  padding: 7px 14px;
}

.ui-tabs.ui-tabs-pills [role="tab"][aria-selected="true"] {
  background: var(--surface-card);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

[role="tabpanel"][hidden] {
  display: none !important;
}

/* --------------------------------------------------------------- filters */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.filters .form-control {
  width: auto;
  min-width: 160px;
  padding: 8px 12px;
  font-size: 0.875rem;
}

.filters .filters-search {
  flex: 1 1 260px;
  position: relative;
}

.filters .filters-search .form-control {
  width: 100%;
  padding-left: 34px;
}

.filters .filters-search > i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.filters .filters-spacer {
  flex: 1 1 auto;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: var(--brand-subtle-bg);
  color: var(--brand-subtle-fg);
  font-size: 0.78rem;
  font-weight: 600;
}

.filter-chip button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
}

.period-bar {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
}

.period-bar button {
  border: none;
  background: none;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.period-bar button:hover {
  color: var(--text);
}

.period-bar button.active,
.period-bar button[aria-pressed="true"] {
  background: var(--surface-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tm-period-bar {
  gap: 2px;
  padding: 3px;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  width: fit-content;
}

.tm-period-btn {
  border: none;
  background: none;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-weight: 600;
}

.tm-period-btn:hover {
  color: var(--text);
}

.tm-period-btn.active {
  background: var(--surface-card);
  color: var(--text);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}

/* ----------------------------------------------------------------- tables */

.table-container {
  position: relative;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 11px 16px;
}

.table tbody td {
  padding: 12px 16px;
  font-size: 0.875rem;
}

.table tbody tr:hover {
  background: var(--surface-sunken);
}

.table-compact tbody td {
  padding: 8px 12px;
  font-size: 0.82rem;
}

.table th[aria-sort] {
  cursor: pointer;
  user-select: none;
}

.table th[aria-sort]::after {
  content: '\f0dc';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-left: 6px;
  opacity: 0.35;
  font-size: 0.65rem;
}

.table th[aria-sort="ascending"]::after { content: '\f0de'; opacity: 1; }
.table th[aria-sort="descending"]::after { content: '\f0dd'; opacity: 1; }

.table .row-link {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.table .row-link:hover {
  color: var(--text-link);
  text-decoration: underline;
}

.table .cell-muted {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.table .cell-mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.table .cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table tbody tr.is-clickable {
  cursor: pointer;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* --------------------------------------------------------------- skeleton */

.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--border) 50%, var(--surface-sunken) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}

.skeleton-text {
  height: 0.85em;
  width: 100%;
  margin: 3px 0;
}

.skeleton-w-sm { width: 55%; }
.skeleton-w-md { width: 70%; }
.skeleton-w-lg { width: 85%; }
.skeleton-w-xl { width: 95%; }

.skeleton-block {
  display: block;
  width: 100%;
  height: 120px;
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.ui-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.ui-skeleton-row td {
  padding: 12px 16px;
}

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

/* ------------------------------------------------------------ empty state */

.empty-state.ui-empty {
  padding: 40px 24px;
  color: var(--text-muted);
}

.empty-state.ui-empty i {
  font-size: 2.2rem;
  margin-bottom: 12px;
  opacity: 0.35;
  color: var(--text-muted);
}

.empty-state.ui-empty h4 {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-state.ui-empty p {
  font-size: 0.875rem;
  max-width: 420px;
  margin: 0 auto;
}

.empty-state.ui-empty .ui-empty-action {
  margin-top: 14px;
}

/* The empty state's icon rules (here and in style.css, dark theme included) are for its own icon, not the
   one inside its button; :root outranks style.css's html[data-theme="dark"] .empty-state i. */
:root .empty-state .btn i {
  font-size: inherit;
  margin: 0;
  opacity: 1;
  color: inherit;
}

.empty-state.ui-empty-compact {
  padding: 24px 16px;
}

.empty-state.ui-empty-compact i {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.ui-empty-row td {
  padding: 0 !important;
}

/* ------------------------------------------------------------------ toast */

.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--z-toast);
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast-stack .toast {
  position: static;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--slate-900);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn 0.22s var(--ease);
  border-left: 4px solid var(--slate-500);
}

html[data-theme="dark"] .toast-stack .toast {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-left-width: 4px;
}

.toast-stack .toast > i {
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.toast-stack .toast-success { background: var(--slate-900); border-left-color: var(--ok-500); }
.toast-stack .toast-success > i { color: var(--ok-500); }
.toast-stack .toast-error { background: var(--slate-900); border-left-color: var(--danger-500); }
.toast-stack .toast-error > i { color: var(--danger-500); }
.toast-stack .toast-warning { background: var(--slate-900); border-left-color: var(--warn-500); }
.toast-stack .toast-warning > i { color: var(--warn-500); }
.toast-stack .toast-info { background: var(--slate-900); border-left-color: var(--accent-400); }
.toast-stack .toast-info > i { color: var(--accent-400); }

html[data-theme="dark"] .toast-stack .toast-success,
html[data-theme="dark"] .toast-stack .toast-error,
html[data-theme="dark"] .toast-stack .toast-warning,
html[data-theme="dark"] .toast-stack .toast-info {
  background: var(--surface-raised);
}

.toast-stack .toast-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.toast-stack .toast-action {
  background: rgba(255,255,255,0.12);
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
}

.toast-stack .toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.toast-stack .toast-close:hover {
  opacity: 1;
}

.toast-stack .toast-leaving {
  animation: toastOut 0.18s ease forwards;
}

@keyframes toastIn {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  to { transform: translateX(24px); opacity: 0; }
}

@media (max-width: 575px) {
  .toast-stack {
    top: auto;
    bottom: 16px;
    left: 16px;
    right: 16px;
    max-width: none;
  }
}

/* ------------------------------------------------------------------ modal */

.modal-sm { max-width: 440px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1080px; }
.modal-full { max-width: calc(100vw - 40px); height: calc(100vh - 40px); }

.modal-tone-danger .modal-header { border-bottom-color: var(--danger-100); }
.modal-tone-danger .modal-title::before,
.modal-tone-warn .modal-title::before {
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  content: '\f071';
  margin-right: 10px;
}

.modal-tone-danger .modal-title::before { color: var(--danger-500); }
.modal-tone-warn .modal-title::before { color: var(--warn-500); }

.ui-confirm-message {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-line;
}

.ui-confirm-require {
  display: block;
  margin-top: 14px;
}

.ui-confirm-require .form-control {
  margin-top: 6px;
}

body.ui-modal-open {
  overflow: hidden;
}

@media (max-width: 575px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100% !important;
    max-height: 92vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
}

/* ------------------------------------------------------------- drawer v2 */

.drawer[hidden] {
  display: none;
}

.drawer-panel {
  display: flex;
  flex-direction: column;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
}

.drawer-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-sunken);
}

@media (max-width: 767px) {
  .drawer-panel {
    max-width: 100%;
  }
}

/* --------------------------------------------------------------- tooltip */

[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  background: var(--slate-900);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  padding: 6px 9px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  max-width: 260px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  z-index: var(--z-dropdown);
  text-transform: none;
  letter-spacing: 0;
}

[data-tip]:hover::after,
[data-tip].tip-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

[data-tip][data-tip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 8px);
}

/* ------------------------------------------------------------- form bits */

.field {
  margin-bottom: 16px;
}

.field > label,
.field .form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

/* `.field > label` is display:block; a switch label must stay a flex row or
   its track paints over the label text. */
.field > label.switch {
  display: inline-flex;
}

.field .form-text,
.field-help {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  margin: 0 0 20px;
  background: var(--surface-card);
}

.fieldset > legend {
  font-weight: 700;
  color: var(--text);
  padding: 0 8px;
  font-size: 0.95rem;
}

.fieldset-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: -6px 0 16px;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.875rem;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .switch-track {
  width: 42px;
  height: 24px;
  border-radius: 24px;
  background: var(--border-strong);
  position: relative;
  transition: background var(--dur-fast) var(--ease);
  flex-shrink: 0;
}

.switch .switch-track::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--dur-fast) var(--ease);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.switch input:checked + .switch-track {
  background: var(--brand-600);
}

.switch input:checked + .switch-track::before {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: var(--ring);
}

.form-actions-sticky {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  margin: 16px -4px 0;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 5;
}

.form-actions-sticky .form-actions-hint {
  margin-right: auto;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* -------------------------------------------------------------- timeline */

.ui-timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 22px;
  position: relative;
}

.ui-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}

.ui-timeline li {
  position: relative;
  padding: 0 0 18px 10px;
}

.ui-timeline li::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand-600);
  box-shadow: 0 0 0 3px var(--surface-card);
}

.ui-timeline li[data-tone="danger"]::before { background: var(--danger-500); }
.ui-timeline li[data-tone="warn"]::before { background: var(--warn-500); }
.ui-timeline li[data-tone="ok"]::before { background: var(--ok-500); }

.ui-timeline .tl-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
}

.ui-timeline .tl-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------------------------------------------------------------- code */

.code-block {
  position: relative;
  background: var(--surface-code);
  color: var(--text-code);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* With a <pre> inside, only the <pre> keeps its line breaks: the markup's own around it rendered as blank lines. */
.code-block:has(> pre) {
  white-space: normal;
}

/* As specific as style.css's dark `pre` rule, and later, so the <pre> takes the block's colours. */
.code-block:has(> pre) > pre {
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  background: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code-block .code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: inherit;
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font-size: 0.72rem;
  cursor: pointer;
}

.code-block .code-copy:hover {
  background: rgba(255,255,255,0.2);
}

/* -------------------------------------------------------------- misc */

.card-title i {
  color: var(--text-muted);
  margin-right: 2px;
}

.card-title i.text-danger { color: var(--danger-500); }
.card-title i.text-info { color: var(--info-500); }
.card-title i.text-success { color: var(--ok-500); }
.card-title i.text-warning { color: var(--warn-500); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}

.section-head h2,
.section-head h3 {
  font-size: 1.05rem;
  margin: 0;
}

.text-mono {
  font-family: var(--font-mono);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  background: var(--brand-700);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--r-md);
  z-index: var(--z-toast);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 8px;
}

/* --------------------------------------------------------- command palette */

.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
}

.cmdk-overlay[hidden] {
  display: none;
}

.cmdk {
  width: 100%;
  max-width: 620px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.cmdk-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.cmdk-input i {
  color: var(--text-muted);
}

.cmdk-input input {
  flex: 1;
  border: none;
  background: none;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  outline: none;
}

.cmdk-list {
  max-height: 55vh;
  overflow-y: auto;
  padding: 6px;
}

.cmdk-group {
  padding: 8px 10px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.cmdk-item i {
  width: 20px;
  text-align: center;
  color: var(--text-muted);
}

.cmdk-item .cmdk-hint {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cmdk-item[aria-selected="true"],
.cmdk-item:hover {
  background: var(--surface-sunken);
}

.cmdk-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.cmdk-foot {
  display: flex;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.cmdk-foot kbd {
  font-family: var(--font-mono);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
}

/* ----------------------------------------------------- legacy harmonising */

.btn,
.form-control,
.badge {
  font-family: inherit;
}

.btn-outline {
  border-width: 1px;
}

.card-header {
  padding: 16px 20px;
}

.card-body {
  padding: 20px;
}

.card-header .card-title {
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-content {
  padding: 24px 28px 48px;
}

@media (max-width: 767px) {
  .page-content {
    padding: 16px 12px 88px;
  }

  .card-header,
  .card-body {
    padding: 12px 14px;
  }
}

/* ------------------------------------------------------------ auth pages */

.login-banner-logo {
  width: 320px;
  height: auto;
  margin-bottom: 0;
}

.login-banner-title {
  font-size: 1.6rem;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.login-banner-subtitle {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.login-banner-features li i {
  color: var(--accent-400);
}

.login-form-header h2 {
  font-size: 1.6rem;
}

.login-form .btn-lg {
  margin-top: 4px;
}

.captcha-section {
  margin-bottom: 20px;
}

.captcha-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.captcha-image {
  height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
}

.captcha-refresh {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.captcha-refresh:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.password-field {
  position: relative;
}

.password-field .form-control {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover {
  color: var(--text);
  background: var(--surface-sunken);
}

.password-strength {
  margin-top: 8px;
}

.password-strength-bar {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  overflow: hidden;
}

.password-strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--danger-500);
  transition: width var(--dur) var(--ease), background var(--dur) var(--ease);
}

.password-strength[data-strength="2"] .password-strength-bar span { background: var(--warn-500); }
.password-strength[data-strength="3"] .password-strength-bar span { background: var(--accent-500); }
.password-strength[data-strength="4"] .password-strength-bar span { background: var(--ok-500); }

.password-strength-text {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.twofa-intro {
  text-align: center;
  margin-bottom: 20px;
}

.twofa-intro .twofa-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-subtle-bg);
  color: var(--brand-subtle-fg);
  font-size: 1.4rem;
}

.twofa-intro h3 {
  font-size: 1.1rem;
  margin: 0 0 4px;
}

.twofa-intro p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.code-input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.verify-waiting {
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.verify-number {
  text-align: center;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.35rem;
  margin: 6px 0;
  font-variant-numeric: tabular-nums;
}

.verify-hint {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.twofa-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 0.875rem;
}

.twofa-links a {
  color: var(--text-link);
}

.twofa-links.twofa-back a {
  color: var(--text-muted);
}

.login-footer .form-footer,
.login-form-wrapper > .form-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.9rem;
}

.login-form-wrapper > .form-footer a {
  color: var(--text-link);
  font-weight: 500;
}

.login-lang-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  margin-bottom: 10px;
}

.login-lang-toggle a {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  text-decoration: none;
}

.login-lang-toggle a.active {
  background: var(--surface-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .login-form .form-control {
  background: var(--surface-input);
  border-color: var(--border-strong);
  color: var(--text);
}

@media (max-width: 991px) {
  .login-banner-logo {
    width: 220px;
  }

  .login-banner-title {
    font-size: 1.25rem;
    margin-bottom: 0;
  }
}

/* Topbar search button: label and shortcut only when there is room. */
@media (max-width: 1199px) {
  .topbar-search-btn .topbar-search-label,
  .topbar-search-btn kbd {
    display: none;
  }

  .topbar-search-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border-color: transparent;
  }

  .topbar-search-btn:hover {
    background: var(--surface-sunken);
  }
}

/* A wide table must scroll inside its container, never widen the page: the
   main column is a flex item and needs min-width:0 to shrink below its
   content (measured on logs.html: scrollWidth 1278 at a 1024 viewport). */
.main-content {
  min-width: 0;
}

.page-content {
  min-width: 0;
  overflow-x: hidden;
}

.ui-tabs {
  overflow-y: hidden;
}

/* A page header with many actions wraps them under the title instead of
   squeezing the title into a column (measured on vulnerabilities.html). */
.page-header {
  flex-wrap: wrap;
}

.page-header-text {
  flex: 1 1 320px;
}

.page-actions {
  justify-content: flex-end;
  max-width: 100%;
}

/* In the stacked (phone) header the text block must not take a 320px
   flex-basis as HEIGHT: basis only applies to the row layout. */
.page-header-text {
  flex: 1 1 auto;
  min-width: min(100%, 320px);
}

@media (max-width: 767px) {
  .page-header-text {
    min-width: 0;
  }

  .table-mobile-cards .cell-sub,
  .table-mobile-cards .cell-muted {
    white-space: normal;
  }
}

/* Phone cards: the table itself must become a block, or a nowrap sub-line
   keeps it at its desktop width (measured: 521px table in a 375px viewport). */
@media (max-width: 767px) {
  .table-mobile-cards table,
  .table-mobile-cards .table {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .table-mobile-cards td {
    flex-wrap: wrap;
    min-width: 0;
  }

  .table-mobile-cards td > * {
    min-width: 0;
  }

  .table-mobile-cards .table .cell-sub {
    flex: 0 0 100%;
    max-width: 100%;
    white-space: normal;
    padding-left: calc(38% + 12px);
  }
}
