:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: #171a1f;
  --panel-2: #1d2128;
  --line: #2b3038;
  --text: #f5f5f5;
  --muted: #969da8;
  --gold: #d6a84b;
  --gold-light: #f4cf74;
  --green: #22c55e;
  --red: #ef4444;
  --red-dark: #b91c1c;
  --orange: #f59e0b;
  --radius: 16px;
  font-family: "Microsoft YaHei UI", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .46; }
.hidden { display: none !important; }
.brand-kicker { margin: 0 0 8px; color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: .22em; }

.login-body {
  background:
    radial-gradient(circle at 50% 7%, rgba(214,168,75,.14), transparent 35%),
    linear-gradient(145deg, #090b0d, #101318 70%);
}
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(430px, 100%);
  padding: 38px 38px 34px;
  background: rgba(23,26,31,.96);
  border: 1px solid rgba(214,168,75,.4);
  border-radius: 24px;
  box-shadow: 0 28px 90px rgba(0,0,0,.46);
  text-align: center;
}
.login-logo { width: 82px; height: 82px; object-fit: contain; margin-bottom: 12px; filter: drop-shadow(0 10px 24px rgba(214,168,75,.25)); }
.login-card h1 { margin: 3px 0 8px; font-size: 27px; }
.login-subtitle { margin: 0 0 30px; color: var(--muted); font-size: 14px; }
.login-card form { display: grid; gap: 10px; text-align: left; }
.login-card label { margin-top: 7px; color: #cfd3d9; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #101318;
  color: var(--text);
  outline: none;
  padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214,168,75,.12); }
