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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
    padding: 10px;
}

.main-panel.container {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

/* 日志区：与紫色顶栏分离，卡片式嵌入浅灰底 */
.log-strip {
    flex-shrink: 0;
    padding: 10px 16px 12px;
    background: #f0f2f5;
    border-bottom: 1px solid #e4e7ec;
}

.log-card {
    display: flex;
    flex-direction: column;
    height: 200px;
    background: #1a1f26;
    border: 1px solid #d8dde6;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.log-card .log-panel-header {
    flex-shrink: 0;
    padding: 8px 12px;
    background: #252b34;
    border-bottom: 1px solid #3a424e;
}

.log-card .log-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #e8edf3;
}

/* 覆盖通用 .log-output 的 min-height:0，避免空日志时高度塌陷 */
.log-card .log-output.log-card-body {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: auto;
    margin: 0;
    padding: 8px 12px;
    background: #1a1f26;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-success {
    background: #2196F3;
    color: white;
}

.btn-success:hover {
    background: #0b7dda;
}

.btn-secondary {
    background: #757575;
    color: white;
}

.btn-secondary:hover {
    background: #616161;
}

.btn-danger {
    background: #f44336;
    color: white;
}

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

.filters {
    padding: 16px 20px;
    background: #f5f5f5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    flex-shrink: 0;
    border-bottom: 1px solid #e8e8e8;
}

.group-filter-multi {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

.group-filter-btn {
    min-width: 120px;
    max-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: white;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-filter-btn:hover {
    border-color: #667eea;
}

.group-filter-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 200;
    min-width: 200px;
    max-width: 280px;
    max-height: 280px;
    overflow-y: auto;
    padding: 10px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.group-filter-all {
    display: block;
    padding: 6px 4px;
    margin-bottom: 6px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    cursor: pointer;
}

.group-filter-item {
    display: block;
    padding: 5px 4px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-filter-item:hover {
    background: #f5f5f5;
}

.group-filter-item input {
    margin-right: 6px;
    vertical-align: middle;
}

.filters select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.account-search-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
}

.account-search-input {
    width: 180px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
}

.account-search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.network-mode-bar,
.network-mode-panel {
    padding: 14px 16px;
    background: #fff8e1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.network-mode-panel {
    border-radius: 8px;
    border: 1px solid #ffe082;
}

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

.network-modal-header h2 {
    font-size: 18px;
    color: #333;
}

.network-modal-content {
    max-width: 900px;
    width: 92vw;
    max-height: 88vh;
    overflow-y: auto;
    margin: 4vh auto;
    padding: 24px 28px;
}

.modal.network-modal.is-open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
}

.network-mode-select,
.network-mode-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    max-width: 220px;
}

.network-mode-input {
    min-width: 200px;
}

.network-mode-textarea {
    display: none;
    width: 100%;
    max-width: 720px;
    margin-top: 8px;
    padding: 8px 10px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    resize: vertical;
}

.subscription-url-input {
    min-width: 280px;
    max-width: 420px;
    flex: 1 1 280px;
}

.proxy-node-select {
    min-width: 200px;
    max-width: 280px;
}

.network-inline-label {
    font-size: 13px;
    color: #5d4037;
    white-space: nowrap;
}

.proxy-node-select option.node-dead {
    color: #999;
}

.proxy-node-select option.node-alive {
    color: #1b5e20;
}

.proxy-options-wrap {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.proxy-options-wrap.is-hidden {
    display: none;
}

.crawl-mode-status {
    color: #555;
    font-size: 13px;
    margin-left: 4px;
}

.crawl-mode-status.ok {
    color: #2e7d32;
}

.crawl-mode-status.warn {
    color: #e65100;
}

.export-range-hint,
.export-range-bounds {
    font-size: 13px;
    color: #666;
    margin: 0 0 12px;
}

.export-range-bounds {
    color: #1976d2;
}

.network-mode-hint {
    flex: 1 1 100%;
    font-size: 12px;
    color: #795548;
    margin-top: 2px;
}

.filters .stats-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 24px;
    margin-left: 8px;
    padding: 8px 16px;
    background: #e3f2fd;
    border-radius: 6px;
    font-size: 14px;
}

.filters .stats-summary .stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.filters .stats-summary .stat-gain-positive {
    color: #2e7d32;
    font-weight: 600;
}

.filters .stats-summary .stat-gain-negative {
    color: #c62828;
    font-weight: 600;
}

.filters .stats-summary .stat-gain-zero {
    color: #666;
    font-weight: 600;
}

.table-container {
    flex: 1;
    overflow: auto;
    padding: 16px 20px;
    width: 100%;
    position: relative;
    min-height: 0;
}

/* 避免 JS 建表头前出现半宽错位表格 */
body:not(.app-ready) .table-container {
    visibility: hidden;
}

