/* ── Сброс и базовые стили ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:    #0062FF;
    --blue-h:  #004ECC;
    --gray-50: #F8F9FA;
    --gray-100:#F1F3F4;
    --gray-200:#E8EAED;
    --gray-400:#9AA0A6;
    --gray-600:#5F6368;
    --gray-900:#202124;
    --red:     #D93025;
    --green:   #1A8754;
    --radius:  10px;
    --shadow:  0 1px 3px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.06);
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: var(--gray-900);
    background: #fff;
    line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, button, select { font-family: inherit; font-size: inherit; }

/* ── Шапка ────────────────────────────────────────────────────────────── */
.header {
    position: sticky; top: 0; z-index: 100;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    height: 56px;
}
.header-inner {
    max-width: 1100px; margin: 0 auto;
    padding: 0 24px;
    height: 100%; display: flex; align-items: center; gap: 24px;
}
.logo {
    font-size: 18px; font-weight: 600; color: var(--gray-900);
    text-decoration: none;
}
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link {
    padding: 6px 12px; border-radius: 6px; color: var(--gray-600);
    font-size: 14px; transition: background .15s;
}
.nav-link:hover { background: var(--gray-100); text-decoration: none; }
.nav-link.active { color: var(--blue); background: #E8F0FE; }
.balance-badge {
    padding: 4px 10px; border-radius: 20px;
    background: var(--gray-100); color: var(--gray-600);
    font-size: 12px; font-weight: 500;
}
.btn-logout {
    background: none; border: none; cursor: pointer;
    padding: 6px 12px; border-radius: 6px;
    color: var(--gray-600); font-size: 14px; transition: background .15s;
}
.btn-logout:hover { background: var(--gray-100); }

/* ── Main ─────────────────────────────────────────────────────────────── */
.main { padding: 32px 24px; min-height: calc(100vh - 56px); }

/* ── Кнопки ───────────────────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--blue); color: #fff;
    border: none; border-radius: var(--radius);
    padding: 10px 24px; font-weight: 500; cursor: pointer;
    transition: background .15s; text-decoration: none; gap: 8px;
}
.btn-primary:hover { background: var(--blue-h); text-decoration: none; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--gray-100); color: var(--gray-900);
    border: none; border-radius: var(--radius);
    padding: 10px 24px; font-weight: 500; cursor: pointer;
    transition: background .15s; text-decoration: none;
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger {
    background: #FDECEA; color: var(--red);
    border: none; border-radius: 6px;
    padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.btn-full { width: 100%; }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; cursor: pointer; border: none; }
.btn-back {
    background: none; border: none; cursor: pointer;
    color: var(--blue); font-size: 14px; padding: 0;
}

/* ── Формы ────────────────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 13px; font-weight: 500; color: var(--gray-600); }
input[type="text"], input[type="number"] {
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: 10px 12px; font-size: 14px; outline: none;
    transition: border-color .15s;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,98,255,.12); }

/* ── Страница логина ──────────────────────────────────────────────────── */
.login-page { background: var(--gray-50); }
.login-container {
    max-width: 420px; margin: 0 auto; padding: 60px 24px;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.login-logo { margin-bottom: 8px; }
.login-title { font-size: 28px; font-weight: 300; color: var(--gray-900); }
.login-sub { color: var(--gray-600); text-align: center; font-size: 14px; max-width: 300px; }
.login-widget-wrap { margin: 8px 0; }
.login-features { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 16px; }
.feature { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--gray-600); }
.feature-icon { font-size: 18px; }

/* ── Карточка загрузки ────────────────────────────────────────────────── */
.page-center { max-width: 860px; margin: 0 auto; }
.upload-card {
    background: #fff; border-radius: 16px;
    border: 1px solid var(--gray-200); padding: 32px;
    box-shadow: var(--shadow);
}
.upload-title { font-size: 22px; font-weight: 500; margin-bottom: 4px; }
.upload-sub { color: var(--gray-600); margin-bottom: 24px; }

.balance-info {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 8px;
    background: #E8F5E9; color: var(--green);
    font-size: 13px; margin-bottom: 24px;
}
.balance-empty { background: #FFF3E0; color: #E65100; }

.files-section { margin-bottom: 24px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; }
.files-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.files-grid-3 { grid-template-columns: repeat(3, 1fr); }

.file-slot { display: flex; flex-direction: column; gap: 4px; }
.file-slot-label { font-size: 12px; font-weight: 500; color: var(--gray-900); }
.file-slot-hint { font-size: 11px; color: var(--gray-400); }
.file-drop-zone {
    border: 1.5px dashed var(--gray-200); border-radius: var(--radius);
    padding: 12px; text-align: center; cursor: pointer;
    transition: all .15s; display: flex; flex-direction: column;
    align-items: center; gap: 4px; min-height: 72px; justify-content: center;
}
.file-drop-zone:hover, .file-drop-zone.drag-over {
    border-color: var(--blue); background: #EBF2FF;
}
.file-drop-zone.has-file {
    border-color: var(--green); border-style: solid; background: #F0FAF5;
}
.drop-icon { font-size: 20px; }
.drop-text { font-size: 11px; color: var(--gray-400); }
.file-slot.optional .file-drop-zone { border-style: dotted; }

/* ── Прогресс / результат ─────────────────────────────────────────────── */
.progress-block, .result-block, .error-block {
    margin-top: 24px; padding: 24px; border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    text-align: center;
}
.progress-block { background: var(--gray-50); }
.result-block { background: #F0FAF5; }
.error-block { background: #FFF5F5; }
.result-icon, .error-icon { font-size: 32px; }
.progress-text, .result-text { font-weight: 500; }
.error-text { color: var(--red); font-size: 13px; max-width: 400px; }
.btn-download { margin-top: 4px; }

.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.spinner-sm { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ── Инструкция ───────────────────────────────────────────────────────── */
.instruction-block {
    margin-top: 24px; border: 1px solid var(--gray-200);
    border-radius: 12px; overflow: hidden;
}
.instruction-block summary {
    padding: 14px 20px; cursor: pointer; font-weight: 500;
    font-size: 13px; color: var(--gray-600); user-select: none;
}
.instruction-block summary:hover { background: var(--gray-50); }
.instruction-content { padding: 0 20px 16px; }
.instruction-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.instruction-table th, .instruction-table td {
    text-align: left; padding: 8px 12px;
    border-bottom: 1px solid var(--gray-100);
}
.instruction-table th { color: var(--gray-600); font-weight: 500; }
.instruction-note { margin-top: 8px; font-size: 12px; color: var(--gray-400); }

/* ── Личный кабинет ───────────────────────────────────────────────────── */
.page-title { font-size: 24px; font-weight: 500; margin-bottom: 24px; }
.cabinet-wrap { max-width: 860px; margin: 0 auto; }
.balance-card {
    background: #fff; border-radius: 16px; border: 1px solid var(--gray-200);
    padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.balance-row { display: flex; align-items: center; gap: 0; flex: 1; }
.balance-item { text-align: center; flex: 1; padding: 0 20px; }
.balance-num { font-size: 32px; font-weight: 600; color: var(--blue); }
.balance-label { font-size: 12px; color: var(--gray-600); }
.balance-divider { width: 1px; height: 48px; background: var(--gray-200); }
.section-card {
    background: #fff; border-radius: 16px; border: 1px solid var(--gray-200);
    padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow);
}
.section-card-title { font-size: 16px; font-weight: 500; margin-bottom: 16px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 8px 12px; color: var(--gray-600); font-weight: 500; border-bottom: 2px solid var(--gray-200); text-align: left; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); }
.data-table tr:last-child td { border-bottom: none; }
.loading-text, .empty-text { color: var(--gray-400); font-size: 13px; padding: 16px 0; }
.status-badge { padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.status-done { background: #E8F5E9; color: var(--green); }
.status-pending { background: #FFF3E0; color: #E65100; }
.status-processing { background: #E3F2FD; color: #1565C0; }
.status-error { background: #FDECEA; color: var(--red); }
.status-paid { background: #E8F5E9; color: var(--green); }
.status-failed { background: #FDECEA; color: var(--red); }
.free-badge { padding: 2px 8px; border-radius: 20px; font-size: 11px; background: #E8F0FE; color: var(--blue); }
.error-hint { cursor: help; color: var(--red); font-size: 12px; border-bottom: 1px dashed; }

/* ── Оплата ───────────────────────────────────────────────────────────── */
.pay-wrap { max-width: 600px; margin: 0 auto; }
.packages-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.package-card {
    border: 2px solid var(--gray-200); border-radius: 16px;
    padding: 24px; text-align: center; cursor: pointer;
    transition: all .15s; background: #fff;
}
.package-card:hover { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,98,255,.1); }
.package-card.best { border-color: var(--blue); position: relative; }
.package-best-label {
    position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
    background: var(--blue); color: #fff; padding: 2px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.package-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.package-price { font-size: 28px; font-weight: 700; color: var(--blue); }
.package-per { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.qr-block { text-align: center; }
.qr-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.qr-title { font-size: 18px; font-weight: 500; }
.qr-info { margin-bottom: 20px; }
.qr-amount { font-size: 32px; font-weight: 700; color: var(--blue); }
.qr-credits { font-size: 14px; color: var(--gray-600); }
.qr-image-wrap { display: flex; justify-content: center; margin: 16px 0; }
.qr-image-wrap canvas { border-radius: 12px; box-shadow: var(--shadow); }
.qr-instruction { font-size: 13px; color: var(--gray-600); margin-bottom: 16px; }
.qr-status { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; color: var(--gray-600); margin-bottom: 12px; }

.success-block { text-align: center; padding: 40px 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.success-icon { font-size: 48px; }
.success-block h2 { font-size: 22px; font-weight: 500; }
.success-block p { color: var(--gray-600); }

/* ── Админка ──────────────────────────────────────────────────────────── */
.admin-wrap { max-width: 1000px; margin: 0 auto; }
.admin-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 2px solid var(--gray-200); padding-bottom: 0; }
.tab {
    background: none; border: none; padding: 10px 20px; cursor: pointer;
    font-size: 14px; color: var(--gray-600); border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all .15s;
}
.tab:hover { color: var(--gray-900); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-content { }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat-card { background: var(--gray-50); border-radius: 12px; padding: 20px; text-align: center; }
.stat-num { font-size: 36px; font-weight: 700; color: var(--blue); }
.stat-label { font-size: 13px; color: var(--gray-600); margin-top: 4px; }

.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-box {
    background: #fff; border-radius: 16px; padding: 32px; width: 360px;
    display: flex; flex-direction: column; gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-box h3 { font-size: 18px; font-weight: 600; }
.modal-actions { display: flex; gap: 12px; }
.link { color: var(--blue); }
.link:hover { text-decoration: underline; }
.form-disabled { opacity: .6; pointer-events: none; }

/* ── Адаптив ──────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .main { padding: 16px; }
    .upload-card { padding: 20px; }
    .files-grid, .files-grid-3 { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .packages-grid { grid-template-columns: 1fr; }
    .balance-row { flex-direction: column; gap: 16px; }
    .balance-divider { width: 80px; height: 1px; }
    .stats-grid { grid-template-columns: 1fr; }
    .header-inner { padding: 0 16px; }
    .nav-link { padding: 6px 8px; font-size: 13px; }
}
@media (max-width: 480px) {
    .files-grid, .files-grid-3 { grid-template-columns: 1fr; }
}