.form-error { min-height: 20px; margin: 3px 0; color: #ff8a8a; font-size: 13px; }

.install-shell { padding-block: 34px; }
.install-card { width: min(760px, 100%); padding: 32px 36px 28px; text-align: left; }
.install-head { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.install-head .login-logo { flex: 0 0 auto; margin: 0; }
.install-head h1 { margin: 2px 0 7px; }
.install-head .login-subtitle { margin: 0; }
.install-card form { gap: 16px; }
.install-card fieldset { display: grid; gap: 11px; margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(10,12,15,.35); }
.install-card legend { padding: 0 8px; color: #f1d184; font-weight: 800; }
.install-card legend span { display: inline-grid; width: 24px; height: 24px; margin-right: 7px; place-items: center; border-radius: 50%; background: rgba(214,168,75,.18); font-size: 12px; }
.install-card label { display: grid; gap: 7px; margin: 0; }
.field-help { margin: -3px 0 3px; color: var(--muted); font-size: 12px; }
.install-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.host-grid { grid-template-columns: minmax(0, 1fr) 140px; }
.setup-warning { margin-bottom: 16px; padding: 12px 14px; border: 1px solid rgba(245,158,11,.48); border-radius: 10px; background: rgba(245,158,11,.1); color: #ffd47f; font-size: 13px; line-height: 1.6; }
.install-progress { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 10px; background: rgba(214,168,75,.08); color: #efd28e; font-size: 13px; }
.install-progress i { width: 15px; height: 15px; border: 2px solid rgba(214,168,75,.3); border-top-color: var(--gold-light); border-radius: 50%; animation: install-spin .75s linear infinite; }
.install-footnote { margin: -4px 0 0; color: #777f8a; text-align: center; font-size: 11px; }
@keyframes install-spin { to { transform: rotate(360deg); } }

.primary-button, .gold-button, .ghost-button, .danger-button, .danger-outline, .cancel-button, .cancel-outline {
  border-radius: 10px;
  padding: 11px 16px;
  border: 1px solid transparent;
  font-weight: 800;
  transition: transform .12s, background .12s, border-color .12s;
}
.primary-button, .gold-button { background: linear-gradient(135deg, #c39437, var(--gold-light)); color: #211706; }
.primary-button { width: 100%; min-height: 48px; }
.primary-button:hover, .gold-button:hover { transform: translateY(-1px); filter: brightness(1.05); }
.ghost-button { color: #d8dce2; background: #20242b; border-color: #343943; }
.ghost-button:hover { border-color: #59616d; background: #272c34; }
.ghost-button.small { padding: 7px 11px; font-size: 12px; }
.danger-button { color: white; background: linear-gradient(135deg, var(--red-dark), var(--red)); border-color: #ff6a6a; }
.danger-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.danger-outline { color: #ff8585; background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.58); }
.danger-outline:hover { color: white; background: rgba(239,68,68,.2); }
.cancel-button { color: white; background: linear-gradient(135deg, #9f570c, #d97a16); border-color: #f3b24f; }
.cancel-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.cancel-outline { color: #f7b75b; background: rgba(217,122,22,.09); border-color: rgba(243,178,79,.62); }
.cancel-outline:hover { color: white; background: rgba(217,122,22,.22); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(22px, calc((100vw - 1240px) / 2));
  background: rgba(13,15,18,.92);
  border-bottom: 1px solid #22262d;
  backdrop-filter: blur(14px);
}
.topbar-brand { display: flex; align-items: center; gap: 11px; }
.topbar-brand img { width: 43px; height: 43px; object-fit: contain; }
.topbar-brand div { display: grid; gap: 2px; }
.topbar-brand strong { color: var(--gold-light); font-size: 16px; }
.topbar-brand span { color: #717986; font-size: 9px; letter-spacing: .12em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.admin-name { color: #b6bcc5; font-size: 13px; }
.connection-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.connection-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.connection-pill.online { color: #72e49a; background: rgba(34,197,94,.11); }
.connection-pill.reconnecting { color: #f9c55d; background: rgba(245,158,11,.11); }
.connection-warning { padding: 10px 20px; background: #8f1f27; color: white; text-align: center; font-size: 13px; font-weight: 700; }
.realtime-online .connection-warning { display: none; }

.dashboard-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 60px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.hero-row h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.03em; }
.hero-row p:last-child { margin: 10px 0 0; color: var(--muted); }
.global-command-actions { display: grid; grid-template-columns: repeat(2, minmax(210px, 1fr)); gap: 10px; }
.global-command { min-width: 210px; min-height: 52px; font-size: 15px; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { display: flex; align-items: center; justify-content: space-between; min-height: 92px; padding: 21px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stat-card span { color: var(--muted); font-size: 14px; }
.stat-card strong { color: var(--gold-light); font-size: 34px; }
.stat-card.online strong { color: #69de93; }

.result-banner { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 15px 18px; margin-bottom: 18px; border: 1px solid rgba(214,168,75,.38); border-radius: 13px; background: rgba(214,168,75,.08); cursor: pointer; }
.result-banner div { display: grid; gap: 4px; }
.result-banner span { color: #c2a35e; font-size: 12px; }
.result-banner strong { font-size: 14px; }

.workspace-card { overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
.workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 5px; padding: 4px; background: #101318; border-radius: 11px; }
.tab-button { border: 0; border-radius: 8px; padding: 9px 14px; background: transparent; color: var(--muted); font-weight: 700; }
.tab-button.active { background: #292e36; color: white; box-shadow: 0 2px 8px rgba(0,0,0,.28); }
.workspace-actions { display: flex; gap: 9px; }
.filter-row { display: flex; align-items: center; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.filter-row input[type="search"] { max-width: 410px; }
.check-label { display: inline-flex; align-items: center; gap: 7px; color: #c7ccd3; font-size: 13px; white-space: nowrap; }
.check-label input { width: 17px; height: 17px; accent-color: var(--gold); }
.selection-controls { display: flex; align-items: center; gap: 8px; }
.selected-command-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.view-panel { padding: 16px 20px 22px; }
.empty-state { padding: 60px 20px; color: var(--muted); text-align: center; }

.member-card { margin-bottom: 11px; border: 1px solid var(--line); border-radius: 14px; background: #14171c; }
.member-main { display: grid; grid-template-columns: auto minmax(190px,1fr) auto auto auto; align-items: center; gap: 14px; padding: 16px; }
.member-check { width: 17px; height: 17px; accent-color: var(--gold); }
.member-title { display: grid; gap: 5px; }
.member-title strong { font-size: 16px; }
.member-title span { color: var(--muted); font-size: 12px; }
.member-title .account-line { color: #747d89; font-size: 11px; }
.count-badge { padding: 6px 9px; border-radius: 999px; background: #20242b; color: #c5cad1; font-size: 12px; }
.count-badge b { color: var(--green); }
.inline-actions { display: flex; gap: 7px; }
.member-command-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.text-button { padding: 7px 9px; border: 0; background: transparent; color: #aab1bc; font-size: 12px; }
.history-row[role="button"] { cursor: pointer; }
.text-button:hover { color: white; }
.text-button.danger { color: #fb8585; }
.member-machines { padding: 0 16px 14px 47px; }
.loading-line, .nested-empty { padding: 18px 14px; color: var(--muted); text-align: center; }

.machine-row, .history-row { display: grid; grid-template-columns: minmax(170px,1.3fr) minmax(130px,1fr) minmax(150px,1fr) minmax(150px,1fr) auto; align-items: center; gap: 14px; min-height: 68px; padding: 12px 14px; border-bottom: 1px solid #292d34; }
.machine-row.selectable { grid-template-columns: auto minmax(170px,1.3fr) minmax(130px,1fr) minmax(150px,1fr) minmax(150px,1fr) auto; }
.row-check { width: 17px; height: 17px; padding: 0; accent-color: var(--gold); }
.machine-row:last-child, .history-row:last-child { border-bottom: 0; }
.machine-ident { display: grid; gap: 4px; }
.machine-ident strong { font-size: 14px; }
.machine-ident code { color: #747d89; font-size: 10px; word-break: break-all; }
.cell-label { display: none; }
.muted { color: var(--muted); font-size: 12px; }
.result-with-action { display: flex; align-items: center; gap: 7px; }
.result-with-action small { color: #b8a064; font-size: 10px; font-weight: 800; }
.action-tag { display: inline-flex; margin-right: 7px; padding: 3px 7px; border-radius: 999px; font-size: 10px; font-weight: 900; vertical-align: middle; }
.action-tag.harvest { color: #ff9292; background: rgba(239,68,68,.12); }
.action-tag.cancel { color: #f6bd67; background: rgba(217,122,22,.14); }
.status-badge { display: inline-flex; align-items: center; gap: 6px; width: max-content; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.online, .status-badge.succeeded { color: #6cdd94; background: rgba(34,197,94,.1); }
.status-badge.offline, .status-badge.skipped_offline { color: #89919d; background: rgba(107,114,128,.14); }
.status-badge.sent, .status-badge.accepted, .status-badge.prepared { color: #f2c55f; background: rgba(245,158,11,.11); }
.status-badge.failed, .status-badge.busy, .status-badge.delivery_failed, .status-badge.result_unknown, .status-badge.command_expired, .status-badge.cancelled_restart { color: #ff8181; background: rgba(239,68,68,.11); }
.machine-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 7px; }
.machine-actions .danger-outline, .machine-actions .cancel-outline, .member-main .danger-outline, .member-main .cancel-outline { padding: 8px 11px; font-size: 12px; }
.table-head { display: grid; grid-template-columns: minmax(170px,1.3fr) minmax(130px,1fr) minmax(150px,1fr) minmax(150px,1fr) auto; gap: 14px; padding: 6px 14px 10px; color: #747c87; font-size: 11px; }
.table-head.selectable { grid-template-columns: auto minmax(170px,1.3fr) minmax(130px,1fr) minmax(150px,1fr) minmax(150px,1fr) auto; }
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; padding: 13px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination-actions { display: flex; align-items: center; gap: 8px; }
.page-size-label { display: inline-flex; align-items: center; gap: 6px; color: #b6bdc7; white-space: nowrap; }
.page-size-label input { width: 70px; padding: 7px 8px; text-align: center; }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.7); backdrop-filter: blur(7px); }
.modal { width: min(520px, 100%); max-height: min(760px, calc(100vh - 40px)); overflow: auto; background: #191d22; border: 1px solid #3b414b; border-radius: 18px; box-shadow: 0 30px 110px rgba(0,0,0,.62); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 19px; }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: #272c33; color: #aeb4bd; font-size: 21px; }
.modal-body { display: grid; gap: 12px; padding: 20px; color: #d8dce2; line-height: 1.65; }
.modal-body label { color: #c3c8d0; font-size: 13px; font-weight: 700; }
.modal-body p { margin: 0; }
.modal-body .warning-copy { padding: 13px 14px; border-left: 3px solid var(--red); background: rgba(239,68,68,.08); color: #ffc2c2; }
.binding-box { display: grid; gap: 9px; padding: 15px; border: 1px solid rgba(214,168,75,.35); border-radius: 12px; background: rgba(214,168,75,.07); }
.binding-code { color: var(--gold-light); font-family: Consolas, monospace; font-size: 15px; word-break: break-all; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 20px 20px; }
.modal-actions button { min-width: 96px; }
.detail-list { display: grid; gap: 8px; }
.detail-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px; border-radius: 10px; background: #12151a; }
.detail-item span { color: var(--muted); font-size: 12px; }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(420px, calc(100% - 44px)); padding: 13px 16px; border-radius: 11px; background: #2a3038; border: 1px solid #4a525e; box-shadow: 0 16px 40px rgba(0,0,0,.4); font-size: 13px; }
.toast.error { background: #4b171a; border-color: #8f3339; }

@media (max-width: 820px) {
  .topbar { height: auto; min-height: 66px; padding: 10px 14px; }
  .topbar-brand span, .admin-name { display: none; }
  .dashboard-shell { width: min(100% - 24px, 680px); padding-top: 22px; }
  .hero-row { align-items: stretch; flex-direction: column; }
  .global-command-actions { width: 100%; grid-template-columns: 1fr 1fr; }
  .global-command { min-width: 0; width: 100%; }
  .stats-grid { gap: 8px; }
  .stat-card { min-height: 76px; padding: 15px 13px; flex-direction: column; align-items: flex-start; }
  .stat-card strong { font-size: 27px; }
  .workspace-head { align-items: stretch; flex-direction: column; }
  .tabs { display: grid; grid-template-columns: repeat(3,1fr); }
  .tab-button { padding-inline: 6px; font-size: 12px; }
  .workspace-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-row { align-items: stretch; flex-wrap: wrap; }
  .filter-row input[type="search"] { max-width: none; }
  .selection-controls { flex: 1 1 100%; flex-wrap: wrap; }
  .selected-command-actions { width: 100%; margin-left: 0; }
  .selected-command-actions button { flex: 1; }
  .member-main { grid-template-columns: auto 1fr auto; }
  .member-main > .count-badge { grid-column: 2 / 4; width: max-content; }
  .member-main > .inline-actions { grid-column: 2 / 3; }
  .member-main > .member-command-actions { grid-column: 2 / 4; justify-content: stretch; }
  .member-command-actions button { flex: 1; }
  .member-machines { padding-left: 14px; }
  .table-head { display: none; }
  .machine-row, .machine-row.selectable, .history-row { grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 10px; padding: 15px; border: 1px solid #2b3038; border-radius: 12px; }
  .machine-row.selectable > .row-check { grid-column: 1 / -1; }
  .machine-row > *, .history-row > * { min-width: 0; }
  .machine-ident { grid-column: 1 / -1; }
  .machine-actions { grid-column: 1 / -1; justify-content: stretch; }
  .machine-actions button { flex: 1; }
  .text-button { min-height: 44px; }
  .cell-label { display: block; margin-bottom: 3px; color: #69717d; font-size: 9px; text-transform: uppercase; }
  .pagination-bar { align-items: flex-start; flex-direction: column; }
  .pagination-actions { width: 100%; flex-wrap: wrap; }
  .pagination-actions button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

@media (max-width: 480px) {
  .login-card { padding: 30px 22px 26px; }
  .install-shell { padding: 14px; align-items: start; }
  .install-card { padding: 24px 17px 22px; }
  .install-head { align-items: flex-start; gap: 12px; }
  .install-head .login-logo { width: 58px; height: 58px; }
  .install-head h1 { font-size: 22px; }
  .install-grid, .host-grid { grid-template-columns: 1fr; }
  .install-card fieldset { padding: 15px 12px; }
  .topbar-brand strong { font-size: 13px; }
  .connection-pill { padding: 6px 8px; font-size: 10px; }
  .hero-row h1 { font-size: 28px; }
  .hero-row p:last-child { font-size: 13px; }
  .global-command-actions { grid-template-columns: 1fr; }
  .view-panel { padding-inline: 10px; }
  .member-main { padding: 14px 10px; gap: 9px; }
  .member-title strong { font-size: 14px; }
  .selection-controls .muted { width: 100%; }
  .pagination-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .page-size-label { grid-column: 1 / -1; justify-content: flex-end; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 88vh; border-radius: 18px 18px 0 0; }
  .modal-actions { position: sticky; bottom: 0; background: #191d22; }
}
