/* ============================================================
   SunX Life | Логирование — Main Stylesheet
   ============================================================ */

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

:root {
    --bg:        #0f1117;
    --surface:   #161b27;
    --border:    #1f2937;
    --primary:   #3b82f6;
    --primary-h: #2563eb;
    --text:      #e2e8f0;
    --muted:     #64748b;
    --danger:    #ef4444;
    --success:   #22c55e;
    --warning:   #f59e0b;
    --radius:    8px;
    --sidebar-w: 240px;
    --font:      'Inter', system-ui, -apple-system, sans-serif;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── SCROLLBAR ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── LOGIN PAGE ────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.login-logo .brand span {
    color: var(--primary);
}

.login-logo .sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.login-box h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-group input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
}

.form-group input:focus {
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
}

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

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 14px;
}

.alert-danger {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
}

/* ── LAYOUT ────────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand .name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.2px;
}

.sidebar-brand .name span { color: var(--primary); }

.sidebar-brand .sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.sidebar-section {
    padding: 16px 10px 8px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    padding: 0 8px;
    margin-bottom: 6px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    margin-bottom: 2px;
    white-space: nowrap;
}

.sidebar-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text);
}

.sidebar-item.active {
    background: rgba(59,130,246,0.12);
    color: var(--primary);
}

.sidebar-item svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 6px;
}

.sidebar-user .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user .info .uname {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.sidebar-user .info .role {
    font-size: 11px;
    color: var(--muted);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    transition: color 0.12s, background 0.12s;
    margin-top: 4px;
}

.logout-btn:hover {
    background: rgba(239,68,68,0.08);
    color: var(--danger);
}

/* ── MAIN CONTENT ──────────────────────────────────────── */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 56px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.topbar-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(59,130,246,0.12);
    color: var(--primary);
    font-weight: 500;
}

.content {
    padding: 24px;
    flex: 1;
}

/* ── DASHBOARD STATS ───────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}

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

.stat-card .value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

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

/* ── RECENT EVENTS ─────────────────────────────────────── */
.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.event-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.event-card .card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.event-card .card-header .title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.event-card .card-header .count {
    font-size: 11px;
    color: var(--muted);
}

.event-list {
    max-height: 260px;
    overflow-y: auto;
}

.event-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(31,41,55,0.5);
    transition: background 0.1s;
}

.event-row:last-child { border-bottom: none; }

.event-row:hover { background: rgba(255,255,255,0.02); }

.event-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}

.dot-blue  { background: var(--primary); }
.dot-green { background: var(--success); }
.dot-amber { background: var(--warning); }
.dot-red   { background: var(--danger); }

.event-text {
    flex: 1;
    font-size: 12px;
    color: var(--text);
    line-height: 1.45;
}

.event-time {
    font-size: 11px;
    color: var(--muted);
    flex-shrink: 0;
    white-space: nowrap;
}

/* ── LOGS PAGE ─────────────────────────────────────────── */
.filters-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 140px;
}

.filter-group label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.filter-group input,
.filter-group select {
    padding: 7px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: var(--primary);
}

.filter-group select option {
    background: var(--surface);
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 13px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ── TABLE ─────────────────────────────────────────────── */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}

.table-info-bar .count-badge {
    background: rgba(59,130,246,0.1);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 600;
    font-size: 11px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: rgba(0,0,0,0.15);
}

tbody td {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid rgba(31,41,55,0.4);
    vertical-align: middle;
}

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

tbody tr:hover td { background: rgba(255,255,255,0.02); }

.td-mono {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--muted);
}

.td-id {
    color: var(--muted);
    font-size: 12px;
}

.td-time {
    white-space: nowrap;
    color: var(--muted);
    font-size: 12px;
}

.td-desc {
    max-width: 380px;
    word-break: break-word;
}

.money-pos { color: var(--success); }
.money-neg { color: var(--danger); }

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(59,130,246,0.1);
    color: var(--primary);
}

/* ── LOAD MORE ─────────────────────────────────────────── */
.load-more-wrap {
    text-align: center;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.btn-load-more {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 8px 24px;
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-load-more:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-load-more:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── EMPTY / LOADING ───────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.3;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* ── FOOTER ────────────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 16px 24px;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.site-footer a {
    color: var(--primary);
    transition: opacity 0.15s;
}

.site-footer a:hover { opacity: 0.75; }

/* ── TOAST ─────────────────────────────────────────────── */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    font-size: 13px;
    color: var(--text);
    z-index: 9999;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

#toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .events-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .filters-bar { flex-direction: column; }
    .filter-group { min-width: unset; width: 100%; }
}
