/* ═══════════════════════════════════════════════════════
   OSFR Admin Panel — Modern CSS (без фреймворков)
   ═══════════════════════════════════════════════════════ */

:root {
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-nav: #1e293b;
    --text: #1e293b;
    --text-light: #64748b;
    --text-nav: #e2e8f0;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --secondary: #94a3b8;
    --secondary-bg: #f1f5f9;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --transition: .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

/* ── NAV ──────────────────────────────────────────────── */
.navbar {
    background: var(--bg-nav);
    color: var(--text-nav);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    margin-right: 2rem;
    white-space: nowrap;
}

.navbar-links {
    display: flex;
    gap: .25rem;
    list-style: none;
    flex: 1;
}

.navbar-links a {
    color: var(--text-nav);
    padding: .5rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    transition: background var(--transition);
}
.navbar-links a:hover,
.navbar-links a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-left: auto;
    font-size: .85rem;
}

.navbar-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.navbar-user .btn-logout {
    color: var(--text-nav);
    opacity: .7;
    font-size: .8rem;
    padding: .35rem .75rem;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: var(--radius);
    transition: all var(--transition);
}
.navbar-user .btn-logout:hover { opacity: 1; background: rgba(255,255,255,.1); }

/* Mobile burger */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-nav);
    font-size: 1.5rem;
    cursor: pointer;
    padding: .25rem;
}

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

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ── CARDS ─────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

/* Stat cards grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    border-top: 3px solid var(--primary);
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card.success { border-top-color: var(--success); }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.danger  { border-top-color: var(--danger); }
.stat-card.secondary { border-top-color: var(--secondary); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-label {
    font-size: .85rem;
    color: var(--text-light);
    margin-top: .25rem;
}

/* ── CHARTS ───────────────────────────────────────────── */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    position: relative;
    height: 280px;
}

/* ── TABLE ─────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

thead th {
    background: var(--secondary-bg);
    padding: .75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-light);
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

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

tbody tr:hover { background: #f8fafc; }

/* ── BADGES ───────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.badge-success   { background: var(--success-bg); color: #065f46; }
.badge-warning   { background: var(--warning-bg); color: #92400e; }
.badge-danger    { background: var(--danger-bg);  color: #991b1b; }
.badge-secondary { background: var(--secondary-bg); color: #475569; }

/* ── BUTTONS ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }

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

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-outline:hover { background: var(--secondary-bg); }

.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-icon { padding: .4rem; min-width: 32px; justify-content: center; }

/* ── FORMS ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: .35rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.form-control.error {
    border-color: var(--danger);
}

.form-error {
    color: var(--danger);
    font-size: .8rem;
    margin-top: .25rem;
}

.form-hint {
    color: var(--text-light);
    font-size: .8rem;
    margin-top: .25rem;
}

select.form-control {
    appearance: auto;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

/* Checkbox / toggle */
.form-check {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ── FILTERS BAR ──────────────────────────────────────── */
.filters {
    display: flex;
    gap: .75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters .form-group {
    margin-bottom: 0;
}

.filters .form-control {
    min-width: 160px;
}

.filter-search {
    flex: 1;
    min-width: 200px;
}

/* ── FLASH MESSAGES ───────────────────────────────────── */
.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.flash-success { background: var(--success-bg); color: #065f46; }
.flash-warning { background: var(--warning-bg); color: #92400e; }
.flash-danger  { background: var(--danger-bg);  color: #991b1b; }

/* ── PAGINATION ───────────────────────────────────────── */
.pagination {
    display: flex;
    gap: .25rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: .4rem .75rem;
    border-radius: var(--radius);
    font-size: .85rem;
    border: 1px solid var(--border);
    color: var(--text);
    transition: all var(--transition);
}
.pagination a:hover { background: var(--secondary-bg); }
.pagination .active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination .disabled {
    opacity: .4;
    pointer-events: none;
}

/* ── DETAIL PAGE ──────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: .6rem 0;
    border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }

.detail-label {
    font-weight: 600;
    font-size: .85rem;
    color: var(--text-light);
    min-width: 140px;
}

.detail-value {
    text-align: right;
    word-break: break-all;
}

/* Actions panel */
.actions-panel {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.actions-panel h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* ── LOGIN PAGE ───────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: .5rem;
}

.login-card p {
    color: var(--text-light);
    font-size: .9rem;
    margin-bottom: 2rem;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-light);
    font-size: .8rem;
}
.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.login-debug {
    margin-top: 1rem;
}

/* ── EMPTY STATE ──────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}
.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: .4;
}
.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: .5rem;
    color: var(--text);
}

/* ── FILE UPLOAD ──────────────────────────────────────── */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}
.file-upload:hover {
    border-color: var(--primary);
    background: rgba(59,130,246,.03);
}
.file-upload input[type="file"] {
    display: none;
}

/* Import results */
.import-results {
    margin-top: 1.5rem;
}

.import-results .result-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 0;
    font-size: .9rem;
}

.import-errors {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--danger-bg);
    border-radius: var(--radius);
    font-size: .85rem;
    max-height: 300px;
    overflow-y: auto;
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: .75rem 1rem;
    }

    .navbar-toggle { display: block; }

    .navbar-links {
        display: none;
        width: 100%;
        flex-direction: column;
        padding: .5rem 0;
    }
    .navbar-links.open { display: flex; }

    .navbar-user {
        width: 100%;
        justify-content: flex-end;
        padding-top: .5rem;
        border-top: 1px solid rgba(255,255,255,.1);
    }

    .container { padding: 1rem; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters {
        flex-direction: column;
    }
    .filters .form-control {
        min-width: 100%;
    }
}

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

    .login-card {
        margin: 1rem;
        padding: 1.5rem;
    }
}
