:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --green: #18a058;
  --orange: #f79009;
  --red: #d92d20;
  --line: #d0d5dd;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.dashboard {
  height: 100vh;
  padding: 2vh 3vw;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 2vh;
  overflow: hidden;
}

.header,
.footer,
.panel,
.control-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(16, 24, 40, 0.08);
}

.header,
.footer {
  padding: 1.4vh 1.8vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.title {
  font-size: clamp(42px, 4.6vw, 86px);
  font-weight: 800;
}

.time {
  color: var(--muted);
  font-size: clamp(24px, 2.1vw, 42px);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 1vw;
}

.connection-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.45em 0.7em;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-size: clamp(14px, 1.2vw, 24px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.connection-dot {
  width: 0.75em;
  height: 0.75em;
  border-radius: 50%;
  background: var(--orange);
}

.connection-indicator.connected .connection-dot {
  background: var(--green);
}

.connection-indicator.disconnected .connection-dot {
  background: var(--red);
}

.andon-alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 4vw;
  animation: alertFlash 1s steps(2, start) infinite;
}

.andon-alert-overlay.alert-orange {
  background: rgba(247, 144, 9, 0.92);
  color: #111827;
}

.andon-alert-overlay.alert-red {
  background: rgba(217, 45, 32, 0.94);
  color: white;
}

.andon-alert-content {
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

.andon-alert-station {
  font-size: clamp(72px, 13vw, 240px);
  font-weight: 900;
  line-height: 0.95;
}

.andon-alert-status {
  margin-top: 3vh;
  font-size: clamp(48px, 8vw, 150px);
  font-weight: 900;
  letter-spacing: 0.06em;
}

@keyframes alertFlash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.22;
  }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2vw;
  min-height: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2vh;
  min-height: 0;
}

.metric {
  padding: 2.4vh 2vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metric-label {
  color: var(--muted);
  font-size: clamp(26px, 2.2vw, 48px);
  font-weight: 700;
}

.metric-value {
  margin-top: 1vh;
  font-size: clamp(96px, 11vw, 220px);
  font-weight: 900;
  line-height: 1;
}

.side-stack {
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 2vh;
  min-height: 0;
}

.andon-panel,
.hanger-panel {
  padding: 2vh 2vw;
}

.panel-title {
  color: var(--muted);
  font-size: clamp(24px, 1.9vw, 40px);
  margin-bottom: 1vh;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.andon-row,
.hanger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1vw;
  padding: 1.2vh 0;
  font-size: clamp(30px, 2.8vw, 56px);
  border-top: 1px solid var(--line);
}

.status-pill {
  color: white;
  border-radius: 999px;
  min-width: 8ch;
  padding: 0.7vh 1.2vw;
  font-size: 0.8em;
  text-align: center;
  font-weight: 800;
  text-transform: uppercase;
}

.status-green {
  background: var(--green);
}

.status-orange {
  background: var(--orange);
}

.status-red {
  background: var(--red);
}

.station {
  min-height: 100vh;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

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

.hub-card {
  display: block;
  min-height: 116px;
  padding: 20px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 25px rgba(16, 24, 40, 0.08);
  color: var(--ink);
  text-decoration: none;
}

.hub-title {
  display: block;
  font-size: clamp(26px, 5vw, 44px);
  font-weight: 900;
}

.hub-meta {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: clamp(18px, 4vw, 28px);
}

.focus-shell {
  min-height: 100vh;
  padding: clamp(12px, 4vw, 22px);
  max-width: 720px;
  margin: 0 auto;
}

.focus-card {
  margin-top: 12px;
  padding: clamp(16px, 4vw, 22px);
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 25px rgba(16, 24, 40, 0.08);
}

.focus-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.focus-title-row h1 {
  margin: 0;
  font-size: clamp(36px, 9vw, 76px);
}

.focus-value {
  margin: clamp(16px, 4vh, 26px) 0;
  text-align: center;
  font-size: clamp(96px, 30vw, 220px);
  font-weight: 900;
  line-height: 0.9;
}

.focus-actions {
  display: grid;
  gap: clamp(10px, 2.5vh, 16px);
}

.focus-actions.two {
  grid-template-columns: 1fr 1fr;
}

.focus-actions button {
  min-height: clamp(80px, 16vh, 150px);
  font-size: clamp(32px, 10vw, 72px);
  border-radius: 18px;
}

.back-link {
  display: inline-block;
  color: #175cd3;
  font-weight: 800;
  font-size: 20px;
  text-decoration: none;
  margin-bottom: 10px;
}

.station h1 {
  font-size: clamp(32px, 7vw, 64px);
  margin: 0 0 8px;
}

.station .subtle {
  color: var(--muted);
  margin: 0 0 24px;
}

.control-panel {
  padding: 20px;
  margin-bottom: 20px;
}

.control-panel h2 {
  margin: 0 0 14px;
  font-size: clamp(24px, 5vw, 42px);
}

.compact-panel h2 {
  font-size: clamp(20px, 4vw, 30px);
}

.compact-control-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) 1.2fr;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.compact-control-row.single {
  border-top: 0;
  padding-top: 0;
}

.compact-control-row strong {
  display: block;
  font-size: clamp(18px, 4vw, 26px);
}

.compact-status {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: clamp(14px, 3.4vw, 20px);
}

.compact-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.compact-button {
  min-height: 44px;
  border-radius: 12px;
  font-size: clamp(14px, 3.6vw, 20px);
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 72px;
  border: 0;
  border-radius: 16px;
  color: white;
  font-weight: 800;
  font-size: clamp(20px, 5vw, 34px);
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

.button-green {
  background: var(--green);
}

.button-orange {
  background: var(--orange);
}

.button-red {
  background: var(--red);
}

.button-secondary {
  background: #344054;
}

.button-light {
  background: #475467;
}

.counter-grid {
  display: grid;
  gap: 12px;
}

.counter-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.counter-label {
  font-size: clamp(22px, 5vw, 36px);
  font-weight: 700;
}

.counter-value {
  color: var(--muted);
  font-size: clamp(22px, 5vw, 36px);
  min-width: 4ch;
  text-align: right;
}

.small-button {
  min-height: 58px;
  min-width: 72px;
}

.target-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.target-form input {
  min-height: 64px;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 0 14px;
  font-size: clamp(20px, 5vw, 32px);
}

.target-form .full {
  grid-column: 1 / -1;
}

.link-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.link-row a {
  color: #175cd3;
  font-weight: 700;
}

@media (max-width: 850px) {
  .dashboard-grid,
  .metric-grid,
  .button-grid,
  .hub-grid,
  .target-form {
    grid-template-columns: 1fr;
  }

  .dashboard {
    height: auto;
    overflow: visible;
  }

  .focus-actions.two {
    grid-template-columns: 1fr 1fr;
  }

  .compact-control-row {
    grid-template-columns: 1fr;
  }
}
