:root {
  --ink: #0d1b2a;
  --cream: #f5ebe0;
  --steel: #778da9;
  --amber: #e0a458;
  --paper: #fffaf2;
  --line: rgba(13, 27, 42, 0.16);
  --line-dark: rgba(245, 235, 224, 0.18);
  --danger: #b14b3d;
  --good: #467d5b;
  --shadow: 0 22px 70px rgba(13, 27, 42, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(13, 27, 42, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(13, 27, 42, 0.08) 1px, transparent 1px),
    var(--cream);
  background-size: 28px 28px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.metrics-spine {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  color: var(--cream);
  background:
    linear-gradient(180deg, rgba(119, 141, 169, 0.18), transparent 28%),
    var(--ink);
  border-right: 1px solid var(--line-dark);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--cream);
  text-decoration: none;
  font-weight: 850;
  letter-spacing: 0;
}

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

.spine-tag,
.eyebrow {
  margin: 0;
  color: var(--steel);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metrics-grid {
  display: grid;
  gap: 10px;
}

.metric {
  min-height: 86px;
  padding: 13px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: rgba(245, 235, 224, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.metric span {
  display: block;
  color: rgba(245, 235, 224, 0.74);
  font-size: 12px;
  line-height: 1.25;
}

.metric strong {
  display: block;
  margin-top: 12px;
  color: var(--cream);
  font-size: 28px;
  line-height: 1;
}

.metric.is-good {
  border-color: rgba(70, 125, 91, 0.76);
}

.metric.is-warning {
  border-color: rgba(224, 164, 88, 0.86);
}

.metric.is-danger {
  border-color: rgba(177, 75, 61, 0.86);
}

.machine-status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(245, 235, 224, 0.72);
  font-size: 12px;
  line-height: 1.3;
}

.status-lamp {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 16px var(--amber);
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ink);
}

.title-block h1,
.section-head h2,
.quick-create h2,
.active-case h2 {
  margin: 5px 0 0;
  max-width: 860px;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1.02;
  letter-spacing: 0;
}

.section-head h2,
.quick-create h2,
.active-case h2 {
  font-size: 22px;
  line-height: 1.14;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tab,
.icon-button,
.action-button {
  min-height: 40px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.tab {
  padding: 0 12px;
  font-size: 13px;
  font-weight: 750;
}

.tab.is-active,
.tab:hover,
.icon-button:hover {
  background: var(--amber);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.alerts {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.alert {
  padding: 10px 12px;
  color: var(--cream);
  background: var(--ink);
  border-left: 5px solid var(--amber);
  border-radius: 4px;
  font-size: 13px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: rise 260ms ease both;
}

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

.board-zone,
.quick-create {
  min-width: 0;
}

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

.tool-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input,
label input,
label select,
label textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}

.search-input {
  width: min(280px, 32vw);
}

.search-input:focus,
label input:focus,
label select:focus,
label textarea:focus {
  box-shadow: 0 0 0 3px rgba(224, 164, 88, 0.35);
}

.icon-button {
  width: 42px;
  flex: 0 0 42px;
  font-size: 20px;
  font-weight: 850;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(188px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.lane {
  min-width: 188px;
  border-top: 5px solid var(--ink);
  background: rgba(255, 250, 242, 0.76);
}

.lane header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.lane header b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--cream);
  background: var(--ink);
  border-radius: 50%;
}

.lane-cards {
  display: grid;
  gap: 10px;
  padding-top: 10px;
}

.case-card {
  display: grid;
  gap: 9px;
  width: 100%;
  min-height: 178px;
  padding: 12px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  text-align: left;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 rgba(13, 27, 42, 0.35);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.case-card:hover,
.case-card.is-active {
  transform: translate(-2px, -2px);
  background: #fff4df;
  box-shadow: 7px 7px 0 var(--ink);
}

.case-topline,
.case-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.case-topline strong {
  font-size: 12px;
  color: var(--steel);
}

.status-pill {
  max-width: 120px;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--cream);
  background: var(--steel);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill.is-blocked {
  background: var(--danger);
}

.status-pill.is-ready,
.status-pill.is-done {
  background: var(--good);
}

.case-title {
  display: block;
  font-size: 18px;
  font-weight: 850;
  line-height: 1.08;
}

.case-section {
  display: block;
  color: rgba(13, 27, 42, 0.72);
  font-size: 13px;
  line-height: 1.25;
}

.case-grid span {
  min-width: 0;
}

.case-grid b,
.case-grid small {
  display: block;
}

.case-grid b {
  max-width: 105px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.case-grid small {
  color: var(--steel);
  font-size: 11px;
}

.progress-rail {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: rgba(119, 141, 169, 0.22);
}

.progress-rail i {
  display: block;
  height: 100%;
  background: var(--amber);
}

.empty-lane,
.empty-panel {
  padding: 14px;
  color: rgba(13, 27, 42, 0.68);
  border: 1px dashed var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.empty-panel.tight {
  padding: 10px;
}

.quick-create {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #f8efe5;
  box-shadow: var(--shadow);
}

.quick-create.compact {
  box-shadow: none;
}

.form-stack,
.detail-body {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: rgba(13, 27, 42, 0.7);
  font-size: 12px;
  font-weight: 800;
}

label textarea {
  resize: vertical;
}

.action-button {
  padding: 0 14px;
  color: var(--cream);
  background: var(--ink);
  font-weight: 850;
}

.action-button:hover {
  color: var(--ink);
  background: var(--amber);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.console {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.actions-list {
  display: grid;
  gap: 8px;
}

.action-row {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-left: 4px solid var(--amber);
  background: var(--paper);
}

.action-row span,
.action-row small {
  color: rgba(13, 27, 42, 0.67);
  font-size: 12px;
  line-height: 1.25;
}

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

.active-case {
  min-height: 500px;
  padding: 18px;
  color: var(--cream);
  background:
    linear-gradient(90deg, rgba(245, 235, 224, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(245, 235, 224, 0.07) 1px, transparent 1px),
    var(--ink);
  background-size: 24px 24px;
  border-radius: 6px;
}

.active-case .eyebrow {
  color: var(--amber);
}

.case-plate,
.detail-strip,
.progress-module {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

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

.case-plate div,
.detail-strip div,
.progress-module {
  padding: 14px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: rgba(245, 235, 224, 0.06);
}

.plate-label,
.detail-strip span {
  display: block;
  margin-bottom: 8px;
  color: rgba(245, 235, 224, 0.62);
  font-size: 12px;
  font-weight: 750;
}

.case-plate strong,
.detail-strip b {
  display: block;
  color: var(--cream);
  font-size: 16px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

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

.progress-module {
  grid-template-columns: minmax(0, 1fr) 116px;
  align-items: center;
}

.progress-module h3 {
  margin: 4px 0 0;
  font-size: 24px;
}

.dial {
  --value: 50;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--ink) 0 54%, transparent 55%),
    conic-gradient(var(--amber) calc(var(--value) * 1%), rgba(245, 235, 224, 0.18) 0);
}

.dial span {
  color: var(--cream);
  font-size: 26px;
  font-weight: 900;
}

.delta {
  grid-column: 1 / -1;
  margin: 0;
  color: rgba(245, 235, 224, 0.72);
}

.stage-note {
  padding: 16px;
  border-left: 5px solid var(--amber);
  background: rgba(224, 164, 88, 0.12);
  color: var(--cream);
}

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

.schedule-row,
.resource-row {
  display: grid;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.schedule-row {
  grid-template-columns: 150px minmax(0, 1fr) 140px;
}

.schedule-row time {
  color: var(--steel);
  font-weight: 850;
}

.schedule-row strong,
.schedule-row span,
.resource-row strong,
.resource-row small {
  display: block;
  line-height: 1.25;
}

.schedule-row span,
.resource-row small {
  color: rgba(13, 27, 42, 0.68);
  font-size: 13px;
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.report-panel {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 5px solid var(--ink);
}

.report-panel h3 {
  margin: 0;
  font-size: 22px;
}

.resource-row {
  grid-template-columns: 12px minmax(0, 1fr) 76px;
}

.resource-dot {
  width: 12px;
  height: 12px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--steel);
}

.resource-dot.is-available {
  background: var(--good);
}

.resource-dot.is-reserved {
  background: var(--amber);
}

.resource-dot.is-maintenance {
  background: var(--danger);
}

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

.report-cell {
  min-height: 128px;
  padding: 14px;
  color: var(--cream);
  background: var(--ink);
  border-radius: 6px;
}

.report-cell span,
.report-cell small {
  display: block;
  color: rgba(245, 235, 224, 0.7);
}

.report-cell strong {
  display: block;
  margin: 12px 0 5px;
  font-size: 34px;
  line-height: 1;
}

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

@media (max-width: 1120px) {
  .app-shell {
    display: block;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .metrics-spine {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .machine-status {
    margin-top: 0;
  }

  .control-layout,
  .detail-layout,
  .report-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .workspace {
    padding: 14px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar,
  .section-head {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .tabs,
  .tool-row {
    justify-content: stretch;
  }

  .tab {
    flex: 1 1 140px;
  }

  .search-input {
    width: 100%;
  }

  .board-grid {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
  }

  .lane {
    flex: 0 0 210px;
  }

  .metrics-grid,
  .case-plate,
  .detail-strip,
  .progress-module,
  .report-cells,
  .schedule-row {
    grid-template-columns: 1fr;
  }

  .schedule-row {
    gap: 5px;
  }
}
