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

:root {
    --bg-primary: #1a1d29;
    --bg-secondary: #252936;
    --bg-tertiary: #2d3142;
    --bg-hover: #353a4f;
    --text-primary: #ffffff;
    --text-secondary: #b4b8c5;
    --text-muted: #8a8f9e;
    --accent-primary: #2ecc71;
    --accent-success: #2ecc71;
    --accent-danger: #e74c3c;
    --accent-warning: #f39c12;
    --border-color: #3a3f52;
    --shadow: rgba(0, 0, 0, 0.3);
    color-scheme: dark;
    accent-color: var(--accent-primary);
}

html {
    color-scheme: dark;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 0;
    margin: 0;
    color-scheme: dark;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 0 150px;
}

/* Top Toolbar */
.top-toolbar {
    background: var(--bg-secondary);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

/* Date Selector in Toolbar */
.date-selector {
    display: flex;
    align-items: center;
}

.date-selector input[type="date"] {
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.date-selector input[type="date"]:hover {
    border-color: var(--accent-primary);
}

.date-selector input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-box {
    position: relative;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 35px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
}

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

.search-box::before {
    content: '⌕';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary:hover {
    background: #27ae60;
}

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

.btn-success:hover {
    background: #27ae60;
}

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

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

.btn-danger {
    background: #9b59b6;
    color: white;
    border-color: #9b59b6;
}

.btn-danger:hover {
    background: #8e44ad;
    border-color: #8e44ad;
}

.btn-icon {
    padding: 8px;
    min-width: 32px;
    justify-content: center;
}

.date-range-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.date-range-selector input[type="date"] {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    padding: 4px;
}

.date-range-selector input[type="date"]:focus {
    outline: none;
}

.date-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.date-nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.refresh-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 主内容区 */
.main-content {
    padding: 20px 0;
}

/* 数据表格 */
.table-wrapper {
    background: var(--bg-primary);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid var(--border-color);
    -webkit-overflow-scrolling: touch;
}

/* Ensure total rows' last cell extends to fill remaining space and covers table background */
.data-table .platform-total-row td:last-child,
.data-table .grand-total-row td:last-child {
    background: #252936 !important;
    background-color: #252936 !important;
    position: relative;
    z-index: 100 !important;
    min-width: 150px !important;
    width: 150px !important;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 13px;
    table-layout: auto;
    min-width: 1200px; /* 确保表格有足够的最小宽度 */
    background: var(--bg-primary);
}

/* History modal table - override min-width for desktop view */
#country-history-modal .table-wrapper {
    overflow-x: visible !important;
    overflow-y: auto;
}

#country-history-modal .history-table,
#country-history-modal .data-table {
    min-width: auto !important;
    width: 100% !important;
    table-layout: fixed !important;
}

#country-history-modal .history-table th,
#country-history-modal .history-table td,
#country-history-modal .data-table th,
#country-history-modal .data-table td {
    padding: 10px 8px;
}

#country-history-modal .history-table th:nth-child(1),
#country-history-modal .history-table td:nth-child(1),
#country-history-modal .data-table th:nth-child(1),
#country-history-modal .data-table td:nth-child(1) {
    width: 16.67% !important;
}

#country-history-modal .history-table th:nth-child(2),
#country-history-modal .history-table td:nth-child(2),
#country-history-modal .data-table th:nth-child(2),
#country-history-modal .data-table td:nth-child(2) {
    width: 16.67% !important;
}

#country-history-modal .history-table th:nth-child(3),
#country-history-modal .history-table td:nth-child(3),
#country-history-modal .data-table th:nth-child(3),
#country-history-modal .data-table td:nth-child(3) {
    width: 16.67% !important;
}

#country-history-modal .history-table th:nth-child(4),
#country-history-modal .history-table td:nth-child(4),
#country-history-modal .data-table th:nth-child(4),
#country-history-modal .data-table td:nth-child(4) {
    width: 16.67% !important;
}

