:root {
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f172a;
  --primary-soft: #1f2937;
  --accent: #ef4444;
  --success: #10b981;
  --warning: #f97316;
  --blue: #3b82f6;
  --shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 2px 6px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

.page {
  position: relative;
  z-index: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 40px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.brand-badge {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
}

.brand-ring {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.brand-icon {
  width: 28px;
  height: 28px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand-label {
  font-size: 14px;
}

.brand-label.muted {
  color: var(--muted);
}

.brand-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.dashboard {
  padding: 32px 40px 80px;
  max-width: 1400px;
  margin: 0 auto;
}

.title-row h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

.title-row p {
  color: var(--muted);
  max-width: 540px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin: 24px 0 28px;
}

.stat-card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.stat-card.alert {
  background: #fff5f5;
  border-color: rgba(239, 68, 68, 0.25);
}

.stat-card.alert .stat-value {
  color: var(--accent);
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
}

.stat-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  color: var(--primary);
}

.stat-icon.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.stat-icon.alert {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent);
}

.stat-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
}

.left-column,
.right-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--card);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 22px;
  box-shadow: var(--shadow);
}

.card-header {
  margin-bottom: 18px;
}

.card-header h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  min-width: 200px;
}

.input-group svg {
  width: 16px;
  height: 16px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
}

.input-group input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  width: 100%;
}

.chip {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
}

.chip-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
}

.chip-select select {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--text);
  outline: none;
  cursor: pointer;
  padding: 0;
}

.chev {
  margin-left: 6px;
  color: var(--muted);
}

.primary-button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 8px 14px rgba(15, 23, 42, 0.2);
}

.primary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.primary-button.full {
  width: 100%;
  margin-top: 10px;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.ghost-button.is-greeting {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  cursor: default;
}

.ghost-button.is-hidden {
  display: none;
}

.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding-bottom: 10px;
}

.sort-button {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 0;
}

.sort-indicator::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid transparent;
  transform: translateY(1px);
}

.sort-button[data-sort-direction="asc"] .sort-indicator::before {
  border-top-color: var(--text);
  transform: rotate(180deg) translateY(-1px);
}

.sort-button[data-sort-direction="desc"] .sort-indicator::before {
  border-top-color: var(--text);
}

.sort-order {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sort-order:empty {
  display: none;
}

.data-table tbody tr {
  border-top: 1px solid var(--border);
}

.data-table tbody td {
  padding: 12px 0;
}

.data-table.compact tbody td {
  padding: 10px 0;
}

.pill {
  background: #eef2ff;
  color: #312e81;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.pill.dark {
  background: #111827;
  color: #fff;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
}

.badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.badge.alert {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent);
}

.badge.muted {
  background: rgba(100, 116, 139, 0.15);
  color: #475569;
}

.tag {
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  background: #f3f4f6;
  color: #1f2937;
}

.hash {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: #334155;
}

.alert-card {
  border-left: 4px solid var(--accent);
}

.alert-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.alert-list li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 12px;
  align-items: center;
}

.alert-list li span:first-child {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #f1f5f9;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted);
}

.alert-list strong {
  display: block;
  font-size: 13px;
}

.alert-list p {
  font-size: 12px;
  color: var(--muted);
}

.fail-pill {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.donut {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 10px auto 16px;
  background: conic-gradient(
    #1f2937 0deg 120deg,
    #ef4444 120deg 190deg,
    #94a3b8 190deg 240deg,
    #cbd5f5 240deg 280deg,
    #0f172a 280deg 360deg
  );
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--card);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  justify-content: center;
}

.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.legend .navy { background: #1f2937; }
.legend .red { background: #ef4444; }
.legend .steel { background: #94a3b8; }
.legend .ice { background: #cbd5f5; }
.legend .dark { background: #0f172a; }

.metric-card .metric-value {
  font-size: 30px;
  font-weight: 700;
  margin: 8px 0 6px;
}

.metric-card .metric-value span {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.policy-card .slider-block {
  margin: 16px 0;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 8px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.table-message {
  margin-top: 12px;
}

.table-pagination {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.table-pagination.is-hidden {
  display: none;
}

.pagination-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.page-number {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

.page-number.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.page-ellipsis {
  color: var(--muted);
  font-size: 12px;
  padding: 0 4px;
}

.page-info {
  font-size: 12px;
  color: var(--muted);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #e2e8f0;
  border-radius: 999px;
  transition: 0.2s;
}

.toggle-track::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.2);
}

.toggle input:checked + .toggle-track {
  background: var(--primary);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.policy-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 12px;
  gap: 12px;
}

.activity-card .card-header p {
  margin-top: 4px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: grid;
  place-items: center;
  z-index: 20;
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease;
}

.modal-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: min(420px, 90vw);
  background: #fff;
  border-radius: 16px;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.28);
  position: relative;
  text-align: center;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.icon-button {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: #f1f5f9;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}

.modal-icon {
  width: 48px;
  height: 48px;
  margin: 4px auto 16px;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 14px;
}

.modal-icon img {
  width: 28px;
  height: 28px;
}

.modal-card h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.modal-card p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}

.modal-card form {
  display: grid;
  gap: 12px;
  text-align: left;
}

.modal-card label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: grid;
  gap: 6px;
}

.modal-card input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.modal-card select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
}

.modal-card input:focus {
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.modal-foot {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.user-modal {
  width: min(560px, 92vw);
}

.user-form {
  display: grid;
  gap: 14px;
}

.user-form .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.link-button {
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: #ffffff;
  padding: 32px 40px 28px;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.footer-brand .brand-pill {
  margin-bottom: 10px;
}

.footer-column h3 {
  font-size: 14px;
  margin-bottom: 10px;
}

.footer-column ul {
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.footer-meta {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.is-hidden {
  display: none;
}

.form-message {
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}

.form-message.error {
  color: var(--accent);
}

.form-message.success {
  color: var(--success);
}

@media (max-width: 1200px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .dashboard {
    padding: 24px;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .site-footer {
    padding: 28px 24px;
  }

  .footer-inner {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .brand-group {
    flex-wrap: wrap;
  }

  .topbar {
    padding: 16px 20px;
  }

  .dashboard {
    padding: 20px;
  }

  .card {
    padding: 18px;
  }

  .modal-card {
    padding: 24px 20px;
  }

  .user-form .form-grid {
    grid-template-columns: 1fr;
  }

  .footer-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}
