:root {
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg-rail: #111322;
  --bg-rail-card: #1A1E36;
  --bg-rail-hover: rgba(255, 255, 255, 0.06);
  --rail-border: rgba(165, 180, 252, 0.14);
  --rail-text: #9FA8C7;
  --rail-text-active: #FFFFFF;

  --bg-shell: #111322;
  --bg-body: #F6F5F2;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F7F6F3;
  --bg-hover: #EFEEE9;

  --border-color: #E2E0DA;
  --border-strong: #CCC9BF;

  --text-primary: #111322;
  --text-secondary: #3E435A;
  --text-muted: #666C85;

  --brand-primary: #4338CA;
  --brand-primary-hover: #3730A3;
  --brand-primary-text: #FFFFFF;
  --brand-primary-soft: rgba(67, 56, 202, 0.09);
  --brand-ring: rgba(67, 56, 202, 0.22);
  --brand-amber: #D97706;
  --brand-amber-soft: rgba(217, 119, 6, 0.12);

  --status-ok: #059669;
  --status-ok-bg: rgba(5, 150, 105, 0.10);
  --status-warn: #B45309;
  --status-warn-bg: rgba(217, 119, 6, 0.12);
  --status-danger: #BE123C;
  --status-danger-bg: rgba(190, 18, 60, 0.10);
  --status-info: #4338CA;
  --status-info-bg: rgba(67, 56, 202, 0.10);

  --glider-bg: #FFFFFF;
  --glider-shadow: 0 1px 3px rgba(17, 19, 34, 0.11), 0 1px 2px rgba(17, 19, 34, 0.06);
  --shadow-card: 0 1px 2px rgba(17, 19, 34, 0.05);
  --shadow-shell: 0 18px 44px -16px rgba(0, 0, 0, 0.40);
  --shadow-elevated: 0 28px 64px -16px rgba(17, 19, 34, 0.28), 0 0 0 1px rgba(17, 19, 34, 0.06);
}

html.dark {
  --bg-rail: #090B14;
  --bg-rail-card: #121627;
  --bg-rail-hover: rgba(255, 255, 255, 0.05);
  --rail-border: rgba(165, 180, 252, 0.12);
  --rail-text: #8D96B5;
  --rail-text-active: #F8FAFC;

  --bg-shell: #090B14;
  --bg-body: #0E111D;
  --bg-surface: #141829;
  --bg-subtle: #1A1F33;
  --bg-hover: #20263D;

  --border-color: #262D47;
  --border-strong: #374063;

  --text-primary: #F3F4F9;
  --text-secondary: #BCC3DA;
  --text-muted: #828BA8;

  --brand-primary: #6366F1;
  --brand-primary-hover: #818CF8;
  --brand-primary-text: #FFFFFF;
  --brand-primary-soft: rgba(99, 102, 241, 0.16);
  --brand-ring: rgba(99, 102, 241, 0.28);
  --brand-amber: #FBBF24;
  --brand-amber-soft: rgba(251, 191, 36, 0.15);

  --status-ok: #34D399;
  --status-ok-bg: rgba(52, 211, 153, 0.13);
  --status-warn: #FBBF24;
  --status-warn-bg: rgba(251, 191, 36, 0.14);
  --status-danger: #FB7185;
  --status-danger-bg: rgba(251, 113, 133, 0.14);
  --status-info: #818CF8;
  --status-info-bg: rgba(129, 140, 248, 0.15);

  --glider-bg: #222842;
  --glider-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.42);
  --shadow-shell: 0 20px 50px -16px rgba(0, 0, 0, 0.78);
  --shadow-elevated: 0 32px 72px -16px rgba(0, 0, 0, 0.86), 0 0 0 1px rgba(255, 255, 255, 0.07);
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-shell);
  color: var(--text-primary);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-display {
  font-family: var(--font-sans);
  letter-spacing: -0.022em;
}
.font-serif-brand { font-family: var(--font-serif); letter-spacing: -0.01em; }
.font-mono, .font-mono-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-amber); }

.ax-shell-frame {
  background: var(--bg-body);
  border: 1px solid var(--rail-border);
  box-shadow: var(--shadow-shell);
}

.ax-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.ax-card-hover:hover {
  border-color: var(--border-strong);
  box-shadow: 0 8px 20px -10px rgba(17, 19, 34, 0.15);
}

.ax-card-hero {
  background: linear-gradient(135deg, #111322 0%, #1C2142 58%, #262C59 100%);
  color: #F8FAFC;
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 14px;
  box-shadow: 0 12px 28px -12px rgba(17, 19, 34, 0.55);
}

.ax-subtle {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.ax-topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.ax-sidebar {
  background: var(--bg-rail);
  color: #F8FAFC;
  transition: width 0.24s cubic-bezier(0.22, 1, 0.36, 1), transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.ax-sidebar.collapsed { width: 70px; }
.ax-sidebar.collapsed .ax-hide-collapsed { display: none; }
.ax-sidebar.collapsed .ax-nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
.ax-sidebar.collapsed .ax-dept-btn { justify-content: center; padding: 8px; }

.ax-rail-card {
  background: var(--bg-rail-card);
  border: 1px solid var(--rail-border);
  border-radius: 10px;
  color: #F8FAFC;
  transition: border-color 0.16s ease;
}
.ax-rail-card:hover { border-color: rgba(245, 158, 11, 0.45); }

.ax-nav-wrap { position: relative; }

.ax-nav-glider {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.28) 0%, rgba(245, 158, 11, 0.12) 100%);
  border: 1px solid rgba(245, 158, 11, 0.36);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), height 0.22s ease, opacity 0.18s ease;
}
.ax-nav-glider::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: #F59E0B;
}