body.app-ready .table-container {
    visibility: visible;
}

.log-modal-content {
    width: min(920px, 92vw);
    height: min(78vh, 720px);
    display: flex;
    flex-direction: column;
    background: #1a1d23;
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    color: #e6edf3;
}

.log-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #252a33;
    border-bottom: 1px solid #333a45;
    flex-shrink: 0;
}

.log-panel-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.log-panel-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.log-auto-scroll-label {
    font-size: 12px;
    color: #aab2bd;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
}

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

.log-output {
    flex: 1;
    margin: 0;
    padding: 12px 14px;
    overflow: auto;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: #c9d1d9;
    min-height: 0;
}

.log-line {
    margin-bottom: 2px;
}

.log-line .log-time {
    color: #6e7681;
    margin-right: 8px;
}

.log-line.level-error .log-text {
    color: #ff7b72;
}

.log-line.level-warn .log-text {
    color: #e3b341;
}

.log-line.level-info .log-text {
    color: #c9d1d9;
}

@media (max-width: 1100px) {
    body {
        overflow: auto;
        height: auto;
    }
    .main-panel.container {
        min-height: calc(100vh - 20px);
    }
    .log-modal-content {
        width: 96vw;
        height: 70vh;
    }
}

#dataTable {
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
    width: 100%;
    border: 1px solid #e0e0e0;
}

#dataTable .col-select {
    width: 3%;
    min-width: 42px;
    text-align: center;
}

#dataTable .col-index {
    width: 4%;
    min-width: 52px;
    text-align: center;
}

#dataTable .col-account {
    width: 11%;
    min-width: 100px;
}

#dataTable .col-group {
    width: 7%;
    min-width: 72px;
}

#dataTable th.date-column,
#dataTable td.date-column {
    text-align: center;
    vertical-align: middle;
    padding: 12px 6px !important;
}

#dataTable thead th.date-column {
    background: #667eea !important;
    color: #fff !important;
    z-index: 11;
}

#dataTable thead th.date-column div {
    color: #fff !important;
}

#dataTable .col-change {
    width: 9%;
    min-width: 96px;
}

#dataTable .col-action {
    width: 14%;
    min-width: 200px;
    text-align: center;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.action-buttons .btn-sm {
    padding: 4px 8px;
    font-size: 12px;
    white-space: nowrap;
}

#dataTable thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #667eea !important;
    color: #fff !important;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
    font-size: 13px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

#dataTable thead th.col-change,
#dataTable thead th.col-action {
    z-index: 12;
}

#dataTable td {
    padding: 12px 8px;
    border: 1px solid #e0e0e0;
    vertical-align: middle;
    font-size: 13px;
    word-break: break-word;
}

#dataTable tbody tr:hover {
    background: #f5f5f5;
}

#dataTable tbody td.date-column .value {
    font-weight: 600;
    color: #333;
}

#dataTable tbody td.date-column .label {
    font-size: 11px;
    color: #999;
    display: block;
    margin-top: 2px;
}

#dataTable .change-column {
    text-align: center;
    font-weight: 600;
    white-space: normal;
    vertical-align: middle;
    padding: 12px 6px !important;
    font-size: 12px;
}

#dataTable .empty-row td {
    text-align: center;
    padding: 24px;
    color: #888;
}

.change-positive {
    color: #4CAF50;
}

.change-negative {
    color: #f44336;
}

.change-zero {
    color: #757575;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal.log-modal {
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.log-modal.is-open {
    display: flex;
}

.account-action-modal {
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.account-action-content {
    max-width: 520px;
    margin: auto;
}

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

.account-action-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.account-action-desc {
    margin: 0 0 16px;
    color: #666;
    font-size: 14px;
}

.account-action-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.account-action-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #f8f9fc;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.account-action-card:hover {
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.account-action-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.account-action-card-desc {
    font-size: 13px;
    color: #777;
}

.modal-content {
    background: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

.banned {
    color: #f44336;
    font-weight: 600;
}

.error {
    color: #f44336;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* 主站密码门（/bz 不使用） */
body:not(.site-authed) .main-panel.container {
    visibility: hidden;
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.site-login-gate {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.site-login-gate[hidden] {
    display: none !important;
}

.site-login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.site-login-card h2 {
    margin: 0 0 8px;
    font-size: 22px;
    color: #333;
    text-align: center;
}

.site-login-hint {
    margin: 0 0 20px;
    font-size: 13px;
    color: #888;
    text-align: center;
}

.site-login-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 8px;
}

.site-login-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}

.site-login-error {
    min-height: 20px;
    margin: 0 0 12px;
    font-size: 13px;
    color: #c62828;
    text-align: center;
}

.site-login-btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
}

