/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #2d3436; font-size: 14px; line-height: 1.5; }
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: #1a2332; color: #fff; height: 48px; }
.header-inner { max-width: 1600px; 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: #1e2d3d; padding: 0 20px; display: flex; gap: 0; }
.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: 1600px; margin: 0 auto; padding: 20px; }

/* ===== 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-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: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.08); margin-bottom: 20px; overflow: hidden; }
.group-header { display: flex; align-items: center; padding: 14px 20px; gap: 12px; cursor: pointer; user-select: none; border-bottom: 1px solid #f0f2f5; }
.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-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); }

/* ===== Project Table ===== */
.project-table { width: 100%; }
.project-table th { background: #f8f9fa; padding: 10px 12px; text-align: left; font-weight: 500; font-size: 12px; color: #636e72; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.project-table td { padding: 10px 12px; border-bottom: 1px solid #f0f2f5; 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-link { color: #00b894; }
.project-link:hover { text-decoration: underline; }

/* ===== 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; }

/* ===== 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: #fff; border-radius: 10px; width: 500px; max-width: 90%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.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: flex-end; gap: 10px; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #636e72; margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 8px 12px; border: 1px solid #dfe6e9; border-radius: 6px; font-size: 14px; color: #2d3436; 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: 50px; 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%; }
.keywords-table th { background: #f8f9fa; padding: 10px 12px; text-align: left; font-weight: 500; font-size: 12px; color: #636e72; }
.keywords-table td { padding: 8px 12px; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.keywords-table tr:hover td { background: #f8f9fa; }
.keyword-url { color: #b2bec3; font-size: 12px; }
.keyword-url-edit { cursor: pointer; color: #00b894; margin-left: 4px; }
.keyword-delete { color: #d63031; cursor: pointer; font-size: 16px; font-weight: bold; }
.keyword-delete:hover { color: #c0392b; }

/* ===== 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; }
.pos-cell { cursor: pointer; padding: 4px 8px; border-radius: 4px; min-width: 30px; display: inline-block; }
.pos-cell:hover { opacity: 0.8; }
.pos-1-3 { background: #d4efdf; color: #1e8449; }
.pos-4-10 { background: #d5f5e3; color: #27ae60; }
.pos-11-20 { background: #fef9e7; color: #f39c12; }
.pos-21-plus { background: #fdecea; color: #d63031; }
.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-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; }

/* ===== 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; }
.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; }
.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); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f0f2f5; }
::-webkit-scrollbar-thumb { background: #b2bec3; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #636e72; }
