* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0b0d11;
    --bg-secondary: #121913;
    --accent: #46e27f;
    --accent-hover: #5cbf60;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border: #2a2a2a;
    --danger: #f44336;
    --warning: #ff9800;
    --info: #2196f3;
    --surface-border: rgba(70, 226, 127, 0.12);
    --radius: 12px;
}

body {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    background-color: #0b0d11;
    background: radial-gradient(circle at 20% 20%, rgba(70, 226, 127, 0.08), transparent 26%),
        radial-gradient(circle at 80% 0%, rgba(60, 180, 120, 0.08), transparent 32%),
        linear-gradient(180deg, #0a0d0b 0%, #0b0d11 100%);
    color: var(--text-primary);
    min-height: 100vh;
    animation: fadeIn 0.6s ease-out;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(10, 10, 11, 0.9);
    border-right: 1px solid var(--surface-border);
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(14px);
    border-radius: 0 var(--radius) var(--radius) 0;
    overflow: hidden;
    transition: width 0.35s ease, box-shadow 0.35s ease;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-logo span,
.sidebar.collapsed .sidebar-nav a span,
.sidebar.collapsed .sidebar-footer .user-info,
.sidebar.collapsed .sidebar-footer .btn span {
    display: none;
}

.sidebar.collapsed .sidebar-footer {
    padding: 10px;
}

.sidebar.collapsed .sidebar-footer .btn {
    padding: 10px 0;
    width: 40px !important;
    /* Override inline style */
    margin: 0 auto;
    display: flex;
    justify-content: center;
}

.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 14px 10px;
}

.sidebar:not(.collapsed) .sidebar-logo span,
.sidebar:not(.collapsed) .sidebar-nav a span,
.sidebar:not(.collapsed) .sidebar-footer .user-info {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.sidebar.collapsed .sidebar-nav a svg {
    margin: 0;
}

.sidebar::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(var(--border-angle, 0deg),
            transparent 40%,
            rgba(70, 226, 127, 0.5) 50%,
            transparent 60%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.sidebar:hover::before {
    opacity: 1;
    animation: border-rotate 3s linear infinite;
}

@keyframes border-rotate {
    to {
        --border-angle: 360deg;
    }
}

@property --border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 30px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.sidebar.collapsed .sidebar-header {
    padding: 0;
    margin-bottom: 20px;
    justify-content: center;
    min-height: 50px;
    /* Unify height */
}

.sidebar.collapsed .sidebar-logo {
    display: none;
}

.sidebar-logo h1 {
    font-size: 24px;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(70, 226, 127, 0.5);
    margin: 0;
}

.sidebar-logo span {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: rgba(70, 226, 127, 0.1);
    color: var(--accent);
}

/* Expanded state - button inside sidebar */
.sidebar:not(.collapsed) .sidebar-toggle {
    position: static;
    background: none;
    color: var(--text-secondary);
    border-radius: 6px;
    width: auto;
    height: auto;
    box-shadow: none;
}

.sidebar-toggle svg {
    width: 16px;
    height: 16px;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Button styling reset for collapsed state handled by default styles */

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-secondary);
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(70, 226, 127, 0.1);
    color: var(--accent);
    border-left-color: var(--accent);
    transform: translateX(5px);
}

.sidebar-nav a svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav {
    flex: 1;
    overflow: hidden;
}

.sidebar-footer {
    padding: 20px;
    flex-shrink: 0;
}

.sidebar-footer .user-info {
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 10px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    transition: margin-left 0.35s ease;
}

.sidebar.collapsed+.main-content {
    margin-left: 60px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.hamburger:hover {
    background: rgba(70, 226, 127, 0.1);
}

.hamburger span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    margin: 2px 0;
    transition: all 0.3s;
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
}

.page-header h2 {
    font-size: 28px;
    font-weight: 600;
}

/* Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.stat-card h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .change {
    font-size: 13px;
    margin-top: 8px;
}

.stat-card .change.positive {
    color: var(--accent);
}

.stat-card .change.negative {
    color: var(--danger);
}

/* Tables */
.table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.table-header h3 {
    font-size: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

tr:hover {
    background: rgba(70, 226, 127, 0.05);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--border);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
}

select.form-control {
    cursor: pointer;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: rgba(76, 175, 80, 0.2);
    color: var(--accent);
}

.badge-danger {
    background: rgba(244, 67, 54, 0.2);
    color: var(--danger);
}

.badge-warning {
    background: rgba(255, 152, 0, 0.2);
    color: var(--warning);
}

.badge-info {
    background: rgba(33, 150, 243, 0.2);
    color: var(--info);
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--accent);
}

.login-box p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.login-box .btn {
    width: 100%;
    justify-content: center;
    padding: 14px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-success {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
    width: 100%;
    max-width: 500px;
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Search & Filters */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-input input {
    padding-left: 40px;
}

.search-input svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Pagination */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 20px;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
}

.pagination a:hover,
.pagination .active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* Actions */
.actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.action-btn.delete:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
        /* Уже на мобильных, но всегда видимый */
        z-index: 100;
    }

    .sidebar.collapsed {
        width: 50px;
    }

    .main-content {
        margin-left: 200px;
    }

    .sidebar.collapsed+.main-content {
        margin-left: 50px;
    }

    .sidebar-nav a {
        padding: 12px 15px;
        font-size: 13px;
    }

    .sidebar-nav a svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 180px;
        /* Еще компактнее на очень маленьких экранах */
    }

    .sidebar.collapsed {
        width: 45px;
    }

    .main-content {
        margin-left: 180px;
    }

    .sidebar.collapsed+.main-content {
        margin-left: 45px;
    }

    .sidebar-nav a {
        padding: 10px 12px;
        font-size: 12px;
        gap: 8px;
    }

    .sidebar-nav a svg {
        width: 14px;
        height: 14px;
    }

    .sidebar-logo h1 {
        font-size: 20px;
    }

    .sidebar-logo span {
        font-size: 11px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 240px;
        /* Немного уже на планшетах */
    }

    .sidebar.collapsed {
        width: 55px;
    }

    .main-content {
        margin-left: 240px;
    }

    .sidebar.collapsed+.main-content {
        margin-left: 55px;
    }
}

@media (min-width: 1921px) {
    .sidebar {
        width: 300px;
        /* Шире на очень больших экранах */
    }

    .sidebar.collapsed {
        width: 65px;
    }

    .main-content {
        margin-left: 300px;
    }

    .sidebar.collapsed+.main-content {
        margin-left: 65px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
    transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}