:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  background: #090b10;
  color: #f4f6fa;
  --panel: #141820;
  --muted: #9199a8;
  --line: #282e39;
  --green: #53d27a;
  --blue: #4b95ff;
  --danger: #ec6a5c;
}
* { box-sizing: border-box; min-width: 0; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top, #17202d 0, #090b10 42%); }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
.shell { width: min(920px, 100%); margin: auto; padding: max(20px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom)); }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
h1 { margin: 2px 0 0; font-size: clamp(25px, 6vw, 38px); }
h2 { margin: 0 0 10px; font-size: 18px; }
p { color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
.panel { background: #141820; background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 14px 40px #0005; }
.login { padding: 20px; }
label { display: block; margin-bottom: 8px; color: #cdd3de; font-size: 13px; }
.login-row { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)) auto; gap: 8px; }
input { min-width: 0; flex: 1; padding: 13px 14px; color: #fff; background: #090c12; border: 1px solid #343b49; border-radius: 10px; outline: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #4b95ff22; }
button { min-height: 42px; padding: 9px 13px; color: #f3f6fa; background: #262c37; border: 1px solid #343b48; border-radius: 10px; }
button:active { transform: translateY(1px); }
.primary { color: #07120a; background: var(--green); border-color: var(--green); font-weight: 750; }
.secondary { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.text-button { min-height: 30px; padding: 4px 8px; color: var(--muted); background: transparent; border: 0; }
.state { flex: none; padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.state.offline { color: #b6bdc9; background: #262b34; }
.state.connecting { color: #cfe2ff; background: #234975; }
.state.online { color: #bdf5cc; background: #174b2a; }
.error { min-height: 20px; margin: 8px 0 0; color: #ff8e84; font-size: 13px; }
.hidden { display: none !important; }
.summary-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.summary-row > div { display: flex; align-items: baseline; gap: 7px; margin-right: auto; }
.summary-row span { font-size: 26px; font-weight: 800; }
small { color: var(--muted); }
.device-list { display: grid; gap: 14px; }
.daily-plan-panel { margin-bottom: 14px; padding: 16px; }
.global-control-panel, .global-monitor-panel { margin-bottom: 14px; padding: 16px; }
.risk-badge { padding: 5px 8px; color: #ffd8d4; background: #562521; border-radius: 999px; font-size: 11px; font-weight: 700; }
.global-control-row { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; align-items: end; gap: 8px; }
.global-control-row label { margin: 0; }
.global-control-row select, .plan-settings input, .plan-settings select { display: block; width: 100%; margin-top: 4px; padding: 10px; color: #f3f6fa; background: #090c12; border: 1px solid #343b48; border-radius: 9px; }
.daily-plan-panel h2 { margin: 3px 0 0; }
.plan-subtitle { margin: 14px 0 6px; color: #eef3f9; font-size: 14px; }
.daily-plan-panel .section-title > div { min-width: 0; }
.daily-plan-panel .automation-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.plan-progress { height: 8px; overflow: hidden; background: #090c12; border: 1px solid var(--line); border-radius: 999px; }
.plan-progress span { display: block; width: 0; height: 100%; background: var(--green); transition: width .25s ease; }
.plan-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.plan-settings label { margin: 0; }
.plan-settings .span-2 { grid-column: span 2; }
.quick-account-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 8px; margin: 12px 0; padding: 11px; background: #0d1118; border: 1px solid var(--line); border-radius: 10px; }
.quick-account-actions label { margin: 0; }
.quick-account-actions input, .quick-account-actions select { display: block; width: 100%; margin-top: 4px; padding: 10px; color: #f3f6fa; background: #090c12; border: 1px solid #343b48; border-radius: 9px; }
.quick-account-actions button { width: 100%; }
.quick-auction-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(150px, .7fr) minmax(220px, 1fr); align-items: end; gap: 8px; margin: 12px 0; }
.quick-auction-row label { margin: 0; }
.quick-auction-row input, .quick-auction-row select { display: block; width: 100%; margin-top: 4px; padding: 10px; color: #f3f6fa; background: #090c12; border: 1px solid #343b48; border-radius: 9px; }
.quick-auction-row button { width: 100%; }
.daily-plan-panel .automation-actions small { align-self: center; }
.plan-intervention { margin-top: 10px; padding: 10px; color: #ffe1aa; background: #422d0c; border: 1px solid #9d7027; border-radius: 9px; font-size: 13px; }
.resume-confirmation { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; align-items: end; gap: 10px; margin-top: 12px; padding: 12px; background: #172033; border: 1px solid #3b5c8c; border-radius: 10px; }
.resume-confirmation label { margin: 0; }
.resume-confirmation select { display: block; width: 100%; margin-top: 4px; padding: 10px; color: #fff; background: #090c12; border: 1px solid #486b9d; border-radius: 9px; }
.resume-confirmation small { padding-bottom: 9px; line-height: 1.5; }
.plan-quick-tools { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.plan-quick-tools > summary { cursor: pointer; font-weight: 700; }
.plan-quick-tools[open] > summary { margin-bottom: 10px; }
.plan-quick-tools .quick-account-actions { margin: 0; }
.device-card { padding: 16px; }
.device-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.device-heading > div { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 8px; }
.device-heading small { grid-column: 2; margin-top: 3px; }
.online-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; box-shadow: 0 0 10px var(--green); }
.last-update { color: var(--muted); font-size: 11px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; }
.metrics > div { display: flex; flex-direction: column; gap: 5px; padding: 11px; background: #0d1118; border-radius: 10px; }
.metrics strong { font-size: 17px; }
.account-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 10px; }
.account-tabs button { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-tabs button.active { color: #07120a; background: var(--green); border-color: var(--green); font-weight: 750; }
.account-tabs button.offline { color: #ffd8d4; background: #562521; border-color: var(--danger); }
.account-tabs button.offline.active { color: #fff; background: #b94438; border-color: #ff8276; }
.account-tabs button.healthy:not(.active) { border-color: #2e7650; }
.button-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; margin-bottom: 10px; }
.button-grid button { min-width: 0; overflow-wrap: anywhere; }
.danger-action { color: #ffd8d4; border-color: #8f4038; }
.daily-monitor-panel { margin: 12px 0; padding: 12px; background: #0d1118; border: 1px solid var(--line); border-radius: 12px; }
.daily-monitor-panel .section-title { align-items: baseline; gap: 8px; }
.daily-monitor-list { display: grid; gap: 7px; margin-top: 10px; }
.daily-monitor-row { display: grid; grid-template-columns: minmax(62px, .7fr) minmax(130px, 1fr) minmax(240px, 3fr) minmax(250px, auto); align-items: center; gap: 8px; padding: 9px; background: #111722; border-radius: 9px; }
.daily-monitor-row small { overflow-wrap: anywhere; }
.daily-status-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.daily-status-actions .compact { padding: 8px 10px; white-space: nowrap; }
.daily-ok { color: var(--green); }
.daily-pending { color: #f0bd66; }
.preview-panel { margin: 12px 0; padding: 12px; background: #0d1118; border: 1px solid var(--line); border-radius: 12px; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.preview-heading > div:first-child { display: flex; flex-direction: column; gap: 3px; }
.preview-actions { display: flex; min-width: 0; align-items: end; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.preview-actions label { display: flex; flex-direction: column; gap: 3px; margin: 0; font-size: 11px; }
.preview-resolution { min-height: 34px; padding: 5px 8px; color: #f3f6fa; background: #262c37; border: 1px solid #343b48; border-radius: 8px; }
.preview-heading button { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.preview-stage { display: grid; place-items: center; width: 100%; max-width: 100%; min-height: 220px; overflow: hidden; background: #030507; border-radius: 9px; }
.preview-stage.portrait { height: min(78vh, 960px); }
.preview-stage.landscape { min-height: 220px; aspect-ratio: var(--frame-ratio, 16 / 9); }
.preview-stage > * { grid-area: 1 / 1; }
.preview-placeholder { padding: 20px; text-align: center; font-size: 13px; }
.preview-image { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
.preview-help { margin: 8px 0 0; font-size: 11px; }
.preview-gesture-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.preview-gesture-actions button { min-height: 36px; padding: 6px; }
.automation-panel { margin: 0 0 10px; padding: 11px; background: #0d1118; border: 1px solid var(--line); border-radius: 12px; }
.automation-panel > summary { cursor: pointer; color: #eef3f9; font-weight: 750; }
.automation-panel[open] > summary { margin-bottom: 12px; }
.automation-panel .section-title > div { display: flex; flex-direction: column; gap: 3px; }
.automation-title { gap: 12px; }
.automation-title .save-automation { min-width: 132px; }
.automation-confirmation { margin-top: 11px; padding: 12px; background: #17321f; border: 1px solid #2d7848; border-radius: 10px; }
.automation-confirmation p { margin: 0; color: #d8f8df; font-size: 13px; }
.automation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 11px; }
.automation-grid label { margin: 0; }
.automation-grid input:not([type="checkbox"]), .automation-grid select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; color: #f3f6fa; background: #080b11; border: 1px solid #343b48; border-radius: 8px; }
.automation-grid .span-2 { grid-column: span 2; }
.automation-group, .equipment-transfer { margin: 12px 0 0; padding: 11px; border: 1px solid #2b3340; border-radius: 10px; background: #10151e; }
.automation-group legend, .equipment-transfer legend { padding: 0 7px; color: #eef3f9; font-weight: 700; }
.group-index { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 3px; color: #07120a; background: var(--green); border-radius: 50%; font-size: 12px; }
.group-help { margin: 2px 0 0; font-size: 11px; }
.toggle-row { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 10px; background: #111722; border: 1px solid #2b3340; border-radius: 9px; }
.toggle-row input { flex: none; width: 18px; height: 18px; margin: 0; }
.automation-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.action-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.action-grid.two-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.action-grid button { width: 100%; min-width: 0; }
.automation-help { margin: 8px 0 0; font-size: 11px; }
.device-note { min-height: 20px; margin: 11px 0 0; font-size: 12px; }
.log-panel { margin-top: 14px; padding: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; }
.event-log { margin: 0; padding: 0; list-style: none; max-height: 220px; overflow: auto; }
.event-log li { padding: 8px 0; color: #c8ced8; border-top: 1px solid var(--line); font-size: 12px; }
.event-log time { margin-right: 8px; color: var(--muted); }
.select-overlay { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); background: #000b; }
.select-dialog { width: min(620px, 100%); max-height: 88vh; padding: 18px; overflow: hidden; }
.select-dialog .section-title { align-items: flex-start; }
.select-dialog h2 { margin-top: 4px; }
.select-account { margin: 4px 0 10px; font-size: 13px; }
.select-options { max-height: 68vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.select-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 52px; padding: 10px 14px; text-align: left; background: #121720; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.select-option:last-child { border-bottom: 0; }
.select-option.selected { color: #07120a; background: var(--green); font-weight: 750; }
.select-option:disabled { opacity: .45; cursor: not-allowed; }
.select-mark { flex: none; width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 50%; }
.select-option.selected .select-mark { border-width: 5px; }
.operation-feedback { padding: 12px 16px; margin-bottom: 16px; border: 1px solid #52647d; border-radius: 12px; overflow-wrap: anywhere; }
.operation-feedback[data-kind="pending"] { border-color: #70b7ff; }
.operation-feedback[data-kind="warning"], .equipment-checks { border-color: #e4b658; }
.operation-feedback[data-kind="error"] { border-color: #ff8080; }
.equipment-checks > div + div { border-top: 1px solid #52647d; margin-top: 16px; padding-top: 16px; }
.equipment-checks p, .single-transfer-panel p { overflow-wrap: anywhere; }
.equipment-checks, .single-transfer-panel { padding: 18px; margin-bottom: 18px; }
.equipment-checks button { white-space: normal; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #94cbff; outline-offset: 3px; }
@media (max-width: 650px) {
  .shell { padding-right: 10px; padding-left: 10px; }
  header { align-items: flex-start; margin-bottom: 14px; }
  .device-card { padding: 10px; }
  .device-heading { align-items: center; }
  .device-heading strong { overflow-wrap: anywhere; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .account-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .global-control-row, .plan-settings, .quick-account-actions, .quick-auction-row { grid-template-columns: 1fr; }
  .resume-confirmation { grid-template-columns: 1fr; align-items: stretch; }
  .resume-confirmation small { padding-bottom: 0; }
  .plan-settings .span-2 { grid-column: span 1; }
  .button-grid { grid-template-columns: repeat(3, 1fr); }
  .daily-monitor-row { grid-template-columns: 1fr 1.4fr; }
  .daily-monitor-row small { grid-column: 1 / -1; grid-row: 2; }
  .daily-status-actions { grid-column: 1 / -1; justify-content: stretch; }
  .daily-status-actions button { flex: 1 1 120px; }
  .login-row { grid-template-columns: 1fr; }
  .preview-heading { align-items: flex-start; flex-direction: column; }
  .preview-actions { width: 100%; flex-wrap: wrap; }
  .preview-actions label { flex: 1 1 130px; }
  .preview-actions button { flex: 1 1 82px; }
  .preview-stage.portrait { height: min(72vh, 760px); }
  .automation-grid { grid-template-columns: 1fr; }
  .automation-grid .span-2 { grid-column: span 1; }
  .automation-title { align-items: stretch; flex-direction: column; }
  .automation-title .save-automation { width: 100%; }
  .automation-actions, .action-grid, .action-grid.two-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .automation-actions button { min-width: 0; padding-right: 6px; padding-left: 6px; }
}
@media (min-width: 651px) and (max-width: 900px) {
  .quick-auction-row { grid-template-columns: 1fr; }
  .daily-monitor-row { grid-template-columns: minmax(62px, .7fr) minmax(110px, 1fr); }
  .daily-monitor-row small, .daily-status-actions { grid-column: 1 / -1; }
  .global-control-row { grid-template-columns: 1fr 1fr; }
  .global-control-row label { grid-column: 1 / -1; }
}
@media (max-width: 390px) {
  .button-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics > div { padding: 9px; }
  .metrics strong { font-size: 15px; }
  .preview-actions label { flex-basis: 100%; }
  .action-grid, .action-grid.two-actions { grid-template-columns: 1fr; }
}
