:root {
  --ink: #14213d;
  --paper: #ffffff;
  --action: #fca311;
  --good: #2a9d8f;
  --line: rgba(20, 33, 61, 0.14);
  --muted: rgba(20, 33, 61, 0.62);
  --soft: #f4f1eb;
  --danger: #c8493a;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(90deg, var(--ink) 0 30%, var(--paper) 30% 100%);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.mobile-field {
  min-height: 100vh;
  padding: 28px;
  color: var(--paper);
  background:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px),
    var(--ink);
  background-size: 28px 28px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
}

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

.brand-mark img {
  flex: 0 0 auto;
}

.brand-mark strong,
.field-ticket h1,
.topbar h2,
.detail-main h3,
.report-topline h3 {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

.brand-mark strong {
  display: block;
  font-size: 21px;
  line-height: 1.05;
}

.brand-mark small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.field-ticket {
  align-self: center;
  display: grid;
  align-content: center;
  gap: 24px;
  min-height: 440px;
  padding: 28px 0;
}

.field-ticket h1 {
  margin: 10px 0 0;
  font-size: clamp(34px, 3.2vw, 44px);
  line-height: 1;
  max-width: 10ch;
  overflow-wrap: anywhere;
}

.field-ticket p {
  max-width: 330px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 17px;
  line-height: 1.45;
}

.mono,
.eyebrow {
  margin: 0;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
}

.eyebrow,
.mono {
  color: var(--muted);
}

.mobile-field .mono {
  color: var(--action);
}

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

.tab,
.ghost-button,
.primary-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 13px;
  background: transparent;
  color: inherit;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.mobile-field .tab {
  color: var(--paper);
  border-color: rgba(255, 255, 255, 0.2);
}

.tab:hover,
.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.tab.is-active,
.primary-button {
  background: var(--action);
  color: #171717;
  border-color: var(--action);
  font-weight: 800;
}

.dispatch-console {
  min-width: 0;
  padding: 26px clamp(18px, 3vw, 40px) 38px;
  background: var(--paper);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  margin: 5px 0 0;
  font-size: clamp(30px, 4vw, 56px);
  line-height: 0.95;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--good);
  font-size: 12px;
  font-weight: 800;
}

.source-pill.is-demo {
  color: var(--danger);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 22px 0;
  border: 1px solid var(--line);
  background: var(--line);
}

.metric {
  min-width: 0;
  padding: 18px;
  background: var(--paper);
}

.metric strong {
  display: block;
  margin: 8px 0 2px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
}

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

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

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

.view {
  display: none;
  animation: rise 260ms ease both;
}

.view.is-visible {
  display: block;
}

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

.board-head,
.section-head,
.report-topline {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px;
}

.board-head h3,
.section-head h3,
.report-topline h3,
.timeline-panel h3 {
  margin: 0;
  font-size: 20px;
}

.board-head p {
  max-width: 560px;
  margin: 5px 0 0;
  color: var(--muted);
}

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

.lane {
  position: relative;
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  overflow: hidden;
}

.lane strong {
  display: block;
  margin-top: 6px;
}

.lane b {
  position: absolute;
  right: 14px;
  top: 12px;
  font-size: 34px;
  line-height: 1;
  color: rgba(20, 33, 61, 0.16);
}

