:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "Noto Sans SC", sans-serif;
  color: #182230;
  background: #edf1f4;
}

* { box-sizing: border-box; }

body { margin: 0; }

.hidden { display: none !important; }
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: #edf1f4;
}
.login-card {
  width: min(100%, 380px); display: grid; gap: 12px; padding: 22px;
  border: 1px solid #d9e1e8; border-radius: 10px; background: #fff;
}
.login-card h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.login-card p { margin: 0; color: #52657a; line-height: 1.45; }
.login-eyebrow { color: #0f5f9c !important; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.form-username-context {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.login-message { min-height: 20px; color: #ae2635; font-size: 13px; font-weight: 700; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; flex: 0 0 200px; padding: 16px 12px;
  background: #0f2233; color: #d6e2ee; display: flex; flex-direction: column; gap: 16px;
}
.sidebar .brand .eyebrow { color: #7fa8c9; margin: 0 0 4px; font-size: 11px; letter-spacing: .08em; }
.sidebar h1 { color: #fff; font-size: 16px; margin: 0; letter-spacing: -.02em; }
.menu { display: flex; flex-direction: column; gap: 4px; }
.menu-item {
  min-height: 34px; padding: 7px 12px; border: 0; border-radius: 6px; text-align: left;
  background: transparent; color: #c3d3e2; cursor: pointer; font: inherit; font-size: 14px; font-weight: 700;
}
.menu-item:hover { background: #1a3550; color: #fff; }
.menu-item.active { background: #0f5f9c; color: #fff; }
.sidebar-foot { margin-top: auto; color: #6f8aa3; font-size: 11px; line-height: 1.5; }
.content { flex: 1; min-width: 0; max-width: none; padding: 20px 20px 40px; }

.dashboard-layout {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(420px, 3fr);
  gap: 10px; align-items: start;
}
.dashboard-main { min-width: 0; }
.dashboard-side {
  position: sticky; top: 20px; display: grid;
  grid-template-rows: minmax(240px, .7fr) minmax(320px, 1.3fr);
  gap: 10px; height: calc(100vh - 40px); min-width: 0;
}
.dashboard-side-panel {
  display: flex; flex-direction: column; min-height: 0; margin-bottom: 0;
}
.dashboard-side-panel .section-heading { flex: 0 0 auto; margin-bottom: 8px; }
.dashboard-side .node-list, .dashboard-side .event-list {
  display: flex; flex-direction: column; gap: 5px;
}
.dashboard-scroll-list {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding-right: 4px; scrollbar-gutter: stable;
}
.dashboard-inventory .dashboard-scroll-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, max-content));
  grid-auto-rows: max-content; justify-content: start; align-content: start; gap: 4px;
}

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.metric-card { padding: 10px 12px; background: #fff; border: 1px solid #d9e1e8; border-radius: 8px; display: flex; flex-direction: column; gap: 4px; }
.metric-card dt { color: #64748b; font-size: 11px; }
.metric-card dd { margin: 0; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.metric-sub { color: #52657a; font-size: 11px; }
.progress { height: 6px; background: #e6ecf1; border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: #0f5f9c; transition: width .4s ease; }
.auto-config-grid {
  display: grid; grid-template-columns: minmax(150px, 1.15fr) repeat(6, minmax(105px, 1fr));
  gap: 8px; align-items: end;
}
.auto-config-grid label { gap: 5px; font-size: 12px; }
.auto-config-grid input { min-height: 34px; text-align: left; font-family: Consolas, monospace; }
.auto-schedule-toggle { align-self: end; min-height: 34px; margin: 0; }
.auto-config-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 16px; margin-top: 6px; }
.auto-config-meta .check-field { margin: 0; font-size: 12px; }
.auto-hint { margin: 8px 0 0; color: #52657a; font-size: 12px; }
.auto-countdown { margin: 4px 0 0; font-family: Consolas, monospace; font-size: 15px; font-weight: 700; color: #0f5f9c; }
.schedule-status { margin: 0; color: #0f5f9c; font-size: 12px; font-weight: 700; }
.schedule-status[data-state="waiting"] { color: #8a5a00; }
.schedule-status[data-state="running"] { color: #176343; }
.schedule-status[data-state="stopped"] { color: #ae2635; }
.schedule-note { margin: 0; color: #64748b; font-size: 11px; }
.manual-pool-bar {
  display: flex; align-items: end; justify-content: space-between; gap: 10px;
  margin-top: 8px; padding: 7px 9px; border: 1px solid #d9e1e8; border-radius: 6px; background: #f6f8fa;
}
.manual-pool-copy { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 3px 10px; min-width: 0; color: #64748b; font-size: 11px; }
.manual-pool-copy strong { color: #30465c; font-size: 12px; }
.manual-pool-status { color: #0f5f9c; font-family: Consolas, monospace; font-size: 12px; font-weight: 700; }
.manual-pool-status[data-state="working"] { color: #176343; }
.manual-pool-status[data-state="queued"] { color: #8a5a00; }
.manual-pool-actions { display: grid; grid-template-columns: 92px auto 76px auto auto; gap: 6px; align-items: end; flex: 0 0 auto; }
.manual-pool-actions label { gap: 3px; font-size: 11px; }
.manual-pool-actions input { min-height: 32px; font-family: Consolas, monospace; }
.manual-pool-actions .button { white-space: nowrap; }
.config-state { align-self: center; padding: 4px 8px; border-radius: 999px; background: #edf2f6; color: #52657a; font-size: 12px; font-weight: 700; white-space: nowrap; }
.config-state[data-state="saved"] { background: #e8f6ec; color: #176343; }
.config-state[data-state="dirty"] { background: #fff4d6; color: #7a5610; }
.config-state[data-state="locked"] { background: #eef2f6; color: #52657a; }
.event-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 4px; margin: 0; padding: 0; list-style: none; }
.event-item { display: grid; grid-template-columns: 128px 1fr; gap: 8px; padding: 3px 8px; background: #f6f8fa; border-radius: 6px; font-size: 12px; }
.event-item span:first-child { color: #64748b; font-family: Consolas, monospace; }
.event-success span:last-child { color: #176343; }
.event-f011 span:last-child, .event-failure span:last-child, .event-error span:last-child { color: #ae2635; }
.token-text { font-family: Consolas, monospace; }

h1, h2, p { margin-top: 0; }
h2 { margin-bottom: 2px; font-size: 15px; }
p { color: #52657a; line-height: 1.45; }
.panel { margin-bottom: 10px; padding: 12px 14px; background: #fff; border: 1px solid #d9e1e8; border-radius: 8px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-heading p { margin-bottom: 0; font-size: 12px; }
.auto-feedback-slot, .view-feedback-slot { flex: 1; min-width: 0; align-self: center; }
.auto-feedback-slot .feedback, .view-feedback-slot .feedback { margin: 0; text-align: left; }
.duration-breakdown { margin-top: 6px; color: #47617a; font-size: 12px; }
.section-heading p[data-state="missing"] { color: #ae2635; font-weight: 700; }
.section-heading p[data-state="ready"] { color: #176343; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.status-grid div { padding: 8px 10px; background: #f6f8fa; border-radius: 6px; }
dt { color: #64748b; font-size: 11px; }
dd { margin: 3px 0 0; overflow-wrap: anywhere; font-weight: 700; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 8px; color: #30465c; font-size: 12px; font-weight: 700; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
label { display: grid; gap: 4px; color: #30465c; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #b9c7d5; border-radius: 5px; color: #182230; background: #fff; font: inherit; }
input, select { min-height: 32px; padding: 5px 8px; }
textarea { padding: 10px; resize: vertical; font-family: Consolas, monospace; font-size: 12px; }
input:focus, select:focus, textarea:focus, button:focus { outline: 3px solid #98b9d8; outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.button { min-height: 32px; padding: 5px 11px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.primary { color: #fff; background: #0f5f9c; }
.secondary { color: #1e4264; border-color: #aebfce; background: #fff; }
.success { color: #176343; border-color: #9fd3b6; background: #f0faf3; }
.danger { color: #8e2532; border-color: #dfadb5; background: #fff7f7; }
.result-label { margin-bottom: 6px; }
.feedback { min-height: 20px; margin: 8px 0 0; font-weight: 700; font-size: 13px; }
.feedback[data-state="error"] { color: #ae2635; }
.feedback[data-state="success"] { color: #176343; }
.feedback[data-state="pending"] { color: #47617a; }
.history-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.history-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 5px; margin: 0; padding-left: 20px; }
.history-item { display: grid; gap: 2px; padding: 5px 10px; background: #f6f8fa; border-radius: 6px; }
.history-item span, .history-empty { color: #52657a; font-size: 12px; line-height: 1.4; }
.node-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin: 0; padding: 0; list-style: none; align-items: stretch; }
.node-item { display: grid; gap: 3px; align-content: start; padding: 6px 10px; background: #f6f8fa; border-radius: 6px; }
.node-item span { color: #52657a; font-size: 12px; overflow-wrap: anywhere; }
.inventory-item {
  grid-template-columns: max-content max-content;
  justify-content: start; align-items: center; gap: 6px; padding: 5px 8px;
}
.inventory-item > strong {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; line-height: 1.2;
}
.inventory-bucket { background: #eef4f8; border: 1px solid #d8e3eb; }
.inventory-count { color: #286185 !important; font-size: 12px !important; font-weight: 700; white-space: nowrap; }
.node-ring-item > strong { font-size: 13px; line-height: 1.3; }
.node-ring-item .node-profile { color: #7b8794; font-size: 11px; font-weight: 400; line-height: 1.35; }
.node-ring-item .node-meta, .node-ring-item .node-state { font-size: 11px; line-height: 1.35; }
/* 双高亮：current=下一个轮到的节点（绿）；last-used=刚使用过的节点（蓝）。 */
.node-item.last-used { background: #e8f1fb; box-shadow: inset 3px 0 0 #1f5f9c; }
.node-item.last-used strong { color: #14406e; }
.last-used-badge { display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 4px; background: #1f5f9c; color: #fff; font-size: 11px; font-weight: 700; overflow-wrap: normal; }
.node-item.current { background: #e8f6ec; box-shadow: inset 3px 0 0 #1f8a4c; }
.node-item.current strong { color: #14603a; }
.current-badge { display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 4px; background: #1f8a4c; color: #fff; font-size: 11px; font-weight: 700; overflow-wrap: normal; }
.node-item.failed { background: #fff0f1; box-shadow: inset 3px 0 0 #cf5966; }
.node-item.failed strong { color: #8e2532; }
.node-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.node-actions .button { min-height: 26px; padding: 3px 9px; font-size: 12px; }
.node-empty { grid-column: 1 / -1; padding: 12px; background: #f6f8fa; border-radius: 6px; color: #52657a; font-size: 13px; list-style: none; }
.check-field { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; font-weight: 700; color: #30465c; }
.check-field input { width: 16px; height: 16px; min-height: 0; padding: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.full-speed-panel { border-color: #b6cee4; }
.full-speed-layout { display: grid; grid-template-columns: minmax(180px, 300px) minmax(0, 1fr); gap: 12px; align-items: end; }
.full-speed-layout label { font-size: 12px; }
.full-speed-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.full-speed-actions .button { white-space: nowrap; }
.worker-bulk-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  margin-bottom: 10px; padding: 7px 9px; border: 1px solid #d9e1e8;
  border-radius: 6px; background: #f6f8fa;
}
.worker-select-all-label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.worker-select-all-label input { width: 16px; height: 16px; min-height: 0; padding: 0; }
.worker-selection-summary { color: #52657a; font-size: 12px; font-weight: 700; }
.worker-bulk-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.worker-table-wrap { overflow: auto; border: 1px solid #d9e1e8; border-radius: 6px; background: #fff; }
.worker-table { width: 100%; min-width: 1590px; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.worker-table th, .worker-table td {
  min-width: 58px; padding: 7px 8px; border-bottom: 1px solid #d9e1e8;
  text-align: left; vertical-align: top; line-height: 1.35;
}
.worker-table th {
  position: sticky; top: 0; z-index: 3; background: #edf2f6; color: #30465c;
  font-size: 11px; white-space: nowrap;
}
.worker-table td { background: var(--worker-row-background, #fff); color: #30465c; }
.worker-table tbody tr:last-child td { border-bottom: 0; }
.worker-select-column { position: sticky; left: 0; z-index: 2; width: 54px; min-width: 54px; text-align: center !important; }
.worker-table th.worker-select-column { z-index: 4; background: #edf2f6; }
.worker-identity-column { position: sticky; left: 54px; z-index: 2; min-width: 180px !important; }
.worker-table th.worker-identity-column { z-index: 4; background: #edf2f6; }
.worker-actions-column { position: sticky; right: 0; z-index: 2; min-width: 184px !important; box-shadow: -1px 0 0 #d9e1e8; }
.worker-table th.worker-actions-column { z-index: 4; background: #edf2f6; }
.worker-table input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; padding: 0; }
.worker-row { --worker-row-background: #f6f8fa; }
.worker-row-full-speed { --worker-row-background: #e8f1fb; }
.worker-row-running { --worker-row-background: #e8f6ec; }
.worker-row-stopped { --worker-row-background: #f1f4f6; }
.worker-row-pending, .worker-row-editing { --worker-row-background: #fff4d6; }
.worker-row-offline { --worker-row-background: #fff0f1; }
.worker-state { display: grid; gap: 3px; min-width: 120px; }
.worker-state-badge { width: max-content; padding: 2px 6px; border-radius: 4px; background: #52657a; color: #fff; font-size: 11px; font-weight: 700; }
.worker-row-full-speed .worker-state-badge { background: #0f5f9c; }
.worker-row-running .worker-state-badge { background: #176343; }
.worker-row-stopped .worker-state-badge { background: #64748b; }
.worker-row-pending .worker-state-badge, .worker-row-editing .worker-state-badge { background: #8a5a00; }
.worker-row-offline .worker-state-badge { background: #ae2635; }
.worker-state-detail, .worker-identity span { color: #52657a; font-size: 11px; overflow-wrap: anywhere; }
.worker-identity { display: grid; gap: 2px; }
.worker-identity strong { color: #182230; font-size: 13px; }
.worker-row-actions { display: flex; flex-wrap: wrap; gap: 5px; min-width: 165px; }
.worker-row-actions .button { min-height: 27px; padding: 3px 7px; font-size: 12px; }
.worker-error { min-width: 160px; color: #8e2532 !important; overflow-wrap: anywhere; }
.worker-table input, .worker-table select { min-height: 28px; padding: 3px 5px; font-size: 12px; }
.worker-table input[type="number"] { width: 68px; min-width: 68px; }
.worker-table input[type="url"] { width: 190px; min-width: 190px; }
.worker-schedule-editor { display: grid; grid-template-columns: 16px 86px 86px; gap: 4px; align-items: center; min-width: 202px; }
.worker-full-speed-editor { display: grid; grid-template-columns: 86px 66px; gap: 4px; min-width: 156px; }
.worker-table td.node-empty { padding: 14px; background: #f6f8fa; color: #52657a; text-align: center; }

@media (max-width: 1500px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .node-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1280px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .dashboard-side {
    position: static; grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none; height: auto;
  }
  .dashboard-side-panel { height: 360px; }
}

@media (max-width: 1100px) {
  .metric-grid, .node-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auto-config-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; flex-direction: row; align-items: center; gap: 10px; padding: 8px 12px; }
  .sidebar .brand h1 { font-size: 14px; }
  .menu { flex-direction: row; flex: 1; }
  .menu-item { flex: 1; text-align: center; min-height: 32px; padding: 5px 6px; }
  .sidebar-foot { display: none; }
  .content { padding-top: 14px; }
  .metric-grid, .status-grid, .field-grid, .auto-config-grid { grid-template-columns: 1fr; }
  .node-list, .event-list, .history-list { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: 1fr; }
  .dashboard-side-panel { height: 320px; }
  .panel { padding: 10px 12px; }
  .section-heading { flex-direction: column; }
  .section-heading .button { width: 100%; }
  .history-actions { width: 100%; }
  .history-actions .button { flex: 1; }
  .manual-pool-bar { align-items: stretch; flex-direction: column; }
  .manual-pool-actions { grid-template-columns: minmax(86px, 1fr) auto minmax(72px, .8fr) auto; width: 100%; }
  #manual-pool-add { grid-column: 1 / -1; }
  .event-item { grid-template-columns: 1fr; }
  .full-speed-layout { grid-template-columns: 1fr; }
  .worker-bulk-actions { width: 100%; margin-left: 0; }
}

@media (max-width: 480px) {
  .manual-pool-actions { grid-template-columns: minmax(0, 1fr) auto; }
  #manual-pool-add { grid-column: 1 / -1; }
}

/* 速率挡位（迁移自旧版界面后新增的最小样式） */
.auto-config-grid select,
.worker-schedule-editor select {
  font: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--input-border, #d7dee8);
  background: var(--input-bg, #fff);
  color: inherit;
}
.worker-tier-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid currentColor;
  opacity: 0.85;
}

/* 舰队告警（fleet watch） */
.fleet-alert-high span:last-child { color: #ae2635; font-weight: 600; }
.fleet-alert-warning span:last-child { color: #9a6700; }
.fleet-alert-info span:last-child { color: #57606a; }
.fleet-alert-high span:first-child { color: #ae2635; font-weight: 600; }

.rotation-phase { margin: 0 0 10px; color: #286185 !important; font-weight: 700; }
.rotation-result { display: grid; gap: 10px; }
.rotation-verdict {
  margin: 0; padding: 10px 14px; border-radius: 6px;
  font-size: 14px; font-weight: 700; line-height: 1.5;
}
.rotation-verdict[data-verdict="ok"], .rotation-verdict[data-verdict="adapted"] { background: #e8f6ec; color: #176343; border: 1px solid #9fd3b6; }
.rotation-verdict[data-verdict="rotated"] { background: #fff7e8; color: #8a5a11; border: 1px solid #ecc98a; }
.rotation-verdict[data-verdict="unmapped"] { background: #fff7e8; color: #8a5a11; border: 1px solid #ecc98a; }
.rotation-verdict[data-verdict="error"] { background: #fff7f7; color: #8e2532; border: 1px solid #dfadb5; }
.rotation-detail {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px; margin: 0;
}
.rotation-detail div { padding: 8px 10px; background: #f6f8fa; border-radius: 6px; }
@media (max-width: 1100px) {
  .rotation-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
