:root {
  --ink: #1a1a2e;
  --paper: #f2e9e4;
  --paper-deep: #e4d5cd;
  --mauve: #9a8c98;
  --rose: #c9ada7;
  --leaf: #526f4f;
  --wheat: #d6a44b;
  --line: rgba(26, 26, 46, 0.18);
  --shadow: 0 24px 70px rgba(26, 26, 46, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(26, 26, 46, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(26, 26, 46, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.left-rail,
.inspection-drawer {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.left-rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  color: var(--paper);
  background: var(--ink);
  border-right: 1px solid rgba(242, 233, 228, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-weight: 800;
  font-size: 20px;
}

.brand img {
  flex: 0 0 auto;
}

.rail-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  padding: 12px 12px;
  color: rgba(242, 233, 228, 0.74);
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
}

.nav-item:hover,
.nav-item.is-active {
  color: var(--paper);
  background: rgba(242, 233, 228, 0.08);
  border-left-color: var(--wheat);
}

.rail-note {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(242, 233, 228, 0.2);
}

.rail-note span,
.eyebrow {
  display: block;
  margin: 0 0 7px;
  color: var(--mauve);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rail-note strong {
  display: block;
  color: rgba(242, 233, 228, 0.82);
  font-size: 13px;
  line-height: 1.45;
}

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

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(31px, 4vw, 58px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.1;
}

.search {
  display: grid;
  gap: 7px;
  width: min(330px, 42vw);
}

.search label {
  color: var(--mauve);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(214, 164, 75, 0.25);
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: rise 280ms ease both;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 22px;
  border: 2px solid var(--ink);
  background: rgba(242, 233, 228, 0.72);
  box-shadow: var(--shadow);
}

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

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

.metric span {
  display: block;
  margin-bottom: 18px;
  color: var(--mauve);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 3.1vw, 44px);
  line-height: 0.96;
  letter-spacing: 0;
}

.metric-hot strong {
  color: #a33f35;
}

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

.metric-wheat strong {
  color: #9b6a14;
}

.metric-rose strong {
  color: #8e5c58;
}

.work-grid,
.history-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.75fr);
  gap: 20px;
}

.canvas-panel {
  min-width: 0;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.06)),
    var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 10px 10px 0 rgba(26, 26, 46, 0.11);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-heading select {
  width: 190px;
}

.stage-lane {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stage-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 54px;
  padding: 10px;
  color: var(--ink);
  background: var(--paper-deep);
  border: 1px solid var(--line);
}

.stage-chip:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}

.stage-chip span {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.stage-chip strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
}

.item-list,
.action-list,
.field-notes,
.shipment-list,
.team-grid {
  display: grid;
}

.item-row {
  display: grid;
  grid-template-columns: 66px minmax(180px, 1.6fr) minmax(86px, 0.7fr) minmax(74px, 0.55fr) minmax(98px, 0.75fr) 88px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 74px;
  padding: 12px 0;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.item-row:hover {
  background: rgba(214, 164, 75, 0.12);
}

.row-risk {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--paper);
  background: var(--ink);
  font-weight: 900;
}

.row-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.row-main strong,
.row-main em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-main em,
.shipment-row p,
.action-row p,
.field-note span {
  color: #5f5963;
  font-size: 13px;
  font-style: normal;
}

