/* Leavitt Group — Inactive Account Monitor */

:root {
  --brand-blue: #1b4e81;
  --brand-gray: #8a8d8f;
  --bg-app: #0d0d0d;
  --bg-sidebar: #111111;
  --bg-surface: #161616;
  --bg-surface-hover: #1c1c1c;
  --bg-table-row-a: #141414;
  --bg-table-row-b: #1a1a1a;
  --bg-table-header: #121212;
  --text-primary: #f5f5f5;
  --text-muted: #8a8a8a;
  --border-subtle: #2a2a2a;
  --accent: #4fd1c5;
  --gradient-header: linear-gradient(90deg, #0d0d0d 0%, #12181f 40%, #0f1a1a 100%);
  --gradient-header-border: linear-gradient(90deg, transparent, #4fd1c5, #1b4e81, transparent);
  --gradient-page-title: linear-gradient(135deg, #ffffff 0%, #4fd1c5 45%, #1b4e81 100%);
  --gradient-card-cyan: linear-gradient(145deg, #161616 0%, #0f2424 50%, #161616 100%);
  --gradient-card-amber: linear-gradient(145deg, #161616 0%, #2a1f0f 50%, #161616 100%);
  --gradient-card-red: linear-gradient(145deg, #161616 0%, #2a1515 50%, #161616 100%);
  --gradient-card-green: linear-gradient(145deg, #161616 0%, #0f2218 50%, #161616 100%);
  --gradient-kpi-cyan: linear-gradient(135deg, #4fd1c5 0%, #63b3ed 100%);
  --gradient-kpi-amber: linear-gradient(135deg, #f6ad55 0%, #fc8181 100%);
  --gradient-kpi-green: linear-gradient(135deg, #48bb78 0%, #4fd1c5 100%);
  --gradient-kpi-red: linear-gradient(135deg, #fc8181 0%, #f6ad55 100%);
  --gradient-banner-alert: linear-gradient(90deg, #0a1f1f 0%, #0f2e2e 50%, #0a1f1f 100%);
  --gradient-table-header: linear-gradient(180deg, #1a1a1a 0%, #121212 100%);
  --gradient-nav-active: linear-gradient(90deg, #1a2e2e 0%, #1a3a35 100%);
  --shadow-glow: 0 0 24px rgba(79, 209, 197, 0.12);
}

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

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* KPI numbers: solid colors (gradient clip text is unreliable in some browsers) */
.kpi-cyan { color: #4fd1c5; }
.kpi-amber { color: #f6ad55; }
.kpi-red { color: #fc8181; }
.kpi-green { color: #68d391; }

.metric-card .value,
.alert-banner .count {
  font-variant-numeric: tabular-nums;
}

/* Header */
.global-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 56px;
  background: var(--gradient-header);
  border-bottom: 1px solid transparent;
  border-image: var(--gradient-header-border) 1;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.brand-title {
  font-size: 0.95rem;
  font-weight: 600;
  background: linear-gradient(135deg, #e8edf4 0%, #4fd1c5 55%, var(--brand-blue) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-discovery-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  color: var(--accent);
  border: 1px solid rgba(79, 209, 197, 0.4);
  background: rgba(79, 209, 197, 0.1);
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.header-discovery-indicator:hover {
  background: rgba(79, 209, 197, 0.18);
  border-color: rgba(79, 209, 197, 0.55);
}

.header-discovery-indicator.hidden {
  display: none;
}

.header-discovery-indicator svg {
  width: 1.15rem;
  height: 1.15rem;
}

.header-discovery-indicator .spin {
  animation: spin 0.9s linear infinite;
}

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

.header-user {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, #2c7a7b 0%, #4fd1c5 100%);
  color: #0d0d0d;
}

.btn-primary:disabled,
.btn-primary[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.35);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-ghost:hover {
  border-image: linear-gradient(135deg, #4fd1c5, #1b4e81) 1;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  position: relative;
}

.btn-icon svg {
  pointer-events: none;
  display: block;
}

.btn-icon:hover {
  color: var(--accent);
  background: rgba(79, 209, 197, 0.1);
}

.ui-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: min(320px, calc(100vw - 24px));
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  color: #f5f5f5;
  background: #1a1a1a;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
  white-space: normal;
  text-align: center;
}

.ui-tooltip.visible {
  opacity: 1;
}

/* Shell */
.app-shell {
  display: flex;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
}

.nav-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0.5rem 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 2px;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.nav-link.active {
  background: var(--gradient-nav-active);
  color: var(--text-primary);
}

.nav-footer {
  margin-top: auto;
}

.main {
  flex: 1;
  padding: 1.5rem 2rem;
  width: 100%;
  max-width: none;
  min-width: 0;
}

.page-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 700;
  background: var(--gradient-page-title);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.page-header .subtitle {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.page-header--dashboard .page-header-intro .subtitle {
  margin-bottom: 0.65rem;
}

.page-header-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-header-strip--discovery-only {
  justify-content: flex-end;
}

.page-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.discovery-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  flex: 0 1 22rem;
  width: 22rem;
  max-width: 100%;
  box-sizing: border-box;
}

.page-header-row .discovery-bar,
.page-header-strip .discovery-bar {
  flex: 1 1 22rem;
  width: auto;
  max-width: 100%;
}

.discovery-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.discovery-bar .btn-stop {
  border-color: rgba(252, 129, 129, 0.45);
  color: #feb2b2;
}

.discovery-bar .btn-stop:hover:not(:disabled) {
  border-color: #fc8181;
  color: #fc8181;
  background: rgba(252, 129, 129, 0.12);
}

.discovery-bar.running {
  border-color: rgba(79, 209, 197, 0.35);
  background: linear-gradient(90deg, #0a1818 0%, #0f2222 45%, #0a1818 100%);
}

.discovery-bar.failed {
  border-color: rgba(252, 129, 129, 0.45);
  background: linear-gradient(90deg, #1a1010 0%, #2a1518 45%, #1a1010 100%);
}

.discovery-bar-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.discovery-bar-status strong {
  color: var(--text);
}

.discovery-bar-status.running strong {
  color: var(--accent);
}

.discovery-bar-status.failed strong {
  color: #fc8181;
}

.discovery-bar-status.failed svg {
  color: #fc8181;
}

.discovery-bar-detail.failed {
  color: #feb2b2;
}

.discovery-bar-status .spin {
  animation: spin 0.9s linear infinite;
  color: var(--accent);
}

.discovery-bar-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.discovery-bar-detail.running {
  color: #a0aec0;
}

/* Alert banner */
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  border-radius: 10px;
  background: var(--gradient-banner-alert);
  border: 1px solid rgba(79, 209, 197, 0.25);
}

.page-header-strip .alert-banner {
  flex: 1 1 14rem;
  min-width: 0;
  margin-bottom: 0;
}

.alert-banner--compact {
  padding: 0.65rem 0.85rem;
  font-size: 0.8125rem;
}

.alert-banner-message {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
  line-height: 1.35;
}

.alert-banner-message svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: #f6ad55;
}

.alert-banner .count {
  font-size: 1.25rem;
  font-weight: 700;
}

.alert-banner--compact .count {
  font-size: 1rem;
}

.alert-banner a {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.8125rem;
}

@media (max-width: 720px) {
  .page-header-strip .alert-banner,
  .page-header-strip .discovery-bar {
    flex: 1 1 100%;
    width: 100%;
  }
}

/* KPI row — single compact row with icons */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 1100px) {
  .cards-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
  }
  .metric-card {
    flex: 0 0 8.5rem;
  }
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--gradient-card-cyan);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  min-width: 0;
}

.metric-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.metric-card.amber { background: var(--gradient-card-amber); border-left: 3px solid #f6ad55; }
.metric-card.red { background: var(--gradient-card-red); }
.metric-card.green { background: var(--gradient-card-green); }

.metric-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  opacity: 0.9;
}

.metric-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}

.metric-card .label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-card .value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.charts-row--half {
  grid-template-columns: minmax(0, 420px);
}

@media (max-width: 768px) {
  .charts-row { grid-template-columns: 1fr; }
  .charts-row--half { grid-template-columns: 1fr; max-width: none; }
}

.chart-caption {
  margin: -0.35rem 0 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
}

.chart-wrap--donut {
  height: 200px;
  max-height: 200px;
}

.chart-wrap--donut-sm {
  height: 180px;
  max-height: 180px;
}

.chart-wrap--bar,
.chart-wrap--line,
.chart-wrap--bar-tall {
  height: 200px;
  max-height: 200px;
}

.panel h3 + .chart-caption + .chart-wrap,
.panel h3 + .chart-wrap--donut,
.panel h3 + .chart-wrap--bar,
.panel h3 + .chart-wrap--line {
  margin-top: 0;
}

.panel .chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem;
}

.panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Filters */
.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
  justify-content: space-between;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.sel-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0 0.25rem;
}

.sel-count.hidden {
  display: none;
}

.col-select {
  width: 2.25rem;
  text-align: center;
  vertical-align: middle;
}

.col-select input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--accent);
}

.data-table tr.row-selected td {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.modal-body .subtitle {
  margin: 0 0 0.75rem;
}

.modal-bulk-label {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
}

.modal-bulk-list {
  margin: 0 0 0.5rem;
  padding-left: 1.25rem;
  max-height: 10rem;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.4;
}

.modal-bulk-list .upn {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.modal-bulk-more {
  color: var(--text-muted);
  font-style: italic;
}

.page-help {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -0.5rem 0 1rem;
  line-height: 1.45;
  max-width: 72rem;
}

.page-header-row--title {
  margin-bottom: 1rem;
}

.page-header-row--title .subtitle {
  margin-bottom: 0;
}

.page-title-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-title-line h1 {
  margin: 0;
}

.page-help-btn {
  flex-shrink: 0;
  color: #4fd1c5;
  border-color: rgba(79, 209, 197, 0.35);
  background: rgba(44, 122, 123, 0.12);
}

.page-help-btn:hover {
  background: rgba(44, 122, 123, 0.28);
  border-color: rgba(79, 209, 197, 0.55);
}

.page-help-btn svg {
  width: 1.05rem;
  height: 1.05rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
}

.pill-filter {
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
}

.pill-filter.active {
  background: linear-gradient(135deg, #2c7a7b 0%, #4fd1c5 100%);
  color: #0d0d0d;
  border-color: transparent;
}

.pill-warning {
  background: linear-gradient(135deg, #2a2010, #3d2a10);
  color: #f6ad55;
}

.pill-grace {
  background: linear-gradient(135deg, #1a2a2e, #1a3540);
  color: #63b3ed;
}

.pill-pending {
  background: linear-gradient(135deg, #2a1a3d, #3d2a55);
  color: #c4b5fd;
}

.pill-escalated {
  background: linear-gradient(135deg, #2a1515, #3d1a1a);
  color: #fc8181;
}

.pill-healthy {
  background: linear-gradient(135deg, #1a2e1a, #1f3d2a);
  color: #48bb78;
}

.pill-slate {
  background: #252525;
  color: var(--text-muted);
}

.pill-awaiting {
  background: linear-gradient(135deg, #3d3d2a, #4a4a35);
  color: #e2e8a0;
}

.pill-sessions-revoked {
  background: linear-gradient(135deg, #1a2838, #243448);
  color: #90cdf4;
}

/* Compact status badges in inactive table (not filter pills) */
.status-pills {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
}

.status-pills .pill {
  padding: 0.1rem 0.4rem;
  font-size: 0.625rem;
  font-weight: 500;
  gap: 0.2rem;
  line-height: 1.25;
  border-width: 1px;
}

.status-pills .pill svg {
  width: 0.7rem;
  height: 0.7rem;
  flex-shrink: 0;
}

.pill-status-mini {
  padding: 0.06rem 0.35rem;
  font-size: 0.5625rem;
  vertical-align: middle;
}

.co-owner-suggest {
  margin-top: 0.35rem;
  font-size: 0.6875rem;
  line-height: 1.35;
  max-width: 14rem;
}

.co-owner-suggest-label {
  display: block;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

.co-owner-suggest-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.co-owner-suggest-link:hover {
  text-decoration: underline;
}

.co-owner-pick-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.co-owner-pick-list {
  max-height: min(320px, 50vh);
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.35rem;
  margin-bottom: 1rem;
  background: rgba(0, 0, 0, 0.2);
}

.co-owner-pick-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.55rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.co-owner-pick-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.co-owner-pick-item input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.co-owner-pick-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.co-owner-pick-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.co-owner-pick-title .pill {
  flex-shrink: 0;
  width: auto;
}

.co-owner-pick-body small {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.3;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
}

.search-input {
  margin-left: auto;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  min-width: 200px;
}

/* Table */
.table-wrap {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow-x: auto;
}

.table-wrap .data-table {
  min-width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table thead {
  background: var(--gradient-table-header);
}

.data-table th.th-sortable {
  padding: 0;
}

.th-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.75rem 1rem;
  margin: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  font-size: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.th-sort-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.data-table th.th-sort-active .th-sort-btn {
  color: var(--accent);
}

.th-sort-icon {
  font-size: 0.65rem;
  line-height: 1;
  opacity: 0.85;
  min-width: 0.75rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr:nth-child(odd) { background: var(--bg-table-row-a); }
.data-table tbody tr:nth-child(even) { background: var(--bg-table-row-b); }

.data-table tbody tr:hover {
  background: #222 !important;
}

.data-table td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
}

.data-table .name-cell .upn {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.data-table .name-cell .name-meta {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.data-table tr.row-alert td {
  background: color-mix(in srgb, #e53e3e 14%, transparent);
}

.data-table tr.row-alert.row-selected td {
  background: color-mix(in srgb, #e53e3e 18%, var(--accent) 10%, transparent);
}

.data-table tr.row-alert .name-primary {
  color: #feb2b2;
  font-weight: 600;
}

.data-table td.col-grace {
  white-space: nowrap;
  width: 1%;
}

.grace-count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #67e8f9;
}

.grace-count.grace-pending {
  color: #c4b5fd;
}

.grace-count.grace-overdue {
  color: #fc8181;
}

/* Do not use display:flex on <td> — breaks table columns (blocklist Actions column). */
.data-table th.col-narrow,
.data-table td.action-cell {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
  overflow: visible;
}

.data-table .col-upn {
  word-break: break-all;
  max-width: 18rem;
}

.data-table-blocklist .col-upn {
  min-width: 12rem;
}

.data-table th.col-expires,
.data-table td.col-expires {
  white-space: nowrap;
  width: 1%;
  min-width: 6.75rem;
}

.action-cell .action-group {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
  align-items: center;
  justify-content: flex-start;
  overflow: visible;
}

.pager-host {
  margin-top: 0.75rem;
}

.table-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.pager-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pager-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.pager-page {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0 0.5rem;
}

.pager-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
}

.settings-maintenance {
  grid-column: 1 / -1;
  border-color: #3a2828;
}

.settings-maintenance h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.maintenance-stats {
  margin: 0.75rem 0 1rem;
}

.maintenance-runs {
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.maintenance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn-maintenance-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid #8b3a3a;
  background: #2a1515;
  color: #fca5a5;
  font-size: 0.875rem;
  cursor: pointer;
}

.btn-maintenance-danger:hover:not(:disabled) {
  background: #3a1a1a;
  border-color: #a44;
}

.btn-maintenance-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.settings-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }
}

.settings-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.25rem;
}

.settings-panel h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--text-primary);
}

.settings-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.settings-form label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.settings-form input,
.settings-form textarea {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-app);
  color: var(--text-primary);
}

.settings-form textarea.code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  min-height: 14rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.brand-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.brand-swatch {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.brand-swatch i {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  display: inline-block;
}

.settings-vars {
  font-size: 0.75rem;
  width: 100%;
  border-collapse: collapse;
}

.settings-vars th,
.settings-vars td {
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.5rem;
  text-align: left;
}

.settings-vars code {
  font-size: 0.72rem;
  color: var(--accent);
}

.email-preview-frame {
  width: 100%;
  min-height: 28rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: #eef1f4;
}

.system-info-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
}

.system-info-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.system-info-list li:last-child {
  border-bottom: none;
}

.system-info-list span:first-child {
  color: var(--text-muted);
}

.help-doc {
  max-width: 52rem;
  line-height: 1.55;
}

.help-doc section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

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

.help-doc h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.help-doc h2 i {
  color: var(--accent);
  width: 1.15rem;
  height: 1.15rem;
}

.help-doc p,
.help-doc li {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.65rem;
}

.help-doc ul {
  margin: 0.35rem 0 0.75rem;
  padding-left: 1.25rem;
}

.help-doc li strong {
  color: var(--text-primary);
}

.help-doc .help-callout {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 0.75rem 0;
}

.help-doc .help-callout p:last-child {
  margin-bottom: 0;
}

.help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.help-toc a {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.help-toc a:hover {
  border-color: var(--accent);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
}

.tab.active {
  background: var(--gradient-nav-active);
  color: var(--text-primary);
  border-color: rgba(79, 209, 197, 0.3);
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list li {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  align-items: flex-start;
}

.activity-list li:last-child { border-bottom: none; }

.activity-list li > i {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
  color: var(--accent);
  opacity: 0.85;
}

.activity-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.activity-title {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.activity-where {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.activity-target {
  font-size: 0.75rem;
  color: var(--accent);
  word-break: break-all;
}

.activity-detail {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.activity-meta {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.loading, .empty {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
}

.toast-host {
  position: fixed;
  top: 4.25rem;
  right: 1rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}

.toast-item {
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateX(1rem);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
}

.toast-item.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-info {
  background: linear-gradient(90deg, #0f2222, #1a1a1a);
  border: 1px solid rgba(79, 209, 197, 0.35);
  color: #a0aec0;
}

.toast-success {
  background: linear-gradient(90deg, #0f2218, #1a1a1a);
  border: 1px solid rgba(104, 211, 145, 0.4);
  color: #9ae6b4;
}

.toast-warning {
  background: linear-gradient(90deg, #2a2010, #1a1a1a);
  border: 1px solid rgba(246, 173, 85, 0.45);
  color: #fbd38d;
}

.toast-error {
  background: linear-gradient(90deg, #2a1515, #1a1a1a);
  border: 1px solid #fc8181;
  color: #feb2b2;
}

/* Inline page error (full-width) */
.toast {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  background: linear-gradient(90deg, #2a1515, #1a1a1a);
  border: 1px solid #fc8181;
  color: #fc8181;
}

.hidden { display: none !important; }

/* Check overlay */
.check-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.check-overlay-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  width: min(480px, 96vw);
  box-shadow: var(--shadow-glow);
}

.check-overlay-panel h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.check-overlay-panel .upn {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  word-break: break-all;
}

.check-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.check-steps li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
}

.check-steps li:last-child {
  border-bottom: none;
}

.step-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 2px;
}

.step-icon.spin {
  animation: spin 0.9s linear infinite;
  color: #4fd1c5;
}

.step-icon.ok {
  color: #48bb78;
}

.step-icon.err {
  color: #fc8181;
}

.step-body strong {
  display: block;
  color: var(--text-primary);
}

.step-body small {
  display: block;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.check-result {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: #1a1a1a;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.check-overlay-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

/* Page help overlay (inactive actions, etc.) */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.help-overlay-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.25rem 1.35rem 1.1rem;
  width: min(520px, 96vw);
  max-height: min(88vh, 640px);
  overflow: auto;
  box-shadow: var(--shadow-glow);
}

.help-overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.help-overlay-head h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

.help-overlay-close {
  flex-shrink: 0;
  margin: -0.15rem -0.15rem 0 0;
}

.help-action-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.help-action-item {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.help-action-item:last-child {
  border-bottom: none;
}

.help-action-icons {
  display: flex;
  flex-shrink: 0;
  gap: 0.35rem;
  padding-top: 0.1rem;
}

.help-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: #1a1a1a;
  border: 1px solid var(--border-subtle);
  color: #4fd1c5;
}

.help-action-icon svg {
  width: 1rem;
  height: 1rem;
}

.help-action-body strong {
  display: block;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.help-action-body p {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.help-overlay-foot {
  margin: 0.85rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.help-link {
  color: #4fd1c5;
  text-decoration: none;
}

.help-link:hover {
  text-decoration: underline;
}

.help-overlay-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

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

.history-none {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.history-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(60vh, 28rem);
  overflow-y: auto;
}

.history-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.history-item:last-child {
  border-bottom: none;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}

.history-meta time {
  color: var(--accent);
  font-weight: 600;
}

.history-by {
  color: var(--text-muted);
}

.history-reason {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.evidence-pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  line-height: 1.45;
  max-height: 60vh;
  overflow-y: auto;
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  background: var(--bg-app);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

/* Modal */
.modal-root:not(.hidden) {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.25rem;
  width: min(440px, 92vw);
  box-shadow: var(--shadow-glow);
}

.modal h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.modal .subtitle {
  white-space: pre-line;
}

.modal textarea {
  width: 100%;
  min-height: 80px;
  margin: 0.75rem 0;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-app);
  color: var(--text-primary);
  resize: vertical;
}

.modal .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal .form-field input {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-app);
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-wide {
  max-width: 520px;
  width: min(520px, 92vw);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 0.75rem 0;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-field .req {
  color: #f6ad55;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.panel-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.panel-toolbar .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.bl-panel.hidden {
  display: none;
}

.data-table tr.row-muted td {
  opacity: 0.55;
}

.expand-row td {
  background: var(--bg-table-row-b) !important;
  padding: 1rem !important;
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: -240px;
    top: 56px;
    bottom: 0;
    z-index: 50;
    transition: left 0.2s;
  }
  .sidebar.open { left: 0; }
}
