:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18212a;
  background: #f4f6f8;
  font-synthesis: none;
  --ink: #18212a;
  --muted: #68737d;
  --line: #dfe4e8;
  --line-strong: #cbd2d8;
  --paper: #ffffff;
  --canvas: #f4f6f8;
  --green: #217a48;
  --green-soft: #eaf5ee;
  --red: #b42318;
  --red-soft: #fff0ee;
  --amber: #9a6700;
  --amber-soft: #fff6dc;
  --blue: #175cd3;
  --blue-soft: #edf4ff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 28px; line-height: 1.2; }
h2 { margin-bottom: 0; font-size: 17px; line-height: 1.35; }
h3 { font-size: 15px; }
pre, code { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; }

.login-view { min-height: 100vh; display: grid; place-content: center; gap: 22px; padding: 24px; background: #eef1f3; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--ink); font-weight: 750; font-size: 20px; }
.login-brand img, .brand img { border-radius: 7px; }
.login-panel { width: min(400px, calc(100vw - 32px)); padding: 30px; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 12px 36px rgba(24, 33, 42, .10); }
.panel-heading { margin-bottom: 24px; }
.login-status { margin-top: 18px; display: flex; justify-content: center; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }

.topbar { height: 62px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1440px) / 2)); color: #fff; background: var(--ink); border-bottom: 1px solid #0d1318; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 750; }
.brand-suffix { color: #aeb7bf; font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.service-status { display: flex; align-items: center; gap: 7px; color: #d8e0e5; }
.admin-name { color: #aeb7bf; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: #8a949e; }
.status-dot-live { background: #42c977; box-shadow: 0 0 0 3px rgba(66, 201, 119, .14); }

.main-content { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 26px 0 52px; }
.view-tabs { min-height: 44px; display: flex; align-items: end; gap: 2px; margin-bottom: 30px; border-bottom: 1px solid var(--line-strong); overflow-x: auto; }
.view-tab { min-width: max-content; height: 44px; padding: 0 18px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; font-weight: 650; }
.view-tab:hover { color: var(--ink); background: #edf0f2; }
.view-tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.admin-page { display: grid; gap: 20px; }
.page-heading { min-height: 62px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-meta, .section-count { margin: 0; color: var(--muted); font-size: 13px; }
.eyebrow { margin-bottom: 6px; color: #71808d; font-size: 11px; font-weight: 750; text-transform: uppercase; }
.page-actions, .button-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.button-row .grow { flex: 1; }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; font-weight: 650; text-decoration: none; }
.button:hover { background: #f1f3f5; border-color: #afb8c0; }
.button:disabled { opacity: .55; cursor: wait; }
.button-primary { color: #fff; background: var(--ink); border-color: var(--ink); }
.button-primary:hover { background: #2b3741; border-color: #2b3741; }
.button-secondary { background: #fff; }
.button-danger { color: var(--red); border-color: #efc0ba; }
.button-danger:hover { background: var(--red-soft); border-color: #e49b92; }
.button-warning { color: var(--amber); border-color: #e5c677; background: var(--amber-soft); }
.button-quiet { min-height: 32px; padding: 5px 10px; color: inherit; background: transparent; border-color: transparent; }
.topbar .button-quiet { color: #d8e0e5; }
.button-wide { width: 100%; margin-top: 14px; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 5px; font-size: 24px; }
.icon-button:hover { color: var(--ink); background: #edf0f2; }

.surface { background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 7px; background: var(--paper); overflow: hidden; }
.metrics-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { min-height: 112px; display: grid; align-content: center; gap: 4px; padding: 18px 22px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label, .metric-note { color: var(--muted); font-size: 12px; }
.metric-value { font-size: 30px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.metric-value-good { color: var(--green); }
.metric-value-alert { color: var(--red); }

.section-heading, .test-form-heading, .test-result-heading, .dialog-header, .image-dialog-header, .credit-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-heading { min-height: 64px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.section-heading > div:first-child { display: flex; align-items: baseline; gap: 12px; }
.accounts-section, .tasks-section, .api-keys-section, .settings-section { overflow: hidden; }
.settings-section { padding-bottom: 18px; }
.settings-section > .form-grid, .settings-section > .page-meta { margin: 18px; }
.filters { display: flex; align-items: center; gap: 8px; }
.filters input { width: 230px; }
.filters select { width: auto; min-width: 128px; }

input, select, textarea { width: 100%; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; outline: none; }
input, select { height: 40px; padding: 0 11px; }
textarea { min-height: 92px; padding: 10px 11px; line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #657581; box-shadow: 0 0 0 3px rgba(70, 88, 102, .10); }
.field { display: grid; align-content: start; gap: 7px; color: #46525c; font-size: 13px; font-weight: 600; }
.field-span { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.check-field { min-height: 40px; display: flex; align-items: center; gap: 10px; color: #46525c; font-size: 13px; }
.check-field input { width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--ink); }
.file-picker { display: block; margin-top: 10px; padding: 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 5px; cursor: pointer; }
.file-picker input { display: none; }
.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; margin: 13px 0; }
.upload-status { margin: -2px 0 13px; }
.form-error { margin: 10px 0 0; padding: 9px 11px; color: var(--red); background: var(--red-soft); border-left: 3px solid var(--red); font-size: 13px; }

.account-grid, .api-keys-grid, .tasks-table { overflow-x: auto; }
.account-grid-header, .account-row { min-width: 1120px; display: grid; grid-template-columns: minmax(250px, 1.7fr) 96px 150px 120px 125px 145px 170px; align-items: center; gap: 12px; padding: 0 18px; }
.account-grid-header, .api-key-grid-header, .task-grid-header { min-height: 42px; color: var(--muted); background: #f8f9fa; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.account-row { min-height: 72px; border-bottom: 1px solid #edf0f2; font-size: 13px; }
.account-row > * { min-width: 0; }
.account-row:last-child { border-bottom: 0; }
.account-row:hover, .task-row:hover { background: #fafbfc; }
.account-identity { min-width: 0; display: grid; gap: 3px; }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.account-meta { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.account-balance { min-width: 0; display: grid; gap: 3px; overflow: hidden; }
.account-balance .account-meta { display: block; width: 100%; max-width: 100%; }
.account-actions { display: flex; justify-content: flex-end; gap: 6px; }
.account-actions .button { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.switch { position: relative; width: 34px; height: 20px; display: inline-block; }
.switch input { width: 0; height: 0; opacity: 0; }
.switch span { position: absolute; inset: 0; background: #aeb6bd; border-radius: 10px; transition: .18s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px #0003; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(14px); }
.status-pill { width: max-content; display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status-active { color: var(--green); background: var(--green-soft); }
.status-disabled { color: #5f6a73; background: #edf0f2; }
.status-error { color: var(--red); background: var(--red-soft); }
.status-warning { color: var(--amber); background: var(--amber-soft); }
.align-right { text-align: right; }

.loading-state, .empty-state, .result-empty, .result-loading { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); text-align: center; }
.empty-state.compact { min-height: 120px; }
.spinner { width: 20px; height: 20px; border: 2px solid #d6dce1; border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.test-workspace { display: grid; grid-template-columns: minmax(390px, .85fr) minmax(440px, 1.15fr); gap: 18px; align-items: start; }
.test-form-stack { display: grid; gap: 18px; }
.test-form, .test-result { padding: 20px; }
.test-form-heading, .test-result-heading { min-height: 34px; margin-bottom: 18px; }
.test-result { min-height: 520px; }
.text-result pre, .credit-detail pre, details pre, .dialog pre { max-height: 420px; margin: 12px 0 0; padding: 13px; overflow: auto; color: #e8eef2; background: #121a21; border-radius: 5px; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.5; }
.size-preview { margin: 15px 0; padding: 10px 12px; color: #245587; background: var(--blue-soft); border-left: 3px solid var(--blue); font-size: 12px; }
.image-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.image-tile { position: relative; min-height: 180px; display: block; padding: 0; overflow: hidden; background: #eef1f3; border: 1px solid var(--line); border-radius: 5px; }
.image-tile img { width: 100%; height: 100%; min-height: 180px; max-height: 360px; display: block; object-fit: contain; }
.image-tile span { position: absolute; left: 8px; bottom: 8px; padding: 3px 6px; color: #fff; background: #111b; border-radius: 3px; font-size: 11px; }
.result-facts, .detail-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 16px 0 0; background: var(--line); border: 1px solid var(--line); }
.result-facts > div, .detail-facts > div { min-width: 0; padding: 9px 11px; background: #fff; }
.result-facts dt, .detail-facts dt { color: var(--muted); font-size: 11px; }
.result-facts dd, .detail-facts dd { margin: 3px 0 0; overflow-wrap: anywhere; font-size: 12px; }
.result-error { padding: 14px; color: var(--red); background: var(--red-soft); border: 1px solid #efc0ba; border-radius: 5px; }
.result-error pre { margin-bottom: 0; white-space: pre-wrap; }
details { margin-top: 16px; }
summary { color: var(--muted); cursor: pointer; font-size: 12px; }

.task-grid-header, .task-row { min-width: 1220px; display: grid; grid-template-columns: minmax(260px, 1.7fr) minmax(170px, 1fr) 70px 86px 85px 170px 120px 80px 100px; align-items: center; gap: 12px; padding: 0 18px; }
.task-row { min-height: 74px; border-bottom: 1px solid #edf0f2; font-size: 12px; cursor: pointer; }
.task-preview { width: 72px; height: 50px; padding: 0; overflow: hidden; background: #edf0f2; border: 1px solid var(--line); border-radius: 4px; }
.task-preview img { width: 100%; height: 100%; object-fit: cover; }
.task-error { color: var(--red); }

.api-key-grid-header, .api-key-row { min-width: 850px; display: grid; grid-template-columns: 1.3fr 1.2fr 100px 100px 160px 130px; align-items: center; gap: 12px; padding: 0 18px; }
.api-key-row { min-height: 66px; border-bottom: 1px solid #edf0f2; font-size: 13px; }
.key-prefix { color: #394955; font-size: 12px; }
.domain-stats-wrap { overflow-x: auto; }
.register-domain-tabs { display: inline-flex; align-items: center; gap: 4px; }
.register-domain-tab { min-height: 32px; padding: 5px 9px; color: var(--muted); background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 12px; font-weight: 650; }
.register-domain-tab:hover { color: var(--ink); background: #f1f3f5; }
.register-domain-tab.active { color: #fff; background: var(--ink); border-color: var(--ink); }
.domain-stats-header, .domain-stats-row { min-width: 850px; display: grid; grid-template-columns: 150px 1fr 120px minmax(260px, 1.2fr); align-items: center; gap: 12px; padding: 0 18px; }
.domain-stats-header { min-height: 42px; color: var(--muted); background: #f8f9fa; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; }
.domain-stats-row { min-height: 58px; border-bottom: 1px solid #edf0f2; font-size: 12px; }
.domain-stats-row:last-child { border-bottom: 0; }
.domain-reason { min-width: 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.proxy-country-field { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.proxy-country-field legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.proxy-country-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.proxy-country-option { display: flex; align-items: center; gap: 7px; padding: 8px 9px; background: #f8f9fa; border: 1px solid var(--line); border-radius: 5px; font-size: 12px; }
.proxy-country-option input { width: 14px; height: 14px; accent-color: var(--ink); }

.dialog { width: min(620px, calc(100vw - 28px)); max-height: calc(100vh - 40px); padding: 22px; overflow: auto; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 24px 70px #18212a3d; }
.dialog-wide { width: min(900px, calc(100vw - 28px)); }
.dialog::backdrop { background: rgba(18, 27, 34, .48); }
.dialog-header { margin-bottom: 20px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dialog-footer-between { align-items: center; }
.dialog-spacer { flex: 1; }
.credit-detail { margin-top: 18px; }
.credit-detail-heading h3 { margin: 0; }
.credit-detail-heading span { color: var(--muted); font-size: 11px; }
.image-dialog { width: min(1100px, calc(100vw - 28px)); }
.image-dialog img { width: 100%; max-height: calc(100vh - 140px); display: block; object-fit: contain; background: #eef1f3; }
.secret-input { font-family: "Cascadia Code", Consolas, monospace; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 11px 14px; color: #fff; background: var(--ink); border-radius: 6px; box-shadow: 0 8px 24px #0003; font-size: 13px; }
.toast.error { background: var(--red); }

@media (max-width: 1000px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .test-workspace { grid-template-columns: 1fr; }
  .test-result { min-height: 400px; }
}

@media (max-width: 680px) {
  .topbar { padding: 0 14px; }
  .brand-suffix, .service-status, .admin-name { display: none; }
  .main-content { width: min(100% - 24px, 1440px); padding-top: 16px; }
  .view-tabs { margin-bottom: 20px; }
  .view-tab { padding: 0 12px; }
  .page-heading { display: grid; }
  .page-actions { justify-content: flex-start; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 96px; padding: 14px; }
  .metric-value { font-size: 24px; }
  .section-heading { align-items: flex-start; }
  .section-heading, .section-heading > div:first-child, .filters { flex-wrap: wrap; }
  .filters input { width: 100%; }
  .form-grid, .upload-grid, .result-facts, .detail-facts { grid-template-columns: 1fr; }
  .field-span { grid-column: auto; }
  .image-gallery { grid-template-columns: 1fr; }
  .test-form, .test-result { padding: 15px; }
  .dialog-footer-between { flex-wrap: wrap; }
}
