/* The IM / RU Simulator's pages: tokens and controls are main.css's. */

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

.dim {
  color: var(--text-dim);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.small {
  font-size: 12px;
}

.strong {
  font-weight: 600;
}

.grow {
  flex: 1;
}

.label {
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.note {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

.link {
  padding: 0;
  background: none;
  border: 0;
  font: 600 14px/1 var(--sans);
  color: var(--accent);
  white-space: nowrap;
}

.link.muted {
  color: var(--text-muted);
}

.ghost {
  height: 32px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: 600 12px/1 var(--sans);
  color: var(--text-muted);
  white-space: nowrap;
}

.ghost.small {
  height: 26px;
  padding: 0 10px;
}

.primary {
  height: 46px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font: 600 15px/1 var(--sans);
}

.primary:hover {
  background: var(--accent-hover);
}

/* Pills and badges */

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 4px;
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill.grey {
  background: var(--sunken);
  color: var(--text-muted);
}

.pill.blue,
.badge.taf {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.green,
.badge.api {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.yellow,
.badge.none {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.red {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Families, as the legend names them */

.fam-session {
  --fam: #4a5d7a;
}

.fam-path {
  --fam: #1a5ec4;
}

.fam-departure {
  --fam: #6b46c1;
}

.fam-position {
  --fam: #157a63;
}

.fam-tsr {
  --fam: #c23b3b;
}

.fam-tcr {
  --fam: #b45f0a;
}

.fam-reroute {
  --fam: #a8327a;
}

.fam-conn {
  --fam: #3d4a57;
}

/* Header */

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav a {
  font: 600 14px/1 var(--sans);
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.nav a[aria-current="page"] {
  color: var(--text);
}

.nav form {
  display: contents;
}

/* Sign in */

.sign-in {
  width: 100%;
  max-width: 380px;
  margin: auto;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sign-in h1 {
  font-size: 24px;
}

.intro,
.stack,
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stack {
  gap: 18px;
}

.errors {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--danger);
}

.banner {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}

.banner.error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Pages */

.page {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px 28px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}

.page-head h1 {
  font-size: 18px;
}

.page-head .note {
  flex: 1 1 260px;
  min-width: 0;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 18px;
  align-items: start;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.list,
.table {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--sunken);
  font-size: 14px;
}

.list-row:first-child,
.table-row:nth-child(2) {
  border-top: 0;
}

.list-row .grow {
  flex: 1 1 160px;
  min-width: 0;
}

.file {
  flex: none;
  font: 400 12px/1.4 var(--mono);
  text-decoration: none;
}

.file:hover {
  text-decoration: underline;
}

.table-head,
.table-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
}

.table-head {
  background: var(--sunken);
  border-bottom: 1px solid var(--border);
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.table-row {
  padding: 12px 16px;
  border-top: 1px solid var(--sunken);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.table-row:hover {
  background: var(--hover);
  color: var(--text);
}

.col-licence {
  flex: 1 1 140px;
  min-width: 0;
}

.table-row .col-licence {
  font-size: 14px;
}

.col-signed {
  flex: none;
  width: 90px;
}

.col-state {
  flex: 1 1 160px;
  min-width: 0;
  display: flex;
}

.col-count {
  flex: none;
  width: 80px;
  text-align: right;
}

.idle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 28px 24px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* A simulation: it fills the window, its panels scroll. */

.sim {
  flex: 1;
  min-height: 0;
  height: calc(100vh - var(--header));
  display: flex;
  flex-direction: column;
}

.context {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  min-width: 0;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.back {
  font: 600 13px/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
}

.rule {
  flex: none;
  width: 1px;
  height: 20px;
  background: var(--border);
}

.licence {
  font: 600 15px/1 var(--mono);
  white-space: nowrap;
}

.ellipsis {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ellipsis.mono {
  font-size: 13px;
}

/* NOTE: fields that wrap to a second row stay under the first; the label,
   the segments and the button keep to the first row's line. */
.toolbar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 12px;
  min-height: 52px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.segments {
  flex: none;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.segment {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 14px;
  font: 600 12px/1 var(--sans);
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.segment + .segment {
  border-left: 1px solid var(--border);
}

.segment[aria-current="page"] {
  background: var(--accent);
  color: #ffffff;
}

.fields {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar > .label,
.gate {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.compact {
  flex: 1 1 140px;
  max-width: 220px;
  width: auto;
  min-width: 0;
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  font-size: 13px;
}

input.compact[type="datetime-local"] {
  flex: 0 0 180px;
}

input.compact[type="number"] {
  flex: 0 0 76px;
}

.toggle {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
}

.toggle input {
  margin: 0;
  padding: 0;
}

.gate {
  flex: none;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.issue {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font: 600 12px/1 var(--sans);
  white-space: nowrap;
}

.issue[disabled],
.toolbar:has(#gate[data-running="false"]) .issue {
  pointer-events: none;
  background: var(--sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.toolbar-status {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
}

.toolbar-status .error {
  color: var(--danger);
}

.toolbar-status .success {
  color: var(--ok);
}

.board {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1.1fr);
  gap: 4px;
  background: var(--divider);
}

.lanes-panel,
.log-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.lane-heads,
.phase {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}

.lane-heads {
  flex: none;
}

.lane-head,
.lane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
}

.who,
.log-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.who strong {
  font-size: 14px;
}

.who .small {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-head {
  flex: none;
  gap: 6px;
}

.sync-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.cols,
.row {
  display: grid;
  column-gap: 0;
  padding: 0 2px;
}

.cols-lane,
.row-lane {
  grid-template-columns: 58px 36px 24px 60px minmax(0, 1fr);
}

.cols-log,
.row-log {
  grid-template-columns: 58px minmax(0, 1.6fr) minmax(0, 1fr);
}

.cols {
  flex: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font: 600 9px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cols span {
  padding: 6px 4px 5px;
  overflow: hidden;
  white-space: nowrap;
}

.cols span + span {
  border-left: 1px solid #c9d1db;
}

/* NOTE: column-reverse keeps a panel scrolled to its newest row, and keeps
   it there as rows arrive, without script. */
.scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
  padding-bottom: 6px;
}

/* NOTE: the auto margin takes the free space while the rows are few, so
   they start at the top; once they overflow it is nothing. */
.scroll > div {
  margin-bottom: auto;
}

.phase-head {
  padding: 7px 8px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font: 700 10px/16px var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.row {
  width: 100%;
  min-width: 0;
  align-items: stretch;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--sunken);
  border-radius: 0;
  background: var(--surface);
  font-family: var(--sans);
}

.row:hover {
  background: var(--hover);
}

.row span {
  padding: 7px 4px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.row span + span {
  border-left: 1px solid var(--rule);
}

.row .time {
  padding-left: 2px;
  font: 400 11px/16px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.row .party {
  font: 700 11px/16px var(--mono);
}

.row .code {
  font: 700 12px/16px var(--mono);
  color: var(--fam);
  text-overflow: ellipsis;
}

.row .type {
  font-size: 12px;
  line-height: 16px;
  text-overflow: ellipsis;
}

.row .ref {
  font: 400 11px/16px var(--mono);
  color: var(--text-muted);
  text-overflow: ellipsis;
}

.none {
  padding: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.legend {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 6px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--fam);
}

/* The drawer */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(18, 32, 46, 0.35);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  width: min(560px, 94vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 40px rgba(18, 32, 46, 0.18);
}

.drawer-head {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-code {
  font: 600 14px/1.3 var(--mono);
  overflow-wrap: anywhere;
}

.pair {
  padding: 5px 7px;
  border-radius: 4px;
  background: var(--mate);
  font: 600 11px/1.5 var(--mono);
}

.drawer-title {
  font-size: 14px;
  line-height: 1.5;
}

.meta {
  font: 400 11px/1.5 var(--mono);
  color: var(--text-muted);
}

.drawer-body {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  padding: 16px 20px;
  background: var(--code-bg);
}

.drawer-body pre {
  margin: 0;
  font: 400 12px/1.65 var(--mono);
  color: var(--code-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.cut {
  font-size: 12px;
  color: var(--code-text);
}

.cut a {
  color: #a9cdf7;
}

/* Narrow windows: the panels stack, the page scrolls. */

@media (max-width: 900px) {
  .sim {
    height: auto;
  }

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

  .scroll {
    max-height: 60vh;
  }

  .page {
    padding: 16px;
  }
}
