:root {
  color-scheme: dark;
  --bg: #080b0e;
  --surface: #10151a;
  --line: #26313a;
  --text: #f5f7f8;
  --muted: #8c99a3;
  --green: #40d98b;
  --amber: #f2b94b;
  --red: #ff6b63;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 280px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

.display-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 84px minmax(0, 1fr) 54px;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
}

.masthead,
.screen-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
  padding: 0 40px;
  background: rgba(8, 11, 14, 0.94);
}

.screen-footer span,
.screen-footer a {
  min-width: 0;
}

#footerStoreName {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#syncText {
  flex: 0 0 auto;
  white-space: nowrap;
}

.screen-footer .police-record {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.screen-footer .police-record:hover {
  color: var(--text);
  text-decoration: underline;
}

.masthead {
  border-bottom: 1px solid var(--line);
}

.brand-block,
.system-block {
  min-width: 0;
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(64, 217, 139, 0.72);
  color: var(--green);
  font-size: 21px;
  font-weight: 800;
}

.brand-block div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.brand-block strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-block div > span,
.screen-footer {
  color: var(--muted);
  font-size: 13px;
}

.system-block {
  flex: 0 0 auto;
  gap: 24px;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #b9c3ca;
  font-size: 14px;
  white-space: nowrap;
}

.connection-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(64, 217, 139, 0.72);
}

.connection-state.offline i {
  background: var(--red);
  box-shadow: 0 0 12px rgba(255, 107, 99, 0.62);
}

.system-block time {
  min-width: 92px;
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.bay-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 34px 48px 30px;
}

.bay-heading {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
}

.eyebrow,
.metric-label {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: 0;
}

.bay-heading h1 {
  margin: 7px 0 0;
  font-size: 42px;
  line-height: 1.08;
  font-weight: 760;
  letter-spacing: 0;
}

.status-badge {
  min-width: 110px;
  padding: 10px 16px;
  border: 1px solid rgba(64, 217, 139, 0.45);
  color: var(--green);
  background: rgba(64, 217, 139, 0.08);
  font-size: 15px;
  line-height: 1;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

[data-status="running"] .status-badge {
  border-color: rgba(242, 185, 75, 0.5);
  color: var(--amber);
  background: rgba(242, 185, 75, 0.08);
}

[data-status="maintenance"] .status-badge {
  border-color: rgba(255, 107, 99, 0.44);
  color: var(--red);
  background: rgba(255, 107, 99, 0.08);
}

[data-status="power_mismatch"] .status-badge {
  border-color: rgba(255, 107, 99, 0.44);
  color: var(--red);
  background: rgba(255, 107, 99, 0.08);
}

.state-view {
  min-width: 0;
  min-height: 0;
}

.idle-view {
  align-self: center;
  justify-self: center;
  display: grid;
  justify-items: center;
  text-align: center;
}

.idle-indicator {
  width: 94px;
  height: 94px;
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  border: 1px solid rgba(64, 217, 139, 0.44);
  border-radius: 50%;
  box-shadow: inset 0 0 0 12px rgba(64, 217, 139, 0.04);
}

.idle-indicator span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 26px rgba(64, 217, 139, 0.8);
}

.idle-view h2 {
  margin: 0;
  color: var(--text);
  font-size: 68px;
  line-height: 1.1;
  font-weight: 760;
  letter-spacing: 0;
}

.idle-view p {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 20px;
}

[data-status="maintenance"] .idle-indicator {
  border-color: rgba(255, 107, 99, 0.38);
  box-shadow: inset 0 0 0 12px rgba(255, 107, 99, 0.035);
}

[data-status="maintenance"] .idle-indicator span {
  background: var(--red);
  box-shadow: 0 0 26px rgba(255, 107, 99, 0.62);
}

[data-status="power_mismatch"] .idle-indicator {
  border-color: rgba(255, 107, 99, 0.38);
  box-shadow: inset 0 0 0 12px rgba(255, 107, 99, 0.035);
}

[data-status="power_mismatch"] .idle-indicator span {
  background: var(--red);
  box-shadow: 0 0 26px rgba(255, 107, 99, 0.62);
}

