/* ===== CSS Variables (Light Theme) ===== */
:root {
    --bg-body: #f0f2f5; --bg-card: #fff; --bg-header: #1a2332; --bg-sub-nav: #1e2d3d;
    --bg-table-header: #f8f9fa; --bg-input: #fff; --border: #dfe6e9; --border-light: #f0f2f5;
    --text-primary: #2d3436; --text-secondary: #636e72; --text-muted: #b2bec3;
    --accent: #00b894; --accent-hover: #00a383; --danger: #d63031;
    --shadow-card: 0 2px 4px rgba(0,0,0,0.08); --shadow-modal: 0 20px 60px rgba(0,0,0,0.3);
}
/* ===== Dark Theme ===== */
[data-theme="dark"] {
    --bg-body: #0f172a; --bg-card: #1e293b; --bg-header: #0f172a; --bg-sub-nav: #162032;
    --bg-table-header: #334155; --bg-input: #334155; --border: #475569; --border-light: #334155;
    --text-primary: #e2e8f0; --text-secondary: #94a3b8; --text-muted: #64748b;
    --shadow-card: 0 2px 4px rgba(0,0,0,0.3); --shadow-modal: 0 20px 60px rgba(0,0,0,0.6);
}
[data-theme="dark"] .status-badge.active { background: #064e3b; color: #34d399; }
[data-theme="dark"] .status-badge.paused { background: #78350f; color: #fbbf24; }
[data-theme="dark"] .status-badge.error { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .auth-page { background: #0f172a; }
[data-theme="dark"] .auth-card { background: #1e293b; color: #e2e8f0; }
[data-theme="dark"] .stat-card { background: #2a1f0a; border: 1px solid #5c3d10; }
[data-theme="dark"] .dashboard-chart { background: #1a1505; border: 1px solid #3d2e0a; }
/* Dark theme: таблицы, кнопки, попапы, инпуты */
[data-theme="dark"] .project-table tr:hover td { background: #263548; }
[data-theme="dark"] .project-table tr.totals-row td { background: #263548; border-top-color: #475569; }
[data-theme="dark"] .keywords-table th { background: linear-gradient(180deg, #334155 0%, #2d3a4d 100%); color: #94a3b8; border-bottom-color: #475569; }
[data-theme="dark"] .keywords-table td { border-bottom-color: #334155; }
[data-theme="dark"] .keywords-table tbody tr:hover td { background: #1a3a2e; }
[data-theme="dark"] .keywords-table tbody tr:nth-child(even) td { background: #253347; }
[data-theme="dark"] .keywords-table tbody tr:nth-child(even):hover td { background: #1a3a2e; }
[data-theme="dark"] .keywords-table .totals-row td { background: linear-gradient(180deg, #334155 0%, #2d3a4d 100%) !important; border-top-color: #475569; }
[data-theme="dark"] .inline-clicks-input { background: #334155; border-color: #475569; color: #e2e8f0; }
[data-theme="dark"] .inline-clicks-input:focus { border-color: #00b894; }
[data-theme="dark"] .inline-clicks-input.input-disabled { background: #1e293b; color: #64748b; }
[data-theme="dark"] .clicks-table th { background: var(--bg-table-header); color: var(--text-secondary); }
[data-theme="dark"] .clicks-table tr:hover td { background: #263548; }
[data-theme="dark"] .positions-table th:first-child,
[data-theme="dark"] .positions-table td:first-child { background: var(--bg-card); }
[data-theme="dark"] .positions-table th, [data-theme="dark"] .positions-table td { border-color: #334155; }
[data-theme="dark"] .chart-canvas { background: var(--bg-card); border-color: #334155; }
[data-theme="dark"] .btn-outline { background: var(--bg-card); color: var(--text-primary); border-color: var(--border); }
[data-theme="dark"] .btn-icon { background: var(--bg-card); color: var(--text-secondary); border-color: var(--border); }
[data-theme="dark"] .task-type-btn { background: var(--bg-card); color: var(--text-secondary); border-color: var(--border); }
[data-theme="dark"] .chart-period-btn { background: var(--bg-card); border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] .btn-add-region { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .region-dropdown { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .region-option:hover { background: #263548; }
[data-theme="dark"] .click-popup { background: var(--bg-card); color: var(--text-primary); }
[data-theme="dark"] .context-menu { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .context-menu-item:hover { background: #263548; }
[data-theme="dark"] .inline-clicks-input { background: var(--bg-input); color: var(--text-primary); border-color: var(--border); }
[data-theme="dark"] .settings-card { background: var(--bg-card); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: var(--bg-input); color: var(--text-primary); border-color: var(--border); }
[data-theme="dark"] .badge-green { background: #064e3b; color: #34d399; }
[data-theme="dark"] .badge-orange { background: #78350f; color: #fbbf24; }

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-body); color: var(--text-primary); font-size: 14px; line-height: 1.5; transition: background 0.3s, color 0.3s; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ===== Top Header ===== */
.top-header { background: var(--bg-header); color: #fff; height: 48px; }
.header-inner { max-width: 1800px; margin: 0 auto; padding: 0 20px; height: 100%; display: flex; align-items: center; gap: 30px; }
.logo { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: 0.5px; }
.header-nav { display: flex; gap: 5px; }
.header-nav a { padding: 6px 14px; border-radius: 4px; color: #b0bec5; font-size: 13px; transition: all 0.2s; }
.header-nav a:hover, .header-nav a.active { color: #fff; background: rgba(255,255,255,0.1); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 15px; }
.header-balance { color: #b0bec5; font-size: 13px; }

/* ===== Sub Navigation ===== */
.sub-nav { background: var(--bg-sub-nav); padding: 0 20px; display: flex; gap: 0; max-width: 1800px; margin: 0 auto; }
.sub-nav-wrap { background: var(--bg-sub-nav); }
.sub-nav a { padding: 10px 18px; color: #8ca0b3; font-size: 13px; border-bottom: 2px solid transparent; transition: all 0.2s; }
.sub-nav a:hover { color: #fff; }
.sub-nav a.active { color: #fff; border-bottom-color: #00b894; }

/* ===== Main Content ===== */
.main-content { max-width: 1800px; margin: 0 auto; padding: 20px; position: relative; }

/* ===== Page Header ===== */
.page-header { display: flex; align-items: center; gap: 20px; margin-bottom: 25px; }
.page-title { font-size: 22px; font-weight: 600; }
.page-actions { display: flex; gap: 10px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 6px; border: 1px solid transparent; font-size: 13px; font-weight: 500; transition: all 0.2s; }
.btn-primary { background: #00b894; color: #fff; border-color: #00b894; }
.btn-primary:hover { background: #00a383; }
.btn-outline { background: #fff; color: #2d3436; border-color: #dfe6e9; }
.btn-outline:hover { border-color: #00b894; color: #00b894; }
.btn-danger { background: #d63031; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: #00b894; color: #fff; }
.btn-success:hover { background: #00a884; }
.btn-warning { background: #fdcb6e; color: #2d3436; }
.btn-warning:hover { background: #f0c040; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; border: 1px solid #dfe6e9; background: #fff; color: #636e72; font-size: 14px; }
.btn-icon:hover { border-color: #00b894; color: #00b894; }
.btn-icon.btn-delete:hover { border-color: #d63031; color: #d63031; }

/* ===== Group Card ===== */
.group-card { background: var(--bg-card); border-radius: 8px; box-shadow: var(--shadow-card); margin-bottom: 20px; overflow: hidden; }
.group-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.group-header { display: flex; align-items: center; padding: 14px 20px; gap: 12px; cursor: pointer; user-select: none; border-bottom: 1px solid var(--border-light); }
.group-name { font-size: 15px; font-weight: 600; }
.group-status { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.group-status.active { color: #00b894; }
.group-status.inactive { color: #d63031; }
.group-status-dot { width: 8px; height: 8px; border-radius: 50%; }
.group-status.active .group-status-dot { background: #00b894; }
.group-status.inactive .group-status-dot { background: #d63031; }
.group-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.group-collapse-icon { transition: transform 0.2s; font-size: 12px; color: #636e72; }
.group-card.collapsed .group-collapse-icon { transform: rotate(-90deg); }
.group-body { padding: 15px 20px; }
.group-card.collapsed .group-body { display: none; }
.group-links-btn { font-size: 12px; color: #00b894; cursor: pointer; }
.group-links-btn:hover { text-decoration: underline; }

/* ===== Toggle Switch ===== */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #dfe6e9; border-radius: 22px; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
.toggle input:checked + .toggle-slider { background: #00b894; }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ===== Sortable Headers ===== */
.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { color: #00b894; }
.sort-icon { font-size: 10px; opacity: 0.4; margin-left: 2px; }
.sortable-th:hover .sort-icon { opacity: 1; }

/* ===== Project Table ===== */
.project-table { width: 100%; min-width: 1400px; }
.project-table th { background: var(--bg-table-header); padding: 10px 12px; text-align: left; font-weight: 500; font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.project-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.project-table tr:hover td { background: #f8f9fa; }
.project-table tr.totals-row td { background: #f8f9fa; font-weight: 600; border-top: 2px solid #dfe6e9; }
.project-table .col-project { min-width: 180px; }
.project-table .col-actions { white-space: nowrap; text-align: right; }
.project-table tr.dragging { opacity: 0.4; background: var(--accent) !important; }
.project-table tr.dragging td { background: transparent !important; }
.project-table tr[draggable]:not(.totals-row) { cursor: default; }
.project-table tr[draggable]:not(.totals-row) td:first-child { cursor: grab; color: var(--text-secondary); user-select: none; }
.group-card.drag-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.project-link { color: #00b894; }
.project-link:hover { text-decoration: underline; }
.bulk-actions-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.bulk-actions-bar .bulk-info { font-size: 13px; margin-right: 8px; color: var(--text-primary); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 4px; border: 1px solid #dfe6e9; background: #fff; cursor: pointer; }
.btn-sm:hover { background: #f0f2f5; }
.btn-sm.btn-success { background: #00b894; color: #fff; border-color: #00b894; }
.btn-sm.btn-success:hover { background: #00a884; }
.btn-sm.btn-danger { background: #e17055; color: #fff; border-color: #e17055; }
.btn-sm.btn-danger:hover { background: #d35040; }
.btn-sm.btn-primary { background: #00b894; color: #fff; border-color: #00b894; }
.btn-sm.btn-primary:hover { background: #00a383; }

/* ===== Keyword Filters ===== */
.kw-filter-row { display: inline-flex; align-items: center; gap: 6px; background: #f8f9fa; padding: 6px 10px; border-radius: 6px; border: 1px solid #dfe6e9; font-size: 12px; }
.kw-filter-row select, .kw-filter-row input { font-size: 12px; padding: 3px 6px; border: 1px solid #dfe6e9; border-radius: 4px; background: #fff; }
.kw-filter-row input[type="number"] { width: 70px; }
.kw-filter-row input[type="text"] { width: 150px; }
.kw-filter-inputs { display: inline-flex; align-items: center; gap: 4px; }
.kw-filter-remove { cursor: pointer; color: #e74c3c; font-size: 16px; font-weight: bold; line-height: 1; }
.kw-filter-remove:hover { color: #c0392b; }
[data-theme="dark"] .kw-filter-row { background: var(--bg-input); border-color: var(--border); }
[data-theme="dark"] .kw-filter-row select, [data-theme="dark"] .kw-filter-row input { background: var(--bg-card); color: var(--text-primary); border-color: var(--border); }

/* ===== Status Badges ===== */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.status-badge.active { background: #e6f9f3; color: #00b894; }
.status-badge.paused { background: #fef9e7; color: #f39c12; }
.status-badge.error { background: #fdecea; color: #d63031; }

/* Badges */
.badge-green { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; background: #e6f9f3; color: #00b894; }
.badge-orange { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; background: #fef9e7; color: #f39c12; }
.badge-red { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; background: #fdecea; color: #d63031; }

/* Error rows (pos=-1, not found) */
.row-error { background: #fef2f2 !important; }
.row-error td { color: #991b1b; }
[data-theme="dark"] .row-error { background: #450a0a !important; }
[data-theme="dark"] .row-error td { color: #fca5a5; }

/* Project alert icon */
.project-alert { color: #dc2626; font-size: 20px; margin-left: 8px; animation: alertPulse 1.5s infinite; cursor: help; }
@keyframes alertPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ===== Modal ===== */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: var(--bg-card); border-radius: 10px; width: 500px; max-width: 90%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-modal); color: var(--text-primary); }
.modal-wide { width: 700px; }
.modal-header { display: flex; align-items: center; justify-content: between; padding: 18px 24px; border-bottom: 1px solid #f0f2f5; }
.modal-title { font-size: 16px; font-weight: 600; flex: 1; }
.modal-close { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border: none; background: none; font-size: 20px; color: #636e72; cursor: pointer; border-radius: 4px; }
.modal-close:hover { background: #f0f2f5; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f0f2f5; display: flex; justify-content: center; gap: 10px; }
.modal-footer .btn { text-align: center; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; color: var(--text-primary); background: var(--bg-input); transition: border-color 0.2s; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: #00b894; }
.form-textarea { min-height: 100px; resize: vertical; }
.form-hint { font-size: 12px; color: #b2bec3; margin-top: 4px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* ===== Task Type Buttons ===== */
.task-type-group { display: flex; gap: 0; }
.task-type-btn { padding: 8px 16px; border: 1px solid #dfe6e9; background: #fff; color: #636e72; font-size: 13px; cursor: pointer; transition: all 0.2s; }
.task-type-btn:first-child { border-radius: 6px 0 0 6px; }
.task-type-btn:last-child { border-radius: 0 6px 6px 0; }
.task-type-btn + .task-type-btn { border-left: none; }
.task-type-btn.active { background: #00b894; color: #fff; border-color: #00b894; }

/* ===== Region List ===== */
.region-list { display: flex; flex-direction: column; gap: 8px; }
.region-row { display: flex; align-items: center; gap: 10px; }
.region-row .form-select { flex: 1; }
.region-row .region-percent { width: 60px; text-align: center; }
.region-percent-label { font-size: 13px; color: #636e72; }
.btn-add-region { width: 100%; padding: 8px; border: 1px dashed #dfe6e9; border-radius: 6px; background: #fff; color: #00b894; font-size: 13px; cursor: pointer; margin-top: 4px; }
.btn-add-region:hover { border-color: #00b894; background: #e6f9f3; }

/* ===== Region Searchable Dropdown ===== */
.region-select-wrap { flex: 1; position: relative; }
.region-select-wrap .region-search { width: 100%; }
.region-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #dfe6e9; border-top: none; border-radius: 0 0 6px 6px; box-shadow: 0 6px 16px rgba(0,0,0,0.12); z-index: 200; max-height: 240px; overflow-y: auto; }
.region-dropdown.show { display: block; }
.region-option { padding: 9px 14px; font-size: 14px; cursor: pointer; transition: background 0.12s; }
.region-option:hover { background: #f0f2f5; }
.region-option.selected { color: #00b894; font-weight: 600; }
.region-option.region-empty { color: #b2bec3; cursor: default; font-style: italic; }

/* ===== Range Slider ===== */
.range-group { display: flex; align-items: center; gap: 12px; }
.range-slider { flex: 1; -webkit-appearance: none; height: 6px; background: #dfe6e9; border-radius: 3px; outline: none; }
.range-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; background: #00b894; border-radius: 50%; cursor: pointer; }
.range-value { width: 80px; text-align: center; padding: 4px 8px; border: 1px solid #dfe6e9; border-radius: 4px; font-size: 13px; }

/* ===== Project Page ===== */
.project-header { display: flex; align-items: center; gap: 15px; margin-bottom: 5px; }
.project-page-title { font-size: 20px; font-weight: 600; }
.project-back { color: #00b894; font-size: 13px; float: right; }
.project-back:hover { text-decoration: underline; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #f0f2f5; margin-bottom: 20px; }
.tab { padding: 10px 20px; font-size: 14px; color: #636e72; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab:hover { color: #2d3436; }
.tab.active { color: #00b894; border-bottom-color: #00b894; font-weight: 500; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Keywords Table ===== */
.keywords-table { width: 100%; border-collapse: separate; border-spacing: 0; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.keywords-table th {
    background: linear-gradient(180deg, #f8f9fa 0%, #eef1f5 100%);
    padding: 10px 12px; text-align: left; font-weight: 600; font-size: 11px;
    color: #636e72; text-transform: uppercase; letter-spacing: 0.3px;
    border-bottom: 2px solid #e0e5ec; white-space: nowrap;
}
.keywords-table td {
    padding: 10px 12px; border-bottom: 1px solid #f0f2f5; font-size: 13px;
    transition: background 0.15s ease;
}
.keywords-table tbody tr:hover td { background: #f0faf6; }
.keywords-table tbody tr:nth-child(even) td { background: #fafbfc; }
.keywords-table tbody tr:nth-child(even):hover td { background: #f0faf6; }
.keywords-table .totals-row td {
    background: linear-gradient(180deg, #f8f9fa 0%, #eef1f5 100%) !important;
    border-top: 2px solid #e0e5ec; font-weight: 600;
}
.keyword-url { color: #b2bec3; font-size: 12px; }
.keyword-url-edit { cursor: pointer; color: #00b894; margin-left: 4px; opacity: 0.6; transition: opacity 0.2s; }
.keyword-url-edit:hover { opacity: 1; }
.keyword-delete { color: #d63031; cursor: pointer; font-size: 16px; font-weight: bold; opacity: 0.5; transition: opacity 0.2s; }
.keyword-delete:hover { opacity: 1; color: #c0392b; }
.keyword-clarification { color: var(--text-secondary); font-size: 12px; }
.kw-favorite { font-size: 16px; transition: transform 0.2s; display: inline-block; }
.kw-favorite:hover { transform: scale(1.3); }
.inline-clicks-input {
    width: 65px; text-align: center; border: 1px solid #dfe6e9; border-radius: 6px;
    padding: 4px 6px; font-size: 13px; background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.inline-clicks-input:focus { border-color: #00b894; box-shadow: 0 0 0 3px rgba(0,184,148,0.15); outline: none; }
.inline-clicks-input.input-disabled { background: #f0f2f5; color: #b2bec3; }
.queue-pending { color: #e67e22; font-weight: 600; }

/* ===== Positions Table ===== */
.positions-table { width: 100%; overflow-x: auto; display: block; }
.positions-table table { width: auto; min-width: 100%; }
.positions-table th, .positions-table td { padding: 8px 10px; text-align: center; font-size: 12px; white-space: nowrap; border: 1px solid #f0f2f5; }
.positions-table th { background: #f8f9fa; font-weight: 500; color: #636e72; }
.positions-table th:first-child, .positions-table td:first-child { text-align: left; min-width: 200px; position: sticky; left: 0; background: #fff; z-index: 1; }
.positions-table th:first-child { background: #f8f9fa; }
.positions-table th:nth-child(2), .positions-table td:nth-child(2) { text-align: center; min-width: 80px; }
/* Position cells — Monstro-style colored backgrounds */
.pos-cell { cursor: pointer; padding: 4px 8px; border-radius: 3px; min-width: 36px; display: inline-block; text-align: center; font-weight: 500; font-size: 13px; }
.pos-cell:hover { opacity: 0.85; filter: brightness(0.95); }
.pos-top1 { background: #3498db; color: #fff; }
.pos-top3 { background: #2ecc71; color: #fff; }
.pos-top5 { background: #82e0aa; color: #145a32; }
.pos-top10 { background: #f1c40f; color: #7d6608; }
.pos-top20 { background: #e67e22; color: #fff; }
.pos-top30 { background: #e74c3c; color: #fff; }
.pos-30-plus { background: #c0392b; color: #fff; }
.pos-none { color: #b2bec3; }

/* ===== Chart ===== */
.chart-container { margin-bottom: 20px; }
.chart-header { display: flex; align-items: center; gap: 15px; margin-bottom: 10px; }
.chart-period { display: flex; gap: 5px; }
.chart-period-btn { padding: 5px 12px; border: 1px solid #dfe6e9; background: #fff; border-radius: 4px; font-size: 12px; cursor: pointer; }
.chart-period-btn.active { background: #00b894; color: #fff; border-color: #00b894; }
.chart-legend { display: flex; gap: 12px; font-size: 11px; color: #636e72; }
.chart-legend-item { display: flex; align-items: center; gap: 4px; }
.chart-line-toggle { cursor: pointer; user-select: none; transition: opacity 0.2s; }
.chart-line-toggle:hover { opacity: 0.7; }
.chart-legend-dot { width: 10px; height: 10px; border-radius: 2px; }
.chart-canvas { width: 100%; height: 200px; background: #fff; border: 1px solid #f0f2f5; border-radius: 6px; }

/* ===== Click Popup ===== */
.click-popup { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); z-index: 1001; min-width: 450px; max-height: 80vh; overflow-y: auto; display: none; }
.click-popup.show { display: block; }
.click-popup-header { padding: 14px 18px; border-bottom: 1px solid #f0f2f5; display: flex; align-items: center; }
.click-popup-title { font-size: 14px; font-weight: 600; flex: 1; }
.click-popup-table { width: 100%; }
.click-popup-table th { background: #f8f9fa; padding: 8px 12px; font-size: 12px; font-weight: 500; color: #636e72; text-align: left; }
.click-popup-table td { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid #f0f2f5; }

/* ===== Click Reports Table ===== */
.clicks-table { width: 100%; }
.clicks-table th { background: #f8f9fa; padding: 8px 10px; font-size: 12px; font-weight: 500; color: #636e72; text-align: left; white-space: nowrap; }
.clicks-table td { padding: 8px 10px; font-size: 12px; border-bottom: 1px solid #f0f2f5; }
.clicks-table tr:hover td { background: #f8f9fa; }

/* ===== Settings Form ===== */
.settings-form { max-width: 700px; margin: 0 auto; }
.settings-form .form-group { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.settings-form .form-label { width: 200px; min-width: 200px; padding-top: 8px; text-align: right; }
.settings-form .form-field { flex: 1; }

/* ===== Settings/Diagnostic Page ===== */
.settings-page { max-width: 800px; }
.settings-card { background: var(--bg-card); border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.08); padding: 24px; margin-bottom: 16px; }
.settings-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); }

/* ===== Links Modal ===== */
.api-link-box { background: #f8f9fa; border: 1px solid #dfe6e9; border-radius: 6px; padding: 10px 14px; font-family: monospace; font-size: 13px; word-break: break-all; display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.api-link-box .copy-btn { flex-shrink: 0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: #00b894; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; }
.api-link-text { flex: 1; color: #2d3436; }
[data-theme="dark"] .api-link-box { background: var(--bg-input); border-color: var(--border); }
[data-theme="dark"] .api-link-text { color: var(--text-primary); }
.api-instructions { font-size: 13px; color: #636e72; line-height: 1.6; }
.api-instructions ol { padding-left: 20px; }
.api-instructions li { margin-bottom: 8px; }

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #636e72; }
.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none !important; }

/* ===== Date Filter ===== */
.date-filter { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.date-filter label { font-size: 13px; color: #636e72; }
.date-input { padding: 6px 10px; border: 1px solid #dfe6e9; border-radius: 4px; font-size: 13px; }

/* ===== Auth Pages ===== */
.auth-page { background: #1a2332; min-height: 100vh; display: flex; flex-direction: column; align-items: center; }
.auth-header { padding: 30px 0 20px; }
.auth-header .logo { font-size: 24px; font-weight: 700; color: #fff; }
.auth-card { background: #fff; border-radius: 10px; padding: 30px; width: 400px; max-width: 90%; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.auth-title { font-size: 20px; font-weight: 600; text-align: center; margin-bottom: 20px; }
.auth-btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 10px; }
.auth-link { text-align: center; margin-top: 16px; font-size: 13px; color: #636e72; }
.auth-link a { color: #00b894; font-weight: 500; }
.auth-link a:hover { text-decoration: underline; }
.auth-error { background: #fdecea; color: #d63031; padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 15px; }
.header-user { color: #b0bec5; font-size: 13px; }
.header-admin-link { color: #00b894; font-size: 13px; margin-right: 15px; }
.header-admin-link:hover { text-decoration: underline; }
.header-logout { color: #e17055; font-size: 13px; margin-left: 10px; }
.header-logout:hover { text-decoration: underline; }

/* ===== Inline Clicks Input ===== */
.inline-clicks-input { width: 70px; padding: 5px 4px; border: 1px solid #dfe6e9; border-radius: 4px; font-size: 13px; text-align: center; background: #fff; transition: border-color 0.2s; -moz-appearance: textfield; }
.inline-clicks-input::-webkit-outer-spin-button, .inline-clicks-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inline-clicks-input:focus { outline: none; border-color: #00b894; box-shadow: 0 0 0 2px rgba(0,184,148,0.15); }
.inline-clicks-input:hover { border-color: #b2bec3; }
.queue-pending { color: #d63031; font-weight: 600; }

/* ===== Auto-mode Ramp ===== */
.ramp-input { width: 60px; padding: 4px 6px; border: 1px solid #dfe6e9; border-radius: 4px; font-size: 12px; text-align: center; }
.ramp-input:focus { outline: none; border-color: #00b894; }
.ramp-cell { font-size: 12px; text-align: center; color: #636e72; }
.ramp-info { font-size: 10px; color: #636e72; display: block; margin-top: 2px; }
.input-disabled { background: #f0f2f5; color: #b2bec3; cursor: not-allowed; }
.toggle-sm { width: 32px; height: 18px; }
.boost-info { font-size: 13px; color: #636e72; }
.boost-info strong { color: #00b894; font-size: 15px; }

/* ===== Context Menu ===== */
.context-menu { display: none; position: absolute; background: #fff; border: 1px solid #dfe6e9; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 1000; min-width: 220px; padding: 6px 0; }
.context-menu-item { padding: 8px 16px; font-size: 13px; cursor: pointer; transition: background 0.15s; }
.context-menu-item:hover { background: #f0f2f5; }
.context-menu-item.ctx-danger { color: #d63031; }
.context-menu-item.ctx-danger:hover { background: #fdecea; }
.context-menu-sep { height: 1px; background: #f0f2f5; margin: 4px 0; }
.toggle-sm .toggle-slider::before { height: 12px; width: 12px; left: 3px; bottom: 3px; }
.toggle-sm input:checked + .toggle-slider::before { transform: translateX(14px); }
.toggle-xs { width: 24px; height: 14px; }
.toggle-xs .toggle-slider::before { height: 8px; width: 8px; left: 3px; bottom: 3px; }
.toggle-xs input:checked + .toggle-slider::before { transform: translateX(10px); }

/* ===== Dashboard Stat Cards ===== */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; margin-bottom: 25px; }
.stat-card { background: var(--bg-card); border-radius: 8px; padding: 20px; box-shadow: var(--shadow-card); text-align: center; transition: transform 0.15s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-number { font-size: 28px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text-secondary); }
.dashboard-chart { background: var(--bg-card); border-radius: 8px; padding: 20px; box-shadow: var(--shadow-card); margin-bottom: 25px; }
.dashboard-filter { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }

/* ===== Toast Notifications ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 20px; border-radius: 8px; color: #fff; font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: toastIn 0.3s ease; max-width: 350px; display: flex; align-items: center; gap: 8px; }
.toast.success { background: #00b894; }
.toast.error { background: #d63031; }
.toast.info { background: #0984e3; }
.toast.removing { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ===== Enhanced Status Badges ===== */
.status-badge.clicking { background: #e6f9f3; color: #00b894; animation: badgePulse 2s infinite; }
.status-badge.waiting { background: #fef9e7; color: #f39c12; }
@keyframes badgePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ===== Theme Toggle ===== */
.theme-toggle { background: none; border: none; color: #b0bec5; font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: color 0.2s; }
.theme-toggle:hover { color: #fff; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 12px 0; flex-wrap: wrap; }
.pagination button { padding: 4px 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary); border-radius: 4px; cursor: pointer; font-size: 13px; min-width: 32px; }
.pagination button:hover { background: var(--bg-table-header); }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination .page-info { font-size: 12px; color: var(--text-secondary); margin: 0 8px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