#country-history-modal .history-table th:nth-child(5),
#country-history-modal .history-table td:nth-child(5),
#country-history-modal .data-table th:nth-child(5),
#country-history-modal .data-table td:nth-child(5) {
    width: 16.67% !important;
}

#country-history-modal .history-table th:nth-child(6),
#country-history-modal .history-table td:nth-child(6),
#country-history-modal .data-table th:nth-child(6),
#country-history-modal .data-table td:nth-child(6) {
    width: 16.65% !important;
    text-align: left !important;
}

/* Mobile responsive for history table */
@media (max-width: 768px) {
    #country-history-modal .table-wrapper {
        overflow-x: auto !important;
        overflow-y: auto;
    }
    
    #country-history-modal .history-table,
    #country-history-modal .data-table {
        min-width: 600px !important;
        table-layout: auto;
    }
}


/* Override table background for total rows' last cell */
.data-table .platform-total-row td:last-child,
.data-table .grand-total-row td:last-child {
    background: #252936 !important;
    background-color: #252936 !important;
    position: relative;
    z-index: 100;
}


/* 强制设置Profit列（第9列）和Actions列（第10列）的宽度，防止重叠 */
.data-table tbody tr td:nth-child(9),
.data-table tbody tr th:nth-child(9) {
    width: 130px !important;
    max-width: 130px !important;
    min-width: 130px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding-right: 10px !important;
    box-sizing: border-box !important;
}

.data-table tbody tr td:nth-child(10),
.data-table thead tr th:nth-child(10),
.data-table tbody tr th:nth-child(10),
.data-table .platform-header th:nth-child(10) {
    width: 150px !important;
    max-width: 150px !important;
    min-width: 150px !important;
    box-sizing: border-box !important;
}

.data-table thead {
    background: var(--bg-secondary) !important;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table thead th {
    background: var(--bg-secondary) !important;
}

.data-table th {
    padding: 10px 8px !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: relative;
    background: var(--bg-secondary) !important;
    vertical-align: middle;
}

/* 固定每列的宽度和间距，确保在所有屏幕尺寸下都保持一致 */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
    min-width: 120px !important;
    width: 120px !important;
    padding: 10px 8px 10px 8px !important;
    padding-right: 12px !important;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    min-width: 80px !important;
    width: 80px !important;
    padding: 10px 12px 10px 8px !important;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    min-width: 100px !important;
    width: 100px !important;
    padding: 10px 12px 10px 8px !important;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4) {
    min-width: 70px !important;
    width: 70px !important;
    padding: 10px 12px 10px 8px !important;
}

/* 增加 % 和 Conversions 列之间的间距 */
.data-table th:nth-child(5),
.data-table td:nth-child(5) {
    min-width: 110px !important;
    width: 110px !important;
    padding: 10px 30px 10px 8px !important;
}

/* 增加 CPM 和 Cost 列之间的间距 */
.data-table th:nth-child(6),
.data-table td:nth-child(6) {
    min-width: 100px !important;
    width: 100px !important;
    padding: 10px 20px 10px 10px !important;
}

.data-table th:nth-child(7),
.data-table td:nth-child(7) {
    min-width: 120px !important;
    width: 120px !important;
    padding: 10px 16px 10px 12px !important;
}

.data-table th:nth-child(8),
.data-table td:nth-child(8) {
    min-width: 120px !important;
    width: 120px !important;
    padding: 10px 12px 10px 8px !important;
}

.data-table th .sort-icon {
    display: inline-block;
    margin-left: 6px;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

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

.data-table th.sortable::after {
    content: ' ↕';
    opacity: 0.3;
    margin-left: 4px;
    display: inline-block;
}

.data-table th.sortable.asc::after {
    content: ' ↑';
    opacity: 1;
}

.data-table th.sortable.desc::after {
    content: ' ↓';
    opacity: 1;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color) !important;
    transition: background 0.2s ease;
    background: var(--bg-primary);
    position: relative;
}

