:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-alt: #edf3ee;
  --ink: #17201d;
  --muted: #61726a;
  --line: #d7e0db;
  --line-strong: #b8c8c0;
  --brand: #1f7a62;
  --brand-strong: #145842;
  --brand-soft: #dcefe8;
  --accent: #b35c14;
  --accent-soft: #fde8d1;
  --blue: #346c9f;
  --blue-soft: #e2eef8;
  --red: #a93c39;
  --red-soft: #fae3e0;
  --yellow: #a17917;
  --yellow-soft: #fff3c4;
  --shadow: 0 14px 40px rgba(25, 38, 32, 0.08);
  --radius: 8px;
  --sidebar: #19231f;
  --sidebar-ink: #eaf1ed;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: var(--brand-strong);
}

.skip-link {
  position: absolute;
  top: -120px;
  left: 12px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 3px solid rgba(31, 122, 98, 0.35);
  outline-offset: 2px;
}

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

.loading-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  gap: 14px;
  color: var(--muted);
}

.loading-mark {
  width: 48px;
  height: 48px;
  border: 4px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 122, 98, 0.12), rgba(179, 92, 20, 0.1)),
    var(--bg);
}

.login-panel {
  display: grid;
  gap: 12px;
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 8px 0 0;
  font-size: 26px;
  line-height: 1.15;
}

.login-note {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 13px;
}

.brand-title.dark {
  color: var(--ink);
}

.brand-subtitle.dark {
  color: var(--muted);
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-block {
  padding: 22px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #41a27f, #c66d1f);
  color: #fff;
  font-weight: 800;
}

.brand-title {
  margin: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 760;
}

.brand-subtitle {
  margin: 3px 0 0;
  color: #b9cac2;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.nav button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d7e3de;
  text-align: left;
}

.nav button:hover,
.nav button[aria-current="page"] {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
}

.nav svg,
.icon svg,
.button-icon svg {
  display: block;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-kicker {
  color: #9bb1a6;
  font-size: 11px;
}

.sidebar-footer {
  margin: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #c8d8d1;
  font-size: 12px;
}

.content {
  min-width: 0;
  overflow-x: clip;
}

.context-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  min-height: 76px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 244, 0.94);
  backdrop-filter: blur(12px);
}

.context-main {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.context-title {
  margin: 0;
  overflow: hidden;
  font-size: 20px;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
}

.context-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.main {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 24px 36px;
}

.view-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.view-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.view-description {
  max-width: 880px;
  margin: 6px 0 0;
  color: var(--muted);
}

.band {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(23, 32, 29, 0.02);
}

.band.soft {
  background: var(--surface-alt);
}

.section-title {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title h2,
.section-title h3 {
  margin: 0;
  font-size: 17px;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card,
.task-item,
.disclosure-row,
.record-row,
.request-item,
.role-row,
.audit-row,
.risk-row,
.snapshot-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-card {
  display: grid;
  gap: 10px;
  min-height: 132px;
  padding: 14px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
}

.metric-sub {
  color: var(--muted);
  font-size: 12px;
}

.stat-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.stat-line:last-child {
  border-bottom: 0;
}

.progress-list {
  display: grid;
  gap: 12px;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(120px, 210px) minmax(0, 1fr) 48px;
  gap: 12px;
  align-items: center;
}

.progress-label {
  color: var(--ink);
  font-size: 13px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe8e3;
}

.progress-bar {
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.progress-bar.warn {
  background: var(--accent);
}

.progress-bar.low {
  background: var(--red);
}

.progress-value {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.brand {
  border-color: #a9d9ca;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.pill.warn {
  border-color: #e5bd84;
  background: var(--accent-soft);
  color: #72420d;
}

.pill.error {
  border-color: #e5aaa5;
  background: var(--red-soft);
  color: #7a2422;
}

.pill.info {
  border-color: #bbd3e8;
  background: var(--blue-soft);
  color: #255177;
}

.pill.neutral {
  background: var(--surface-alt);
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 720;
}

.button {
  gap: 8px;
  padding: 8px 12px;
}

.icon-button {
  width: 38px;
  padding: 0;
}

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

.button.danger {
  border-color: #d68f8a;
  background: var(--red-soft);
  color: #7a2422;
}

.button.ghost {
  border-color: transparent;
  background: transparent;
}

.button:hover,
.icon-button:hover {
  box-shadow: 0 0 0 3px rgba(31, 122, 98, 0.08);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

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

th {
  background: #f7faf8;
  color: #34463e;
  font-size: 12px;
  font-weight: 800;
}

td {
  color: #26332e;
}

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

.compact td,
.compact th {
  min-width: 90px;
  padding: 8px 10px;
}

.task-list,
.record-list,
.disclosure-list,
.request-list,
.audit-list,
.snapshot-list,
.risk-list {
  display: grid;
  gap: 10px;
}

.task-item,
.record-row,
.disclosure-row,
.request-item,
.audit-row,
.snapshot-row,
.risk-row {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.row-header {
  display: flex;
  gap: 10px;
  align-items: start;
  justify-content: space-between;
}

.row-title {
  margin: 0;
  font-weight: 780;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

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

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

.field.full {
  grid-column: 1 / -1;
}

label {
  color: #34463e;
  font-size: 12px;
  font-weight: 800;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

legend {
  padding: 0 4px;
  color: #34463e;
  font-size: 12px;
  font-weight: 800;
}

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

.check-item {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.check-item input {
  width: 16px;
  min-height: 16px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 124px;
  resize: vertical;
}

.split {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  min-height: 38px;
  margin-bottom: -1px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 760;
}

.tabs button[aria-selected="true"] {
  border-color: var(--line);
  border-bottom-color: var(--surface);
  background: var(--surface);
  color: var(--ink);
}

.state-machine {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.state-step {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.state-step.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.chart {
  min-height: 260px;
}

.chart svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
}

.chart-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.lineage {
  display: grid;
  gap: 10px;
}

.lineage-node {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.lineage-index {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: #255177;
  font-weight: 800;
}

.lineage-label {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 40px));
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 60;
  width: min(560px, 100vw);
  padding: 20px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(15, 24, 20, 0.25);
}

.hidden {
  display: none !important;
}

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

  .brand-block {
    padding: 16px 12px;
  }

  .brand-title,
  .brand-subtitle,
  .nav-label,
  .nav-kicker,
  .sidebar-footer {
    display: none;
  }

  .nav button {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .check-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .brand-block {
    display: none;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(84px, 1fr);
    overflow-x: auto;
    padding: 8px;
  }

  .nav button {
    grid-template-columns: 1fr;
  }

  .nav-label {
    display: block;
    font-size: 11px;
    text-align: center;
  }

  .context-bar,
  .view-header {
    grid-template-columns: 1fr;
  }

  .context-actions {
    justify-content: flex-start;
  }

  .main {
    padding: 16px;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .split {
    grid-template-columns: 1fr;
  }

  .progress-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .progress-value {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .context-title,
  .view-title {
    white-space: normal;
  }

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

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

  .metric-value {
    font-size: 24px;
  }

  th,
  td {
    min-width: 160px;
  }
}
