:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: #18212f;
  background: #f7f9fc;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }


.main { padding: 34px 42px; max-width: 1400px; min-width: 0; margin: 0 auto; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 28px; }
.topbar h1 { font-size: 27px; margin: 0 0 7px; }
.subtle { color: #6c7788; margin: 0; }
.line-height { line-height: 1.7; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 16px; }
.card, .panel { background: #fff; border: 1px solid #e3e9f2; border-radius: 13px; box-shadow: 0 5px 18px rgba(45, 65, 95, .055); }
.card { padding: 20px; }
.card-label { color: #738094; font-size: 13px; }
.card-value { font-size: 29px; font-weight: 750; margin-top: 9px; }
.gateway-card { margin-top: 20px; padding: 22px; background: #fff; border: 1px solid #dfe6f0; border-radius: 16px; box-shadow: 0 7px 24px rgba(45,65,95,.07); }
.gateway-head { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.gateway-head h2 { display:inline; margin:0 12px 0 0; font-size:20px; }
.gateway-badge { display:inline-flex; padding:6px 11px; border-radius:99px; background:#eef4ff; color:#315db8; font-size:13px; font-weight:650; }
.icon-btn { border:1px solid #dfe6f0; background:#fff; color:#315db8; border-radius:8px; padding:8px 10px; cursor:pointer; }
.gateway-code-section { margin-top:20px; }
.gateway-code-head { display:flex; align-items:center; justify-content:space-between; gap:12px; color:#34445d; }
.gateway-code { margin:9px 0 0; padding:14px 16px; border:1px solid #e1e7ef; border-radius:10px; background:#f7f9fc; color:#1e2b43; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; font:13px/1.65 ui-monospace,SFMono-Regular,Menlo,monospace; }
.gateway-code.command { background:#f7f9fc; border-color:#e1e7ef; color:#1e2b43; }
.gateway-hint { display:block; margin-top:8px; color:#8794a6; }
.panel { margin-top: 20px; padding: 20px; overflow-x: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.panel h2 { font-size: 17px; margin: 0; }
.panel-description { margin-top: 6px; }
.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.select-all { color: #66758a; font-size: 13px; white-space: nowrap; }

.btn { border: 0; border-radius: 8px; padding: 9px 14px; background: #2463eb; color: #fff; font-weight: 650; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #174fca; }
.btn.secondary { background: #f1f4f8; color: #34445d; border: 1px solid #e1e7ef; }
.btn.danger { background: #fff1f1; color: #c53030; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.refresh-button { min-width: 96px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.button-spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: button-spin .7s linear infinite; }
@keyframes button-spin { to { transform: rotate(360deg); } }
.input { border: 1px solid #d9dfe8; border-radius: 8px; padding: 9px 11px; background: #fff; min-width: 180px; }
.input:focus { outline: 2px solid #bed1ff; border-color: #5e8df5; }

table { width: 100%; border-collapse: collapse; min-width: 700px; }
th { text-align: left; font-size: 12px; color: #7b8798; font-weight: 650; padding: 10px; border-bottom: 1px solid #e7ebf1; }
td { padding: 13px 10px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 99px; background: #eaf8ef; color: #19723a; font-size: 12px; font-weight: 650; }
.status.off { background: #f1f3f6; color: #707b8b; }
.status.error { background: #fff0f0; color: #c53030; }
.progress { height: 7px; background: #edf0f4; border-radius: 99px; overflow: hidden; min-width: 90px; }
.progress i { display: block; height: 100%; background: #3978ef; border-radius: 99px; }
.empty { text-align: center; color: #7a8697; padding: 35px; }

.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.account-card { min-width: 0; padding: 20px; border: 1px solid #dfe6f0; border-radius: 16px; background: linear-gradient(160deg, #fff, #fbfcff); box-shadow: 0 7px 24px rgba(45, 65, 95, .07); }
.account-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.account-title { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.account-title span { display: grid; min-width: 0; gap: 4px; }
.account-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.account-title small { color: #8794a6; }
.account-warning { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 5px; border-radius: 50%; background: #f59e0b; color: #fff; font-size: 11px; font-weight: 800; line-height: 1; cursor: help; vertical-align: -1px; }
.quota { margin-top: 15px; }
.quota-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.quota-head strong { font-size: 15px; }
.quota-head b { color: #0891a2; font-size: 15px; }
.quota .progress { height: 9px; }
.quota .progress i { background: #b7e8df; }
.quota.low .quota-head b { color: #d97706; }
.quota.low .progress i { background: #f6c27a; }
.quota small { display: block; margin-top: 6px; color: #8b99ad; }
.subscription-meta { margin-top: 13px; color: #8794a6; font-size: 12px; }
.subscription-meta strong { color: #66758a; font-weight: 550; }
.account-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid #edf0f4; }
.icon-action { display: inline-grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid #e1e8f1; border-radius: 11px; background: #f1f5f9; color: #465a75; cursor: pointer; transition: background .15s, color .15s, transform .15s; }
.icon-action:hover { background: #e6eef8; color: #2456b6; transform: translateY(-1px); }
.icon-action svg { width: 20px; height: 20px; }
.icon-action.danger { background: #fff1f1; border-color: #ffe0e0; color: #c53030; }
.icon-action.danger:hover { background: #ffe3e3; color: #a52222; }

.login-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(145deg, #eef3ff, #f8fafc); }
.login-card { width: min(410px, calc(100vw - 36px)); background: #fff; border: 1px solid #e1e6ee; border-radius: 16px; padding: 34px; box-shadow: 0 18px 60px rgba(32, 49, 76, .12); }
.login-card h1 { margin: 0 0 8px; }
.login-card .input { width: 100%; margin: 20px 0 12px; }
.login-card .btn { width: 100%; }
.error { color: #c53030; min-height: 20px; margin-top: 12px; }

.modal { position: fixed; inset: 0; background: rgba(20, 30, 48, .48); display: none; place-items: center; padding: 20px; z-index: 20; }
.modal.open { display: grid; }
.modal-card { width: min(520px, 100%); background: #fff; border: 1px solid #dfe6f0; border-radius: 18px; padding: 28px; box-shadow: 0 24px 80px rgba(15, 28, 52, .24); }
.modal-card.modal-wide { width: min(920px, 100%); max-height: min(900px, calc(100vh - 36px)); overflow: auto; padding: 0; border-radius: 24px; }
.modal-card.modal-wide > .modal-content { padding: 0; }
.modal-card.modal-wide > .modal-close { display: none; }
.wakeup-modal, .wakeup-results { min-height: 560px; display: flex; flex-direction: column; }
.wakeup-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 30px 34px 24px; border-bottom: 1px solid #e6ebf1; }
.wakeup-heading h2 { margin: 0; font-size: 26px; }
.wakeup-heading p { margin: 7px 0 0; }
.modal-x { border: 0; background: transparent; color: #53637a; font-size: 32px; line-height: 1; cursor: pointer; padding: 0 2px; }
.wakeup-section { padding: 26px 34px 22px; }
.wakeup-selection-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.wakeup-selection-toolbar .input { flex: 1; min-width: 0; }
.wakeup-selection-toolbar label { white-space: nowrap; color: #66758a; }
.wakeup-section h3 { margin: 0 0 14px; font-size: 17px; }
.wakeup-account-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-height: 260px; overflow: auto; }
.wakeup-account { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 16px; border: 1px solid #dfe6f0; border-radius: 14px; cursor: pointer; }
.wakeup-account.unavailable { opacity: .58; cursor: not-allowed; background: #f8fafc; }
.wakeup-account:has(input:checked) { border-color: #8eb2ff; background: #f3f7ff; }
.wakeup-account[hidden] { display: none; }
.wakeup-account input { width: 18px; height: 18px; accent-color: #2463eb; flex: 0 0 auto; }
.wakeup-account span { display: grid; gap: 4px; min-width: 0; }
.wakeup-account strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wakeup-account small { color: #8b99ad; }
.wakeup-account b { margin-left: auto; color: #2b67d1; font-size: 12px; white-space: nowrap; }
.wakeup-fields { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.wakeup-fields label, .wakeup-prompt { display: grid; gap: 7px; color: #66758a; font-size: 13px; }
.wakeup-fields select, .wakeup-prompt textarea { width: 100%; border: 1px solid #cad5e4; border-radius: 11px; padding: 12px; color: #24334c; background: #f8faff; font: inherit; }
.wakeup-prompt { margin-top: 14px; }
.wakeup-prompt textarea { resize: vertical; min-height: 76px; }
.wakeup-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 12px; margin-top: auto; padding: 22px 34px 28px; background: #f2f6fa; border-top: 1px solid #e3eaf2; }
.wakeup-progress { height: 8px; margin: 24px 34px 0; border-radius: 99px; background: #eaf0f6; overflow: hidden; }
.wakeup-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2864eb, #12b6a3); transition: width .3s; }
.wakeup-counts { margin: 18px 34px 0; font-size: 14px; color: #53637a; line-height: 1.8; }
.wakeup-result-list { display: grid; gap: 12px; padding: 22px 34px 32px; overflow: auto; }
.wakeup-result { display: grid; gap: 12px; padding: 18px 20px; border: 1px solid #dfe6f0; border-radius: 14px; background: #fbfdff; overflow-wrap: anywhere; }
.wakeup-result.running { border-color: #8eb2ff; background: #f3f7ff; }
.wakeup-result.success { border-color: #a9edc9; background: #f5fffa; }
.wakeup-result.failure { border-color: #ffc5c5; background: #fff8f8; }
.wakeup-result .wakeup-result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.wakeup-result p { white-space: pre-wrap; margin: 0; color: #24334c; }
.wakeup-result small { color: #8b99ad; }
.wakeup-result > span { max-width: 60%; color: #53637a; text-align: right; overflow-wrap: anywhere; }
.modal-card h2 { margin: 0 0 10px; font-size: 20px; }
.modal-card .modal-close { margin-top: 18px; min-width: 88px; }
.code { font: 700 24px ui-monospace, monospace; letter-spacing: .08em; padding: 15px; background: #f3f6fa; border-radius: 9px; margin: 15px 0; word-break: break-all; }
.notice { position: fixed; top: 18px; right: 24px; z-index: 30; max-width: min(420px, calc(100vw - 36px)); padding: 12px 14px; border: 1px solid #d5e2fa; border-radius: 9px; background: #eef4ff; color: #284e91; box-shadow: 0 10px 28px rgba(45, 65, 95, .14); visibility: hidden; opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity .16s ease, transform .16s ease, visibility .16s ease; }
.notice.show { visibility: visible; opacity: 1; transform: translateY(0); pointer-events: auto; }

@media (max-width: 900px) {
  .main { padding: 24px 18px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; }
  .topbar .toolbar { width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .input { width: 100%; min-width: 0 !important; }
  .toolbar .btn { flex: 1; }
  .panel { padding: 16px; }
  .wakeup-account-list, .wakeup-fields { grid-template-columns: 1fr; }
  .wakeup-heading, .wakeup-section { padding-left: 20px; padding-right: 20px; }
  .wakeup-footer { padding-left: 20px; padding-right: 20px; }
  .wakeup-progress { margin-left: 20px; margin-right: 20px; }
  .wakeup-result-list { padding-left: 20px; padding-right: 20px; }
  .wakeup-result { display: grid; }
  .wakeup-result > span { max-width: 100%; text-align: left; }
}

.gateway-head { flex-wrap:wrap; }
.gateway-head-actions { display:flex; align-items:center; gap:32px; margin-left:auto; }
.strategy-switch { display:inline-flex; gap:3px; min-width:0; margin:0; padding:4px; border:1px solid #e8edf4; border-radius:999px; background:#f1f4f8; }
.strategy-switch label { position:relative; cursor:pointer; }
.strategy-switch input { position:absolute; width:1px; height:1px; opacity:0; }
.strategy-switch span { display:block; padding:8px 17px; border-radius:999px; color:#7b8799; font-size:13px; line-height:20px; font-weight:600; white-space:nowrap; transition:background .15s,color .15s,box-shadow .15s; }
.strategy-switch label:hover span { color:#34445d; background:rgba(255,255,255,.5); }
.strategy-switch input:checked + span { color:#2563eb; background:#fff; box-shadow:0 1px 4px rgba(35,55,85,.12); }
.strategy-switch input:focus-visible + span { outline:2px solid #93b4fa; outline-offset:1px; }
.strategy-switch:disabled { opacity:.55; }
.strategy-switch:disabled label { cursor:wait; }
@media (max-width:560px) {
  .gateway-head-actions { gap:20px; }
  .strategy-switch span { padding:7px 13px; }
}
.water-level { display:grid; gap:5px; margin-top:14px; padding:10px 12px; border-radius:9px; background:#f3f7ff; }
.water-level strong { font-size:13px; color:#315db8; }
.water-level small { font-size:12px; color:#738094; }