.data-table tbody tr td,
.data-table tbody tr th {
    border-bottom: none !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

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

.data-table tbody tr:not(.platform-total-row):not(.grand-total-row):hover td {
    background: var(--bg-secondary) !important;
}

.data-table tbody tr:not(.platform-total-row):not(.grand-total-row):hover td.action-cell,
.data-table tbody tr:not(.platform-total-row):not(.grand-total-row):hover td:last-child.action-cell {
    background: var(--bg-secondary) !important;
}

.data-table tbody tr:nth-child(even) {
    background: var(--bg-primary) !important;
}

.data-table tbody tr:nth-child(even):not(.platform-total-row):not(.grand-total-row) td {
    background: var(--bg-primary) !important;
}

.data-table tbody tr:nth-child(even):not(.platform-total-row):not(.grand-total-row) td.action-cell,
.data-table tbody tr:nth-child(even):not(.platform-total-row):not(.grand-total-row) td:last-child.action-cell {
    background: var(--bg-primary) !important;
}

.data-table tbody tr:nth-child(even):hover {
    background: var(--bg-secondary) !important;
}

.data-table tbody tr:nth-child(even):not(.platform-total-row):not(.grand-total-row):hover td {
    background: var(--bg-secondary) !important;
}

.data-table tbody tr:nth-child(even):not(.platform-total-row):not(.grand-total-row):hover td.action-cell,
.data-table tbody tr:nth-child(even):not(.platform-total-row):not(.grand-total-row):hover td:last-child.action-cell {
    background: var(--bg-secondary) !important;
}

.data-table tbody tr:not(.platform-total-row):not(.grand-total-row) td.action-cell,
.data-table tbody tr:not(.platform-total-row):not(.grand-total-row) td:last-child.action-cell {
    background: var(--bg-primary) !important;
}

.data-table .platform-header {
    background: var(--bg-secondary) !important;
    border-top: 1px solid var(--border-color);
}

.data-table .platform-header th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary) !important;
}

.data-table .platform-header th.number-cell,
.data-table .platform-header th.currency-cell {
    text-align: left;
}

.data-table .platform-data-row {
    background: rgba(255, 255, 255, 0.01);
}

.data-table .platform-data-row:hover {
    background: var(--bg-hover);
}

.data-table .platform-total-row {
    background: var(--bg-secondary) !important;
    border-top: 1px solid var(--border-color);
}

.data-table .platform-total-row td {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-top: 1px solid var(--border-color);
}

.data-table .platform-total-row td.action-cell,
.data-table .platform-total-row td.number-cell,
.data-table .platform-total-row td.currency-cell {
    background: var(--bg-secondary) !important;
}

.data-table .platform-total-row td.profit-positive {
    color: #2ecc71 !important;
}

.data-table .platform-total-row td.profit-negative {
    color: #e74c3c !important;
}

.data-table .grand-total-row {
    position: sticky;
    bottom: 0;
    z-index: 5;
    box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.2);
    background: var(--bg-secondary) !important;
    border-top: 1px solid var(--border-color);
}

.data-table .grand-total-row td {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-top: 1px solid var(--border-color);
}

.data-table .grand-total-row td.action-cell,
.data-table .grand-total-row td.number-cell,
.data-table .grand-total-row td.currency-cell {
    background: var(--bg-secondary) !important;
}

.data-table .grand-total-row td:first-child {
    min-width: 300px;
    width: 30%;
}

.data-table .grand-total-row td:last-child {
    background: #252936 !important;
    background-color: #252936 !important;
}

.data-table .platform-total-row td:last-child {
    background: #252936 !important;
    background-color: #252936 !important;
}

/* Force last cell in total rows to be gray - highest priority */
.data-table tr.platform-total-row td:last-child:not(.action-cell),
.data-table tr.grand-total-row td:last-child:not(.action-cell),
.data-table .platform-total-row td:last-child:not(.action-cell),
.data-table .grand-total-row td:last-child:not(.action-cell) {
    background: #252936 !important;
    background-color: #252936 !important;
}

