/* src/web/styles.css */
:root {
  color-scheme: dark;
  --bg: #071019;
  --bg-2: #0d1822;
  --panel: rgba(10, 18, 29, 0.88);
  --panel-strong: rgba(16, 27, 41, 0.96);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #edf3fb;
  --muted: #a8b6c7;
  --accent: #f2a05f;
  --accent-2: #43d3c0;
  --good: #8ae7b0;
  --danger: #ff8181;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}
* {
  box-sizing: border-box;
}
html,
body {
  min-height: 100%;
}
body {
  margin: 0;
  color: var(--text);
  font-family:
    "IBM Plex Sans",
    "Avenir Next",
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(
      circle at top left,
      rgba(242, 160, 95, 0.18),
      transparent 28%),
    radial-gradient(
      circle at 86% 14%,
      rgba(67, 211, 192, 0.16),
      transparent 24%),
    linear-gradient(
      180deg,
      var(--bg) 0%,
      #09131d 50%,
      #0b1320 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background:
    linear-gradient(rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.02)),
    radial-gradient(
      circle at 1px 1px,
      rgba(255, 255, 255, 0.05) 1px,
      transparent 0);
  background-size: auto, 24px 24px;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  font-family:
    "Fraunces",
    "Georgia",
    serif;
  letter-spacing: 0.01em;
}
p {
  margin: 0;
}
.workspace {
  max-width: 1880px;
  margin: 0 auto;
  padding: 28px;
  position: relative;
  z-index: 1;
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card,
.overview-card,
.clock-card,
.panel,
.box-card,
.admin-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.auth-card {
  width: min(480px, 100%);
  padding: 32px;
  background:
    linear-gradient(
      180deg,
      rgba(16, 27, 41, 0.97),
      rgba(10, 18, 29, 0.94));
}
.auth-card h1 {
  margin-top: 10px;
  font-size: clamp(2rem, 4.6vw, 3.4rem);
}
.auth-card p {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.auth-card__actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.eyebrow {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
}
.page-header,
.toolbar,
.hero-grid,
.box-card__header,
.box-section__head,
.work-row,
.admin-panel__summary,
.admin-card__actions,
.admin-form__row {
  display: flex;
  gap: 14px;
}
.page-header {
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}
.page-header__copy {
  max-width: 58rem;
}
.lede {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.toolbar {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.session-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.session-controls__user {
  color: var(--muted);
  font-size: 0.95rem;
}
.hero-grid {
  align-items: stretch;
  margin-bottom: 18px;
}
.overview-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.overview-card,
.clock-card {
  padding: 18px;
}
.overview-card__label,
.clock-card__label,
.overview-card__detail,
.clock-card__sub,
.panel__head p,
.box-card__summary,
.work-row__meta,
.admin-panel__summary p,
.admin-form__title {
  color: var(--muted);
}
.overview-card__label {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 10px;
}
.overview-card__value {
  display: block;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}
.overview-card__detail {
  display: block;
  margin-top: 8px;
  line-height: 1.4;
}
.clock-card {
  width: min(320px, 100%);
  background:
    linear-gradient(
      180deg,
      rgba(242, 160, 95, 0.18),
      rgba(67, 211, 192, 0.12));
}
.clock-card__value {
  margin-top: 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
}
.clock-card__sub {
  margin-top: 10px;
  font-size: 0.9rem;
}
.panel {
  padding: 20px;
  margin-bottom: 18px;
}
.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.panel__head p {
  margin-top: 6px;
  line-height: 1.5;
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.82rem;
  white-space: nowrap;
}
.pill--neutral {
  color: var(--text);
}
.pill--accent {
  color: #ffd1ad;
}
.pill--good {
  color: var(--good);
}
.pill--danger {
  color: var(--danger);
}
.btn,
.input {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
}
.btn {
  padding: 10px 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    opacity 120ms ease;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn--primary {
  background:
    linear-gradient(
      180deg,
      rgba(242, 160, 95, 0.96),
      rgba(207, 109, 48, 0.96));
  color: #1c1109;
}
.btn--secondary {
  background:
    linear-gradient(
      180deg,
      rgba(67, 211, 192, 0.92),
      rgba(26, 133, 122, 0.92));
  color: #071615;
}
.btn--ghost {
  background: rgba(255, 255, 255, 0.03);
}
.btn--danger {
  background:
    linear-gradient(
      180deg,
      rgba(255, 129, 129, 0.92),
      rgba(165, 58, 58, 0.92));
}
.btn--compact {
  padding: 7px 11px;
  font-size: 0.84rem;
}
.input {
  min-width: 0;
  padding: 10px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.input:focus {
  outline: 2px solid rgba(67, 211, 192, 0.28);
  outline-offset: 1px;
}
.alert {
  padding: 14px 16px;
  margin-bottom: 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 129, 129, 0.35);
  background: rgba(255, 129, 129, 0.1);
}
.btn.is-active,
.work-row.is-selected,
.box-rail__item.is-active {
  border-color: rgba(67, 211, 192, 0.5);
  background: rgba(67, 211, 192, 0.12);
}
.box-workspace-panel {
  padding: 22px;
}
.box-workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.box-rail,
.box-stage-shell,
.box-context-card,
.box-context-section {
  background: rgba(8, 15, 24, 0.82);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.box-rail {
  padding: 16px;
  position: sticky;
  top: 20px;
}
.box-rail__head p,
.box-stage-shell__lede,
.box-context-card__lede,
.box-context-card__detail {
  color: var(--muted);
}
.box-rail__head p,
.box-stage-shell__lede {
  margin-top: 8px;
  line-height: 1.45;
}
.box-rail__list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.box-rail__item {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
}
.box-rail__title,
.box-rail__meta {
  display: block;
}
.box-rail__title {
  font-weight: 600;
}
.box-rail__meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}
.box-stage-shell {
  padding: 18px;
  position: relative;
}
.box-stage-shell__head,
.box-toolbar,
.box-toolbar__group,
.box-stage-shell__meta,
.box-context-card__actions {
  display: flex;
  gap: 10px;
}
.box-stage-shell__head {
  align-items: flex-start;
  justify-content: space-between;
}
.box-stage-shell__meta,
.box-toolbar,
.box-toolbar__group,
.box-context-card__actions {
  flex-wrap: wrap;
}
.box-toolbar {
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.box-toolbar__status {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.88rem;
}
.box-toolbar__group--tools {
  flex: 1 1 560px;
}
.box-stage-shell__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(340px, 0.8fr);
  gap: 20px;
  margin-top: 18px;
}
.box-stage-wrap {
  min-width: 0;
}
.box-stage-shell.is-expanded {
  position: fixed;
  inset: 18px;
  z-index: 40;
  padding: 22px;
  background:
    linear-gradient(
      180deg,
      rgba(10, 18, 29, 0.98),
      rgba(10, 18, 29, 0.95));
  overflow: auto;
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.58);
}
.box-stage-shell.is-expanded::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 14, 0.58);
  z-index: -1;
}
.box-stage-shell.is-expanded .box-stage-shell__grid {
  grid-template-columns: minmax(0, 2.2fr) minmax(340px, 0.7fr);
  align-items: start;
}
.box-stage-shell.is-expanded .box-context {
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 6px;
}
.box-stage {
  width: 100%;
  display: block;
  border-radius: 22px;
  border: 1px solid var(--border);
  background:
    radial-gradient(
      circle at 12% 16%,
      rgba(67, 211, 192, 0.08),
      transparent 28%),
    linear-gradient(
      180deg,
      rgba(7, 16, 25, 0.98),
      rgba(10, 18, 29, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.box-stage pattern path {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
}
.box-stage__surface {
  fill: rgba(10, 18, 29, 0.92);
}
.box-stage__grid {
  fill: url(#box-grid-pattern);
  opacity: 0.52;
}
.box-stage-wrap__hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}
.box-track path {
  fill: none;
  stroke: rgba(223, 236, 248, 0.68);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.box-track text {
  fill: rgba(255, 255, 255, 0.56);
  font-size: 12px;
  font-weight: 600;
}
.box-track,
.box-structure,
.box-signal {
  cursor: grab;
}
.box-block {
  cursor: pointer;
}
.box-track:active,
.box-structure:active,
.box-signal:active {
  cursor: grabbing;
}
.box-track--main path {
  stroke: #f2f7ff;
}
.box-track--loop path {
  stroke: #bcd5ff;
}
.box-track--siding path {
  stroke: #7fd0ff;
}
.box-track--spur path {
  stroke: #f2a05f;
}
.box-track.is-selected path {
  stroke: var(--accent-2);
  stroke-width: 5;
}
.box-block path {
  fill: none;
  stroke: rgba(242, 160, 95, 0.88);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.26;
}
.box-block text {
  fill: rgba(255, 224, 198, 0.92);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.box-block.is-occupied path {
  stroke: rgba(255, 129, 129, 0.96);
  opacity: 0.42;
}
.box-block.is-selected path {
  stroke: rgba(67, 211, 192, 0.94);
  opacity: 0.58;
}
.box-block.is-selected text {
  fill: rgba(67, 211, 192, 0.98);
}
.box-switch-marker {
  fill: var(--accent-2);
  stroke: rgba(7, 16, 25, 0.9);
  stroke-width: 2;
}
.box-structure rect {
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 2;
}
.box-structure text {
  fill: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.box-structure__sub {
  fill: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  font-weight: 500;
}
.box-structure--platform rect {
  fill: rgba(243, 210, 151, 0.16);
}
.box-structure--junction rect {
  fill: rgba(151, 173, 243, 0.16);
}
.box-structure--yard rect {
  fill: rgba(151, 243, 184, 0.13);
}
.box-structure--siding rect {
  fill: rgba(114, 195, 255, 0.16);
}
.box-structure--depot rect {
  fill: rgba(242, 160, 95, 0.15);
}
.box-structure--maintenance rect {
  fill: rgba(255, 129, 129, 0.14);
}
.box-structure.is-selected rect {
  stroke: var(--accent-2);
  filter: drop-shadow(0 0 14px rgba(67, 211, 192, 0.18));
}
.box-unit-badge {
  cursor: pointer;
}
.box-unit-badge rect {
  fill: rgba(8, 15, 24, 0.92);
  stroke: rgba(67, 211, 192, 0.36);
}
.box-unit-badge text {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
}
.box-signal {
  cursor: pointer;
}
.box-signal circle:first-child {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 2;
}
.box-signal circle:last-child {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1.5;
}
.box-signal--stop circle:first-child {
  fill: var(--danger);
}
.box-signal--clear circle:first-child {
  fill: var(--good);
}
.box-signal.is-selected circle:last-child {
  stroke: var(--accent-2);
  stroke-width: 2;
}
.box-port-marker circle {
  fill: var(--accent-2);
  stroke: rgba(7, 16, 25, 0.9);
  stroke-width: 2;
}
.box-port-marker text {
  fill: rgba(255, 255, 255, 0.68);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.box-track-anchor {
  fill: rgba(242, 160, 95, 0.2);
  stroke: rgba(242, 160, 95, 0.9);
  stroke-width: 2;
  animation: box-anchor-pulse 1.2s ease-in-out infinite;
}
.box-context {
  display: grid;
  gap: 14px;
  align-content: start;
}
.box-context-card,
.box-context-section {
  padding: 16px;
}
.box-context-card__lede {
  margin-top: 8px;
  line-height: 1.45;
}
.box-context-card__detail {
  margin-top: 10px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.box-context-section .box-section__head {
  margin-bottom: 12px;
}
.box-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.box-card {
  padding: 18px;
  background:
    linear-gradient(
      180deg,
      rgba(12, 20, 31, 0.96),
      rgba(10, 18, 29, 0.9));
}
.box-card__header {
  justify-content: space-between;
  align-items: flex-start;
}
.box-card__summary {
  margin-top: 8px;
  line-height: 1.45;
}
.box-card__meta,
.box-card__chips,
.box-card__ports,
.work-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.box-card__chips,
.box-card__ports {
  margin-top: 14px;
}
.box-card__sections {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}
.box-section {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.box-section__head {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.box-section__head h4 {
  font-size: 1rem;
}
.work-row {
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}
.work-row + .work-row {
  margin-top: 10px;
}
.work-row__content {
  min-width: 0;
}
.work-row__meta {
  margin-top: 5px;
  line-height: 1.4;
}
.empty-state {
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
}
.admin-panel > summary {
  list-style: none;
  cursor: pointer;
}
.admin-panel > summary::-webkit-details-marker {
  display: none;
}
.admin-panel__summary {
  align-items: flex-start;
  justify-content: space-between;
}
.admin-panel__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.admin-card {
  padding: 18px;
}
.admin-card__actions,
.admin-form__row {
  flex-wrap: wrap;
}
.admin-form + .admin-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.admin-form__title {
  margin-bottom: 10px;
  font-size: 0.85rem;
}
@media (max-width: 1100px) {
  .hero-grid,
  .page-header,
  .box-card__header,
  .work-row,
  .admin-panel__summary,
  .box-stage-shell__head {
    flex-direction: column;
  }
  .overview-grid,
  .box-grid,
  .admin-panel__grid,
  .box-workspace,
  .box-stage-shell__grid {
    grid-template-columns: 1fr;
  }
  .clock-card {
    width: 100%;
  }
  .box-toolbar__status {
    margin-left: 0;
  }
  .box-rail {
    position: static;
  }
  .box-stage-shell.is-expanded {
    inset: 10px;
  }
  .box-stage-shell.is-expanded .box-stage-shell__grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  .workspace {
    padding: 18px;
  }
  .toolbar,
  .session-controls,
  .box-toolbar {
    width: 100%;
    justify-content: flex-start;
  }
  .work-row__actions,
  .admin-card__actions,
  .admin-form__row,
  .box-toolbar__group,
  .box-context-card__actions {
    width: 100%;
  }
  .btn,
  .input {
    width: 100%;
  }
}
@keyframes box-anchor-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.25);
    opacity: 1;
  }
}
