* {
  box-sizing: border-box;
}

:root {
  --ink: #102a43;
  --paper: #f5f7fa;
  --line: #d7dde4;
  --danger: #d64545;
  --teal: #56a3a6;
  --soft: #e9eef3;
  --muted: #657487;
  --panel: #ffffff;
  --shadow: 0 18px 45px rgba(16, 42, 67, 0.12);
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(16, 42, 67, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(16, 42, 67, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 44px 44px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--paper);
  text-decoration: none;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand img {
  flex: 0 0 auto;
}

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

.nav-tab {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(245, 247, 250, 0.18);
  border-radius: 7px;
  color: var(--paper);
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.nav-tab:hover,
.nav-tab.is-active {
  background: rgba(86, 163, 166, 0.22);
  border-color: var(--teal);
  transform: translateX(2px);
}

.rail-note {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(245, 247, 250, 0.2);
  border-radius: 8px;
  color: rgba(245, 247, 250, 0.82);
  line-height: 1.55;
}

.note-label,
.kicker {
  color: var(--teal);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--ink);
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(34px, 5vw, 66px);
  line-height: 0.95;
  letter-spacing: 0;
}

.kicker {
  margin: 0;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 10px;
  min-width: min(540px, 100%);
}

.metric {
  display: grid;
  gap: 3px;
  min-height: 68px;
  padding: 10px 12px;
  border-left: 4px solid var(--teal);
  background: rgba(255, 255, 255, 0.72);
}

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

.metric small {
  color: var(--muted);
  line-height: 1.25;
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding: 18px 0;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter,
.action-btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 9px 12px;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

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

.action-btn:hover {
  transform: translateY(-1px);
}

.search {
  display: grid;
  gap: 5px;
  color: var(--muted);
  min-width: 260px;
}

.search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 9px 12px;
}

.screen {
  display: none;
}

.screen.is-visible {
  display: block;
  animation: panelIn 220ms ease both;
}

.screen-queue.is-visible {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 22px;
  align-items: start;
}

.patch-wall {
  display: grid;
  gap: 10px;
}

.patch-row {
  width: 100%;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto 74px;
  gap: 12px;
  align-items: center;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 8px solid var(--teal);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 1px 0 rgba(16, 42, 67, 0.05);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.patch-row:hover,
.patch-row.is-selected {
  transform: translateY(-2px);
  border-color: var(--ink);
  box-shadow: var(--shadow);
}

.drawer-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  min-width: 68px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
}

.drawer-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.drawer-main strong,
.sheet-head h2,
.person h3,
.rule h3 {
  overflow-wrap: anywhere;
}

.drawer-main small,
.sheet-head p,
.person p {
  color: var(--muted);
  line-height: 1.4;
}

.drawer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.badge-missing,
.badge-incident,
.badge-high {
  background: rgba(214, 69, 69, 0.15);
  color: #942c2c;
}

.badge-late,
.badge-review,
.badge-medium {
  background: rgba(214, 69, 69, 0.08);
  color: #7a3a20;
}

.badge-paid,
.badge-clear,
.badge-low {
  background: rgba(86, 163, 166, 0.18);
  color: #245e61;
}

.quality {
  justify-self: end;
  font-size: 24px;
  font-weight: 900;
}

.detail-sheet {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 18px;
  min-height: 520px;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.empty-detail,
.notice {
  min-height: 160px;
  display: grid;
  place-items: center;
  padding: 22px;
  border: 1px dashed var(--line);
  color: var(--muted);
  line-height: 1.6;
  text-align: center;
}

.sheet-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sheet-head h2 {
  margin: 0;
  font-size: 30px;
}

.sheet-head p {
  margin: 4px 0 0;
}

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

.route-step {
  min-height: 86px;
  padding: 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  display: grid;
  align-content: space-between;
}

.route-step span {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

.route-step strong {
  overflow-wrap: anywhere;
}

.route-step.ok {
  border-color: rgba(86, 163, 166, 0.48);
  background: rgba(86, 163, 166, 0.11);
}

.route-step.risk {
  border-color: rgba(214, 69, 69, 0.4);
  background: rgba(214, 69, 69, 0.08);
}

.recommendation {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.recommendation span,
.amount-line span {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

.recommendation p {
  margin: 6px 0 0;
  line-height: 1.7;
}

.amount-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.amount-line strong {
  font-size: 28px;
}

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

.section-title {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}

.section-title h2 {
  margin: 0;
  font-size: 36px;
}

.section-title p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.timeline,
.rule-grid,
.team-list {
  margin: 0;
  padding: 0;
}

.timeline {
  display: grid;
  gap: 10px;
  list-style: none;
}

.timeline li,
.rule,
.person {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-left: 6px solid var(--teal);
  border-radius: 8px;
  padding: 16px;
}

.timeline li {
  display: grid;
  grid-template-columns: 90px 120px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.timeline time,
.timeline span,
.rule span {
  color: var(--teal);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 12px;
}

.timeline p,
.rule p {
  margin: 0;
  line-height: 1.65;
}

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

.rule h3 {
  margin: 8px 0;
}

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

.team-list {
  display: grid;
  gap: 10px;
}

.person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.person h3,
.person p {
  margin: 0;
}

.person dl {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px 14px;
  margin: 0;
}

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

.person dd {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

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

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

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

  .nav-tabs {
    display: flex;
    flex-wrap: wrap;
  }

  .rail-note {
    width: 100%;
    margin-top: 0;
  }

  .topbar,
  .controls,
  .person {
    align-items: stretch;
    flex-direction: column;
  }

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

  .screen-queue.is-visible {
    grid-template-columns: 1fr;
  }

  .detail-sheet {
    position: static;
  }
}

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

  .rail {
    padding: 18px 14px;
  }

  .nav-tab {
    flex: 1 1 132px;
  }

  .search {
    min-width: 0;
  }

  .patch-row {
    grid-template-columns: 1fr;
  }

  .drawer-tags {
    justify-content: flex-start;
  }

  .quality {
    justify-self: start;
  }

  .route,
  .actions,
  .rule-grid,
  .metric-strip,
  .timeline li {
    grid-template-columns: 1fr;
  }

  .person dl {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
}