.data-table .grand-total-row td.profit-positive {
    color: #2ecc71 !important;
}

.data-table .grand-total-row td.profit-negative {
    color: #e74c3c !important;
}

.data-table td {
    padding: 10px 8px !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    border-bottom: none !important;
    border-right: none;
    border-left: none;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    vertical-align: middle;
}

.data-table .offer-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-table .offer-indicator {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--accent-success);
    flex-shrink: 0;
}

.data-table .number-cell {
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.data-table .currency-cell {
    text-align: left;
    font-variant-numeric: tabular-nums;
    white-space: nowrap !important;
}

.data-table .positive {
    color: var(--accent-success);
}

.data-table .negative {
    color: var(--accent-danger);
}

.profit-positive {
    color: #2ecc71 !important;
}

.profit-negative {
    color: #e74c3c !important;
}

.data-table .action-cell {
    display: flex !important;
    gap: 6px;
    justify-content: flex-end !important;
    align-items: center;
    padding-right: 8px;
    text-align: right;
}

.data-table th:last-child,
.data-table td:last-child {
    border-right: none !important;
    border-bottom: none !important;
}

/* Force right alignment for Actions column - last column */
.data-table th:last-child {
    width: 150px !important;
    min-width: 150px !important;
    max-width: 150px !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    padding-left: 30px !important;
    padding-right: 12px !important;
    text-align: right !important;
    box-sizing: border-box !important;
    vertical-align: middle !important;
}

.data-table td:last-child.action-cell {
    width: 150px !important;
    min-width: 150px !important;
    max-width: 150px !important;
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    text-align: right !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    padding-left: 30px !important;
    padding-right: 12px !important;
    box-sizing: border-box !important;
    position: relative;
    z-index: 0 !important;
    vertical-align: middle !important;
    border-bottom: none !important;
}

/* Prevent Profit column overflow */
.data-table td.currency-cell.profit-positive,
.data-table td.currency-cell.profit-negative {
    width: 130px !important;
    max-width: 130px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding-right: 10px !important;
}

/* Prevent Profit column overflow */
.data-table td.currency-cell {
    position: relative;
    overflow: visible;
}

.data-table td.currency-cell.profit-positive,
.data-table td.currency-cell.profit-negative {
    white-space: nowrap !important;
    overflow: visible !important;
    max-width: 140px !important;
    padding-right: 50px !important;
}

/* Ensure Actions column has fixed width and doesn't overlap */
.data-table th:last-child:not(:has(.sortable)) {
    position: relative;
    z-index: 10;
}

/* Ensure total rows' last cell uses correct background - higher specificity */
.data-table tr.platform-total-row td:last-child,
.data-table tr.grand-total-row td:last-child {
    background: #252936 !important;
    background-color: #252936 !important;
    position: relative;
    z-index: 100 !important;
}

/* Ensure all last cells in total rows are gray - highest priority */
.data-table .platform-total-row td:last-child,
.data-table .grand-total-row td:last-child,
.data-table tr.platform-total-row > td:last-child,
.data-table tr.grand-total-row > td:last-child {
    background: #252936 !important;
    background-color: #252936 !important;
}

.data-table thead th:last-child {
    background: var(--bg-secondary) !important;
}

/* Platform header Actions column should also be gray and right-aligned */
.data-table .platform-header th:last-child {
    background: var(--bg-secondary) !important;
    text-align: right !important;
    padding-right: 8px !important;
}

.data-table .action-btn {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 3px;
}

/* 汇总行 */
.summary-row {
    background: #1e2330;
    font-weight: 600;
}

.summary-row td {
    color: var(--text-primary);
    border-top: 1px solid var(--border-color);
}

/* 底部信息栏 */
.footer-bar {
    background: var(--bg-secondary);
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    overflow: auto;
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    position: relative;
}

.modal-content h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
}

