:root {
  --ink: #1f2933;
  --paper: #fbfbf2;
  --blue: #4c6fff;
  --orange: #f9703e;
  --mint: #29b891;
  --line: rgba(31, 41, 51, 0.14);
  --muted: rgba(31, 41, 51, 0.62);
  --panel: rgba(251, 251, 242, 0.92);
  --shadow: 0 24px 80px rgba(31, 41, 51, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background:
    linear-gradient(90deg, rgba(31, 41, 51, 0.06) 1px, transparent 1px) 0 0 / 44px 44px,
    radial-gradient(circle at 92% 8%, rgba(249, 112, 62, 0.18), transparent 26rem),
    var(--paper);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  background: var(--ink);
  color: var(--paper);
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-weight: 760;
  letter-spacing: 0;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  min-height: 42px;
  border: 1px solid rgba(251, 251, 242, 0.14);
  border-radius: 8px;
  background: transparent;
  color: rgba(251, 251, 242, 0.74);
  text-align: left;
  padding: 0 12px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover,
.tab.is-active {
  background: rgba(76, 111, 255, 0.22);
  color: var(--paper);
  transform: translateX(3px);
}

.rail-note {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding-top: 18px;
  border-top: 1px solid rgba(251, 251, 242, 0.16);
  color: rgba(251, 251, 242, 0.68);
  font-size: 13px;
  line-height: 1.45;
}

.rail-note strong {
  color: var(--paper);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 56px);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  letter-spacing: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.search {
  width: min(340px, 100%);
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.search input,
.toolbar select,
.form-grid input,
.form-grid select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--ink);
  padding: 0 12px;
  outline-color: var(--blue);
}

.summary-strip {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr)) minmax(260px, 1.5fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: 0 14px 28px rgba(31, 41, 51, 0.08);
}

.metric,
.stage-pulse {
  min-height: 76px;
  padding: 12px;
  background: rgba(251, 251, 242, 0.96);
}

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

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 31px;
  line-height: 1;
}

.stage-pulse {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
}

.stage-pulse span {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  min-width: 0;
}

.stage-pulse b {
  color: var(--ink);
  font-size: 22px;
}

.view {
  display: none;
  padding-top: 18px;
  animation: lift 220ms ease both;
}

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

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

.board-grid,
.request-layout,
.docs-layout,
.finance-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

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

.section-head p {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.primary-action,
.inspector-actions button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  padding: 0 14px;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary-action:hover,
.inspector-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(76, 111, 255, 0.22);
}

.table-zone,
.request-form,
.docs-layout > section,
.finance-layout > section {
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 251, 242, 0.86);
}

.object-table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 77px;
  z-index: 2;
  background: #eef0f2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

td {
  font-size: 14px;
}

td span,
td small {
  display: block;
  color: var(--muted);
  line-height: 1.35;
}

tr {
  transition: background 140ms ease;
}

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

.row-pick {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.stage,
.risk,
.doc-status,
.finance-status {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 760;
}

.stage {
  background: rgba(31, 41, 51, 0.08);
}

.risk-low {
  background: rgba(41, 184, 145, 0.16);
  color: #12664f;
}

.risk-medium {
  background: rgba(249, 112, 62, 0.15);
  color: #9a3a12;
}

.risk-high,
.risk-critical {
  background: var(--orange);
  color: white;
}

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

.gate span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--mint));
}

.photo-count {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(31, 41, 51, 0.08);
  color: var(--ink);
  font-weight: 760;
}

.inspector,
.asset-graph,
.photo-lane,
.action-log {
  position: sticky;
  top: 96px;
  border: 1px solid rgba(31, 41, 51, 0.16);
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
  padding: 18px;
}

.inspector-head p {
  color: rgba(251, 251, 242, 0.64);
  line-height: 1.45;
}

.score-dial {
  width: 164px;
  aspect-ratio: 1;
  margin: 18px auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--ink) 0 54%, transparent 55%),
    conic-gradient(var(--orange) calc(var(--score) * 1%), rgba(251, 251, 242, 0.14) 0);
}

