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

:root {
    /* Primary colors */
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --secondary: #14B8A6;
    --accent: #8B5CF6;

    /* Backgrounds — Light */
    --bg-main: #EBEEF2;
    --bg-sidebar: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-secondary: #F3F4F6;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    /* Borders */
    --border: #E5E7EB;
    --border-light: #F3F4F6;

    /* Status colors */
    --success: #3B82F6;
    --warning: #F59E0B;
    --error: #EF4444;
    --danger: #EF4444;
    --info: #3B82F6;

    /* Card colors */
    --card-blue: linear-gradient(135deg, #4285F4, #2A56C6);
    --card-green: linear-gradient(135deg, #34A853, #1E7E3E);
    --card-yellow: linear-gradient(135deg, #FBBC05, #F29900);
    --card-red: linear-gradient(135deg, #EA4335, #C5221F);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    /* Modal */
    --modal-overlay: rgba(0, 0, 0, 0.5);
}

/* ========================================
   DARK THEME
   ======================================== */
[data-theme="dark"] {
    --bg-main: #2B2F36;
    --bg-sidebar: #242830;
    --bg-card: #33373F;
    --bg-secondary: #3A3F48;

    --text-primary: #E8ECF1;
    --text-secondary: #A0A8B4;
    --text-muted: #6B7585;

    --border: #3E434C;
    --border-light: #33373F;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px -1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);

    --modal-overlay: rgba(0, 0, 0, 0.7);
}

/* Dark theme body gradient */
[data-theme="dark"] body {
    background: linear-gradient(180deg, #2F343C, #242830);
}

/* Dark theme form inputs */
[data-theme="dark"] .form-control,
[data-theme="dark"] select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] textarea {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border);
}

/* Dark theme tables */
[data-theme="dark"] .table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

[data-theme="dark"] .table tr:hover td {
    background: rgba(59, 130, 246, 0.05);
}

/* Dark theme modals */
[data-theme="dark"] .modal-backdrop {
    background: var(--modal-overlay);
}

[data-theme="dark"] .modal {
    background: var(--bg-card);
}

/* Dark theme chart period buttons */
[data-theme="dark"] .chart-period-btn {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border);
}

[data-theme="dark"] .chart-period-btn.active {
    background: var(--primary);
    color: white;
}

/* Dark theme yellow card — white text */
[data-theme="dark"] .color-card.yellow {
    color: #FFFFFF;
}

/* ========================================
   THEME TOGGLE BUTTON
   ======================================== */
.theme-toggle {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    position: relative;
    background: #E5E7EB;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.theme-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="dark"] .theme-toggle {
    background: var(--primary);
}

[data-theme="dark"] .theme-toggle::after {
    transform: translateX(20px);
}

.theme-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.theme-toggle-wrap svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.theme-toggle-label {
    font-size: 12px;
    color: var(--text-muted);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overscroll-behavior-x: none;
}

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

/* ========================================
   LAYOUT
   ======================================== */
.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 100;
    /* Скролл колесом работает, но полосу прокрутки не показываем */
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* IE/old Edge */
}
.sidebar::-webkit-scrollbar {     /* Chrome/Safari/Edge */
    width: 0;
    height: 0;
    display: none;
}

.sidebar-logo {
    padding: 16px 24px;
    height: 65px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
}

.sidebar-logo svg {
    width: 32px;
    height: 32px;
    padding: 6px;
    background: var(--card-blue);
    border-radius: 8px;
    color: white;
}

.sidebar-logo span {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-bottom: 2px;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: #3B82F6;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* === Внешние ссылки на наши другие сервисы === */
.nav-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 14px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}
.nav-divider::before,
.nav-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

.nav-ext {
    align-items: center;
}
.nav-ext-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    line-height: 1.25;
}
.nav-ext-text strong {
    font-size: 14px;
    color: inherit;
    font-weight: 500;
}
.nav-ext-text small {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 1px;
    font-weight: 400;
}
.nav-ext-arrow {
    width: 13px !important;
    height: 13px !important;
    color: var(--text-muted);
    opacity: 0;
    transform: translate(-3px, 3px);
    transition: opacity 0.15s, transform 0.15s;
    align-self: center;
}
.nav-ext:hover .nav-ext-arrow {
    opacity: 0.7;
    transform: translate(0, 0);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: var(--card-blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.sidebar-user-info {
    flex: 1;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.sidebar-user-logout {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-user-logout:hover {
    color: var(--primary);
}

/* Main content */
.main {
    flex: 1;
    min-width: 0; /* критично: flex-item не должен растягивать viewport под широкий контент */
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    height: 65px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
    box-sizing: border-box;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

/* Hamburger menu button */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    gap: 5px;
    border-radius: 8px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.hamburger:hover {
    background: var(--bg-secondary);
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Sidebar overlay (hidden by default) */
.sidebar-overlay {
    display: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Content */
.content {
    flex: 1;
    min-width: 0; /* флекс-фикс: контент-обёртка не должна растягиваться по ребёнку */
    padding: 24px 32px;
}

/* ========================================
   COLOR CARDS (Stats)
   ======================================== */
.color-cards-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.color-card {
    border-radius: 16px;
    padding: 24px;
    color: white;
    position: relative;
    overflow: hidden;
    min-height: 140px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.color-card.blue { background: var(--card-blue); }
.color-card.green { background: var(--card-green); }
.color-card.yellow { background: var(--card-yellow); color: #FFFFFF; }
.color-card.yellow .color-card-title { opacity: 0.8; }
.color-card.yellow .color-card-stats { opacity: 0.7; }
.color-card.yellow .color-card-icon { opacity: 0.12; }
.color-card.red { background: var(--card-red); }

.color-card-title {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 8px;
}

.color-card-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 12px;
}

.color-card-stats {
    font-size: 13px;
    opacity: 0.85;
    line-height: 1.6;
}

.color-card-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: 80px;
    opacity: 0.15;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-link {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
}

.card-body {
    padding: 24px;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.card-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap; /* на узких экранах кнопки переносятся на новую строку, а не уезжают за viewport */
}

.card-filters .form-control {
    height: 40px;
    padding: 8px 14px;
    font-size: 14px;
    line-height: 1.4;
}

.card-filters select.form-control {
    padding-right: 36px;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn:hover { text-decoration: none; }

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
}

.btn-secondary {
    background: var(--border-light);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--error);
    color: white;
}
.btn-danger:hover {
    background: #DC2626;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ========================================
   FORMS
   ======================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

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

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ========================================
   CUSTOM SELECT
   ======================================== */
.custom-select-wrapper {
    position: relative;
}

.custom-select {
    position: relative;
    cursor: pointer;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s ease;
    min-height: 42px;
}

.custom-select-trigger:hover {
    border-color: var(--primary);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-radius: 10px 10px 0 0;
}

.custom-select-trigger span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.custom-select-trigger span.placeholder {
    color: var(--text-muted);
}

.custom-select-arrow {
    width: 16px;
    height: 16px;
    margin-left: 8px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.custom-select.open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    width: max-content;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1001;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.custom-select.open .custom-select-options {
    display: block;
}

.custom-select-search {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    outline: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 1;
}

.custom-select-search::placeholder {
    color: var(--text-muted);
}

.custom-select-option {
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
}

.custom-select-option:hover {
    background: var(--bg-secondary);
}

.custom-select-option.selected {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    font-weight: 500;
}

.custom-select-option:last-child {
    border-radius: 0 0 10px 10px;
}

/* Scrollbar for options */
.custom-select-options::-webkit-scrollbar {
    width: 6px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Hide native select when custom is active */
select.form-control.has-custom {
    display: none;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* ========================================
   TABLES
   ======================================== */
.table-wrapper {
    overflow-x: auto;
}

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

.table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--border-light);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.table tbody tr:hover {
    background: var(--bg-secondary);
}

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

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
}

.badge-secondary {
    background: var(--border-light);
    color: var(--text-secondary);
}

/* ========================================
   MODALS
   ======================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-lg {
    max-width: 800px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-light);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal > form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--border-light);
    flex-shrink: 0;
}

/* ========================================
   ACTIONS
   ======================================== */
.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-light);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

.action-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

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

/* ========================================
   ALERTS
   ======================================== */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.alert-success {
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

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

/* ========================================
   CODE BLOCK
   ======================================== */
.code-block {
    background: #0f172a;
    color: #A5F3FC;
    padding: 16px;
    border-radius: 10px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    position: relative;
}

.code-block .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    cursor: pointer;
}

.code-block .copy-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* ========================================
   FILTERS
   ======================================== */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--border-light);
    border-radius: 10px;
}

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

/* Period Quick Buttons */
.period-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
}

.period-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.period-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-color: var(--text-muted);
}

.period-btn.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
}

/* ========================================
   CHART SECTION
   ======================================== */
.chart-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

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

.chart-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chart-total {
    font-size: 13px;
    color: var(--text-secondary);
}

.chart-total strong {
    color: var(--text-primary);
}

.chart-interval-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
}

.interval-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.interval-btn:hover {
    color: var(--text-primary);
}

.interval-btn.active {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.chart-container {
    height: 260px;
    position: relative;
    margin: 0 -4px;
}

/* ========================================
   DASHBOARD CHART
   ======================================== */
.dashboard-chart-card {
    margin-bottom: 24px;
    padding: 0;
    overflow: hidden;
}

.dashboard-chart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.chart-period-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chart-period-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.chart-period-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.chart-period-btn.active {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}

.dashboard-chart-container {
    height: 320px;
    padding: 20px;
    position: relative;
}

.dashboard-chart-empty {
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
}

.dashboard-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}

.chart-legend-item input {
    display: none;
}

.chart-legend-item .legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-legend-item input:not(:checked) + .legend-color {
    opacity: 0.3;
}

.chart-legend-item input:not(:checked) ~ .legend-label {
    opacity: 0.5;
    text-decoration: line-through;
}

.chart-legend-item:hover {
    color: var(--text-primary);
}

/* Custom Chart Tooltip */
#chartjs-tooltip {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    font-family: inherit;
    font-size: 13px;
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
    transition: opacity 0.15s ease;
}

#chartjs-tooltip .tooltip-header {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 10px 14px;
    font-weight: 600;
    text-align: center;
}