.close {
    color: var(--text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 20px;
    line-height: 1;
}

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

/* 表单样式 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-group input[type="date"] {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group input[readonly] {
    background: var(--bg-tertiary);
    cursor: not-allowed;
    opacity: 1;
    color: var(--text-primary);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 15px;
}

.pagination button {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.pagination button:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

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

.pagination .page-info {
    padding: 6px 12px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .top-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 15px;
        gap: 12px;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
    }

    .toolbar-left {
        flex-direction: column;
    }

    .date-selector {
        width: 100%;
        margin-right: 0 !important;
    }

    .date-selector input[type="date"] {
        width: 100%;
        min-width: 100%;
    }

    .search-box {
        width: 100%;
    }

    .main-content {
        padding: 15px 0;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 4px;
    }
    
    /* History modal tablet responsive */
    #country-history-modal .history-controls {
        flex-wrap: wrap !important;
        gap: 12px !important;
    }
    
    #country-history-modal .history-controls .date-range-display {
        flex: 1 !important;
        min-width: 200px !important;
    }
    
    #country-history-modal .history-controls .btn-primary {
        flex-shrink: 0 !important;
    }

    .data-table {
        font-size: 11px;
        min-width: 1200px; /* 保持固定的最小宽度，确保所有列都能显示 */
    }

    /* 在移动端保持固定的列宽和间距 */
    .data-table th,
    .data-table td {
        white-space: nowrap;
    }

    .data-table th {
        font-size: 11px;
    }
    
    /* 确保所有列在移动端保持固定宽度和间距 - 与桌面版完全一致 */
    .data-table th:nth-child(1),
    .data-table td:nth-child(1) {
        min-width: 120px !important;
        width: 120px !important;
        padding: 10px 8px 10px 8px !important;
        padding-right: 12px !important;
    }

    .data-table th:nth-child(2),
    .data-table td:nth-child(2) {
        min-width: 80px !important;
        width: 80px !important;
        padding: 10px 12px 10px 8px !important;
    }

    .data-table th:nth-child(3),
    .data-table td:nth-child(3) {
        min-width: 100px !important;
        width: 100px !important;
        padding: 10px 12px 10px 8px !important;
    }

    .data-table th:nth-child(4),
    .data-table td:nth-child(4) {
        min-width: 70px !important;
        width: 70px !important;
        padding: 10px 12px 10px 8px !important;
    }

    .data-table th:nth-child(5),
    .data-table td:nth-child(5) {
        min-width: 110px !important;
        width: 110px !important;
        padding: 10px 30px 10px 8px !important;
    }

    .data-table th:nth-child(6),
    .data-table td:nth-child(6) {
        min-width: 100px !important;
        width: 100px !important;
        padding: 10px 20px 10px 10px !important;
    }

    .data-table th:nth-child(7),
    .data-table td:nth-child(7) {
        min-width: 120px !important;
        width: 120px !important;
        padding: 10px 16px 10px 12px !important;
    }

    .data-table th:nth-child(8),
    .data-table td:nth-child(8) {
        min-width: 120px !important;
        width: 120px !important;
        padding: 10px 12px 10px 8px !important;
    }

    .data-table .action-cell {
        flex-direction: column;
        gap: 4px;
    }

    .data-table .action-btn {
        padding: 4px 8px;
        font-size: 11px;
        width: 100%;
    }

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

    .form-actions {
        flex-direction: column;
        gap: 8px;
    }

    .form-actions button {
        width: 100%;
    }

    .btn {
        padding: 10px 16px;
        font-size: 14px;
        width: 100%;
        justify-content: center;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }

    .pagination button {
        padding: 8px 12px;
        font-size: 12px;
    }

    .footer-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 15px;
    }

    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10px auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* History modal mobile responsive */
    #country-history-modal .history-controls {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    
    #country-history-modal .history-controls .date-range-display {
        min-width: 100% !important;
        width: 100% !important;
    }
    
    #country-history-modal .history-controls .btn-primary {
        width: 100% !important;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .statistics-container {
        padding: 15px;
    }
}