.running-view {
  align-self: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  align-items: center;
  gap: 0;
  padding: 28px 0 10px;
}

.time-section,
.balance-section {
  min-width: 0;
  display: grid;
  align-content: center;
}

.time-section {
  padding-right: 6vw;
}

.balance-section {
  min-height: 62%;
  padding-left: 6vw;
  border-left: 1px solid var(--line);
}

.elapsed-time,
.secondary-value {
  display: block;
  margin-top: 20px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  text-overflow: clip;
  white-space: nowrap;
}

.elapsed-time {
  color: var(--text);
  font-family: "DIN Alternate", "SF Pro Display", Arial, sans-serif;
  font-size: 132px;
  line-height: 0.95;
  font-weight: 760;
}

.secondary-value {
  color: var(--amber);
  font-size: 76px;
  line-height: 1;
  font-weight: 760;
}

.secondary-value.is-updating {
  animation: balance-roll 420ms ease-out;
}

.metric-note {
  margin-top: 22px;
  color: #aeb8bf;
  font-size: 16px;
  line-height: 1.4;
}

.screen-footer {
  border-top: 1px solid var(--line);
}

.screen-footer span:last-child {
  text-align: right;
}

@keyframes balance-roll {
  from {
    opacity: 0.25;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .display-shell {
    grid-template-rows: 72px minmax(0, 1fr) 48px;
  }

  .masthead,
  .screen-footer {
    padding: 0 24px;
  }

  .brand-block strong {
    font-size: 17px;
  }

  .brand-block div > span,
  .connection-state {
    display: none;
  }

  .system-block {
    gap: 0;
  }

  .bay-stage {
    padding: 26px 28px 22px;
  }

  .bay-heading h1 {
    font-size: 36px;
  }

  .running-view {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    padding-top: 16px;
  }

  .time-section,
  .balance-section {
    justify-items: center;
    padding: 24px 0;
    text-align: center;
  }

  .balance-section {
    min-height: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .elapsed-time {
    font-size: 96px;
  }

  .secondary-value {
    font-size: 68px;
  }

  .idle-view h2 {
    font-size: 54px;
  }
}

@media (max-width: 560px) {
  .display-shell {
    grid-template-rows: 64px minmax(0, 1fr) 44px;
  }

  .masthead,
  .screen-footer {
    padding: 0 16px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    font-size: 18px;
  }

  .brand-block {
    gap: 10px;
  }

  .brand-block strong {
    max-width: 58vw;
    font-size: 15px;
  }

  .system-block time {
    min-width: 76px;
    font-size: 15px;
  }

  .bay-stage {
    padding: 20px 16px 16px;
  }

  .bay-heading {
    align-items: center;
    gap: 12px;
  }

  .eyebrow {
    display: none;
  }

  .bay-heading h1 {
    margin-top: 0;
    font-size: 30px;
  }

  .status-badge {
    min-width: 88px;
    padding: 9px 10px;
    font-size: 13px;
  }

  .idle-indicator {
    width: 76px;
    height: 76px;
    margin-bottom: 22px;
  }

  .idle-view h2 {
    font-size: 42px;
  }

  .idle-view p {
    margin-top: 14px;
    font-size: 17px;
  }

  .time-section,
  .balance-section {
    padding: 14px 0;
  }

  .elapsed-time {
    margin-top: 12px;
    font-size: 72px;
  }

  .secondary-value {
    margin-top: 12px;
    font-size: 52px;
  }

  .metric-note {
    margin-top: 12px;
    font-size: 13px;
  }

  .screen-footer {
    font-size: 11px;
  }
}

@media (max-height: 650px) and (min-width: 901px) {
  .display-shell {
    grid-template-rows: 70px minmax(0, 1fr) 44px;
  }

  .bay-stage {
    padding-top: 22px;
    padding-bottom: 18px;
  }

  .bay-heading h1 {
    font-size: 34px;
  }

  .elapsed-time {
    font-size: 104px;
  }

  .secondary-value {
    font-size: 64px;
  }

  .idle-indicator {
    width: 72px;
    height: 72px;
    margin-bottom: 18px;
  }

  .idle-view h2 {
    font-size: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .secondary-value.is-updating {
    animation: none;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
