:root {
    --bg: #0c0f14;
    --bg-elevated: #12171f;
    --card: #161c26;
    --card-hover: #1a2230;
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --muted: #64748b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.35);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.12);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --border: rgba(148, 163, 184, 0.12);
    --border-strong: rgba(148, 163, 184, 0.2);
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --font: "DM Sans", system-ui, -apple-system, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

/* Subtle background texture */
.dashboard-page {
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.12), transparent),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(99, 102, 241, 0.06), transparent),
        var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* —— Header —— */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(12, 15, 20, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.app-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.brand-title {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 400;
}

/* —— Main layout —— */
.app-main {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 2.5rem;
}

.app-footer {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 1rem 1.5rem 1.5rem;
    font-size: 0.8rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

.footer-sep {
    margin: 0 0.4rem;
    opacity: 0.5;
}

/* —— Stats —— */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.75rem;
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s, background 0.2s;
}

.stat-card:hover {
    background: var(--card-hover);
    border-color: var(--border-strong);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    flex-shrink: 0;
}

.stat-icon-sites {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.stat-icon-ready {
    background: var(--success-bg);
    color: var(--success);
}

.stat-icon-archives {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.stat-icon-time {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.stat-value-sm {
    font-size: 1rem;
    font-weight: 600;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

/* —— Panels —— */
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.15);
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.panel-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    flex-shrink: 0;
}

.panel-icon-archive {
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
}

.panel-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.panel-desc {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--muted);
}

/* —— Tables —— */
.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    background: rgba(0, 0, 0, 0.2);
}

.data-table th {
    padding: 0.85rem 1.25rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.col-action {
    text-align: right;
    white-space: nowrap;
}

.domain-name {
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.path-cell {
    max-width: 22rem;
}

.path-code {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.25);
    padding: 0.3rem 0.55rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    word-break: break-all;
    line-height: 1.4;
}

.tag {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--muted);
    background: rgba(148, 163, 184, 0.08);
    padding: 0.2rem 0.5rem;
    border-radius: 5px;
}

.date-cell {
    white-space: nowrap;
}

.date-cell time {
    display: block;
    font-weight: 500;
    color: var(--text-secondary);
}

.time-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.text-muted {
    color: var(--muted);
    font-size: 0.875rem;
}

.muted-cell {
    color: var(--muted);
    font-size: 0.85rem;
}

.file-name {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.file-icon {
    flex-shrink: 0;
    opacity: 0.6;
}

.size-badge {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* —— Badges —— */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.9;
}

.badge-success {
    background: var(--success-bg);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.25);
}

/* —— Buttons —— */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: 9px;
    border: none;
    text-decoration: none;
    color: #fff;
    background: var(--primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn:hover {
    background: var(--primary-hover);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(180deg, #4b8ef8 0%, var(--primary) 100%);
    box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #5b9cf9 0%, var(--primary-hover) 100%);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
    box-shadow: none;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-color: var(--muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    box-shadow: none;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.btn-secondary {
    background: #334155;
}

.btn-sm,
.btn-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.inline-form {
    display: inline;
    margin: 0;
}

/* —— Alerts —— */
.alert {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border: 1px solid;
}

.alert-content {
    flex: 1;
}

.alert-message {
    margin: 0 0 0.75rem;
}

.alert-success {
    background: var(--success-bg);
    border-color: rgba(34, 197, 94, 0.3);
}

.alert-error {
    background: var(--error-bg);
    border-color: rgba(248, 113, 113, 0.3);
}

.alert-warning {
    background: var(--warning-bg);
    border-color: rgba(251, 191, 36, 0.3);
}

/* —— Empty states —— */
.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
}

.empty-state-compact {
    padding: 1.75rem 1rem;
}

.empty-title {
    margin: 0 0 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-desc {
    margin: 0;
    font-size: 0.875rem;
    color: var(--muted);
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
}

.empty-desc code {
    font-family: var(--mono);
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.discovery-hints {
    margin: 1rem auto 0;
    padding-left: 1.25rem;
    text-align: left;
    max-width: 32rem;
    color: var(--muted);
    font-size: 0.85rem;
}

/* —— Login (unchanged structure, refined) —— */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.15), transparent),
        var(--bg);
}

.login-card,
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 500;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.7rem 0.85rem;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.toolbar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.hint {
    color: var(--muted);
    font-size: 0.9rem;
}

h1, h2 {
    margin-top: 0;
}

/* —— Backup overlay —— */
.backup-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 8, 12, 0.88);
    backdrop-filter: blur(8px);
}

.backup-overlay[hidden] {
    display: none !important;
}

.backup-overlay-panel {
    text-align: center;
    width: min(440px, 92vw);
    padding: 2.25rem 2rem;
    background: var(--card);
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.backup-overlay-spinner {
    width: 52px;
    height: 52px;
    margin: 0 auto 1.5rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: backup-spin 0.85s linear infinite;
}

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

.backup-overlay-title {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.backup-overlay-domain {
    margin: 0 0 1.5rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.backup-overlay-progress-track {
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.85rem;
}

.backup-overlay-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    border-radius: 999px;
    transition: width 0.35s ease;
    box-shadow: 0 0 12px var(--primary-glow);
}

.backup-overlay-percent {
    margin: 0 0 0.5rem;
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}

.backup-overlay-message {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    min-height: 1.35em;
}

body.backup-in-progress {
    overflow: hidden;
}