/* 小屏幕设备 */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .top-toolbar {
        padding: 10px;
    }

    .main-content {
        padding: 10px 0;
    }

    .data-table {
        font-size: 10px;
        min-width: 1200px; /* 保持固定的最小宽度 */
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px !important;
    }

    .data-table th {
        font-size: 10px;
        padding: 10px 8px !important;
    }
    
    /* 在小屏幕上也保持固定的列宽和间距 - 与桌面版完全一致 */
    .data-table th:nth-child(1),
    .data-table td:nth-child(1) {
        min-width: 120px !important;
        width: 120px !important;
    }

    .data-table th:nth-child(2),
    .data-table td:nth-child(2) {
        min-width: 80px !important;
        width: 80px !important;
    }

    .data-table th:nth-child(3),
    .data-table td:nth-child(3) {
        min-width: 100px !important;
        width: 100px !important;
    }

    .data-table th:nth-child(4),
    .data-table td:nth-child(4) {
        min-width: 70px !important;
        width: 70px !important;
    }

    .data-table th:nth-child(5),
    .data-table td:nth-child(5) {
        min-width: 110px !important;
        width: 110px !important;
    }

    .data-table th:nth-child(6),
    .data-table td:nth-child(6) {
        min-width: 100px !important;
        width: 100px !important;
    }

    .data-table th:nth-child(7),
    .data-table td:nth-child(7) {
        min-width: 120px !important;
        width: 120px !important;
    }

    .data-table th:nth-child(8),
    .data-table td:nth-child(8) {
        min-width: 120px !important;
        width: 120px !important;
    }

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

    .statistics-title {
        font-size: 20px;
    }
}

/* 登录页面响应式 */
@media (max-width: 768px) {
    .login-container {
        width: 90%;
        max-width: 90%;
        padding: 30px 20px;
    }

    .login-form {
        width: 100%;
    }

    .login-form input {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

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

::-webkit-scrollbar-corner {
    background: var(--bg-primary);
}

/* Force English locale for date inputs */
input[type="date"] {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: dark;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    accent-color: var(--accent-primary);
}

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

/* Style date input components */
input[type="date"]::-webkit-datetime-edit {
    color: var(--text-primary);
    background-color: transparent;
}

input[type="date"]::-webkit-datetime-edit-fields-wrapper {
    color: var(--text-primary);
    background-color: transparent;
}

input[type="date"]::-webkit-datetime-edit-text {
    color: var(--text-primary);
}

input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
    color: var(--text-primary);
    background-color: transparent;
}

input[type="date"]::-webkit-datetime-edit-month-field:focus,
input[type="date"]::-webkit-datetime-edit-day-field:focus,
input[type="date"]::-webkit-datetime-edit-year-field:focus {
    background-color: var(--accent-primary);
    color: white;
    border-radius: 2px;
    outline: none;
}

/* Force dark color scheme for date picker popup */
/* Note: Native date picker popup styling is controlled by the browser */
/* color-scheme: dark in :root and input should make it use dark theme */

/* Additional styling to try to influence native date picker colors */
/* Note: Native date picker popup button colors are browser-controlled */
/* accent-color may help in some browsers but not all */
* {
    accent-color: #2ecc71;
}

html, body {
    accent-color: #2ecc71;
}

/* Attempt to style native date picker popup buttons (limited browser support) */
input[type="date"] {
    accent-color: #2ecc71 !important;
}

/* Filter Modal Styles */
#country-list label, #platform-list-checkboxes label {
    display: flex;
    align-items: center;
    padding: 8px;
    margin: 2px 0;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

#country-list label:hover, #platform-list-checkboxes label:hover {
    background: var(--bg-hover);
}

#country-list input[type="checkbox"], #platform-list-checkboxes input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#available-dates-list label {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    font-size: 13px;
}

#available-dates-list label:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

#available-dates-list input[type="checkbox"] {
    margin-right: 6px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

#country-search {
    font-size: 14px;
}

#country-search:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2);
}

