:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --sidebar: #ffffff;
  --sidebar-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --green: #16a34a;
  --amber: #d97706;
  --blue: #2563eb;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --sidebar-width: 288px;
  --header-height: 72px;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(15, 23, 42, 0.55);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  color: #334155;
}

.sidebar-header {
  display: flex;
  min-height: 84px;
  align-items: center;
  gap: 12px;
  padding: 0 26px;
}

.brand-mark {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.brand-name {
  margin: 0;
  color: #111827;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-subtitle {
  display: block;
  color: #94a3b8;
  font-size: 12px;
}

.sidebar-close {
  display: none;
  margin-left: auto;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.nav-section + .nav-section {
  margin-top: 26px;
}

.nav-section-title {
  margin: 0 0 10px;
  padding: 0 10px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.nav-link {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 12px;
  border-radius: 8px;
  padding: 9px 10px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.nav-link:hover {
  background: #f8fafc;
  color: var(--brand);
}

.nav-link.is-active {
  background: #f8fafc;
  color: var(--brand);
}

.nav-link:not(.is-active) .nav-icon {
  color: #94a3b8;
}

.nav-icon {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
}

.nav-icon svg {
  display: block;
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.nav-badge {
  margin-left: auto;
  min-width: 28px;
  border-radius: 999px;
  background: #f1f5f9;
  color: inherit;
  padding: 2px 7px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
}

.nav-link.is-active .nav-badge {
  background: #eef2ff;
  color: var(--brand);
}

.sidebar-footer {
  padding: 16px;
  border-top: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 8px;
  padding: 8px 10px;
  color: #111827;
}

.sidebar-user:hover {
  background: #f8fafc;
}

.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  background: #e2e8f0;
  color: #334155;
}

.sidebar-user-name {
  display: block;
  font-weight: 800;
}

.sidebar-user-role {
  display: block;
  color: #94a3b8;
  font-size: 12px;
}

.main-shell {
  min-height: 100vh;
  padding-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: var(--header-height);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 0 32px;
  backdrop-filter: blur(16px);
}

.mobile-menu-button,
.icon-button,
.sidebar-close {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
}

.icon-button:hover,
.mobile-menu-button:hover,
.sidebar-close:hover {
  background: #f1f5f9;
  color: #111827;
}

.mobile-menu-button {
  display: none;
}

.sidebar-close {
  display: none;
}

.topbar-left,
.topbar-right {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.topbar-left {
  flex: 1;
}

.page-eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.page-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

.search {
  position: relative;
  width: min(520px, 48vw);
}

.search input {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0 12px 0 36px;
  outline: none;
  font-size: 14px;
}

.search svg {
  position: absolute;
  top: 10px;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 1px solid var(--line);
  padding-left: 20px;
  color: #111827;
  font-weight: 700;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
}

.content-wrap {
  width: 100%;
  padding: 32px 32px 40px;
}

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

.diagram-card {
  display: flex;
  min-height: 152px;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.diagram-card:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow);
}

.diagram-card-code {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--brand);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.diagram-card h3 {
  margin: 12px 0 6px;
  font-size: 17px;
}

.diagram-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.diagram-card-footer {
  margin-top: 16px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.diagram-panel {
  overflow: hidden;
}

.diagram-stack {
  display: grid;
  gap: 24px;
}

.diagram-stack .diagram-panel {
  min-width: 0;
}

.diagram-canvas-wrap {
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #fff;
}

.blank-state {
  display: grid;
  min-height: 460px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #f8fafc;
  color: #94a3b8;
  font-weight: 800;
}

.static-diagram {
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.static-diagram svg {
  display: block;
  width: 1680px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

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

.page-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.page-header p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.panel {
  overflow-x: auto;
}

.stat-card {
  padding: 16px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 8px;
  color: #0f172a;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.stat-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.panel-header {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.panel-body {
  padding: 16px;
}

.table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 16px;
  text-align: left;
  vertical-align: middle;
}

.table th {
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.table tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.status.green {
  background: #dcfce7;
  color: #166534;
}

.status.amber {
  background: #fef3c7;
  color: #92400e;
}

.status.red {
  background: #fee2e2;
  color: #991b1b;
}

.status.blue {
  background: #dbeafe;
  color: #1d4ed8;
}

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

.timeline-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
}

.timeline-dot {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: #fee2e2;
  color: var(--brand-strong);
  font-size: 11px;
  font-weight: 900;
}

.timeline-title {
  margin: 0;
  font-weight: 800;
}

.timeline-copy {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.audit-copy {
  display: grid;
  gap: 10px;
  color: #334155;
}

.audit-copy p {
  margin: 0;
}

.audit-copy code,
.table code {
  border-radius: 6px;
  background: #f1f5f9;
  color: #334155;
  padding: 2px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.code-block {
  overflow: auto;
  margin: 0;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

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

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

.field label {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.footer {
  border-top: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 14px 28px;
  font-size: 12px;
}

.footer-inner {
  display: flex;
  width: min(1240px, 100%);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 auto;
}

@media (max-width: 1080px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .diagram-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-backdrop.is-open {
    display: block;
  }

  .sidebar-close,
  .mobile-menu-button {
    display: inline-grid;
  }

  .main-shell {
    padding-left: 0;
  }

  .topbar {
    padding: 0 16px;
  }

  .search,
  .user-chip span {
    display: none;
  }

  .content-wrap {
    padding: 20px 16px 28px;
  }

  .page-header {
    display: grid;
  }

  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
