/* ================================================================
   Облако NPV - Тёмная тема (стиль 3X-UI)
   ================================================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --bg-input: #1a1a3e;
    --bg-hover: #1a4a7a;
    --bg-sidebar: #0d1b2a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --text-muted: #6c6c80;
    --text-heading: #ffffff;
    --accent: #4fc3f7;
    --accent-hover: #29b6f6;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --info: #2196f3;
    --border: #2a2a4a;
    --border-light: #3a3a5a;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --radius: 8px;
    --radius-sm: 4px;
    --sidebar-width: 250px;
    --header-height: 60px;
    --font-main: 'Segoe UI', 'Roboto', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

/* --- Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* --- Layout --- */
.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo h2 {
    color: var(--text-heading);
    font-size: 1.3rem;
    font-weight: 700;
}

.sidebar-logo img {
    max-height: 40px;
    margin-bottom: 8px;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    gap: 12px;
}

.sidebar-nav a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: rgba(79, 195, 247, 0.1);
    color: var(--accent);
    border-left-color: var(--accent);
}

.sidebar-nav a .icon {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--accent);
    color: #000;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sidebar-footer .user-info .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.sidebar-footer .user-info .details {
    flex: 1;
    min-width: 0;
}

.sidebar-footer .user-info .details .name {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .user-info .details .role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-footer .logout-btn {
    display: block;
    width: 100%;
    padding: 8px;
    text-align: center;
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    transition: background 0.2s;
}

.sidebar-footer .logout-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    color: var(--danger);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px 25px;
    min-height: 100vh;
}

/* --- Header --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h1 {
    font-size: 1.5rem;
    color: var(--text-heading);
    font-weight: 600;
}

.page-header .actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3 {
    color: var(--text-heading);
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    color: var(--text-primary);
}

/* --- Stats Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-heading);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.stat-card.accent {
    border-color: var(--accent);
}

.stat-card.success {
    border-color: var(--success);
}

.stat-card.warning {
    border-color: var(--warning);
}

.stat-card.danger {
    border-color: var(--danger);
}

/* --- Tables --- */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tr:hover td {
    background: rgba(79, 195, 247, 0.03);
}

table td {
    font-size: 0.9rem;
}

table td .actions {
    display: flex;
    gap: 6px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    color: #000;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background: #43a047;
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-warning:hover:not(:disabled) {
    background: #fb8c00;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #e53935;
}

.btn-info {
    background: var(--info);
    color: #fff;
}

.btn-info:hover:not(:disabled) {
    background: #1e88e5;
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 4px;
}

/* --- Status Badges --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-active {
    background: rgba(76, 175, 80, 0.15);
    color: var(--success);
}

.status-active .dot {
    background: var(--success);
}

.status-expired {
    background: rgba(244, 67, 54, 0.15);
    color: var(--danger);
}

.status-expired .dot {
    background: var(--danger);
}

.status-disabled {
    background: rgba(255, 152, 0, 0.15);
    color: var(--warning);
}

.status-disabled .dot {
    background: var(--warning);
}

.status-limited {
    background: rgba(255, 87, 34, 0.15);
    color: var(--danger);
}

.status-limited .dot {
    background: #ff5722;
}

/* --- Alerts / Flash --- */
.flash-message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(76, 175, 80, 0.12);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: var(--success);
}

.alert-danger {
    background: rgba(244, 67, 54, 0.12);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: var(--danger);
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 25px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    color: var(--text-heading);
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 5px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

/* --- Login Page --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    margin: 0;
}

.login-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.login-card .logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-card .logo h1 {
    color: var(--text-heading);
    font-size: 1.6rem;
    margin-bottom: 5px;
}

.login-card .logo p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.login-card .form-group {
    margin-bottom: 20px;
}

.login-card .btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

/* --- Subscription Link --- */
.sub-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(79, 195, 247, 0.1);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 0.8rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-link:hover {
    background: rgba(79, 195, 247, 0.2);
}

/* --- Traffic Bar --- */
.traffic-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.traffic-bar .bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    min-width: 60px;
}

.traffic-bar .bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.traffic-bar .bar .fill.low { background: var(--success); }
.traffic-bar .bar .fill.medium { background: var(--warning); }
.traffic-bar .bar .fill.high { background: var(--danger); }

.traffic-bar .traffic-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* --- Client Cabinet --- */
.client-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.client-info-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
}

.client-info-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.client-info-item .value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.client-info-item .value.mono {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    word-break: break-all;
}

.qr-container {
    text-align: center;
    padding: 20px;
}

.qr-container img {
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 10px;
}

.config-block {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 5px;
}

.config-block pre {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
}

.copy-btn {
    cursor: pointer;
    background: none;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    transition: all 0.2s;
}

.copy-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* --- Support Button --- */
.support-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #0088cc;
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.support-btn:hover {
    background: #0077b5;
    color: #fff;
}

/* --- Responsive --- */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 15px;
    }

    .sidebar-toggle {
        display: block;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .client-info-grid {
        grid-template-columns: 1fr;
    }

    table th,
    table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .modal {
        width: 95%;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Loading Spinner --- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* --- QR Section --- */
.qr-section {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}

.qr-section .qr-code {
    flex: 0 0 200px;
}

.qr-section .configs {
    flex: 1;
    min-width: 300px;
}