/* 隐藏数字输入框的上下箭头 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Platform Edit Modal - Compact Styles */
.platform-edit-modal-content {
    max-width: 500px !important;
    padding: 20px !important;
    margin: 10% auto !important;
    position: relative !important;
}

.platform-edit-modal-content .close {
    position: absolute !important;
    right: 15px !important;
    top: 10px !important;
    z-index: 100 !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    line-height: 1 !important;
}

.platform-edit-modal-content h2 {
    margin-bottom: 15px !important;
    font-size: 18px;
}

.platform-edit-form-grid {
    gap: 15px !important;
    margin-bottom: 15px !important;
}

.platform-edit-form-grid .form-group label {
    margin-bottom: 6px !important;
    font-size: 12px !important;
}

.platform-edit-form-grid .form-group input,
.platform-edit-form-grid .form-group textarea {
    padding: 8px 10px !important;
    font-size: 13px !important;
}

.platform-edit-form-grid .form-group textarea {
    min-height: 60px;
}

.platform-edit-form-actions {
    margin-top: 15px !important;
    gap: 8px !important;
}

.platform-edit-form-actions .btn {
    padding: 8px 16px !important;
    font-size: 13px !important;
}

/* Mobile responsive for platform edit modal */
@media (max-width: 480px) {
    .platform-edit-modal-content {
        width: 95% !important;
        max-width: 95% !important;
        padding: 15px !important;
        margin: 5% auto !important;
        max-height: 90vh;
    }

    .platform-edit-modal-content h2 {
        font-size: 16px !important;
        margin-bottom: 12px !important;
    }

    .platform-edit-form-grid {
        gap: 12px !important;
        margin-bottom: 12px !important;
    }

    .platform-edit-form-grid .form-group label {
        font-size: 11px !important;
        margin-bottom: 5px !important;
    }

    .platform-edit-form-grid .form-group input,
    .platform-edit-form-grid .form-group textarea {
        padding: 7px 9px !important;
        font-size: 12px !important;
    }

    .platform-edit-form-actions {
        flex-direction: column !important;
        margin-top: 12px !important;
        gap: 8px !important;
    }

    .platform-edit-form-actions .btn {
        width: 100% !important;
        padding: 10px 16px !important;
        font-size: 13px !important;
    }

    .platform-edit-modal-content .close {
        position: absolute !important;
        font-size: 24px !important;
        right: 10px !important;
        top: 10px !important;
        z-index: 10 !important;
        float: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* Platform List Modal - Compact Styles */
.platform-list-modal-content {
    max-width: 800px !important;
    padding: 25px !important;
    margin: 5% auto !important;
}

.platform-list-table {
    table-layout: fixed;
    width: 100%;
}

/* Set fixed column widths for platform list table */
.platform-list-table th:nth-child(1),
.platform-list-table td:nth-child(1) {
    width: 45% !important;
    min-width: 45% !important;
    max-width: 45% !important;
}

.platform-list-table th:nth-child(2),
.platform-list-table td:nth-child(2) {
    width: 25% !important;
    min-width: 25% !important;
    max-width: 25% !important;
}

.platform-list-table th:nth-child(3),
.platform-list-table td:nth-child(3) {
    width: 30% !important;
    min-width: 250px !important;
    max-width: 30% !important;
    white-space: nowrap !important;
    overflow: visible !important;
}

.platform-list-table th:last-child,
.platform-list-table td:last-child {
    text-align: right !important;
}

.platform-list-header {
    margin-bottom: 12px !important;
}

.platform-list-header .btn {
    padding: 8px 16px !important;
    font-size: 14px !important;
}

.platform-list-table-wrapper {
    max-height: 500px !important;
    overflow-x: visible !important;
    overflow-y: auto !important;
}

.platform-list-table {
    font-size: 12px !important;
}

.platform-list-table th {
    padding: 12px 12px !important;
    font-size: 14px !important;
    white-space: normal;
    word-wrap: break-word;
}

.platform-list-table th:first-child {
    padding-left: 10px !important;
}

.platform-list-table th:last-child {
    padding-right: 10px !important;
}

.platform-list-table td {
    padding: 10px 12px !important;
    font-size: 14px !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.platform-list-table td.action-cell {
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    white-space: nowrap !important;
}

.platform-list-table td:first-child {
    padding-left: 10px !important;
}

.platform-list-table td:last-child {
    padding-right: 10px !important;
}

.platform-list-table .action-cell {
    display: flex !important;
    gap: 4px !important;
    justify-content: flex-start !important;
    align-items: center !important;
    white-space: nowrap !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    overflow: visible !important;
}

.platform-list-table .action-cell .action-btn {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

.platform-list-table th:last-child {
    text-align: left !important;
    padding-right: 10px !important;
}

.platform-list-table td:last-child {
    text-align: left !important;
    padding-right: 10px !important;
}

.platform-list-table .action-btn {
    padding: 6px 12px !important;
    font-size: 13px !important;
}

/* Mobile responsive for platform list modal */
@media (max-width: 480px) {
    .platform-list-modal-content {
        width: 95% !important;
        max-width: 95% !important;
        padding: 10px !important;
        margin: 2% auto !important;
        max-height: 95vh;
        display: flex;
        flex-direction: column;
    }

    .platform-list-header {
        margin-bottom: 8px !important;
        flex-shrink: 0;
    }

    .platform-list-header .btn {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }

    .platform-list-table-wrapper {
        max-height: calc(95vh - 100px) !important;
        overflow-y: auto;
        flex: 1;
        min-height: 0;
    }

    .platform-list-table {
        font-size: 11px !important;
    }

    /* Hide Created column on mobile */
    .platform-list-table thead tr th:nth-child(2),
    .platform-list-table tbody tr td:nth-child(2) {
        display: none !important;
    }

    .platform-list-table th {
        padding: 6px 6px !important;
        font-size: 11px !important;
    }

    .platform-list-table th:first-child {
        padding-left: 8px !important;
    }

    .platform-list-table th:last-child {
        padding-right: 8px !important;
    }

    .platform-list-table td {
        padding: 5px 6px !important;
        font-size: 11px !important;
    }

    .platform-list-table td:first-child {
        padding-left: 8px !important;
    }

    .platform-list-table td:last-child {
        padding-right: 8px !important;
    }

    /* Override the general .data-table .action-cell rule specifically for platform list */
    .platform-list-modal-content .platform-list-table-wrapper .platform-list-table tbody tr td.action-cell {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 4px !important;
        justify-content: flex-start !important;
        align-items: center !important;
    }

    .platform-list-modal-content .platform-list-table-wrapper .platform-list-table tbody tr td.action-cell .action-btn {
        padding: 4px 6px !important;
        font-size: 10px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        width: auto !important;
        min-width: auto !important;
    }

    .platform-list-modal-content .close {
        font-size: 22px !important;
        right: 8px !important;
        top: 8px !important;
    }
}

/* Word Upload Modal - Compact Vertical Design */

/* Word Upload Modal - Compact Vertical Design */
.word-upload-modal-content {
    max-width: 300px !important;
    padding: 25px !important;
    margin: 10% auto !important;
    position: relative !important;
}

.word-upload-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.word-upload-btn {
    width: 100% !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    border-radius: 4px !important;
    text-align: center !important;
}

.word-upload-btn:first-child {
    background: #9b59b6 !important;
    border-color: #9b59b6 !important;
    color: white !important;
}

.word-upload-btn:first-child:hover {
    background: #8e44ad !important;
    border-color: #8e44ad !important;
}

/* Mobile responsive for word upload modal */
@media (max-width: 480px) {
    .word-upload-modal-content {
        width: 85% !important;
        max-width: 280px !important;
        padding: 20px !important;
        margin: 5% auto !important;
    }

    .word-upload-btn {
        padding: 10px 14px !important;
        font-size: 13px !important;
    }
}
