:root {
  color-scheme: light;
  --bg: #f3f5f6;
  --panel: #ffffff;
  --panel-alt: #f8f9fa;
  --text: #20272c;
  --muted: #667078;
  --line: #dfe4e7;
  --line-strong: #cbd2d6;
  --sidebar: #22282c;
  --sidebar-muted: #9ba5ab;
  --accent: #127a55;
  --accent-soft: #e5f4ee;
  --amber: #a96508;
  --amber-soft: #fff2d8;
  --red: #b43b3b;
  --red-soft: #fae9e8;
  --focus: #2878b7;
  --shadow: 0 1px 2px rgba(23, 32, 38, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

body.auth-pending .app-shell,
body.auth-required .app-shell {
  visibility: hidden;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef1f2;
}

.auth-gate[hidden] {
  display: none;
}

.login-panel {
  width: min(400px, 100%);
  display: grid;
  gap: 18px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(23, 32, 38, 0.12);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 12px;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  padding: 20px 14px 16px;
  background: var(--sidebar);
  color: #f4f6f7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
}

.brand-mark,
.zone-symbol,
.user-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 5px;
  font-weight: 800;
}

.brand-mark {
  width: 38px;
  height: 38px;
  background: #f1b24a;
  color: #22282c;
  font-size: 13px;
}

.brand div,
.sidebar-user div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.brand strong {
  font-size: 15px;
}

.brand span,
.sidebar-user span {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.primary-nav,
#zoneNav {
  display: grid;
  gap: 5px;
}

.nav-label {
  margin: 15px 10px 5px;
  color: #7f8a91;
  font-size: 11px;
}

.nav-button {
  min-height: 40px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 8px;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #cfd5d8;
  text-align: left;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-button.active {
  background: #f7f8f8;
  color: #20272c;
  font-weight: 700;
}

.nav-symbol {
  color: #8f9ba1;
  font-size: 11px;
  font-weight: 800;
}

.nav-button.active .nav-symbol {
  color: var(--accent);
}

.nav-button > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #667078;
}

.nav-dot.online {
  background: #27aa76;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.11);
}

.sidebar-logout {
  margin-left: auto;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  background: transparent;
  color: #dbe1e4;
  font-size: 11px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: #394247;
  color: #fff;
}

.sidebar-user strong {
  font-size: 13px;
}

.content-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}

.topbar p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.node-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.node-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #23a36f;
}

.node-state.offline i {
  background: var(--amber);
}

#mainContent {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 26px 48px;
}

.loading-state,
.error-state {
  padding: 60px 24px;
  color: var(--muted);
  text-align: center;
}

.error-state strong {
  color: var(--red);
}

.overview-metrics,
.zone-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.metric-block {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-block > span,
.metric-block small {
  color: var(--muted);
  font-size: 12px;
}

.metric-block strong {
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.15;
}

.metric-block small {
  min-height: 16px;
}

.section-block {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 17px;
}

.section-title > div {
  min-width: 0;
}

.section-title span,
.room-intro span {
  color: var(--muted);
  font-size: 11px;
}

.section-title h2,
.room-intro h2 {
  margin: 3px 0 0;
  font-size: 16px;
}

.section-title > small {
  color: var(--muted);
  font-size: 12px;
}

.section-title > strong {
  color: var(--accent);
  font-size: 28px;
}

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

.zone-summary {
  min-width: 0;
  min-height: 248px;
  display: flex;
  flex-direction: column;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-alt);
  color: var(--text);
  text-align: left;
}

.zone-summary:hover {
  border-color: #9eb4a9;
  background: #fff;
  box-shadow: 0 5px 16px rgba(23, 32, 38, 0.08);
}

.zone-summary header,
.zone-summary footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.zone-symbol {
  width: 34px;
  height: 34px;
  background: #e7ebed;
  color: #354047;
}

.zone-summary:nth-child(1) .zone-symbol {
  background: #e3f3ec;
  color: var(--accent);
}

.zone-summary:nth-child(2) .zone-symbol {
  background: #e8edf6;
  color: #3e5f91;
}

.zone-summary:nth-child(3) .zone-symbol {
  background: #fff0d8;
  color: var(--amber);
}

.zone-summary h3 {
  margin: 18px 0 7px;
  font-size: 17px;
}

.zone-summary > p {
  min-height: 42px;
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.data-freshness {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 28px;
  margin-bottom: 10px;
}

.freshness-time {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-metrics > span {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 11px 7px;
}

.summary-metrics small {
  color: var(--muted);
  font-size: 10px;
}

.summary-metrics strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-summary footer {
  margin-top: auto;
  color: var(--muted);
  font-size: 11px;
}

.zone-summary footer strong {
  color: var(--accent);
  font-size: 12px;
}

.overview-columns {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(250px, 0.75fr);
  gap: 14px;
  margin-top: 14px;
}

.access-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 14px;
}

.access-columns {
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
}

.permission-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.permission-list span {
  padding: 5px 8px;
  border: 1px solid #b8ddce;
  border-radius: 4px;
  background: var(--accent-soft);
  color: #0d694a;
  font-size: 11px;
}

.muted-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.role-list,
.user-list {
  display: grid;
  gap: 9px;
}

.role-list article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-alt);
}

.role-list header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.role-list header span {
  min-width: 24px;
  color: var(--accent);
  font-weight: 700;
  text-align: right;
}

.role-list p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.user-section {
  margin-top: 14px;
}

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

.user-list article {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-alt);
}

.user-list article > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.user-list small {
  color: var(--muted);
}

