:root {
  --ink: #102a43;
  --paper: #f5f7fa;
  --accent: #d64545;
  --aqua: #56a3a6;
  --line: rgba(16, 42, 67, 0.14);
  --muted: #64748b;
  --white: #ffffff;
  --shadow: 0 24px 70px rgba(16, 42, 67, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(16, 42, 67, 0.04) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(0deg, rgba(16, 42, 67, 0.035) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--paper);
  font-family: "Arial Narrow", "Roboto Condensed", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.loading {
  grid-column: 1 / -1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  color: var(--ink);
  font-size: 18px;
}

.loading img {
  filter: drop-shadow(0 16px 22px rgba(16, 42, 67, 0.18));
}

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

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

.brand img {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
}

.brand span {
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
}

.rail-nav {
  display: grid;
  gap: 8px;
  margin-top: 38px;
}

.nav-button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-left: 3px solid transparent;
  padding: 10px 12px;
  color: rgba(245, 247, 250, 0.72);
  background: transparent;
  text-align: left;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.nav-button.is-active,
.nav-button:hover {
  color: var(--paper);
  border-left-color: var(--aqua);
  background: rgba(245, 247, 250, 0.08);
}

.rail-note {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(245, 247, 250, 0.18);
  display: grid;
  gap: 8px;
  line-height: 1.35;
}

.rail-note span {
  color: rgba(245, 247, 250, 0.62);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.rail-note strong {
  font-size: 19px;
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(360px, 620px);
  align-items: end;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.96;
}

h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.metric {
  min-width: 0;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.api-error {
  margin-bottom: 18px;
  padding: 12px 14px;
  color: #7f1d1d;
  background: #fee2e2;
  border: 1px solid #fecaca;
}

.queue-grid {
  display: grid;
  grid-template-columns: 230px minmax(340px, 1fr) minmax(300px, 390px);
  gap: 18px;
  align-items: start;
}

.timeline-panel,
.drawer-wall,
.detail-sheet,
.sheet-view,
.workflow-view,
.team-view {
  min-width: 0;
}

.timeline-panel {
  border-left: 6px solid var(--ink);
  padding-left: 14px;
}

.panel-title {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
}

.panel-title span,
.detail-kicker {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.panel-title strong {
  line-height: 1.25;
}

.timeline-step {
  width: 100%;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  padding: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.timeline-step:hover {
  transform: translateX(4px);
  border-color: var(--aqua);
  background: var(--white);
}

.step-index {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  font-weight: 800;
}

.step-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.step-copy em {
  color: var(--muted);
  font-style: normal;
}

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
  margin-bottom: 12px;
}

.stage-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.stage-tab {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid var(--line);
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

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

.search-box {
  display: grid;
  gap: 4px;
}

.search-box span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.search-box input,
.rules-panel input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  color: var(--ink);
  background: var(--white);
}

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

.offer-row {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 8px 8px 0 rgba(86, 163, 166, 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.offer-row:hover,
.offer-row.is-selected {
  transform: translateY(-2px);
  border-color: var(--aqua);
  box-shadow: 10px 10px 0 rgba(214, 69, 69, 0.14);
}

.offer-marker {
  background: repeating-linear-gradient(180deg, var(--ink), var(--ink) 5px, #183b56 5px, #183b56 10px);
}

.offer-marker span {
  display: block;
  width: 11px;
  height: 42px;
  margin: 14px auto;
  background: var(--aqua);
}

.offer-main {
  min-width: 0;
  padding: 14px 14px 14px 0;
}

.offer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.offer-head strong {
  font-size: 20px;
  line-height: 1.15;
}

.priority {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: var(--paper);
  background: var(--aqua);
  font-size: 12px;
  font-weight: 800;
}

.priority-urgent {
  background: var(--accent);
}

.priority-high {
  background: var(--ink);
}

.offer-main p {
  margin: 8px 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

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

.offer-meta span {
  min-height: 28px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.detail-sheet {
  position: sticky;
  top: 28px;
  padding: 20px;
  color: var(--paper);
  background: var(--ink);
  box-shadow: var(--shadow);
}

.detail-sheet h2 {
  margin: 8px 0 12px;
}

.detail-desc {
  margin: 0 0 18px;
  color: rgba(245, 247, 250, 0.78);
  line-height: 1.65;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid rgba(245, 247, 250, 0.15);
}

.detail-list dt {
  color: rgba(245, 247, 250, 0.58);
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 18px;
}

.detail-actions button {
  min-height: 42px;
  border: 0;
  padding: 9px;
  color: var(--paper);
  background: var(--accent);
  font-weight: 800;
}

.detail-actions button:nth-child(2),
.detail-actions button:nth-child(3) {
  background: var(--aqua);
  color: #06212d;
}

.detail-actions .ghost {
  color: var(--paper);
  background: transparent;
  border: 1px solid rgba(245, 247, 250, 0.28);
}

.section-heading {
  margin-bottom: 18px;
}

.history-table,
.workflow-columns,
.team-grid {
  display: grid;
  gap: 12px;
}

.history-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 170px 170px;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.history-row p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.status-dot {
  width: 12px;
  height: 42px;
  background: var(--aqua);
}

.status-blocked {
  background: var(--accent);
}

.status-pending {
  background: #e0a100;
}

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

.workflow-step,
.team-tile {
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.workflow-step span {
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.workflow-step strong,
.team-tile strong {
  display: block;
  margin: 8px 0;
  font-size: 24px;
}

.workflow-step p,
.team-tile p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.rules-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 3px solid var(--ink);
}

.rules-panel label {
  display: grid;
  gap: 8px;
}

.rules-panel label span {
  color: var(--muted);
}

.toggle {
  position: relative;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle i {
  width: 62px;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--white);
}

.toggle i,
.toggle i::after {
  display: block;
  transition: transform 160ms ease, background 160ms ease;
}

.toggle i::after {
  width: 24px;
  height: 24px;
  margin: 4px;
  background: var(--muted);
  content: "";
}

.toggle input:checked + i {
  background: var(--aqua);
}

.toggle input:checked + i::after {
  transform: translateX(28px);
  background: var(--ink);
}

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

.team-tile span {
  display: block;
  color: var(--accent);
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
}

.empty {
  padding: 20px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed var(--line);
}

@media (max-width: 1180px) {
  .queue-grid {
    grid-template-columns: 190px minmax(320px, 1fr);
  }

  .detail-sheet {
    position: static;
    grid-column: 1 / -1;
  }

  .workflow-columns,
  .team-grid,
  .rules-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .rail {
    position: static;
    height: auto;
    padding: 14px;
  }

  .rail-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 14px;
  }

  .nav-button {
    min-height: 38px;
    padding: 8px;
    text-align: center;
    border-left: 0;
    border-bottom: 3px solid transparent;
    font-size: 11px;
  }

  .nav-button.is-active,
  .nav-button:hover {
    border-bottom-color: var(--aqua);
  }

  .rail-note {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

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

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

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(1),
  .metric:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }

  .queue-grid,
  .filters {
    grid-template-columns: 1fr;
  }

  .timeline-panel {
    border-left-width: 4px;
  }

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

  .history-row time,
  .history-row em {
    grid-column: 2;
  }
}

@media (max-width: 560px) {
  .rail-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics,
  .workflow-columns,
  .team-grid,
  .rules-panel,
  .detail-actions {
    grid-template-columns: 1fr;
  }

  .metric,
  .metric:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .offer-head {
    display: grid;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

