:root {
  --bg-deep: #0b1220;
  --bg-panel: rgba(18, 28, 48, 0.92);
  --bg-panel-edge: rgba(56, 189, 180, 0.22);
  --line: rgba(148, 163, 184, 0.18);
  --text: #e8eef7;
  --text-muted: #8fa0b8;
  --accent: #2dd4bf;
  --warn: #f5a524;
  --danger: #f07178;
  --ok: #3dd68c;
  --idle: #7c8db5;
  --maint: #6ea8fe;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --pad: 12px;
  --gap: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  width: 100%;
  min-height: 100%;
}

body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 8% -10%, rgba(45, 212, 191, 0.12), transparent 55%),
    radial-gradient(900px 600px at 100% 0%, rgba(110, 168, 254, 0.1), transparent 50%),
    linear-gradient(165deg, #071018 0%, #0b1220 45%, #101828 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 35%, transparent 85%);
}

.board {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
}

/* —— Header —— */
.board-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  width: 10px;
  height: 32px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), #0ea5a4);
  box-shadow: 0 0 20px rgba(45, 212, 191, 0.4);
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  font-size: clamp(18px, 5vw, 32px);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.brand-text p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: clamp(11px, 2.8vw, 14px);
  letter-spacing: 0.04em;
}

.header-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.meta-item {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
}

.meta-label {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.meta-value {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(12px, 3.2vw, 17px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.meta-item.clock .meta-value {
  color: var(--accent);
  font-size: clamp(15px, 4vw, 22px);
}

.refresh-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 2s ease-out infinite;
}

.refresh-dot.updating {
  background: var(--warn);
  animation: none;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(61, 214, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 214, 140, 0); }
}

/* —— Main stack (mobile first) —— */
.board-main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--bg-panel-edge);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 10px 12px 0;
  flex-shrink: 0;
}

.panel-head h2 {
  font-size: clamp(14px, 3.6vw, 18px);
  font-weight: 650;
  letter-spacing: 0.04em;
}

.hint {
  color: var(--text-muted);
  font-size: 11px;
}

.gantt-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.now-line-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--warn);
  font-size: 11px;
}

.now-line-hint i {
  width: 12px;
  height: 2px;
  background: var(--warn);
  box-shadow: 0 0 8px rgba(245, 165, 36, 0.8);
}

.panel-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding: 8px 10px 12px;
}

.panel-top {
  flex: 0 0 auto;
  overflow: visible;
}

.top-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

/* 环图固定正方形，完整显示 */
.top-body > .chart,
.chart-ring {
  width: min(100%, 200px);
  height: 200px;
  aspect-ratio: 1 / 1;
  max-width: 200px;
  max-height: 200px;
  margin: 0 auto;
  flex: 0 0 auto;
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.status-card {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), transparent 60%);
}

.status-cards .status-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.status-card .label {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.status-card .value {
  margin-top: 4px;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.status-card .sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-card.run .value { color: var(--ok); }
.status-card.idle .value { color: var(--idle); }
.status-card.setup .value { color: var(--warn); }
.status-card.fault .value { color: var(--danger); }
.status-card.maint .value { color: var(--maint); }

.panel-gantt {
  flex: 0 0 auto;
  height: 440px;
}

.chart {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.chart-gantt {
  min-height: 300px;
}

.panel-bottom {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 0 0 auto;
}

.panel-half {
  flex: 0 0 auto;
  height: 280px;
}

.board-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 2px 6px;
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

/* —— ≥600px 平板 —— */
@media (min-width: 600px) {
  :root {
    --pad: 14px;
    --gap: 12px;
  }

  .board-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  .header-meta {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex: 1 1 380px;
    width: auto;
    max-width: 100%;
  }

  .status-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-cards .status-card:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .panel-gantt {
    height: 480px;
  }

  .panel-half {
    height: 300px;
  }

  .board-footer {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
  }
}

/* —— ≥768px：状态区左右排列，底部双列 —— */
@media (min-width: 768px) {
  .brand-mark {
    width: 12px;
    height: 40px;
  }

  .top-body {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 12px;
    min-height: 180px;
  }

  .top-body > .chart,
  .chart-ring {
    width: 180px;
    height: 180px;
    max-width: 180px;
    max-height: 180px;
    margin: 0;
  }

  .status-cards {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-content: center;
  }

  .panel-gantt {
    height: 520px;
  }

  .panel-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* —— 大屏车间（宽+高够）：一屏铺满 —— */
@media (min-width: 1200px) and (min-height: 780px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .board {
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    padding: 14px 18px 10px;
  }

  .board-header {
    flex-wrap: nowrap;
  }

  .header-meta {
    flex: 0 1 auto;
    width: auto;
    grid-template-columns: repeat(4, auto);
  }

  .meta-item {
    min-width: 118px;
  }

  .board-main {
    flex: 1;
    min-height: 0;
    display: grid;
    /* 顶区按内容撑开，避免环图/卡片被裁切一半 */
    grid-template-rows: auto minmax(0, 1fr) minmax(180px, 22%);
    overflow: hidden;
  }

  .panel-top,
  .panel-gantt,
  .panel-bottom,
  .panel-half {
    height: auto;
    min-height: 0;
  }

  .panel-top {
    overflow: visible;
    min-height: 0;
  }

  .panel {
    min-height: 0;
  }

  .panel-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 0;
  }

  .top-body {
    height: auto;
    min-height: 160px;
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .top-body > .chart,
  .chart-ring {
    width: 160px;
    height: 160px;
    max-width: 160px;
    max-height: 160px;
    aspect-ratio: 1 / 1;
    margin: 0;
  }

  .status-cards {
    height: auto;
    align-content: center;
  }
}

/* —— 宽但矮：仍滚动 —— */
@media (min-width: 1200px) and (max-height: 779px) {
  .top-body {
    grid-template-columns: auto 1fr;
    align-items: center;
    min-height: 190px;
  }

  .top-body > .chart,
  .chart-ring {
    width: 180px;
    height: 180px;
    max-height: 180px;
  }

  .panel-gantt {
    height: 400px;
  }

  .panel-half {
    height: 260px;
  }
}

/* —— 超窄 —— */
@media (max-width: 399px) {
  :root {
    --pad: 8px;
    --gap: 8px;
  }

  .gantt-tools .hint {
    display: none;
  }

  .panel-gantt {
    height: 400px;
  }

  .panel-half {
    height: 260px;
  }

  .top-body > .chart,
  .chart-ring {
    width: min(100%, 200px);
    height: 200px;
    max-width: 200px;
    max-height: 200px;
  }
}
