/* CSS Variables */
:root {
    --primary: #6366F1;
    --primary-hover: #4F46E5;
    --secondary: #22D3EE;
    --accent: #F472B6;
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #EF4444;
    --bg: #0F172A;
    --surface: #1E293B;
    --surface-light: #334155;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --border: #475569;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --transition: 200ms ease-out;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

::selection {
    background: var(--primary);
    color: white;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

/* App Container */
.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
    padding-top: 140px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

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

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

.logo svg {
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.data-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.status-dot.active {
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2,
.filter-header h3,
.summary-header h3,
.table-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Upload Section */
.upload-section {
    margin-bottom: 32px;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-zone.dragover {
    transform: scale(1.01);
}

.upload-icon {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-text {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.file-list {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.file-item-info {
    flex: 1;
}

.file-item-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.file-item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.file-item-delete {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.file-item-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

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

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-light);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Filter Section */
.filter-section {
    background: var(--surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 16px;
    margin-bottom: 24px;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1100px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.filter-fetch-status {
    min-width: 48px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}


.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.date-range,
.range-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-range span,
.range-inputs span {
    color: var(--text-secondary);
}

input[type="date"],
input[type="number"],
input[type="text"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8125rem;
    transition: var(--transition);
}

input[type="date"]:focus,
input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

.quick-dates {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.quick-date {
    padding: 4px 10px;
    font-size: 0.6875rem;
    background: var(--surface-light);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.quick-date:hover {
    background: var(--primary);
    color: white;
}

.quick-date.active {
    background: var(--primary);
    color: white;
}

/* Multi-select Dropdown */
.multi-select {
    position: relative;
    min-width: 100px;
}

.select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: var(--transition);
}

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

.select-trigger span {
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

.select-trigger {
    min-width: 80px;
    width: 100%;
    max-width: none;
}

.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    z-index: 100;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.select-dropdown.open {
    display: block;
}

.select-dropdown label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--surface);
}

.select-dropdown label:hover {
    background: var(--surface-light);
}

.select-dropdown input[type="checkbox"] {
    accent-color: var(--primary);
}

.search-input {
    width: 100%;
}

.dropdown-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.dropdown-search:focus {
    outline: none;
    border-color: var(--primary);
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.tag-remove {
    cursor: pointer;
    opacity: 0.7;
}

.tag-remove:hover {
    opacity: 1;
}

.filter-summary {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.filter-summary span {
    color: var(--secondary);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* Stats & Alerts Section */
.stats-alerts-section {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 24px;
    margin-bottom: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    color: var(--primary);
}

.stat-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Alerts Panel */
.alerts-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.alerts-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: var(--warning);
    margin-bottom: 16px;
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.alert-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--warning);
}

.alert-card.danger {
    border-left-color: var(--danger);
}

.alert-card.info {
    border-left-color: var(--secondary);
}

.alert-icon {
    flex-shrink: 0;
    color: var(--warning);
}

.alert-card.danger .alert-icon {
    color: var(--danger);
}

.alert-card.info .alert-icon {
    color: var(--secondary);
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.alert-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.alert-time {
    font-size: 0.625rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.alerts-empty {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.alerts-empty svg {
    margin-bottom: 8px;
    opacity: 0.5;
}

/* Charts Section */
.charts-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.chart-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.chart-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-family: inherit;
}

.chart-tab:hover {
    color: var(--text-primary);
    background: var(--surface-light);
}

.chart-tab.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.2);
}

.chart-container {
    position: relative;
    height: 400px;
    max-width: 800px;
    margin: 0 auto;
}

/* TR/ID Charts Section */
.trid-charts-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.trid-header {
    margin-bottom: 20px;
}

.trid-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.trid-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.trid-kpi-card {
    background: var(--surface-light);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    text-align: center;
}

.trid-kpi-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.trid-kpi-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.trid-kpi-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.trid-chart-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

/* Summary Section */
.summary-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 24px;
}

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

.summary-content {
    display: grid;
    gap: 12px;
}

.summary-paragraph {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 2px 0;
}

.summary-paragraph strong {
    color: var(--secondary);
}

.summary-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
    margin-top: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
    font-size: 0.75rem;
}

.summary-table th,
.summary-table td {
    padding: 4px 6px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.summary-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-table td {
    color: var(--text-primary);
}

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

/* Summary Box Layout */
.summary-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.summary-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.summary-row:first-child {
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.summary-stat {
    flex: 1;
    min-width: 120px;
    text-align: center;
}

.summary-stat-label {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.summary-stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.summary-stat-change {
    font-size: 0.6875rem;
    margin-top: 2px;
}

.summary-table-wrapper {
    flex: 1;
    min-width: 280px;
}

.summary-mini-title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.summary-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.6875rem;
}

.summary-mini-table th,
.summary-mini-table td {
    padding: 3px 6px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.summary-mini-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-mini-table td {
    color: var(--text-primary);
}

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

.key-findings {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.finding-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-md);
}

.finding-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.finding-icon.positive {
    background: rgba(52, 211, 153, 0.2);
    color: var(--success);
}

.finding-icon.negative {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.finding-icon.neutral {
    background: rgba(34, 211, 238, 0.2);
    color: var(--secondary);
}

.finding-text {
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* Table Section */
.table-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

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

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 8px 10px;
    background: var(--bg);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.data-table th:first-child {
    min-width: 110px;
    white-space: nowrap;
}

.data-table th:hover {
    color: var(--text-primary);
}

.data-table th .sort-icon {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.3;
}

.data-table th.sorted .sort-icon {
    opacity: 1;
    color: var(--primary);
}

.data-table th.sorted.desc .sort-icon::after {
    content: ' ↓';
}

.data-table th.sorted.asc .sort-icon::after {
    content: ' ↑';
}

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

.data-table tbody tr:hover {
    background: var(--surface-light);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:nth-child(even):hover {
    background: var(--surface-light);
}

.daily-detail-quick-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.daily-detail-country-select {
    min-width: 150px;
}

.daily-detail-country-select .select-trigger {
    min-height: 32px;
    padding: 6px 10px;
}

.country-filter-option,
.daily-detail-country-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.country-filter-choice,
.daily-detail-country-choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.country-filter-only,
.daily-detail-country-only {
    border: 0;
    background: transparent;
    color: var(--primary);
    font-size: 0.75rem;
    padding: 2px 4px;
    cursor: pointer;
    white-space: nowrap;
}

.country-filter-only:hover,
.daily-detail-country-only:hover {
    text-decoration: underline;
}

.daily-detail-summary-row td {
    background: rgba(99, 102, 241, 0.08);
    font-weight: 700;
}

.daily-detail-day-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.daily-detail-day-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    color: var(--primary);
    font-size: 0.72rem;
    line-height: 1;
}

.daily-detail-day-toggle:hover {
    color: var(--primary);
}

.spend-cell {
    font-family: 'JetBrains Mono', monospace;
    color: var(--secondary);
}

.country-summary-row td {
    background: var(--surface-light);
    border-top: 2px solid var(--border);
}

.country-summary-row:hover td {
    background: var(--surface-light);
}

.table02-country-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.table02-country-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    color: var(--primary);
    font-size: 0.72rem;
    line-height: 1;
}

.table02-country-toggle:hover {
    color: var(--primary);
}

.roas-cell {
    color: var(--danger) !important;
    font-weight: 600;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    gap: 8px;
}

.pagination-btn {
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--surface-light);
    color: var(--text-primary);
}

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

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-size-select {
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    font-family: inherit;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

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

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    animation: slideIn 300ms ease-out;
    font-size: 0.875rem;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--secondary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-alerts-section {
        grid-template-columns: 1fr;
    }

    .alerts-panel {
        order: -1;
    }
}

@media (max-width: 768px) {
    .app {
        padding: 16px;
    }

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

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 300px;
    }

    .data-table {
        font-size: 0.8125rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 12px;
    }

    .pagination {
        flex-direction: column;
        gap: 12px;
    }
}

/* Loading State */
.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-light) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h4 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.875rem;
}

/* Weekly Report Section */
.weekly-report-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.weekly-report-header {
    margin-bottom: 20px;
}

.weekly-report-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.weekly-table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

.weekly-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.weekly-stats-table th {
    background: var(--surface-light);
    color: var(--text-secondary);
    font-weight: 500;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

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

.weekly-stats-table tr:hover td {
    background: rgba(99, 102, 241, 0.05);
}

.weekly-stats-table .country-cell {
    font-weight: 600;
}

.weekly-stats-table .week-cell {
    color: var(--text-secondary);
}

.weekly-analysis {
    background: var(--surface-light);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 16px;
}

.weekly-analysis h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.weekly-analysis p {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.weekly-analysis .highlight {
    color: var(--primary);
    font-weight: 500;
}

.weekly-analysis .up {
    color: var(--success);
}

.weekly-analysis .down {
    color: var(--danger);
}

.weekly-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.weekly-nav-btn {
    padding: 6px 12px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.weekly-nav-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

/* Market Section */
.market-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.market-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.market-section .section-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.market-filter {
    display: flex;
    align-items: center;
    gap: 12px;
}

.market-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.market-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border);
}

.market-card h4 {
    margin: 0 0 12px 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.market-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.market-kpi {
    text-align: center;
    padding: 8px;
    border-radius: 6px;
}

.market-kpi-row1 {
    background: rgba(99, 102, 241, 0.1);
}

.market-kpi-row2 {
    background: rgba(16, 185, 129, 0.1);
}

.market-compare {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
}

.market-compare-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.market-compare-item {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    color: var(--text-secondary);
}

.market-compare-item span:first-child {
    min-width: 90px;
}

.market-compare-item .normal {
    color: var(--text-secondary);
}

.market-compare-item .alert-up {
    color: #EF4444;
}

.market-compare-item .alert-down {
    color: #3B82F6;
}

.market-kpi-label {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.market-kpi-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.market-tr-charts {
    background: transparent;
    border-radius: var(--radius-md);
    padding: 20px;
    border: none;
}

.market-goldcoin-table {
    margin-top: 16px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.market-table-header {
    margin-bottom: 12px;
}

.market-table-header.auto-table-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.market-table-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.auto-table-filters {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.auto-table-filters input,
.auto-table-filters select {
    min-height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-light);
    color: var(--text-primary);
    font-size: 0.75rem;
    padding: 4px 8px;
}

.auto-table-filters input {
    width: 132px;
}

.auto-table-filters select {
    min-width: 150px;
    max-width: 180px;
    height: 32px;
}

.auto-country-filter {
    position: relative;
}

.auto-country-filter-btn {
    position: relative;
    min-width: 150px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-light);
    color: var(--text-primary);
    font-size: 0.75rem;
    padding: 4px 28px 4px 10px;
    text-align: left;
    cursor: pointer;
}

.auto-country-filter-btn::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 13px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-secondary);
    pointer-events: none;
}

.auto-country-filter-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 38px;
    z-index: 20;
    min-width: 150px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.auto-country-filter-menu.open {
    display: grid;
    gap: 1px;
}

.auto-country-filter-option {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.75rem;
    line-height: 1.2;
    cursor: pointer;
}

.auto-country-filter-option input[type="checkbox"] {
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
    flex: 0 0 12px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    accent-color: var(--primary);
}

.auto-country-filter-option:hover {
    background: var(--surface-light);
}

.auto-wide-table {
    overflow-x: auto;
}

#autoDailyCountryTable {
    min-width: 1720px;
}

#autoDailyCountryTable th,
#autoDailyCountryTable td {
    white-space: nowrap;
}

#autoDailyCountryTable td:first-child,
#autoDailyCountryTable td:nth-child(2) {
    font-family: 'JetBrains Mono', monospace;
}

#autoDailyCountryTable .auto-day-summary-row td {
    background: rgba(99, 102, 241, 0.08);
    font-weight: 700;
}

#autoDailyCountryTable .auto-dau-cell {
    color: #2563eb;
    font-weight: 700;
}

#autoDailyCountryTable .auto-gmv-cell {
    color: #dc2626;
    font-weight: 700;
}

.auto-day-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.auto-day-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    color: var(--primary);
    font-size: 0.72rem;
    line-height: 1;
}

.auto-day-toggle:hover {
    color: var(--primary);
}

.auto-fetch-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 24px;
}

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

.auto-fetch-section .section-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.auto-fetch-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 4px 12px;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
}

