:root {
  --ink: #2d3142;
  --paper: #f7fff7;
  --line: #d7ded9;
  --muted: #66706a;
  --amber: #ff9f1c;
  --teal: #2ec4b6;
  --danger: #b73535;
  --white: #ffffff;
  --shadow: 0 18px 60px rgba(45, 49, 66, 0.16);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    linear-gradient(90deg, rgba(45, 49, 66, 0.05) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(180deg, #f7fff7 0%, #eef6ef 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.command-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr minmax(260px, 420px);
  align-items: center;
  gap: 20px;
  padding: 14px clamp(16px, 3vw, 32px);
  background: var(--ink);
  color: var(--paper);
  border-bottom: 4px solid var(--amber);
}

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

.brand img {
  flex: 0 0 auto;
  filter: drop-shadow(0 7px 16px rgba(0, 0, 0, 0.26));
}

.brand strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 0.95;
  font-weight: 700;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: rgba(247, 255, 247, 0.72);
  font-size: 12px;
  white-space: nowrap;
}

.tabs,
.filters {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar,
.filters::-webkit-scrollbar {
  display: none;
}

.tab,
.filter {
  min-height: 40px;
  border: 1px solid rgba(247, 255, 247, 0.18);
  border-radius: 6px;
  background: rgba(247, 255, 247, 0.08);
  color: inherit;
  padding: 0 14px;
  white-space: nowrap;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.filter {
  border-color: var(--line);
  background: var(--white);
  color: var(--ink);
}

.tab:hover,
.filter:hover {
  transform: translateY(-1px);
}

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

.filter.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.command-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.search {
  width: min(100%, 340px);
  display: grid;
  gap: 4px;
}

.search span,
.label,
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.command-bar .search span {
  color: rgba(247, 255, 247, 0.7);
}

.search input,
.booking-form input,
.booking-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  padding: 0 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(247, 255, 247, 0.28);
  border-radius: 6px;
  background: transparent;
  color: var(--paper);
  font-size: 22px;
}

.workspace {
  padding: 20px clamp(16px, 3vw, 32px) 24px;
  overflow: hidden;
}

.status-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 20px;
  background: var(--line);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.status-rail div {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 8px;
  background: var(--white);
  padding: 14px;
}

.status-rail strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
}

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

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

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

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

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

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.98;
  max-width: 780px;
}

h2 {
  font-size: 27px;
  line-height: 1.05;
  margin-bottom: 12px;
}

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

.board,
.inspector,
.rules-panel,
.list-view {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.board {
  min-height: 430px;
  overflow: auto;
}

.board.is-loading {
  opacity: 0.72;
}

.board-grid,
.board-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) minmax(160px, 1fr) 88px 102px 82px 108px;
  gap: 12px;
  align-items: center;
  min-width: 830px;
}

.board-grid-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 44px;
  padding: 0 14px;
  background: #eef6ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.board-row {
  width: 100%;
  min-height: 76px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  padding: 10px 14px;
  text-align: left;
  transition: background 150ms ease, box-shadow 150ms ease;
}

.board-row:hover,
.board-row.is-selected {
  background: #fff8eb;
  box-shadow: inset 4px 0 0 var(--amber);
}

.board-row span {
  min-width: 0;
}

.board-row strong,
.board-row small {
  display: block;
  overflow-wrap: anywhere;
}

.board-row small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.status,
.doc-state {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-queued {
  background: #eef6ef;
  color: var(--ink);
}

.status-in_test {
  background: rgba(46, 196, 182, 0.18);
  color: #12675f;
}

.status-ready {
  background: rgba(46, 196, 182, 0.28);
  color: #0b554f;
}

.status-blocked {
  background: rgba(183, 53, 53, 0.13);
  color: var(--danger);
}

.inspector,
.rules-panel {
  padding: 18px;
}

.details {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
}

.details div {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

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

.risk {
  display: grid;
  gap: 4px;
  margin: 14px 0;
  border-left: 4px solid var(--teal);
  background: rgba(46, 196, 182, 0.12);
  padding: 12px;
}

.risk-high {
  border-left-color: var(--amber);
  background: rgba(255, 159, 28, 0.14);
}

.notes {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.split-work {
  display: grid;
  grid-template-columns: minmax(0, 720px) minmax(260px, 360px);
  gap: 20px;
  align-items: start;
}

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

.booking-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.primary {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--amber);
  color: #1b1a17;
  font-weight: 900;
  grid-column: 1 / -1;
}

.rules-panel ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.6;
}

.form-status {
  min-height: 24px;
  margin: 12px 0 0;
  font-weight: 800;
}

.form-status.is-ok {
  color: #0b554f;
}

.form-status.is-error,
.empty.is-error {
  color: var(--danger);
}

.list-view {
  display: grid;
  overflow: hidden;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(96px, 0.5fr) minmax(96px, auto) minmax(132px, auto);
  gap: 16px;
  align-items: center;
  min-height: 72px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--white);
}

.finance-view .list-row {
  grid-template-columns: minmax(180px, 1fr) 90px 120px 82px 100px;
}

.list-row:first-child {
  border-top: 0;
}

.list-row strong,
.list-row small {
  display: block;
  overflow-wrap: anywhere;
}

.list-row small,
.list-row span {
  color: var(--muted);
}

.doc-state {
  background: #eef6ef;
  color: var(--ink);
  justify-self: start;
}

.finance-total {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border-left: 4px solid var(--teal);
  background: var(--white);
  padding: 0 14px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.money-in {
  color: #0b554f;
}

.money-out {
  color: var(--danger);
}

.empty {
  padding: 24px;
  color: var(--muted);
  font-weight: 800;
}

.event-stream {
  min-height: 72px;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px clamp(16px, 3vw, 32px);
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.stream-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 rgba(46, 196, 182, 0.55);
  animation: pulse 1600ms ease infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 12px rgba(46, 196, 182, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(46, 196, 182, 0);
  }
}

.events {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.event {
  flex: 0 0 auto;
  max-width: min(460px, 78vw);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 9px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event b {
  color: var(--ink);
}

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

@media (max-width: 980px) {
  .command-bar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .command-actions {
    justify-content: stretch;
  }

  .search {
    width: 100%;
  }

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

  .registry-layout,
  .split-work {
    grid-template-columns: 1fr;
  }

  .inspector {
    order: -1;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding-top: 14px;
  }

  .brand small {
    white-space: normal;
  }

  .board-head {
    display: grid;
    align-items: start;
  }

  .status-rail {
    grid-template-columns: 1fr 1fr;
  }

  .status-rail div {
    min-height: 74px;
  }

  .booking-form,
  .list-row,
  .finance-view .list-row {
    grid-template-columns: 1fr;
  }

  .event-stream {
    grid-template-columns: 1fr;
  }
}

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