.lane-meter {
  height: 6px;
  background: rgba(20, 33, 61, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.lane-meter i {
  display: block;
  height: 100%;
  background: var(--good);
  border-radius: inherit;
  transition: width 260ms ease;
}

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

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

.queue-panel,
.inspector,
.detail-main,
.timeline-panel {
  min-width: 0;
}

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

.item-row {
  width: 100%;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) minmax(112px, 0.32fr) 58px;
  align-items: center;
  gap: 8px;
}

.item-row:hover,
.item-row.is-selected {
  border-color: var(--ink);
  background: #fbfaf7;
}

.item-row.is-risk {
  border-left: 5px solid var(--action);
}

.item-row.is-paused {
  border-left: 5px solid var(--danger);
}

.item-row.is-clear {
  border-left: 5px solid var(--good);
}

.row-stage {
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.row-main,
.row-plan,
.row-score {
  min-width: 0;
}

.row-main strong,
.row-main small,
.row-plan small,
.row-score small {
  display: block;
}

.row-main strong {
  overflow-wrap: anywhere;
}

.row-main small,
.row-plan small,
.row-score small {
  margin-top: 4px;
  color: var(--muted);
}

.row-score {
  text-align: right;
  font-size: 20px;
  font-weight: 900;
  color: var(--good);
}

.inspector {
  position: sticky;
  top: 18px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 18px;
  background: var(--ink);
  color: var(--paper);
}

.inspector .mono,
.inspector dt,
.inspector p {
  color: rgba(255, 255, 255, 0.68);
}

.inspector h3 {
  margin: 10px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1.05;
}

.inspector dl {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.inspector dl div {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 10px;
}

.inspector dt {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

.inspector dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.inspector-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inspector .ghost-button {
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--paper);
}

.detail-main {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.detail-main h3 {
  margin: 10px 0 8px;
  font-size: 32px;
  line-height: 1.05;
}

.detail-main > p {
  margin: 0 0 18px;
  color: var(--muted);
}

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

.spec-cell,
.wide-block,
.timeline-item,
.calendar-row,
.report-section article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

.spec-cell {
  min-height: 82px;
  padding: 14px;
}

.spec-cell span,
.report-section span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.spec-cell strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.wide-block {
  grid-column: 1 / -1;
  padding: 14px;
}

.wide-block h4,
.report-section h4 {
  margin: 0 0 10px;
}

.wide-block p {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.wide-block p:first-of-type {
  border-top: 0;
}

.wide-block span {
  color: var(--muted);
  text-align: right;
}

.timeline {
  display: grid;
  gap: 8px;
}

.timeline-item {
  padding: 13px;
}

.timeline-item strong {
  display: block;
  margin: 6px 0;
}

.timeline-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

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

.calendar-row {
  min-height: 84px;
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 96px;
  gap: 16px;
  align-items: center;
  padding: 14px;
}

.calendar-row time {
  font-weight: 900;
  color: var(--good);
}

.calendar-row p {
  margin: 4px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.calendar-row > span {
  text-align: right;
  font-weight: 800;
}

.report-topline {
  align-items: center;
}

.report-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 14px;
}

.report-section {
  display: grid;
  gap: 8px;
}

.report-section article {
  min-height: 98px;
  padding: 14px;
}

.report-section strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  color: var(--good);
}

.report-section p {
  margin: 4px 0 0;
  color: var(--muted);
}

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

dialog {
  width: min(480px, calc(100vw - 28px));
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(20, 33, 61, 0.52);
}

.dialog-form {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.dialog-form h3 {
  margin: 6px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
}

.dialog-form label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1100px) {
  body {
    background: var(--paper);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-field {
    min-height: auto;
    grid-template-rows: auto auto auto;
  }

  .field-ticket {
    min-height: 0;
  }

  .field-ticket h1 {
    max-width: none;
  }
}

@media (max-width: 840px) {
  .dispatch-console,
  .mobile-field {
    padding: 18px;
  }

  .topbar,
  .board-head,
  .section-head,
  .report-topline {
    display: grid;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .metric-strip,
  .lane-board,
  .workgrid,
  .detail-layout,
  .report-grid,
  .spec-grid {
    grid-template-columns: 1fr;
  }

  .item-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .row-score {
    text-align: left;
  }

  .inspector {
    position: static;
  }

  .calendar-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .calendar-row > span,
  .wide-block span {
    text-align: left;
  }

  .wide-block p {
    display: grid;
  }
}

@media (max-width: 480px) {
  .rail-tabs {
    grid-template-columns: 1fr;
  }

  .topbar h2,
  .detail-main h3,
  .report-topline h3 {
    font-size: 28px;
  }

  .field-ticket h1 {
    font-size: 36px;
    max-width: 100%;
  }

  .metric {
    padding: 14px;
  }

  .dialog-actions,
  .inspector-actions {
    display: grid;
  }
}
