:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647087;
  --line: #dce3ee;
  --blue: #1769e0;
  --cyan: #00a6a6;
  --green: #12a150;
  --yellow: #d58b00;
  --red: #d92d20;
  --dark: #0f172a;
  --shadow: 0 12px 28px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: #101928;
  color: #f8fafc;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin: 8px 0 0;
  color: #b8c4d8;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  color: #d9e3f4;
  background: transparent;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: #24324a;
  color: #ffffff;
}

.status-strip {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: #b8c4d8;
  font-size: 12px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  margin: 0;
  font-size: 22px;
}

.topbar-meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 16px;
  align-items: center;
}

.content {
  padding: 24px 28px 36px;
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.card h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 32px;
  line-height: 1;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary {
  background: var(--blue);
  color: #ffffff;
  padding: 10px 14px;
}

.success {
  background: var(--green);
  color: #ffffff;
  padding: 10px 14px;
}

.warning {
  background: var(--yellow);
  color: #ffffff;
  padding: 10px 14px;
}

.danger {
  background: var(--red);
  color: #ffffff;
  padding: 10px 14px;
}

.ghost {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 9px 13px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select,
.field textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--ink);
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.running,
.green {
  color: #067647;
  background: #dcfae6;
}

.idle {
  color: #344054;
  background: #eef2f6;
}

.waiting_qc,
.yellow {
  color: #b54708;
  background: #fef0c7;
}

.blocked,
.red {
  color: #b42318;
  background: #fee4e2;
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

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

.notice {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

.notice.ok {
  color: #067647;
  background: #dcfae6;
  border: 1px solid #abefc6;
}

.notice.warn {
  color: #b54708;
  background: #fef0c7;
  border: 1px solid #fedf89;
}

.workstation-layout {
  grid-template-columns: minmax(280px, 420px) 1fr;
  align-items: start;
}

.sop-box {
  min-height: 220px;
  background: #f7fbff;
  border: 1px dashed #9ec5ff;
  border-radius: 8px;
  padding: 18px;
  line-height: 1.7;
}

.sop-box.blocked {
  background: #fff8f6;
  border-color: #fecdca;
}

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

.andon-pad button {
  min-height: 132px;
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
}

.andon-pad .green-btn {
  background: var(--green);
}

.andon-pad .yellow-btn {
  background: var(--yellow);
}

.andon-pad .red-btn {
  background: var(--red);
}

.tv {
  min-height: 100vh;
  background: #080f1f;
  color: #e7eefc;
}

.tv .sidebar,
.tv .topbar {
  display: none;
}

.tv .shell {
  display: block;
}

.tv .content {
  padding: 28px;
}

.tv .card {
  background: #111b2f;
  border-color: #24344f;
  box-shadow: none;
}

.tv .metric strong {
  color: #ffffff;
  font-size: 50px;
}

.tv-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 8px;
}

.tv-title h1 {
  margin: 0;
  font-size: 34px;
}

/* ---- 汉堡菜单按钮（默认隐藏） ---- */
.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1100;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--dark);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  border: 0;
  cursor: pointer;
}

/* ---- 平板端 (768px ~ 1024px) ---- */
@media (max-width: 1024px) {
  /* 触控友好：按钮和输入框增大 */
  button, .field input, .field select, .field textarea {
    min-height: 48px;
    font-size: 15px;
  }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  /* 侧边栏变为可折叠覆盖层 */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .workstation-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 16px 16px 16px 64px;
  }

  .content {
    padding: 16px;
  }
}

/* ---- 手机端 (< 620px) ---- */
@media (max-width: 620px) {
  .andon-pad {
    grid-template-columns: 1fr;
  }
  .andon-pad button {
    min-height: 100px;
    font-size: 20px;
  }
  .topbar-meta {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ---- TV 大屏增强 ---- */
.tv .hamburger { display: none; }

.tv-exit {
  background: rgba(255,255,255,0.12);
  color: #c8d6e8;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 6px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}
.tv-exit:hover {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.tv .metric strong {
  font-size: 72px;
}

.tv .table th,
.tv .table td {
  font-size: 18px;
  padding: 14px 10px;
}

.tv .tv-title h1 {
  font-size: 42px;
}

.tv .tv-title span {
  font-size: 20px;
}

.tv .card h3 {
  font-size: 22px;
}

.tv .pill {
  font-size: 15px;
  padding: 2px 12px;
}

.tv .item {
  font-size: 16px;
  background: #1a2540;
  border-color: #24344f;
  color: #e7eefc;
}

.tv .item .muted {
  color: #8899b4;
}

.tv .item-head strong {
  color: #f0f4fc;
}
