:root {
  --bg: #020617;
  --bg-soft: #0b1120;
  --sidebar: #08101f;
  --panel: #111827;
  --panel-strong: #0f172a;
  --panel-soft: #162033;
  --line: #334155;
  --line-soft: rgba(148, 163, 184, 0.16);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --muted-strong: #cbd5e1;
  --primary: #38bdf8;
  --primary-soft: rgba(56, 189, 248, 0.14);
  --primary-border: rgba(56, 189, 248, 0.28);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --success-border: rgba(34, 197, 94, 0.28);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --warning-border: rgba(245, 158, 11, 0.24);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.24);
  --shadow: 0 24px 64px rgba(2, 8, 23, 0.45);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Arial Nova", Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.06), transparent 22%),
    radial-gradient(circle at top left, rgba(129, 140, 248, 0.08), transparent 18%),
    linear-gradient(180deg, #0b1120 0%, #020617 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.app-shell {
  display: block;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 232px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(8, 16, 31, 0.98), rgba(2, 8, 23, 0.98));
  overflow-y: auto;
}

.sidebar-brand {
  display: grid;
  gap: 4px;
  padding: 4px 8px 18px;
}

.brand-mark {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
}

.brand-subtitle,
.sidebar-footer span {
  color: var(--muted);
  font-size: 0.8rem;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted-strong);
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.18);
  color: #e0f2fe;
}

.sidebar-footer {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding: 14px 8px 6px;
  border-top: 1px solid var(--line-soft);
}

.sidebar-footer strong {
  font-size: 0.85rem;
}

.content-shell {
  min-width: 0;
  margin-left: 232px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(2, 8, 23, 0.7);
  backdrop-filter: blur(10px);
}

.topbar h1,
.section-header h2,
.section-header h3,
.subpanel-head h3 {
  margin: 0;
}

.topbar-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  color: var(--muted);
}

.topbar h1 {
  font-size: 1.45rem;
  line-height: 1.1;
  font-weight: 700;
}

.topbar-badges,
.detail-actions,
.form-actions,
.consent-tags,
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-shell {
  padding: 18px;
}

.dashboard-panel,
.panel,
.detail-card,
.metric-card,
.subpanel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.98));
  box-shadow: var(--shadow);
}

.dashboard-panel,
.panel {
  padding: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.95fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.left-column,
.right-rail,
.form-stack,
.detail-grid {
  display: grid;
  gap: 16px;
}

.right-rail {
  position: sticky;
  top: 18px;
}

.panel-intro {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.section-header.compact {
  margin-bottom: 8px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  position: relative;
  padding: 14px;
  min-height: 94px;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: 12px 0 0 12px;
  background: linear-gradient(180deg, var(--primary), rgba(56, 189, 248, 0.2));
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-value {
  display: block;
  margin-top: 10px;
  font-size: 1.65rem;
  line-height: 1;
  color: #f8fafc;
}

.metric-helper {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.table-responsive {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 312px;
}

.consent-table {
  min-width: 100%;
}

.consent-table-header,
.consent-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.3fr) minmax(180px, 1.5fr) 100px 124px 124px 88px;
  gap: 12px;
  align-items: center;
}

.consent-table-header.archive-mode,
.consent-row-archive {
  grid-template-columns: minmax(150px, 1.2fr) minmax(180px, 1.35fr) 100px 112px 112px 112px 88px;
}

.consent-table-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.consent-row {
  padding: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  background: transparent;
  transition: background 120ms ease, border-color 120ms ease;
}

.consent-row:last-child {
  border-bottom: none;
}

.consent-row:hover {
  background: rgba(56, 189, 248, 0.06);
}

.consent-row.is-selected {
  background: rgba(56, 189, 248, 0.1);
  box-shadow: inset 2px 0 0 var(--primary);
}

.consent-primary {
  min-width: 0;
}

.consent-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f8fafc;
}

.consent-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}

.badge-warning {
  color: #fcd34d;
  background: var(--warning-soft);
  border-color: var(--warning-border);
}