.ax-nav-item {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border-radius: 9px;
  color: var(--rail-text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease;
  user-select: none;
}
.ax-nav-item:hover:not(.active) { background: var(--bg-rail-hover); color: #EEF2FF; }
.ax-nav-item.active { color: var(--rail-text-active); font-weight: 600; }
.ax-nav-item.active svg { color: #F59E0B; }

.ax-rail-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(159, 168, 199, 0.15);
  color: #CBD5E1;
}
.ax-nav-item.active .ax-rail-badge {
  background: rgba(245, 158, 11, 0.26);
  color: #FDE68A;
}

.ax-seg-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 9px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}
.ax-seg-track.grid { display: grid; }
.ax-seg-glider {
  position: absolute;
  top: 3px; bottom: 3px; left: 0;
  border-radius: 7px;
  background: var(--glider-bg);
  border: 1px solid var(--border-color);
  box-shadow: var(--glider-shadow);
  pointer-events: none;
  z-index: 0;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), width 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.ax-seg-btn {
  position: relative;
  z-index: 1;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.18s ease;
}
.ax-seg-btn:hover { color: var(--text-primary); }
.ax-seg-btn.active { color: var(--text-primary); font-weight: 700; }

.ax-btn-primary {
  background: linear-gradient(180deg, #4F46E5 0%, #3730A3 100%);
  color: #FFFFFF;
  border: 1px solid rgba(55, 48, 163, 0.9);
  box-shadow: 0 1px 2px rgba(17, 19, 34, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  font-weight: 600;
  transition: filter 0.14s ease;
  cursor: pointer;
}
.ax-btn-primary:hover { filter: brightness(1.08); }

.ax-btn-outline {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-weight: 500;
  transition: background 0.14s ease, border-color 0.14s ease;
  cursor: pointer;
}
.ax-btn-outline:hover { border-color: var(--border-strong); background: var(--bg-subtle); }

.ax-btn-amber {
  background: var(--brand-amber-soft);
  color: var(--brand-amber);
  border: 1px solid rgba(217, 119, 6, 0.34);
  border-radius: 8px;
  font-weight: 700;
  transition: all 0.14s ease;
  cursor: pointer;
}
.ax-btn-amber:hover { background: rgba(217, 119, 6, 0.22); }

:where(.ax-input) {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 0.48rem 0.75rem;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.ax-input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px var(--brand-ring); }

.ax-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
}
.ax-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.ax-switch-track { position: absolute; inset: 0; border-radius: 999px; transition: background 0.2s ease; }
.ax-switch-knob {
  position: absolute; left: 2px; top: 2px; width: 15px; height: 15px;
  border-radius: 999px; background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.ax-switch input:checked ~ .ax-switch-track { background: var(--brand-primary); }
.ax-switch input:checked ~ .ax-switch-knob { transform: translateX(15px); }

.ax-login-stage {
  background-color: #F6F5F2;
  background-image:
    radial-gradient(ellipse 75% 48% at 50% -10%, rgba(67, 56, 202, 0.13), transparent 65%),
    radial-gradient(rgba(17, 19, 34, 0.08) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px;
}
html.dark .ax-login-stage {
  background-color: #090B14;
  background-image:
    radial-gradient(ellipse 75% 48% at 50% -10%, rgba(99, 102, 241, 0.18), transparent 65%),
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
}

.ax-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}
.ax-badge-ok { background: var(--status-ok-bg); color: var(--status-ok); }
.ax-badge-warn { background: var(--status-warn-bg); color: var(--status-warn); }
.ax-badge-danger { background: var(--status-danger-bg); color: var(--status-danger); }
.ax-badge-info { background: var(--status-info-bg); color: var(--status-info); }
.ax-badge-neutral { background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--border-color); }

.ax-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ax-table thead th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}
.ax-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.ax-table tbody tr:last-child td { border-bottom: none; }
.ax-table tbody tr:hover td { background: var(--bg-hover); }
.ax-row-selected td { background: var(--brand-primary-soft) !important; }

.ax-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.ax-heat-cell { width: 100%; aspect-ratio: 1; border-radius: 3px; transition: transform 0.12s ease; }
.ax-heat-cell:hover { transform: scale(1.25); }

.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #34D399;
  display: inline-block; animation: axPulse 2.2s ease-in-out infinite;
}
@keyframes axPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.cert-frame {
  background: linear-gradient(180deg, #FFFDF9 0%, #FAF7F0 100%);
  color: #111322;
  border: 2px solid #D97706;
  outline: 6px solid #111322;
  outline-offset: -10px;
  border-radius: 10px;
  padding: 28px 26px;
}

.ax-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(9, 11, 20, 0.52); backdrop-filter: blur(3px);
  z-index: 80; display: none;
}
.ax-drawer-backdrop.open { display: block; }
.ax-drawer {
  position: fixed; top: 10px; right: 10px; bottom: 10px;
  width: calc(100% - 20px); max-width: 560px;
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 14px;
  box-shadow: var(--shadow-elevated); z-index: 85;
  transform: translateX(calc(100% + 24px));
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
.ax-drawer.open { transform: translateX(0); }

@keyframes slideInRight { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.ax-toast { animation: slideInRight 0.2s ease forwards; }

@media print {
  aside, header, .no-print { display: none !important; }
  main { padding: 0 !important; }
}
