/* === ADMIN.CSS === */
/* admin/assets/admin.css */
/* НАЗНАЧЕНИЕ: Стили админки. Dark theme дефолт, компактный layout (Bloomberg-like density) */
/* СВЯЗИ: admin/index.php, admin/assets/admin.js */
/* РАЗМЕР: ~520 строк */

:root {
    --bg: oklch(0.13 0.012 240);
    --bg-2: oklch(0.17 0.014 240);
    --bg-3: oklch(0.21 0.014 240);
    --border: oklch(0.27 0.012 240);
    --border-strong: oklch(0.35 0.012 240);
    --text: oklch(0.92 0.005 240);
    --text-2: oklch(0.72 0.01 240);
    --muted: oklch(0.55 0.012 240);
    --accent: oklch(0.7 0.18 250);
    --accent-2: oklch(0.6 0.2 250);
    --success: oklch(0.7 0.18 145);
    --warning: oklch(0.78 0.16 70);
    --error: oklch(0.7 0.2 25);
    --info: oklch(0.7 0.13 215);

    --radius: 8px;
    --radius-sm: 5px;
    --gap: 10px;
    --row-h: 32px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

button { font-family: inherit; cursor: pointer; }

/* === LOGIN === */
body.login-mode {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1200px 600px at 50% -100px, oklch(0.22 0.06 250 / 0.6), transparent),
        var(--bg);
}

.login-wrap { width: 100%; max-width: 400px; padding: 24px; }

.login-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}

.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }

.login-logo-mark {
    width: 36px; height: 36px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
}

.login-logo-text { font-weight: 700; font-size: 18px; }
.login-logo-sub { color: var(--muted); font-weight: 500; }

.login-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; }

.login-error {
    background: oklch(0.25 0.1 25 / 0.4);
    color: var(--error);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.login-field { display: block; margin-bottom: 14px; }
.login-field span {
    display: block;
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 6px;
}

.login-field input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s var(--ease);
}

.login-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-btn {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-top: 4px;
    transition: background 0.15s var(--ease);
}

.login-btn:hover { background: var(--accent-2); }

.login-hint {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin-top: 16px;
}

/* === APP LAYOUT === */
body.app-mode {
    overflow: hidden;
}

#admin-app {
    display: grid;
    grid-template-columns: 220px 1fr;
    height: 100vh;
}

.adm-sidebar {
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
}

.adm-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.adm-logo-mark {
    width: 32px; height: 32px;
    background: var(--accent);
    color: #fff;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
}

.adm-logo-text { font-weight: 700; font-size: 14px; line-height: 1.2; }
.adm-logo-sub { font-size: 11px; color: var(--muted); }

.adm-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.adm-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.1s var(--ease);
}

.adm-nav-link:hover {
    background: var(--bg-3);
    color: var(--text);
}

.adm-nav-link.active {
    background: oklch(0.25 0.1 250 / 0.3);
    color: var(--accent);
}

.adm-nav-icon { font-size: 14px; }

.adm-sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 12px;
}

.adm-user-name {
    font-size: 12px;
    font-weight: 500;
    word-break: break-all;
    margin-bottom: 2px;
}

.adm-user-role {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.adm-logout {
    display: block;
    margin-top: 10px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-2);
    border: 1px solid var(--border);
    text-align: center;
    transition: all 0.1s var(--ease);
}

.adm-logout:hover { background: var(--bg-3); color: var(--text); }

.adm-main {
    overflow: auto;
    padding: 16px;
}

.adm-loading {
    text-align: center;
    color: var(--muted);
    padding: 60px;
    font-size: 14px;
}

/* === PAGE HEADER === */
.adm-page-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.adm-page-title {
    font-size: 18px;
    font-weight: 700;
}

.adm-page-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* === STATS GRID === */
.adm-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--gap);
    margin-bottom: 16px;
}

.adm-stat {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.adm-stat-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.adm-stat-num {
    font-size: 22px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
}

.adm-stat-num.warning { color: var(--warning); }
.adm-stat-num.error { color: var(--error); }
.adm-stat-num.success { color: var(--success); }

.adm-stat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* === FILTERS === */
.adm-filters {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.adm-filters input,
.adm-filters select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    min-height: 28px;
}

.adm-filters input:focus,
.adm-filters select:focus {
    outline: none;
    border-color: var(--accent);
}

.adm-filters input[type="search"] { min-width: 200px; }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-3);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.1s var(--ease);
    text-decoration: none;
}

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

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

.btn-danger { background: oklch(0.4 0.15 25); color: #fff; border-color: oklch(0.5 0.15 25); }
.btn-sm { padding: 3px 8px; font-size: 11px; }

/* === TABLE === */
.adm-table-wrap {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.adm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.adm-table thead th {
    background: var(--bg-3);
    color: var(--text-2);
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.adm-table tbody td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    height: var(--row-h);
}

.adm-table tbody tr:hover { background: oklch(0.2 0.014 240); }

.adm-table .num {
    font-family: 'JetBrains Mono', monospace;
    text-align: right;
    font-feature-settings: 'tnum';
}

.adm-table .mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-2);
}

.adm-table .empty {
    padding: 40px;
    text-align: center;
    color: var(--muted);
}

.adm-table .row-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

/* === STATUS BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
    text-transform: lowercase;
}

.badge-expected { background: oklch(0.3 0.05 215 / 0.4); color: var(--info); border-color: oklch(0.3 0.08 215); }
.badge-paid { background: oklch(0.3 0.08 145 / 0.4); color: var(--success); border-color: oklch(0.3 0.1 145); }
.badge-overpaid { background: oklch(0.3 0.08 145 / 0.4); color: var(--success); border-color: oklch(0.3 0.1 145); }
.badge-partial_paid { background: oklch(0.3 0.08 70 / 0.4); color: var(--warning); border-color: oklch(0.3 0.1 70); }
.badge-underpaid { background: oklch(0.3 0.08 70 / 0.4); color: var(--warning); border-color: oklch(0.3 0.1 70); }
.badge-expired { background: oklch(0.25 0.012 240); color: var(--muted); border-color: var(--border); }
.badge-cancelled { background: oklch(0.25 0.012 240); color: var(--muted); border-color: var(--border); }
.badge-manual_review { background: oklch(0.3 0.1 25 / 0.4); color: var(--error); border-color: oklch(0.3 0.12 25); }

/* === PAGINATION === */
.adm-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-2);
    font-size: 12px;
    color: var(--text-2);
}

.adm-pag-buttons { display: flex; gap: 4px; }

/* === MODAL === */
.adm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.adm-modal {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 16px 64px rgba(0,0,0,0.5);
}

.adm-modal-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-2);
    z-index: 1;
}

.adm-modal-title { font-size: 15px; font-weight: 700; }
.adm-modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    padding: 0;
}
.adm-modal-close:hover { color: var(--text); }

.adm-modal-body { padding: 18px; }
.adm-modal-section { margin-bottom: 18px; }
.adm-modal-section h4 {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 600;
}

.adm-kv {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 4px 12px;
    font-size: 12px;
}

.adm-kv-k { color: var(--muted); }
.adm-kv-v { word-break: break-all; }
.adm-kv-v.mono { font-family: 'JetBrains Mono', monospace; }

/* === TOAST === */
#adm-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
    min-width: 220px;
}

.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* === MOBILE === */
@media (max-width: 800px) {
    #admin-app { grid-template-columns: 1fr; }
    .adm-sidebar { display: none; }
}
