:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(14, 27, 45, .86);
  --panel-2: rgba(21, 39, 62, .86);
  --line: rgba(153, 192, 229, .16);
  --text: #f4f8fc;
  --muted: #94a9bd;
  --cyan: #57d9ff;
  --blue: #2c73ff;
  --green: #4ee2a0;
  --amber: #ffcb66;
  --red: #ff6f7d;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--text); background:
    radial-gradient(circle at 30% -10%, #14325a 0, transparent 42%),
    linear-gradient(160deg, #050b13 0%, var(--bg) 58%, #091a2b 100%);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.ambient { position: fixed; width: 280px; height: 280px; filter: blur(80px); opacity: .16; border-radius: 50%; pointer-events: none; }
.ambient-a { background: var(--blue); top: 7%; right: -120px; }
.ambient-b { background: #00d5ad; bottom: -140px; left: -100px; }
.shell { width: min(100%, 780px); margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 18px max(40px, env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
.auth-card, .panel, .status-strip {
  border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(20px);
  border-radius: 22px; box-shadow: 0 24px 80px rgba(0,0,0,.28);
}
.auth-card { max-width: 430px; margin: 8vh auto 0; padding: 34px 28px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; font-weight: 900; font-size: 22px; background: linear-gradient(145deg, var(--cyan), var(--blue)); color: #00101c; box-shadow: 0 8px 32px rgba(44,115,255,.35); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(27px, 6vw, 38px); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -.02em; }
.eyebrow { margin-bottom: 7px; font-size: 10px; letter-spacing: .18em; color: var(--cyan); font-weight: 800; }
.muted, footer, .task-time, .status-strip p { color: var(--muted); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 2px 20px; }
.topbar h1 { margin: 0; }
.panel { margin-top: 16px; padding: 20px; }
.create-panel { background: linear-gradient(145deg, rgba(18,39,65,.94), rgba(9,24,41,.94)); }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.badge, .state-pill { flex: 0 0 auto; white-space: nowrap; border: 1px solid var(--line); padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; color: var(--cyan); background: rgba(87,217,255,.07); }
.stack { display: grid; gap: 15px; }
label { display: grid; gap: 8px; color: #c8d6e4; font-size: 13px; font-weight: 650; }
input, textarea {
  width: 100%; border: 1px solid rgba(154,188,220,.2); outline: none; border-radius: 13px;
  padding: 13px 14px; color: var(--text); background: rgba(4,13,23,.64); transition: border-color .2s, box-shadow .2s;
  font-size: 16px;
}
textarea { resize: vertical; min-height: 92px; }
input:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(87,217,255,.12); }
.money-input { position: relative; }
.money-input span { position: absolute; left: 14px; top: 12px; color: var(--cyan); font-weight: 800; }
.money-input input { padding-left: 32px; }
.primary, .danger, .ghost {
  border: 0; border-radius: 13px; padding: 13px 16px; font-weight: 800; color: white;
}
.primary { background: linear-gradient(135deg, #2585ff, #2b5eff); box-shadow: 0 8px 24px rgba(35,102,255,.23); }
.danger { background: linear-gradient(135deg, #ff776d, #ef4562); }
.ghost { background: rgba(143,173,205,.10); border: 1px solid var(--line); color: #dce9f5; }
.small { padding: 9px 12px; border-radius: 10px; font-size: 12px; }
button:disabled { cursor: not-allowed; opacity: .5; }
.error-text { color: var(--red); font-size: 13px; margin: 10px 0 0; min-height: 1em; }
.device-pair-copy { margin: 0; font-size: 13px; line-height: 1.65; }
.status-strip { display: flex; align-items: center; gap: 12px; padding: 15px 17px; }
.status-strip strong { display: block; font-size: 13px; }
.status-strip p { margin: 3px 0 0; font-size: 11px; }
.status-dot { flex: 0 0 auto; width: 11px; height: 11px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 5px rgba(255,203,102,.08); }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 5px rgba(78,226,160,.09); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 0 5px rgba(255,111,125,.08); }
.banner { margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; font-size: 12px; }
.banner.warning { color: #ffe6ad; border: 1px solid rgba(255,203,102,.24); background: rgba(255,174,44,.09); }
.task-list { display: grid; gap: 12px; }
.task-card { background: rgba(5,16,28,.58); border: 1px solid var(--line); border-radius: 17px; padding: 16px; }
.task-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-head > div { min-width: 0; }
.task-user { font-size: 16px; font-weight: 850; word-break: break-all; }
.task-time { overflow-wrap: anywhere; font-size: 11px; margin-top: 4px; }
.task-summary { margin-top: 13px; padding: 12px; border-radius: 12px; background: rgba(126,164,200,.06); color: #cbdbea; font-size: 13px; line-height: 1.65; }
.preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-top: 10px; }
.metric { padding: 11px; border-radius: 11px; background: rgba(87,217,255,.055); }
.metric span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 4px; }
.metric strong { font-size: 16px; }
.task-message { margin-top: 10px; border-left: 3px solid var(--amber); padding: 9px 11px; background: rgba(255,203,102,.07); color: #f8dfab; font-size: 12px; line-height: 1.55; }
.task-message.error { border-color: var(--red); background: rgba(255,111,125,.07); color: #ffc3ca; }
.captcha-box, .grant-box { margin-top: 12px; padding: 13px; border: 1px solid rgba(87,217,255,.15); border-radius: 13px; background: rgba(20,47,71,.55); }
.captcha-box p, .grant-copy { font-size: 12px; color: #c9d9e7; line-height: 1.55; }
.captcha-image { display: block; max-width: 220px; max-height: 90px; margin: 10px 0; padding: 5px; border-radius: 8px; background: white; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { min-width: 0; }
.task-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; font-size: 13px; }
footer { padding: 24px 4px 0; text-align: center; font-size: 10px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #eaf8ff; color: #052033; border-radius: 11px; padding: 11px 15px; box-shadow: 0 12px 42px rgba(0,0,0,.35); font-size: 12px; font-weight: 750; }
.state-PREVIEW_READY { color: var(--amber); }
.state-SUCCEEDED { color: var(--green); }
.state-FAILED, .state-NEEDS_REVIEW { color: var(--red); }
@media (max-width: 520px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .panel { padding: 16px; border-radius: 18px; }
  .auth-card { padding: 28px 20px; }
  .preview-grid { grid-template-columns: 1fr 1fr; }
  .inline-form { align-items: stretch; }
}
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.status-grid .status-strip { min-width: 0; }
.status-grid .status-strip div { min-width: 0; }
.status-grid .status-strip p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.automation-panel { border-color: rgba(87,217,255,.23); background: linear-gradient(145deg, rgba(13,35,60,.96), rgba(8,23,40,.94)); }
.tabs { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 13px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 9px 11px; background: rgba(143,173,205,.07); color: var(--muted); font-size: 12px; font-weight: 750; }
.tabs button.active { color: #eefdff; border-color: rgba(87,217,255,.42); background: rgba(44,115,255,.24); }
.tabs b { display: inline-grid; min-width: 18px; height: 18px; padding: 0 5px; place-items: center; margin-left: 3px; border-radius: 9px; background: rgba(255,255,255,.09); font-size: 10px; }
.automation-card { border-left: 3px solid rgba(87,217,255,.5); }
.oa-line { margin-top: 8px; color: var(--cyan); font-size: 12px; font-weight: 700; word-break: break-all; }
.message-details { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(2,10,19,.35); }
.message-details > summary { cursor: pointer; list-style: none; padding: 10px 12px; color: #b8cbe0; font-size: 12px; font-weight: 800; }
.message-details > summary::-webkit-details-marker { display: none; }
.message-details > summary::after { content: '＋'; float: right; color: var(--cyan); }
.message-details[open] > summary::after { content: '－'; }
.source-message { border-top: 1px solid var(--line); padding: 11px 12px; }
.source-message.withdrawn { opacity: .55; }
.source-meta { margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.source-text { white-space: pre-wrap; word-break: break-word; color: #e1ebf5; font-size: 13px; line-height: 1.55; }
.manual-panel { padding: 0; overflow: hidden; }
.manual-title { padding: 19px 20px; }
.manual-title strong { display: block; font-size: 18px; }
.manual-title .eyebrow { display: block; margin-bottom: 6px; }
.manual-content { border-top: 1px solid var(--line); padding: 20px; background: rgba(8,23,40,.45); }
.current-task-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 10px; color: #dce9f5; font-size: 13px; font-weight: 800; }
.current-task-heading small { color: var(--muted); font-size: 10px; font-weight: 600; }
.grant-copy { margin-bottom: 12px; }
.grant-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 9px; }
.task-log-button { width: 100%; margin-top: 12px; }
.task-log-button b { display: inline-grid; min-width: 20px; height: 20px; margin-left: 6px; place-items: center; border-radius: 10px; background: rgba(255,255,255,.09); font-size: 10px; }
.task-log-dialog { width: min(calc(100% - 24px), 720px); max-height: min(86vh, 900px); }
.log-dialog-card { max-height: min(86vh, 900px); overflow-y: auto; }
.success-log-card { border-left: 3px solid rgba(78,226,160,.72); }
.task-actions { flex-wrap: wrap; }
dialog { width: min(calc(100% - 28px), 430px); padding: 0; border: 1px solid rgba(87,217,255,.25); border-radius: 20px; color: var(--text); background: #0d2035; box-shadow: 0 32px 120px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(0,5,12,.72); backdrop-filter: blur(5px); }
.dialog-card { padding: 24px; }
.dialog-copy { margin: 16px 0 20px; padding: 14px; border-radius: 13px; background: rgba(5,16,28,.58); color: #d9e7f4; font-size: 13px; line-height: 1.55; }
.dialog-copy p { margin: 0 0 8px; }
.dialog-copy p:last-child { margin-bottom: 0; color: var(--amber); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 9px; }
.auto-PENDING_APPROVAL, .auto-AWAITING_CAPTCHA { color: var(--amber); }
.auto-ACCOUNT_NOT_FOUND, .auto-QUERY_FAILED, .auto-NEEDS_REVIEW, .auto-RECEIPT_FAILED, .auto-FAILED { color: var(--red); }
.auto-QUOTA_SUFFICIENT { color: var(--cyan); }
.auto-RECEIPT_SENT, .auto-SUCCEEDED { color: var(--green); }
.auto-SUSPECTED, .auto-IDENTIFICATION_FAILED { color: #d8adff; }
@media (max-width: 620px) {
  .status-grid { grid-template-columns: 1fr; }
  .automation-panel { padding-left: 13px; padding-right: 13px; }
  .task-actions .small { flex: 1 1 auto; }
  .dialog-actions { grid-template-columns: 1fr; }
  .grant-actions { grid-template-columns: 1fr; }
}