.auto-fetch-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.auto-fetch-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auto-fetch-result {
    padding: 12px;
    background: var(--surface-light);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-height: 60px;
}

#goldCoinTableBody td.up {
    color: #EF4444;
}

#goldCoinTableBody td.down {
    color: #3B82F6;
}

#autoGoldCoinTableBody td:first-child {
    width: 70px;
    min-width: 70px;
    max-width: 70px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#autoGoldCoinTableBody td.up {
    color: #EF4444 !important;
}

#autoGoldCoinTableBody td.down {
    color: #3B82F6 !important;
}

.pagination {
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
}

.market-chart-header {
    margin-bottom: 16px;
}

.market-chart-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.market-chart-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.market-chart-tabs .chart-tab {
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.market-chart-tabs .chart-tab:hover {
    background: var(--surface-light);
    border-color: var(--primary);
}

.market-chart-tabs .chart-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}


.monthly-total-row td {
    background: rgba(79, 209, 197, 0.08);
    border-top: 2px solid var(--secondary);
    font-weight: 700;
}

.monthly-total-row:hover td {
    background: rgba(79, 209, 197, 0.12);
}

.monthly-group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.monthly-group-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    color: var(--secondary);
    font-size: 0.72rem;
    line-height: 1;
}

.monthly-group-toggle:hover {
    color: var(--secondary);
}
