: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, .pending-button, .pending-outline, .cancel-button, .cancel-outline, .position-harvest-button, .plan-button, .independent-button {
  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; }
.settings-entry { color: #9bdcff; border-color: rgba(56,189,248,.48); background: rgba(14,116,144,.13); }
.settings-entry:hover { color: #d6f2ff; border-color: rgba(103,207,255,.78); background: rgba(14,116,144,.25); }
.management-entry { color: #d9c5ff; border-color: rgba(139,92,246,.48); background: rgba(91,33,182,.13); }
.management-entry:hover { color: #eee5ff; border-color: rgba(183,148,246,.75); background: rgba(91,33,182,.25); }
.config-entry {
  color: #2b1a04;
  border-color: #f7d778;
  background: linear-gradient(135deg, #c77a12, #f2c65b);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 5px 16px rgba(198,122,18,.16);
}
.config-entry:hover {
  color: #1f1202;
  border-color: #ffe59b;
  background: linear-gradient(135deg, #dc8d18, #ffda73);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 7px 20px rgba(225,151,28,.25);
}
.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); }
.position-harvest-button { color: #35101f; background: linear-gradient(135deg, #eb70a3, #ffb3cf); border-color: #ffd1e1; }
.position-harvest-button:hover { transform: translateY(-1px); filter: brightness(1.06); }
.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); }
.pending-button { color: #071914; background: linear-gradient(135deg, #31b78f, #76e6bd); border-color: #9af4d4; }
.pending-button:hover { transform: translateY(-1px); filter: brightness(1.06); }
.pending-button.small { padding: 7px 11px; font-size: 12px; }
.pending-outline { color: #75e6bd; background: rgba(49,183,143,.09); border-color: rgba(117,230,189,.58); }
.pending-outline:hover { color: white; background: rgba(49,183,143,.21); }
.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; }
.topbar-actions a { text-decoration: none; }
.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 .hero-copy { margin: 10px 0 0; color: var(--muted); }
.global-command-actions { display: grid; grid-template-columns: repeat(2, minmax(155px, 1fr)); gap: 10px; width: min(650px, 56vw); }
.global-command-actions.admin-plan-grid { grid-template-columns: repeat(2, minmax(155px, 1fr)); }
.global-command { min-width: 0; min-height: 52px; font-size: 15px; }
.global-harvest { min-height: 64px; padding-inline: 8px; font-size: 15px; }
.global-command-actions:not(.admin-plan-grid) .cancel-button { grid-column: 1 / -1; }
.plan-command-heading { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 5px; padding: 4px 2px 0; }
.plan-command-heading span { color: #e8c56f; font-size: 13px; font-weight: 900; letter-spacing: .08em; }
.plan-command-heading small { color: #707986; font-size: 10px; }
.plan-button { position: relative; min-height: 50px; color: #b7bdc7; background: #171b21; border-color: #343b46; box-shadow: inset 0 0 0 1px rgba(255,255,255,.015); }
.plan-button { caret-color: transparent; user-select: none; -webkit-user-select: none; }
.plan-button:hover { transform: translateY(-1px); color: #fff; filter: brightness(1.08); }
.plan-button.plan-a { color: #e8c56f; border-color: rgba(214,168,75,.48); background: rgba(214,168,75,.08); }
.plan-button.plan-b { color: #82c4ff; border-color: rgba(59,130,246,.52); background: rgba(37,99,235,.09); }
.plan-button.plan-c { color: #c4b5fd; border-color: rgba(139,92,246,.54); background: rgba(91,33,182,.1); }
.plan-button.plan-stop { color: #ff9696; border-color: rgba(239,68,68,.55); background: rgba(80,25,29,.2); }
.plan-button.is-active { color: #101318; border-color: rgba(255,255,255,.45); box-shadow: 0 0 0 2px rgba(255,255,255,.07), 0 8px 24px rgba(0,0,0,.28); }
.plan-button.plan-a.is-active { background: linear-gradient(135deg,#c39437,#f4cf74); }
.plan-button.plan-b.is-active { background: linear-gradient(135deg,#2f73d9,#7cc5ff); }
.plan-button.plan-c.is-active { background: linear-gradient(135deg,#7450d7,#c1a5ff); }
.plan-button.plan-stop.is-active { color:#fff; background: linear-gradient(135deg,#6f242a,#c13b44); }
.plan-button.is-busy::after { content:""; display:inline-block; width:12px; height:12px; margin-left:8px; border:2px solid currentColor; border-top-color:transparent; border-radius:50%; vertical-align:-2px; animation:install-spin .7s linear infinite; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 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; white-space: nowrap; }
.stat-card strong { color: var(--gold-light); font-size: 34px; }
.stat-card.online strong { color: #69de93; }
.stat-card.current-plan strong { font-size: 25px; white-space: nowrap; }
.stat-card.current-plan[data-plan="A"] strong { color: var(--gold-light); }
.stat-card.current-plan[data-plan="B"] strong { color: #79beff; }
.stat-card.current-plan[data-plan="C"] strong { color: #bda8ff; }
.stat-card.current-plan[data-plan="STOPPED"] strong { color: #ff7777; }
.stat-card.current-plan[data-plan="MIXED"] strong { color: #f2b84b; }

.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; }
.member-expiry-line { display: block; }
.expiry-badge { display: inline-flex; width: max-content; max-width: 100%; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: normal; }
.expiry-badge.active { color: #6cdd94; background: rgba(34,197,94,.1); }
.expiry-badge.expiring { color: #f2c55f; background: rgba(245,158,11,.12); }
.expiry-badge.expired { color: #ff8181; background: rgba(239,68,68,.12); }
.expiry-badge.unset { color: #89919d; background: rgba(107,114,128,.14); }
.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.positions { color: #ff9fc4; background: rgba(236,72,153,.13); }
.action-tag.cancel { color: #f6bd67; background: rgba(217,122,22,.14); }
.action-tag.pending { color: #75e6bd; background: rgba(49,183,143,.13); }
.action-tag.plan { color: #f4cf70; background: rgba(218,171,57,.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, .status-badge.queued_offline { color: #f2c55f; background: rgba(245,158,11,.11); }
.status-badge.superseded { color: #c4b5fd; background: rgba(139,92,246,.12); }
.status-badge.failed, .status-badge.busy, .status-badge.delivery_failed, .status-badge.result_unknown, .status-badge.command_expired, .status-badge.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 .pending-outline, .machine-actions .cancel-outline, .member-main .danger-outline, .member-main .pending-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; }
.independent-button { color: #7fd6ff; border: 1px solid rgba(54,178,231,.65); background: rgba(18,95,132,.18); }
.independent-button:hover { color: #d8f4ff; border-color: #42c5ff; background: rgba(19,126,174,.3); }
.independent-button.small { padding: 7px 11px; font-size: 12px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: rgba(3,5,7,.78); backdrop-filter: blur(9px) saturate(.82); }
.modal { width: min(560px, 100%); max-height: min(820px, calc(100vh - 48px)); overflow: auto; background: #1a1e23; border: 1px solid #3b444f; border-radius: 24px; box-shadow: 0 34px 120px rgba(0,0,0,.72), inset 0 1px 0 rgba(255,255,255,.025); }
.modal-backdrop:not(.hidden) .modal { animation: poison-modal-in .16s ease-out both; }
.modal-head { display: flex; align-items: center; justify-content: space-between; min-height: 82px; padding: 22px 28px; border-bottom: 1px solid #30363e; }
.modal-head h2 { margin: 0; color: #f4f5f7; font-size: 25px; font-weight: 900; letter-spacing: -.02em; }
.icon-button { width: 38px; height: 38px; border: 1px solid #343b45; border-radius: 11px; background: #252a31; color: #bbc1ca; font-size: 23px; }
.icon-button:hover { color: #fff; border-color: #59636f; background: #2d333b; }
.modal-body { display: grid; gap: 14px; padding: 26px 28px; color: #d8dce2; font-size: 15px; line-height: 1.72; }
.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: 12px; padding: 18px 28px 28px; }
.modal-actions button { min-width: 112px; min-height: 46px; border-radius: 12px; font-size: 15px; }
.modal.confirm-modal, .modal[data-confirm-mode="1"] { display: flex; width: min(700px, 100%); min-height: 330px; flex-direction: column; overflow: hidden; }
.confirm-modal .modal-head, .confirm-modal .modal-actions, .modal[data-confirm-mode="1"] .modal-head, .modal[data-confirm-mode="1"] .modal-actions { flex: 0 0 auto; }
.confirm-modal .modal-body, .modal[data-confirm-mode="1"] .modal-body { align-content: start; min-height: 0; overflow-y: auto; flex: 1; gap: 16px; padding-top: 29px; color: #cfd3d9; font-size: 18px; font-weight: 600; line-height: 1.7; }
.confirm-modal .modal-body .warning-copy, .modal[data-confirm-mode="1"] .modal-body .warning-copy { padding: 0; border: 0; background: transparent; color: #e5e8ed; font-weight: 900; }
.confirm-modal .modal-actions, .modal[data-confirm-mode="1"] .modal-actions { padding-top: 14px; }
.confirm-modal .modal-actions button, .modal[data-confirm-mode="1"] .modal-actions button { min-width: 128px; min-height: 58px; border-radius: 14px; font-size: 18px; }
.modal[data-confirm-mode="1"] .modal-head .icon-button { display: none; }
.ui-dialog-backdrop { z-index: 140; }
.ui-dialog-backdrop.ui-dialog-closing { background: transparent; backdrop-filter: none; }
.ui-dialog-backdrop.ui-dialog-closing .ui-dialog { visibility: hidden; }
.ui-dialog-body .ui-dialog-message { color: #cfd3d9; }
.ui-dialog-body .ui-dialog-detail { color: #aeb5bf; font-size: 15px; font-weight: 600; }
.ui-dialog-body .ui-dialog-emphasis { color: #e6e9ee; font-weight: 900; }
.ui-dialog-input-label { display: grid; gap: 8px; margin-top: 2px; }
.ui-dialog-input { min-height: 48px; }
.ui-dialog-error { margin: 0 28px 2px; }
body.ui-dialog-open { overflow: hidden; }
@keyframes poison-modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .modal-backdrop:not(.hidden) .modal { animation: none; } }
.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; }

.modal.command-settings-modal { width: min(820px, 100%); }
.command-settings-intro { display: grid; gap: 5px; padding: 14px 16px; border: 1px solid rgba(56,189,248,.3); border-radius: 12px; background: rgba(14,116,144,.09); }
.command-settings-intro strong { color: #b9e8ff; }
.command-settings-intro span { color: #9ba8b5; font-size: 12px; line-height: 1.7; }
.command-settings-table { display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.command-setting-row { display: grid; grid-template-columns: minmax(145px,1fr) minmax(220px,1.35fr) minmax(110px,.55fr) 68px; align-items: end; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); background: #14171c; }
.command-setting-row:last-child { border-bottom: 0; }
.command-setting-row label { display: grid; gap: 5px; color: #89929f; font-size: 10px; font-weight: 700; }
.command-setting-row select, .command-setting-row input { min-height: 40px; padding: 8px 10px; }
.command-setting-row input:disabled { color: #747c87; background: #171a1f; opacity: .7; }
.command-setting-name { align-self: center; display: grid; gap: 4px; }
.command-setting-name strong { color: #edf0f4; font-size: 13px; }
.command-setting-name span { color: #747d89; font-size: 10px; }
.command-setting-status { align-self: center; color: #6cdd94; font-size: 11px; text-align: right; white-space: nowrap; }
.command-setting-status.saving { color: #f2c55f; }
.command-setting-status.error { color: #ff8181; }
.command-setting-status.saved { color: #6cdd94; }
.command-settings-foot { display: flex; justify-content: space-between; gap: 18px; color: #7f8996; font-size: 11px; }

.modal.management-modal { width: min(760px, 100%); }
.modal.legal-documents-modal { width: min(1040px, 100%); }
.modal.mt5-accounts-modal { width: min(780px, 100%); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid > label, .document-editor label, .mt5-single-grid label { display: grid; gap: 6px; }
.management-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid rgba(139,92,246,.3); border-radius: 12px; background: rgba(91,33,182,.09); }
.management-toolbar > div { display: grid; gap: 3px; }
.management-toolbar span { color: #9ba3ae; font-size: 12px; }
.management-list { display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.management-row { display: grid; grid-template-columns: minmax(180px,1fr) auto auto; align-items: center; gap: 14px; padding: 13px 15px; border-bottom: 1px solid var(--line); background: #14171c; }
.management-row:last-child { border-bottom: 0; }
.management-identity { display: grid; gap: 3px; }
.management-identity span { color: var(--muted); font-size: 11px; }
.role-badge { padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.role-badge.admin { color: #9bdcff; background: rgba(14,116,144,.16); }
.role-badge.superadmin { color: #d9c5ff; background: rgba(91,33,182,.2); }
.legal-document-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.legal-document-grid > .form-error { grid-column: 1 / -1; }
.document-editor { display: grid; gap: 10px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #14171c; }
.document-editor > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.document-editor > div span { color: var(--muted); font-size: 10px; }
.document-editor textarea { min-height: 260px; resize: vertical; line-height: 1.65; }
.mt5-section { display: grid; gap: 10px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #14171c; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading span { color: var(--muted); font-size: 11px; }
.mt5-single-grid { display: grid; grid-template-columns: minmax(130px,.8fr) minmax(180px,1.2fr) auto; align-items: end; gap: 10px; }
.mt5-single-grid button { min-height: 45px; }
.mt5-account-list { display: grid; overflow: hidden; border: 1px solid #292e36; border-radius: 10px; }
.mt5-account-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 11px 13px; border-bottom: 1px solid #292e36; background: #101318; }
.mt5-account-row:last-child { border-bottom: 0; }
.mt5-account-row > div { display: grid; gap: 2px; }
.mt5-account-row span { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.mt5-account-row.is-hidden { background:#0d1014; opacity:.84; }
.mt5-row-actions { display:flex !important; grid-auto-flow:column; align-items:center; gap:10px !important; }
.permission-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; margin-top:12px; }
.permission-option { display:flex !important; grid-template-columns:none !important; align-items:center; gap:10px !important; min-height:46px; padding:10px 12px; border:1px solid var(--line); border-radius:10px; background:#14171c; cursor:pointer; }
.permission-option input { width:18px; height:18px; margin:0; accent-color:var(--gold); }
.permission-option span { color:#d7dbe2; font-weight:800; }

.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, .global-command-actions.admin-plan-grid { 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; }
  .command-setting-row { grid-template-columns: minmax(130px,.8fr) minmax(210px,1.2fr) minmax(95px,.5fr); }
  .command-setting-status { grid-column: 1 / -1; text-align: right; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar-actions { width: 100%; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
  .topbar #logout-button { position: absolute; top: 15px; right: 14px; }
  .topbar-actions .config-entry, .topbar-actions .strategy-entry, .topbar-actions .independent-entry, .topbar-actions .settings-entry, .topbar-actions .management-entry { padding-inline: 7px; font-size: 11px; }
  .legal-document-grid { grid-template-columns: 1fr; }
  .command-setting-row { grid-template-columns: 1fr; align-items: stretch; gap: 9px; }
  .command-setting-status { grid-column: auto; text-align: left; }
  .command-settings-foot { flex-direction: column; gap: 5px; }
}

@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 { flex-wrap: wrap; gap: 8px; }
  .topbar-brand strong { font-size: 13px; }
  .topbar-actions { gap: 5px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .topbar-actions .config-entry, .topbar-actions .strategy-entry, .topbar-actions .independent-entry, .topbar-actions .settings-entry, .topbar-actions .management-entry { padding-inline: 7px; font-size: 11px; }
  .connection-pill { padding: 6px 8px; font-size: 10px; }
  .hero-row h1 { font-size: 28px; }
  .hero-row .hero-copy { font-size: 13px; }
  .global-command-actions:not(.admin-plan-grid) { grid-template-columns: 1fr 1fr; }
  .global-command-actions.admin-plan-grid { grid-template-columns: 1fr 1fr; }
  .plan-button { min-height: 48px; padding-inline: 8px; font-size: 13px; }
  .plan-command-heading small { display: none; }
  .stats-grid { gap: 5px; }
  .stat-card { min-width: 0; min-height: 70px; padding: 11px 7px; border-radius: 12px; }
  .stat-card span { font-size: 10px; }
  .stat-card strong, .stat-card.current-plan strong { max-width: 100%; font-size: 21px; overflow: hidden; text-overflow: ellipsis; }
  .stat-card.current-plan strong { font-size: 18px; }
  .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: center; padding: 12px; }
  .modal { width: 100%; max-height: 92svh; border-radius: 20px; }
  .modal-head { min-height: 68px; padding: 18px 20px; }
  .modal-head h2 { font-size: 21px; }
  .modal-body { padding: 21px 20px; }
  .modal-actions { position: sticky; bottom: 0; padding: 14px 20px 20px; background: #1a1e23; }
  .modal.confirm-modal, .modal[data-confirm-mode="1"] { min-height: min(330px, calc(100svh - 24px)); }
  .confirm-modal .modal-body, .modal[data-confirm-mode="1"] .modal-body { font-size: 16px; }
  .confirm-modal .modal-actions button, .modal[data-confirm-mode="1"] .modal-actions button { min-width: 0; flex: 1; }
  .command-setting-row { grid-template-columns: 1fr; align-items: stretch; gap: 9px; }
  .command-setting-status { grid-column: auto; text-align: left; }
  .command-settings-foot { flex-direction: column; gap: 5px; }
  .form-grid, .mt5-single-grid { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns:1fr; }
  .management-toolbar { align-items: stretch; flex-direction: column; }
  .management-row { grid-template-columns: 1fr auto; }
  .management-row > .inline-actions { grid-column: 1 / -1; }
}