#chartjs-tooltip .tooltip-body {
    padding: 12px 14px;
}

#chartjs-tooltip .tooltip-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

#chartjs-tooltip .tooltip-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

#chartjs-tooltip .tooltip-label {
    color: var(--text-muted);
    flex: 1;
}

#chartjs-tooltip .tooltip-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* ========================================
   BOTTOM ROW (Two columns)
   ======================================== */
.bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ========================================
   UTILITIES
   ======================================== */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

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

.login-card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.login-header {
    padding: 32px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.login-logo {
    width: 60px;
    height: 60px;
    background: var(--card-blue);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.login-logo svg {
    width: 32px;
    height: 32px;
    color: white;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

.login-body {
    padding: 32px;
}

/* ========================================
   OFFER ROW (Site Modal)
   ======================================== */
.offer-row {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.offer-row:last-child {
    margin-bottom: 0;
}

.offer-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.offer-row-number {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.offer-row-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 768px) {
    .offer-row-content {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1200px) {
    .color-cards-row {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 768px) {
    /* ======== APP CONTAINER ======== */
    .app {
        display: block;
        min-height: auto;
    }

    /* ======== SIDEBAR & NAVIGATION ======== */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .hamburger {
        display: flex;
    }

    .main {
        margin-left: 0;
        min-height: auto;
        display: block;
    }

    .header {
        padding: 12px 16px;
    }

    .page-title {
        font-size: 18px;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .content {
        padding: 16px;
    }

    /* ======== CARDS ======== */
    .color-cards-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .color-card {
        min-height: 100px;
        padding: 16px;
    }

    .color-card-value {
        font-size: 26px;
    }

    .color-card-icon {
        width: 50px;
        height: 50px;
        right: 12px;
    }

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

    .card {
        border-radius: 12px;
        margin-bottom: 16px;
    }

    .card-header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .card-title {
        font-size: 15px;
    }

    .card-filters {
        flex-wrap: wrap;
        width: 100%;
        gap: 8px;
    }

    .card-filters .form-control {
        width: 100% !important;
        min-width: 0 !important;
    }

    .card-filters .btn {
        width: 100%;
    }

    .card-body {
        padding: 16px;
    }

    .card-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .card-actions .btn {
        flex: 1;
        min-width: 0;
    }

    /* ======== BOTTOM ROW ======== */
    .bottom-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* ======== FILTERS ======== */
    .filters {
        padding: 12px;
        gap: 8px;
    }

    .filters form {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .filters .form-control {
        width: 100% !important;
        min-width: 0 !important;
    }

    .filters .btn {
        width: 100%;
    }

    /* ======== PERIOD BUTTONS ======== */
    .period-buttons {
        padding: 12px;
        gap: 6px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .period-buttons::-webkit-scrollbar {
        display: none;
    }

    .period-btn {
        padding: 6px 12px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* ======== CHART PERIOD BUTTONS (Dashboard) ======== */
    .dashboard-chart-header {
        padding: 12px;
    }

    .chart-period-buttons {
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 4px;
    }

    .chart-period-buttons::-webkit-scrollbar {
        display: none;
    }

    .chart-period-btn {
        padding: 5px 10px;
        font-size: 11px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .dashboard-chart-container {
        height: 220px;
        padding: 12px;
    }

    .dashboard-chart-legend {
        padding: 12px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .chart-legend-item {
        font-size: 12px;
        flex: 0 0 auto;
    }

    /* ======== CHART SECTION (Clicks) ======== */
    .chart-section {
        padding: 12px;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chart-controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chart-interval-selector {
        width: 100%;
    }

    .interval-btn {
        flex: 1;
        text-align: center;
    }

    .chart-container {
        height: 200px;
    }

    /* ======== TABLES ======== */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
        font-size: 13px;
    }

    .table th,
    .table td {
        padding: 10px 12px;
        white-space: nowrap;
    }

    .table th {
        font-size: 11px;
    }

    /* ======== ACTIONS ======== */
    .actions {
        gap: 4px;
        flex-wrap: nowrap;
    }

    .action-btn {
        width: 32px;
        height: 32px;
    }

    .action-btn svg {
        width: 14px;
        height: 14px;
    }

    /* ======== MODALS ======== */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal {
        max-width: 100%;
        max-height: 90vh;
        margin: 0;
        border-radius: 16px 16px 0 0;
    }

    .modal-lg,
    .modal-xl {
        max-width: 100%;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* ======== BADGES ======== */
    .badge {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* ======== PAGINATION ======== */
    .pagination {
        padding: 16px 12px;
        gap: 4px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .pagination a,
    .pagination span {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 13px;
    }

    /* ======== ALERTS ======== */
    .alert {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* ======== CODE BLOCKS ======== */
    .code-block {
        padding: 12px;
        font-size: 11px;
    }

    .code-block .copy-btn {
        padding: 4px 8px;
        font-size: 10px;
    }

    /* ======== CONVERSION LIST ======== */
    .conversion-item {
        padding: 12px 16px;
        gap: 10px;
    }

    .conversion-icon {
        width: 36px;
        height: 36px;
    }

    .conversion-title {
        font-size: 13px;
    }

    .conversion-subtitle {
        font-size: 11px;
    }

    .conversion-amount {
        font-size: 13px;
    }

    .conversion-time {
        font-size: 11px;
    }

    /* ======== SETTINGS PAGE ======== */
    .settings-grid,
    form > div[style*="grid"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* ======== EXPENSES - CATEGORY STATS ======== */
    .category-stats {
        padding: 12px;
        gap: 8px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .category-stats::-webkit-scrollbar {
        display: none;
    }

    .category-stat-item {
        padding: 8px 12px;
        font-size: 13px;
        flex-shrink: 0;
    }

    .category-stat-icon {
        width: 28px;
        height: 28px;
    }

    .category-stat-icon svg {
        width: 14px;
        height: 14px;
    }

    .category-stat-name {
        font-size: 13px;
    }

    .category-stat-amount {
        font-size: 11px;
    }

    /* ======== EXPENSES - CATEGORY SELECTOR (Modal) ======== */
    .category-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .category-card {
        padding: 12px 8px;
        gap: 8px;
    }

    .category-card-icon {
        width: 40px;
        height: 40px;
    }

    .category-card-icon svg {
        width: 20px;
        height: 20px;
    }

    .category-card-name {
        font-size: 12px;
    }

    /* ======== EXPENSES - COLOR/ICON SELECTORS ======== */
    .color-selector {
        gap: 6px;
    }

    .color-option {
        width: 32px;
        height: 32px;
    }

    .icon-selector {
        gap: 4px;
    }

    .icon-option {
        width: 36px;
        height: 36px;
    }

    .icon-option svg {
        width: 18px;
        height: 18px;
    }

    /* ======== EXPENSES - CATEGORY LIST (Manage Modal) ======== */
    .category-list-item {
        padding: 10px;
        gap: 10px;
    }

    .category-list-item-icon {
        width: 36px;
        height: 36px;
    }

    .category-list-item-icon svg {
        width: 18px;
        height: 18px;
    }

    .category-list-item-name {
        font-size: 13px;
    }

    .category-list-item-count {
        font-size: 11px;
    }

    /* ======== BUTTONS ======== */
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
    }

    .btn svg {
        width: 16px;
        height: 16px;
    }

    /* ======== FORMS ======== */
    .form-group {
        margin-bottom: 16px;
    }

    .form-group label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .form-control {
        padding: 10px 12px;
        font-size: 14px;
    }

    .form-hint {
        font-size: 11px;
    }

    /* ======== LOGIN PAGE ======== */
    .login-card {
        margin: 16px;
        max-width: none;
    }

    .login-header {
        padding: 24px 20px;
    }

    .login-body {
        padding: 24px 20px;
    }

    /* ======== UTILITIES ======== */
    .mb-3 {
        margin-bottom: 16px;
    }

    .mt-3 {
        margin-top: 16px;
    }

    /* ======== EMPTY STATE ======== */
    .empty-state {
        padding: 40px 16px;
    }

    .empty-state svg {
        width: 48px;
        height: 48px;
    }
}

/* ========================================
   EXTRA SMALL DEVICES (max-width: 480px)
   ======================================== */
@media (max-width: 480px) {
    .content {
        padding: 12px;
    }

    .color-card {
        min-height: 90px;
        padding: 14px;
    }

    .color-card-value {
        font-size: 22px;
    }

    .color-card-title {
        font-size: 12px;
    }

    .color-card-stats {
        font-size: 11px;
    }

    .color-card-icon {
        width: 40px;
        height: 40px;
        right: 10px;
    }

    .card-header {
        padding: 10px 12px;
    }

    .card-title {
        font-size: 14px;
    }

    .card-body {
        padding: 12px;
    }

    .table {
        min-width: 500px;
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 8px 10px;
    }

    .modal-header {
        padding: 14px;
    }

    .modal-title {
        font-size: 15px;
    }

    .modal-body {
        padding: 14px;
    }

    .modal-footer {
        padding: 10px 14px;
    }

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

    .form-control {
        padding: 8px 10px;
        font-size: 13px;
    }

    .filters {
        padding: 10px;
    }

    .period-btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .chart-period-btn {
        padding: 4px 8px;
        font-size: 10px;
    }

    .dashboard-chart-container {
        height: 180px;
        padding: 10px;
    }

    .chart-container {
        height: 160px;
    }

    .category-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .category-card {
        padding: 10px 6px;
    }

    .category-card-icon {
        width: 36px;
        height: 36px;
    }

    .category-card-icon svg {
        width: 18px;
        height: 18px;
    }

    .category-card-name {
        font-size: 11px;
    }

    .conversion-item {
        padding: 10px 12px;
    }

    .conversion-icon {
        width: 32px;
        height: 32px;
    }

    .conversion-title {
        font-size: 12px;
    }

    .action-btn {
        width: 28px;
        height: 28px;
    }

    .action-btn svg {
        width: 12px;
        height: 12px;
    }

    .pagination a,
    .pagination span {
        min-width: 28px;
        height: 28px;
        padding: 0 6px;
        font-size: 12px;
    }

    .badge {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* ========================================
   CONVERSIONS LIST
   ======================================== */
.conversion-list {
    display: flex;
    flex-direction: column;
}

.conversion-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}

.conversion-item:last-child {
    border-bottom: none;
}

.conversion-item:hover {
    background: var(--bg-secondary);
}

.conversion-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.conversion-icon.ftd {
    background: rgba(59, 130, 246, 0.15);
}

.conversion-icon.reg {
    background: rgba(59, 130, 246, 0.15);
}

.conversion-info {
    flex: 1;
    min-width: 0;
}

.conversion-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.conversion-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversion-meta {
    text-align: right;
    flex-shrink: 0;
}

.conversion-amount {
    font-weight: 700;
    font-size: 14px;
    color: var(--success);
}

.conversion-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ========================================
   PAGINATION
   ======================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    border-top: 1px solid var(--border-light);
}

.pagination a,
.pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
}

.pagination a {
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.pagination a:hover {
    color: var(--text-primary);
    background: var(--border);
    border-color: var(--text-muted);
}

.pagination span.active {
    color: white;
    background: var(--primary);
    border: 1px solid var(--primary);
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ========================================
   EXPENSES PAGE - CATEGORY STATS
   ======================================== */
.category-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.category-stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
    color: var(--text-secondary);
}

.category-stat-item:hover {
    background: var(--border-light);
    border-color: var(--text-muted);
}

.category-stat-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.category-stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.category-stat-icon svg {
    width: 16px;
    height: 16px;
}

.category-stat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.category-stat-name {
    font-weight: 500;
    color: var(--text-primary);
}

.category-stat-amount {
    font-size: 12px;
}

/* ========================================
   EXPENSES PAGE - CATEGORY SELECTOR (Modal)
   ======================================== */
.category-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 12px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.category-card:hover {
    background: var(--border-light);
    border-color: var(--text-muted);
}

.category-card.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.category-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.category-card-icon svg {
    width: 24px;
    height: 24px;
}

.category-card-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

/* ========================================
   EXPENSES PAGE - COLOR & ICON SELECTORS
   ======================================== */
.color-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.color-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    margin: 0;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option:has(input:checked) {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-card) inset;
}

.icon-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.icon-option {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--text-muted);
    transition: all 0.15s ease;
    position: relative;
}

.icon-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.icon-option:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

.icon-option:has(input:checked) {
    background: var(--primary);
    color: white;
}

.icon-option svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   EXPENSES PAGE - TABLE CATEGORY ICON
   ======================================== */
.expense-category {
    display: flex;
    align-items: center;
    gap: 10px;
}

.expense-category-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.expense-category-icon svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   EXPENSES PAGE - CATEGORY LIST (Manage Modal)
   ======================================== */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 10px;
}

.category-list-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.category-list-item-icon svg {
    width: 20px;
    height: 20px;
}

.category-list-item-info {
    flex: 1;
}

.category-list-item-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.category-list-item-count {
    font-size: 12px;
    color: var(--text-muted);
}

.category-list-item-actions {
    display: flex;
    gap: 6px;
}

/* ========================================
   TOGGLE SWITCH
   ======================================== */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    min-width: 52px;
    width: 52px;
    height: 28px;
    background: #4b5563;
    border-radius: 28px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    border: 2px solid #6b7280;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
    border-color: var(--primary-dark);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-label {
    font-weight: 500;
    color: var(--text-primary);
}

/* RKN Status Icons */
.rkn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
}

.rkn-icon.rkn-blocked {
    color: var(--danger);
}

.rkn-icon.rkn-registry {
    color: var(--warning);
}
.bot-active-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    margin-left: 6px;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s;
    position: relative;
    top: 1px;
}
.bot-active-icon svg {
    width: 16px;
    height: 16px;
}
.bot-active-icon:hover {
    opacity: 1;
    transform: rotate(-15deg) scale(1.25);
    filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.5));
}

/* ========================================
   CF-PANEL — дополнения
   ======================================== */
.cf-toast-host {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 4000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.cf-toast {
    min-width: 240px;
    max-width: 380px;
    padding: 12px 16px;
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: auto;
}
.cf-toast.show { opacity: 1; transform: translateY(0); }
.cf-toast-info    { background: var(--primary); }
.cf-toast-success { background: #34A853; }
.cf-toast-warning { background: #F59E0B; }
.cf-toast-error   { background: #EA4335; }

.cf-flash {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
}
.cf-flash-success { background: rgba(52,168,83,0.12); color: #1E7E3E; }
.cf-flash-error   { background: rgba(234,67,53,0.12);  color: #C5221F; }
.cf-flash-info    { background: rgba(59,130,246,0.12); color: #2563EB; }
[data-theme="dark"] .cf-flash-success { color: #6ee7a8; }
[data-theme="dark"] .cf-flash-error   { color: #fca5a5; }
[data-theme="dark"] .cf-flash-info    { color: #93c5fd; }

/* Моноширинные значения (токены/ID) */
.cf-mono {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
}
.cf-copy {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}
.cf-copy:hover { color: var(--primary); }
.cf-secret {
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* Маленькая таблица-«пусто» */
.cf-muted { color: var(--text-muted); }
.cf-nowrap { white-space: nowrap; }
.cf-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Stat-cards grid адаптив */
@media (max-width: 1100px) {
    .color-cards-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .color-cards-row { grid-template-columns: 1fr; }
}
