:root {
  --ink: #1f2933;
  --paper: #fbfbf2;
  --blue: #4c6fff;
  --heat: #f9703e;
  --line: rgba(31, 41, 51, 0.14);
  --muted: #6d7884;
  --ok: #1f9d74;
  --panel: #ffffff;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(76, 111, 255, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(31, 41, 51, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
}

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

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(14px, 3vw, 34px);
  background: rgba(251, 251, 242, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 220px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 19px;
  line-height: 1.05;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.tab,
.primary-action {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  padding: 8px 13px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tab:hover,
.primary-action:hover {
  transform: translateY(-1px);
  border-color: rgba(76, 111, 255, 0.45);
}

.tab.is-active,
.primary-action {
  background: var(--ink);
  color: var(--paper);
}

.app-shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2.6vw, 34px) 38px;
}

.summary-row {
  position: sticky;
  top: 73px;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.metric {
  min-width: 0;
  padding: 14px 15px;
  background: var(--paper);
}

.metric span,
.form-head span,
.board-head span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: clamp(26px, 3vw, 45px);
  line-height: 0.92;
}

.metric.danger strong {
  color: var(--heat);
}

.metric.money strong {
  color: var(--blue);
}

.screen {
  display: none;
  animation: enter 260ms ease both;
}

.screen.is-active {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}

.registry-pane,
.risk-board,
.request-grid,
.list-screen {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.search-field,
.select-field,
.request-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.search-field {
  flex: 1 1 280px;
}

.select-field {
  flex: 0 1 180px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 41px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(76, 111, 255, 0.14);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

td strong,
td span {
  display: block;
}

td strong {
  font-size: 15px;
}

td span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

tbody tr {
  transition: background 160ms ease, transform 160ms ease;
}

tbody tr:hover,
tbody tr.is-selected {
  background: rgba(76, 111, 255, 0.08);
}

.loadbar {
  width: 116px;
  max-width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(31, 41, 51, 0.12);
}

.loadbar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--heat));
}

.risk {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.risk.normal,
.dot.normal {
  background: var(--ok);
}

.risk.high,
.dot.high {
  background: var(--blue);
}

.risk.critical,
.dot.critical {
  background: var(--heat);
}

.risk-board {
  position: sticky;
  top: 164px;
  overflow: hidden;
}

.board-head,
.form-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.board-head strong,
.form-head strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1.05;
}

.graph {
  position: relative;
  min-height: 310px;
  padding: 18px;
  background:
    radial-gradient(circle at 23% 24%, rgba(249, 112, 62, 0.18), transparent 30%),
    radial-gradient(circle at 76% 68%, rgba(76, 111, 255, 0.16), transparent 32%),
    #26313c;
}

.graph::before {
  position: absolute;
  inset: 18px;
  border: 1px dashed rgba(251, 251, 242, 0.24);
  border-radius: 8px;
  content: "";
}

.graph-node {
  position: absolute;
  display: grid;
  gap: 4px;
  width: 132px;
  min-height: 86px;
  border: 1px solid rgba(251, 251, 242, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(249, 112, 62, calc((var(--heat-level, 50) / 100) * 0.7)), rgba(76, 111, 255, 0.2)),
    rgba(251, 251, 242, 0.1);
  color: var(--paper);
  padding: 10px;
  text-align: left;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.22);
  transition: transform 180ms ease, background 180ms ease;
}

.graph-node:hover {
  transform: translateY(-3px) scale(1.02);
}

.graph-node span,
.graph-node i {
  overflow-wrap: anywhere;
  font-size: 11px;
  font-style: normal;
  line-height: 1.25;
}

.graph-node strong {
  font-size: 25px;
  line-height: 0.95;
}

.node-0 { left: 8%; top: 13%; }
.node-1 { right: 10%; top: 24%; }
.node-2 { left: 28%; bottom: 12%; }
.node-3 { right: 18%; bottom: 10%; }
.node-4 { left: 10%; bottom: 34%; }

.detail-panel {
  padding: 16px;
}

.empty-state,
.empty-row {
  color: var(--muted);
}

.detail-title span,
.detail-title strong {
  display: block;
}

.detail-title span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-title strong {
  margin-top: 4px;
  font-size: 30px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px 12px;
  margin: 14px 0;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.detail-grid dd {
  margin: 0;
  font-weight: 700;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-list span,
.comment,
.row-item {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.mini-list b {
  display: inline-block;
  min-width: 58px;
  margin-right: 8px;
  color: var(--heat);
  font-size: 11px;
  text-transform: uppercase;
}

.comment {
  color: var(--muted);
  line-height: 1.45;
}

.request-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 0 16px 16px;
}

.request-grid .form-head,
.request-grid .wide {
  grid-column: 1 / -1;
}

.request-grid .form-head {
  margin: 0 -16px;
}

.form-status {
  grid-column: 1 / -1;
  min-height: 22px;
  margin: 0;
  color: var(--blue);
  font-weight: 800;
}

.list-screen {
  padding-bottom: 8px;
}

.document-list,
.finance-list {
  display: grid;
  gap: 1px;
  padding: 0 16px 12px;
}

.row-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-height: 64px;
}

.row-item strong,
.row-item small {
  display: block;
}

.row-item small {
  margin-top: 4px;
  color: var(--muted);
}

.row-item b {
  white-space: nowrap;
}

.row-item em {
  color: var(--muted);
  font-style: normal;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.finance-bar {
  width: 160px;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1060px) {
  .summary-row {
    top: 94px;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

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

  .risk-board {
    position: static;
  }

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

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
  }

  .brand {
    min-width: 0;
  }

  .summary-row {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric strong {
    font-size: 28px;
  }

  .toolbar {
    align-items: stretch;
  }

  .select-field,
  .search-field,
  .toolbar .primary-action {
    flex: 1 1 100%;
  }

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

  .graph {
    min-height: 360px;
  }

  .graph-node {
    width: 124px;
  }

  .row-item,
  .finance-row {
    grid-template-columns: 14px minmax(0, 1fr);
  }

  .row-item b,
  .row-item em,
  .finance-bar {
    grid-column: 2;
  }
}