.badge-primary {
  color: #7dd3fc;
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.badge-danger {
  color: #fca5a5;
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.badge-muted {
  color: var(--muted-strong);
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.16);
}

.status-active {
  color: #86efac;
  background: var(--success-soft);
  border-color: var(--success-border);
}

.status-revoked {
  color: #fca5a5;
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.status-expired {
  color: #fcd34d;
  background: var(--warning-soft);
  border-color: var(--warning-border);
}

.chip-list {
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--muted-strong);
  font-size: 0.73rem;
}

.row-date,
.row-actions {
  color: var(--muted);
  font-size: 0.78rem;
}

.button {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, opacity 120ms ease;
  white-space: nowrap;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  color: #08111f;
  background: linear-gradient(180deg, #67e8f9 0%, #38bdf8 100%);
  border-color: rgba(103, 232, 249, 0.2);
}

.button-secondary {
  color: var(--text);
  background: rgba(15, 23, 42, 0.68);
  border-color: var(--line);
}

.button-danger {
  color: #fee2e2;
  background: rgba(127, 29, 29, 0.75);
  border-color: rgba(248, 113, 113, 0.28);
}

.button-compact {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 0.78rem;
}

.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.step {
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.6);
  color: var(--muted);
  font-size: 0.77rem;
}

.step.is-active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: #bae6fd;
}

.form-step {
  display: none;
}

.hidden {
  display: none !important;
}

.form-step.is-active {
  display: block;
}

.field-grid,
.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.subpanel {
  padding: 12px;
}

.subpanel-head {
  margin-bottom: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted-strong);
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.88);
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #64748b;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.checkbox-card {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 9px 10px;
  min-height: 52px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.68);
  color: var(--muted-strong);
  font-size: 0.84rem;
}

.checkbox-card input {
  width: auto;
  margin-top: 2px;
  accent-color: var(--primary);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.6);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr:last-child td {
  border-bottom: none;
}

.detail-grid {
  grid-template-columns: 1fr;
}

.detail-card {
  padding: 14px;
}

.detail-card.full-width {
  grid-column: 1 / -1;
}

.detail-summary-card {
  border-color: rgba(56, 189, 248, 0.14);
}

.summary-box,
.empty-state,
.detail-list dd {
  color: var(--muted);
  line-height: 1.55;
}

.summary-box {
  margin: 0;
  font-size: 0.9rem;
}

.detail-list {
  display: grid;
  gap: 9px;
  margin: 14px 0 0;
}

.detail-list div {
  padding-top: 9px;
  border-top: 1px solid var(--line-soft);
}

.detail-list dt {
  margin-bottom: 4px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--muted-strong);
}

.audit-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.audit-item {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.68);
  font-size: 0.84rem;
}

.audit-time {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  margin-bottom: 4px;
}

.code-block,
.export-output {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, 0.12);
  border-radius: var(--radius-md);
  background: #020617;
  color: #dbeafe;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  line-height: 1.55;
}

.collapse-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 600;
  text-align: left;
  margin-bottom: 12px;
}

.collapse-toggle:hover {
  color: #e0f2fe;
}

.empty-state {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.58);
  font-size: 0.9rem;
}

.form-actions-end {
  justify-content: flex-end;
}

.revoke-dialog {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(460px, calc(100% - 24px));
  color: var(--text);
  background: transparent;
  box-shadow: var(--shadow);
}

.revoke-dialog::backdrop {
  background: rgba(2, 8, 23, 0.72);
}

.revoke-dialog form {
  padding: 16px;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.98));
}

@media (max-width: 1260px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .right-rail {
    position: static;
  }
}

@media (max-width: 1080px) {
  .consent-table-header,
  .consent-row {
    grid-template-columns: minmax(150px, 1.2fr) minmax(180px, 1.2fr) 96px 112px 112px 76px;
  }

  .consent-table-header.archive-mode,
  .consent-row-archive {
    grid-template-columns: minmax(150px, 1.15fr) minmax(180px, 1.15fr) 96px 100px 100px 100px 76px;
  }
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
    overflow: visible;
  }

  .content-shell {
    margin-left: 0;
  }

  .metrics-grid,
  .field-grid,
  .split-grid,
  .choice-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .consent-table-header {
    display: none;
  }

  .consent-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    background: rgba(15, 23, 42, 0.68);
  }

  .consent-row:last-child {
    margin-bottom: 0;
  }
}