.score-dial strong {
  font-size: 42px;
  line-height: 1;
}

.score-dial span {
  display: block;
  color: rgba(251, 251, 242, 0.62);
  font-size: 11px;
  text-align: center;
}

.timeline-window {
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.timeline-window span {
  height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--orange));
  position: relative;
}

.timeline-window span::after {
  content: "";
  position: absolute;
  inset: -16px 38% -16px auto;
  width: 56px;
  border: 1px solid rgba(251, 251, 242, 0.74);
  background: rgba(251, 251, 242, 0.08);
  backdrop-filter: blur(4px);
}

.timeline-window b {
  color: var(--paper);
}

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

.check {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid rgba(251, 251, 242, 0.12);
}

.severity {
  width: 12px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--orange) calc(var(--heat) * 11%), rgba(251, 251, 242, 0.16) 0);
}

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

.check small {
  margin-top: 4px;
  color: rgba(251, 251, 242, 0.62);
  line-height: 1.35;
}

.inspector-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.inspector-actions button:nth-child(3) {
  background: var(--orange);
}

.inspector-actions button:nth-child(4) {
  background: rgba(251, 251, 242, 0.16);
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.gate-preview {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.gate-preview div {
  min-height: 116px;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 242, 0.74);
  line-height: 1.35;
}

.gate-preview span {
  display: block;
  margin-bottom: 18px;
  color: var(--blue);
  font-size: 28px;
  font-weight: 800;
}

.asset-graph {
  min-height: 370px;
  position: sticky;
  overflow: hidden;
}

.graph-line {
  position: absolute;
  inset: 50% 36px auto;
  height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--orange));
}

.graph-node {
  position: absolute;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(251, 251, 242, 0.32);
  background: rgba(251, 251, 242, 0.08);
  font-weight: 800;
  animation: pulse 2600ms ease-in-out infinite;
}

.node-a { left: 28px; top: 44%; }
.node-b { left: 35%; top: 22%; animation-delay: 180ms; }
.node-c { right: 30%; bottom: 20%; animation-delay: 360ms; }
.node-d { right: 26px; top: 44%; animation-delay: 540ms; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.document-list,
.finance-list,
.action-log > div {
  display: grid;
  gap: 8px;
}

.doc-row,
.finance-row,
.log-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 251, 242, 0.82);
  padding: 12px;
}

.doc-row span,
.finance-row span,
.log-row small {
  display: block;
  color: var(--muted);
  line-height: 1.35;
}

.doc-status,
.finance-status {
  background: rgba(76, 111, 255, 0.14);
  color: var(--blue);
}

.photo-lane,
.action-log {
  background: #eef0f2;
  color: var(--ink);
}

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

.photo-grid span {
  display: block;
  aspect-ratio: 1.25;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(31, 41, 51, 0.2), rgba(76, 111, 255, 0.18)),
    repeating-linear-gradient(45deg, rgba(31, 41, 51, 0.1) 0 8px, rgba(249, 112, 62, 0.12) 8px 16px);
}

.log-row {
  grid-template-columns: 58px 1fr;
  background: rgba(255, 255, 255, 0.46);
}

.log-row small {
  grid-column: 2;
}

.empty,
.error {
  padding: 18px;
  color: var(--muted);
}

.error {
  color: #9a3a12;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex: 1 1 460px;
  }

  .rail-note {
    display: none;
  }

  .summary-strip,
  .board-grid,
  .request-layout,
  .docs-layout,
  .finance-layout {
    grid-template-columns: 1fr;
  }

  .inspector,
  .asset-graph,
  .photo-lane,
  .action-log {
    position: static;
  }

  th {
    top: 0;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

  .toolbar {
    justify-content: stretch;
  }

  .search,
  .toolbar select {
    width: 100%;
  }

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

  .stage-pulse,
  .gate-preview,
  .form-grid,
  .doc-row,
  .finance-row {
    grid-template-columns: 1fr;
  }

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

  .brand {
    width: 100%;
  }

  .inspector-actions {
    grid-template-columns: 1fr;
  }
}