.future-summary p {
  min-height: 76px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.primary-button,
.secondary-button,
.text-button,
.segmented-control button {
  min-height: 36px;
  border-radius: 5px;
}

.primary-button {
  padding: 8px 18px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: #0f6849;
}

.row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.small-button {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 11px;
}

.small-button:hover {
  border-color: #98a2a8;
  background: #f8f9fa;
}

.small-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.secondary-button:hover {
  border-color: #98a2a8;
  background: #f8f9fa;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

.full-width {
  width: 100%;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.status-pill,
.cell-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  width: fit-content;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}

.success {
  border-color: #b8ddce;
  background: var(--accent-soft);
  color: #0d694a;
}

.warning {
  border-color: #efd49e;
  background: var(--amber-soft);
  color: #885609;
}

.danger {
  border-color: #edc1be;
  background: var(--red-soft);
  color: #973232;
}

.neutral {
  border-color: #d9dee1;
  background: #f1f3f4;
  color: #5f6970;
}

.zone-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 17px;
}

.zone-heading p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.data-status-banner {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(180px, 0.9fr) minmax(220px, 1fr);
  gap: 1px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px;
  background: var(--line);
  overflow: hidden;
}

.data-status-banner.success {
  border-left-color: #16865f;
}

.data-status-banner.warning {
  border-left-color: #b87512;
}

.data-status-banner.danger {
  border-left-color: #b7433e;
}

.data-status-banner > div {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 78px;
  padding: 12px 14px;
  background: #fff;
}

.data-status-banner span,
.data-status-banner small {
  color: var(--muted);
  font-size: 11px;
}

.data-status-banner strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eaedef;
}

.segmented-control button {
  min-width: 90px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.segmented-control button.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 700;
}

.execution-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  gap: 14px;
  margin-bottom: 14px;
}

.execution-form,
.execution-status {
  min-height: 280px;
}

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

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.field > span {
  color: #4f5a61;
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
}

.field input:hover,
.field select:hover {
  border-color: #9fa9ae;
}

.form-actions {
  min-height: 54px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.form-actions > span {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  min-height: 152px;
  display: grid;
  place-content: center;
  gap: 7px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: #4f5960;
}

.empty-state span {
  font-size: 12px;
}

.job-summary dl {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
}

.job-summary dl div {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
}

.job-summary dt {
  color: var(--muted);
}

.job-summary dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.job-summary pre {
  max-height: 150px;
  margin: 0;
  overflow: auto;
  padding: 11px;
  border: 1px solid var(--line);
  background: #f7f8f8;
  color: #424b50;
  font: 12px/1.6 Consolas, "Microsoft YaHei UI", monospace;
  white-space: pre-wrap;
}

.schedule-panel {
  margin-bottom: 14px;
}

.schedule-line {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.schedule-line div {
  display: grid;
  gap: 5px;
  padding: 17px 10px;
}

.schedule-line span {
  color: var(--muted);
  font-size: 11px;
}

.schedule-line strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.result-section {
  padding-right: 0;
  padding-left: 0;
}

.result-section .section-title {
  padding: 0 20px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 12px;
}

th,
td {
  min-width: 110px;
  padding: 11px 13px;
  border-bottom: 1px solid #e8ebed;
  color: #40494f;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f8f8;
  color: #606a70;
  font-weight: 700;
  white-space: nowrap;
}

th.wide,
td.wide {
  min-width: 310px;
  max-width: 470px;
}

td.wide {
  line-height: 1.5;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfcfc;
}

.jobs-table td {
  vertical-align: middle;
}

.table-empty {
  border-top: 1px solid var(--line);
}

.overview-metrics.compact {
  margin-bottom: 14px;
}

.room-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.room-intro p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
}

.room-directory {
  display: grid;
  gap: 14px;
}

.room-group {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.room-group > header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
}

.room-group h3 {
  margin: 0;
  font-size: 15px;
}

.room-group > header > span {
  color: var(--muted);
  font-size: 12px;
}

.room-group > div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.room-group article {
  min-width: 0;
  min-height: 128px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-alt);
}

.room-group article strong {
  font-size: 13px;
}

.room-group article p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 1120px) {
  .zone-summary-grid,
  .room-group > div,
  .user-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .execution-layout,
  .overview-columns,
  .access-summary {
    grid-template-columns: 1fr;
  }

  .execution-form,
  .execution-status {
    min-height: auto;
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: 30;
    height: auto;
    padding: 11px 12px;
    gap: 10px;
  }

  .brand {
    padding: 0 2px 10px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .primary-nav,
  #zoneNav {
    display: flex;
    gap: 6px;
  }

  .primary-nav {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  #zoneNav {
    display: contents;
  }

  .nav-label,
  .sidebar-user {
    display: none;
  }

  .nav-button {
    min-width: 122px;
    grid-template-columns: 22px minmax(0, 1fr) 8px;
    background: rgba(255, 255, 255, 0.05);
  }

  .topbar {
    position: static;
    min-height: 70px;
    padding: 13px 16px;
  }

  #mainContent {
    padding: 16px 16px 40px;
  }

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

  .node-state {
    display: none;
  }
}

@media (max-width: 620px) {
  .topbar h1 {
    font-size: 19px;
  }

  .zone-summary-grid,
  .room-group > div,
  .user-list,
  .form-grid,
  .schedule-line {
    grid-template-columns: 1fr;
  }

  .zone-heading,
  .room-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .data-status-banner {
    grid-template-columns: 1fr;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    flex: 1;
  }

  .overview-metrics,
  .zone-metrics {
    gap: 8px;
  }

  .metric-block {
    min-height: 84px;
    padding: 13px;
  }

  .metric-block strong {
    font-size: 20px;
  }

  .section-block {
    padding: 15px;
  }

  .result-section {
    padding-right: 0;
    padding-left: 0;
  }

  .result-section .section-title {
    padding: 0 15px;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }

  th.wide,
  td.wide {
    min-width: 260px;
  }
}