.status-pill {
  padding: 7px 9px;
  color: var(--paper);
  text-align: center;
  background: var(--leaf);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.field-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.field-note div {
  display: grid;
  gap: 4px;
}

.field-note b {
  align-self: start;
  padding: 8px 0;
  color: var(--paper);
  text-align: center;
  background: #8e5c58;
}

.field-note p {
  grid-column: 1 / -1;
  margin-bottom: 0;
  color: #393245;
  line-height: 1.4;
}

.inspection-drawer {
  padding: 24px 18px;
  color: var(--paper);
  background:
    linear-gradient(rgba(242, 233, 228, 0.035) 1px, transparent 1px),
    var(--ink);
  background-size: 100% 26px;
  border-left: 1px solid rgba(242, 233, 228, 0.16);
}

.drawer-section {
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid rgba(242, 233, 228, 0.18);
}

.drawer-section h2 {
  color: var(--paper);
}

.risk-dial {
  display: grid;
  place-items: center;
  width: 164px;
  height: 164px;
  margin: 22px auto;
  color: var(--paper);
  border: 2px solid var(--wheat);
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 48px;
}

.drawer-section p {
  color: rgba(242, 233, 228, 0.78);
  line-height: 1.5;
}

.shipment-row {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(242, 233, 228, 0.14);
}

.shipment-row span,
.shipment-row em {
  color: var(--rose);
  font-size: 12px;
  font-style: normal;
  text-transform: uppercase;
}

.history-layout {
  align-items: start;
}

.action-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 145px;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.action-row span {
  color: var(--leaf);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.action-row p {
  margin: 5px 0 0;
  line-height: 1.4;
}

.action-row time {
  color: #5f5963;
  font-size: 12px;
  text-align: right;
}

.action-form {
  display: grid;
  gap: 14px;
}

.action-form label {
  display: grid;
  gap: 7px;
  color: #4d4653;
  font-size: 13px;
  font-weight: 800;
}

.primary-command,
.text-command,
.icon-command {
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
}

.primary-command {
  height: 44px;
  padding: 0 16px;
  font-weight: 900;
}

.text-command {
  min-height: 40px;
  padding: 0 13px;
  font-weight: 900;
}

.icon-command {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  font-size: 24px;
  line-height: 1;
}

.workflow-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.workflow-step {
  min-height: 360px;
  padding: 22px;
  border-right: 1px solid var(--line);
}

.workflow-step:last-child {
  border-right: 0;
}

.workflow-step span {
  display: block;
  margin-bottom: 72px;
  color: var(--mauve);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 54px;
}

.workflow-step p {
  color: #4d4653;
  line-height: 1.5;
}

.team-grid {
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.team-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 190px;
  gap: 16px;
  align-items: center;
  min-height: 92px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.team-row:last-child {
  border-bottom: 0;
}

.team-row span {
  color: var(--leaf);
  font-weight: 900;
}

.team-row em {
  color: #5f5963;
  font-style: normal;
  text-align: right;
}

.empty-state {
  padding: 20px;
  color: #5f5963;
  background: rgba(255, 255, 255, 0.45);
  border: 1px dashed var(--line);
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .inspection-drawer {
    grid-column: 1 / -1;
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 0.7fr) minmax(0, 1fr);
    gap: 20px;
  }

  .drawer-section {
    margin-bottom: 0;
    border-bottom: 0;
  }

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

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

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .left-rail,
  .inspection-drawer {
    position: static;
    height: auto;
  }

  .left-rail {
    padding: 16px;
  }

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

  .nav-item {
    padding: 10px 6px;
    text-align: center;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }

  .nav-item.is-active {
    border-bottom-color: var(--wheat);
  }

  .workspace {
    padding: 18px 14px;
  }

  .topbar,
  .work-grid,
  .history-layout,
  .inspection-drawer {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .search {
    width: 100%;
  }

  .metric-strip,
  .stage-lane,
  .workflow-board {
    grid-template-columns: 1fr;
  }

  .metric,
  .workflow-step {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .item-row,
  .action-row,
  .team-row {
    grid-template-columns: 1fr;
  }

  .row-risk {
    width: 100%;
    height: 36px;
  }

  .row-main strong,
  .row-main em {
    white-space: normal;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-heading select {
    width: 100%;
  }

  .workflow-step {
    min-height: 220px;
  }

  .workflow-step span {
    margin-bottom: 28px;
  }

  .team-row em,
  .action-row time {
    text-align: left;
  }
}

