:root {
    --bg: #f6f8fb;
    --bg-gradient-top: #f6f8fb;
    --bg-gradient-bot: #eef2f7;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #1f2937;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-tint: rgba(37, 99, 235, 0.1);
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --warning-text: #854d0e;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --success-text: #166534;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --error-text: #991b1b;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow:    0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.05);
    --radius: 12px;
    --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg-gradient-bot) 100%);
    background-attachment: fixed;
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.92em;
    padding: 1px 5px;
    background: #f3f4f6;
    border-radius: 4px;
    color: #374151;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 48px 20px 40px;
}

.header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-wrap {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    background: var(--primary);
    color: #fff;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.logo-wrap.success {
    background: var(--success);
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}

.logo {
    width: 28px;
    height: 28px;
}

.header h1 {
    font-size: 26px;
    font-weight: 600;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}

.header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 14px;
}

.header p code {
    font-size: 13px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 32px;
    margin-bottom: 16px;
}

.section {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.section:first-child {
    padding-top: 0;
}

.section:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    margin: 0 0 14px;
}

.field {
    margin-bottom: 16px;
}

.field:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text);
}

.help {
    font-size: 13px;
    color: var(--text-muted);
    margin: 6px 0 0;
    line-height: 1.5;
}

.help a {
    color: var(--primary);
    text-decoration: none;
}

.help a:hover {
    text-decoration: underline;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-sm);
}

input::placeholder, textarea::placeholder {
    color: var(--text-faint);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-tint);
}

textarea {
    min-height: 84px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-sm);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 38px;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-tint);
}

.provider-creds {
    display: none;
    padding: 14px 16px;
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.provider-creds .field:last-child {
    margin-bottom: 0;
}

input[type="file"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fafbfc;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

input[type="file"]:hover {
    border-color: var(--primary);
    background: #fff;
}

input[type="file"]::file-selector-button {
    padding: 6px 12px;
    margin-right: 12px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

input[type="file"]::file-selector-button:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.checkbox input[type="checkbox"] {
    margin: 3px 0 0 0;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-label {
    flex: 1;
}

.checkbox-label strong {
    font-weight: 500;
    color: var(--text);
}

.checkbox-label .help {
    margin-top: 2px;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 540px) {
    .row { grid-template-columns: 1fr; }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s, border-color 0.15s, transform 0.05s;
    font-family: inherit;
    text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: var(--text-muted);
}

.btn-danger {
    background: #fff;
    color: var(--danger);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

.alert pre {
    margin: 8px 0 0;
    padding: 10px 12px;
    background: rgba(0,0,0,0.04);
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 24px;
    padding: 0 12px;
}

.muted { color: var(--text-muted); }
.small { font-size: 13px; }

.tag {
    display: inline-block;
    padding: 3px 8px;
    background: #f3f4f6;
    color: var(--text);
    border-radius: 4px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.tag-domain {
    background: var(--primary-tint);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.2);
    padding: 4px 10px;
    margin: 2px;
}

.domain-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.kv {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px 16px;
    align-items: start;
    font-size: 14px;
}

.kv-key {
    color: var(--text-muted);
    font-size: 13px;
    padding-top: 2px;
}

.kv-val {
    color: var(--text);
}

.download-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    background: #fafbfc;
}

.download-card:last-child {
    margin-bottom: 0;
}

.download-info {
    flex: 1;
    min-width: 0;
}

.download-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.download-meta {
    font-size: 12px;
    color: var(--text-faint);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    margin: 2px 0 6px;
}

.download-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ---- Manual DNS challenge dialog page ---- */

body.dialog-body {
    background: linear-gradient(180deg, #e0e7ef 0%, #cdd6e2 100%);
    min-height: 100vh;
}

.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1;
}

.dialog-container {
    position: relative;
    z-index: 2;
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 20px;
}

.dialog-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.08),
        0 12px 36px rgba(15, 23, 42, 0.18),
        0 24px 64px rgba(15, 23, 42, 0.10);
    padding: 32px 36px;
}

.dialog-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

.dialog-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-tint);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-icon svg {
    width: 24px;
    height: 24px;
}

.dialog-header h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 4px;
    line-height: 1.3;
}

.dialog-sub {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
    line-height: 1.5;
}

.dialog-section {
    padding: 18px 0;
    border-top: 1px solid var(--border);
}

.dialog-section:first-of-type {
    border-top: none;
    padding-top: 0;
}

.dialog-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    margin: 0 0 12px;
}

.record-block {
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 12px;
}

.record-block:last-child { margin-bottom: 0; }

.record-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 8px 16px;
    align-items: start;
    padding: 4px 0;
}

.record-label {
    color: var(--text-muted);
    font-size: 13px;
    padding-top: 4px;
}

.record-value {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.record-value.record-values {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.value-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.record-code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    color: #1f2937;
    word-break: break-all;
    flex: 1;
    min-width: 0;
}

.value-code {
    font-size: 12px;
    color: #374151;
}

.copy-btn {
    flex: 0 0 auto;
    padding: 4px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.copy-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.copy-btn.copied {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.status-badge {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
}

.status-pending {
    background: #f3f4f6;
    color: var(--text-muted);
    border-color: var(--border);
}

.status-ok {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-border);
}

.status-missing {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: var(--error-border);
}

.tips-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.55;
}

.tips-list li { margin-bottom: 4px; }

.dialog-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 6px;
}

.dialog-actions .btn-primary {
    width: auto;
    flex: 1 1 auto;
    min-width: 220px;
    padding: 12px 18px;
    font-size: 14px;
}

.dialog-actions .btn-secondary {
    padding: 11px 16px;
}

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: -2px;
}

.dialog-cancel-form {
    margin: 14px 0 0;
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
    font-size: 13px;
}

.link-btn:hover { color: var(--danger); }

.verify-result {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 14px;
}

.verify-result code {
    background: rgba(0,0,0,0.06);
}

.verify-ok {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.verify-warn {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

.verify-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.provider-creds-empty {
    padding: 14px 16px;
}

@media (max-width: 540px) {
    .record-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .record-label {
        padding-top: 0;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }
    .dialog-card {
        padding: 24px 20px;
    }
    .dialog-actions .btn-primary {
        min-width: 0;
        width: 100%;
    }
}

.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.spinner-overlay.active { display: flex; }

.spinner-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 40px;
    text-align: center;
    max-width: 400px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }
