/* Escape Links - Professional UI */
:root {
    --bg: #f7f9fc;
    --bg-alt: #eef4ff;
    --surface: rgba(255, 255, 255, 0.96);
    --surface-solid: #ffffff;
    --surface-strong: #f8fafc;
    --text: #1f2937;
    --muted: #667085;
    --line: #dde6f2;
    --line-strong: #cdd8e8;
    --primary: #0061ff;
    --primary-dark: #0050d6;
    --primary-soft: rgba(0, 97, 255, 0.10);
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.10);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --warning: #d97706;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 70px rgba(15, 23, 42, 0.12);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 26px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(0, 97, 255, 0.08), transparent 28%),
        radial-gradient(circle at top right, rgba(77, 113, 255, 0.08), transparent 24%),
        linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(rgba(15, 23, 42, 0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(15, 23, 42, 0.025) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 85%);
    opacity: 0.35;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

/* Common surfaces */
.card,
.login-container,
.hero,
.container-card,
.modal-content,
.download-card,
.error-card,
.section,
.panel,
.install-card {
    background: var(--surface);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: var(--shadow-lg);
}

/* Buttons */
.btn,
.login-button,
.cta-button,
button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 46px;
    padding: 0.85rem 1.25rem;
    border: 0;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, opacity 160ms ease, border-color 160ms ease;
    box-shadow: var(--shadow-sm);
}

.btn:hover,
.login-button:hover,
.cta-button:hover,
button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.btn:active,
.login-button:active,
.cta-button:active,
button[type="submit"]:active {
    transform: translateY(0);
}

.btn-primary,
.login-button,
.cta-button,
button[type="submit"] {
    color: #fff;
    background: linear-gradient(135deg, #0061ff 0%, #0b77ff 100%);
}

.btn-primary:hover,
.login-button:hover,
.cta-button:hover,
button[type="submit"]:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #0068e6 100%);
}

.btn-danger,
.action-delete {
    color: #fff;
    background: linear-gradient(135deg, #e02424 0%, #dc2626 100%);
}

.btn-secondary,
.cancel-button,
button[type="button"] {
    color: var(--text);
    background: #f4f7fb;
    border: 1px solid var(--line);
}

.btn-ghost {
    color: var(--primary);
    background: var(--primary-soft);
}

/* Auth pages */
.auth-shell,
body.auth-page,
body.public-page,
body.download-page,
body.error-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-container,
.hero,
.download-card,
.error-card,
.install-card {
    width: min(100%, 520px);
    border-radius: var(--radius-lg);
    padding: 44px;
}

.login-header,
.hero-header,
.page-header,
.download-header,
.error-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header h1,
.hero h1,
.download-header h1,
.error-header h1 {
    margin: 0 0 10px;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    letter-spacing: -0.04em;
}

.login-header p,
.hero p,
.download-header p,
.error-header p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-weight: 600;
    font-size: 0.94rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: rgba(0, 97, 255, 0.55);
    box-shadow: 0 0 0 4px rgba(0, 97, 255, 0.10);
}

.form-group textarea {
    min-height: 96px;
    resize: vertical;
}

.error-message,
.alert-box,
.info,
.notice {
    border-radius: 14px;
    padding: 14px 16px;
    line-height: 1.6;
}

.error-message {
    margin-bottom: 20px;
    color: #991b1b;
    background: rgba(254, 242, 242, 0.95);
    border: 1px solid rgba(220, 38, 38, 0.14);
}

.info,
.notice {
    margin-top: 24px;
    color: var(--muted);
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--line);
    font-size: 0.95rem;
}

/* Public hero */
.hero {
    max-width: 760px;
    text-align: center;
}

.features {
    text-align: left;
    margin: 28px 0 30px;
    display: grid;
    gap: 12px;
}

.feature {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
}

.feature-icon {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.1rem;
}

.feature-text {
    color: var(--text);
    line-height: 1.55;
    padding-top: 7px;
}

.hero .cta-button {
    min-width: 220px;
}

/* Dashboard */
header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(221, 230, 242, 0.9);
}

.header-container,
.container {
    width: min(100%, 1200px);
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
}

.header-container {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.container {
    padding-top: 28px;
    padding-bottom: 32px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    padding: 22px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(217, 226, 239, 0.82);
    box-shadow: var(--shadow-md);
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto -30px -30px auto;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(0, 97, 255, 0.09), transparent 70%);
}

.stat-card.success::after {
    background: radial-gradient(circle, rgba(22, 163, 74, 0.12), transparent 70%);
}

.stat-card.danger::after {
    background: radial-gradient(circle, rgba(220, 38, 38, 0.12), transparent 70%);
}

.stat-card.success {
    border-left: 5px solid var(--success);
}

.stat-card.danger {
    border-left: 5px solid var(--danger);
}

.stat-label {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.10em;
}

.stat-value {
    margin-top: 10px;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.section,
.panel {
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 20px;
}

.section-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 18px;
    font-size: 1.05rem;
    font-weight: 800;
}

.file-list {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
}

.file-list thead th {
    padding: 14px 12px;
    text-align: left;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    background: #f6f8fb;
    border-bottom: 1px solid var(--line);
}

.file-list tbody tr {
    transition: background 160ms ease, transform 160ms ease;
}

.file-list tbody tr:hover {
    background: rgba(0, 97, 255, 0.035);
}

.file-list td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.file-name {
    font-weight: 700;
    word-break: break-word;
}

.file-size,
.file-meta {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-weight: 700;
    word-break: break-all;
}

.file-link:hover {
    text-decoration: none;
    opacity: 0.9;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.status-active {
    color: #166534;
    background: var(--success-soft);
    border: 1px solid rgba(22, 163, 74, 0.16);
}

.status-expired {
    color: #991b1b;
    background: var(--danger-soft);
    border: 1px solid rgba(220, 38, 38, 0.16);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.action-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 97, 255, 0.12);
    background: rgba(0, 97, 255, 0.06);
    color: var(--primary);
    font-weight: 600;
}

.action-link:hover {
    text-decoration: none;
    background: rgba(0, 97, 255, 0.10);
}

.action-delete {
    background: var(--danger-soft);
    color: var(--danger);
}

.action-delete:hover {
    background: rgba(220, 38, 38, 0.14);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    padding: 20px;
    background: rgba(15, 23, 42, 0.46);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: min(100%, 560px);
    border-radius: 24px;
    padding: 28px;
}

.modal-title {
    margin-bottom: 18px;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.progress {
    display: none;
    width: 100%;
    height: 8px;
    margin: 12px 0 16px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.08);
}

.progress-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0061ff 0%, #2880ff 50%, #56a0ff 100%);
    transition: width 200ms ease;
}

/* Download / error pages */
.download-card,
.error-card {
    text-align: center;
}

.password-form {
    margin-top: 22px;
    text-align: left;
}

.error-code {
    margin-bottom: 8px;
    font-size: 0.82rem;
    font-weight: 900;
    color: var(--muted);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.back-link {
    display: inline-flex;
    margin-top: 18px;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    background: rgba(0, 97, 255, 0.08);
    color: var(--primary);
    font-weight: 600;
}

.back-link:hover {
    text-decoration: none;
    background: rgba(0, 97, 255, 0.12);
}

/* Installer */
.install-shell,
body.install-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 28px;
}

.install-card {
    width: min(100%, 760px);
    padding: 40px;
}

.install-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.install-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
}

.install-title {
    margin: 10px 0 8px;
    font-size: clamp(2rem, 4vw, 2.9rem);
    line-height: 1.05;
    letter-spacing: -0.05em;
}

.install-subtitle {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.install-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
    margin-top: 24px;
}

.install-panel {
    padding: 22px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: #fff;
}

.install-panel h2,
.install-panel h3 {
    margin: 0 0 14px;
    letter-spacing: -0.03em;
}

.install-status-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.install-status-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #f8fbff;
    border: 1px solid var(--line);
}

.install-status-ok {
    color: #166534;
    background: var(--success-soft);
}

.install-status-bad {
    color: #991b1b;
    background: var(--danger-soft);
}

.install-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.install-note {
    margin-top: 16px;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .login-container,
    .hero,
    .download-card,
    .error-card,
    .modal-content,
    .section,
    .panel {
        border-radius: 18px;
    }

    .header-container {
        flex-direction: column;
        align-items: stretch;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn,
    .header-actions a {
        flex: 1 1 auto;
        justify-content: center;
    }

    .file-list,
    .file-list thead,
    .file-list tbody,
    .file-list th,
    .file-list td,
    .file-list tr {
        display: block;
    }

    .file-list thead {
        display: none;
    }

    .file-list tr {
        border-bottom: 1px solid var(--line);
        padding: 10px 0;
    }

    .file-list td {
        border: 0;
        padding: 8px 0;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .install-hero,
    .install-grid {
        grid-template-columns: 1fr;
        display: grid;
    }

    .install-card {
        padding: 24px;
    }
}
