/* ========================================
 * 及时晓-数据采集管理系统 - Design System
 * Brand: #2563eb (CTS Blue 600)
 * Fonts: DM Sans + Noto Sans SC
 * Grid: 4px base, 8px grid
 * ======================================== */

/* === RESET & BASE === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'DM Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1e293b;
    background: #f1f5f9;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: #2563eb;
    text-decoration: none;
}

/* === APP LAYOUT === */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.2s ease;
}

.sidebar.collapsed {
    width: 64px;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-label {
    display: none;
}

.sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    min-height: 56px;
}

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

.logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: #f1f5f9;
    border-radius: 4px;
    cursor: pointer;
    color: #64748b;
    flex-shrink: 0;
    transition: background 0.15s;
}

.sidebar-toggle:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.sidebar.collapsed .sidebar-toggle {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.nav-item.active {
    background: #eff6ff;
    color: #2563eb;
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-footer {
    border-top: 1px solid #e2e8f0;
    padding: 8px;
}

.sidebar-footer-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #64748b;
    font-size: 14px;
}

/* === MOBILE MENU === */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f5f9;
    border-radius: 8px;
    cursor: pointer;
    color: #64748b;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.2s ease;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 64px;
}

.main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 56px;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
}

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

.header-time {
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
}

.main-body {
    flex: 1;
    padding: 24px;
}

/* === PAGES === */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* === STATS CARDS === */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: box-shadow 0.15s;
}

.stat-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-icon--blue {
    background: #dbeafe;
    color: #2563eb;
}

.stat-card-icon--indigo {
    background: #e0e7ff;
    color: #4f46e5;
}

.stat-card-icon--orange {
    background: #ffedd5;
    color: #ea580c;
}

.stat-card-icon--red {
    background: #fee2e2;
    color: #ef4444;
}

.stat-card-body {
    display: flex;
    flex-direction: column;
}

.stat-card-value {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.stat-card-label {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

/* === TOOLBAR === */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

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

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

.search-box {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.search-input {
    height: 36px;
    padding: 0 12px 0 32px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 240px;
}

.search-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.search-input::placeholder {
    color: #94a3b8;
}

/* === SELECTION BAR === */
.selection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    margin-bottom: 12px;
}

.selection-info {
    font-size: 13px;
    color: #1e40af;
}

.selection-info strong {
    font-weight: 700;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.btn-outline {
    background: transparent;
    color: #475569;
    border-color: #e2e8f0;
}

.btn-outline:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.btn-danger {
    background: transparent;
    color: #ef4444;
    border-color: #fca5a5;
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

.btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 4px;
}

/* === TABLE === */
.table-wrapper {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.tbl {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.tbl thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.tbl th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    white-space: nowrap;
}

.tbl td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: #334155;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tbl tbody tr {
    transition: background 0.1s;
}

.tbl tbody tr:hover {
    background: #f8fafc;
}

.th-check {
    width: 40px;
    text-align: center;
}

.td-check {
    text-align: center;
    width: 40px;
}

.th-sortable {
    cursor: pointer;
    user-select: none;
}

.th-sortable svg {
    opacity: 0.4;
    vertical-align: middle;
    margin-left: 2px;
}

.th-sortable:hover svg {
    opacity: 0.8;
}

.th-sortable.th-sort-asc svg,
.th-sortable.th-sort-desc svg {
    opacity: 1;
    color: #2563eb;
}

.th-sort-asc svg {
    transform: rotate(180deg);
}

/* Table column widths */
.tbl th:nth-child(1),
.tbl td:nth-child(1) { width: 40px; }
.tbl th:nth-child(2),
.tbl td:nth-child(2) { width: 70px; }
.tbl th:nth-child(3),
.tbl td:nth-child(3) { width: 80px; }
.tbl th:nth-child(4),
.tbl td:nth-child(4) { width: 140px; }
.tbl th:nth-child(5),
.tbl td:nth-child(5) { width: 70px; }
.tbl th:nth-child(6),
.tbl td:nth-child(6) { width: 120px; }
.tbl th:nth-child(7),
.tbl td:nth-child(7) { width: auto; }
.tbl th:nth-child(8),
.tbl td:nth-child(8) { width: 60px; text-align: center; }
.tbl th:nth-child(9),
.tbl td:nth-child(9) { width: 150px; }

.td-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-actions {
    white-space: nowrap !important;
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-article {
    background: #dbeafe;
    color: #2563eb;
}

.badge-video {
    background: #ffedd5;
    color: #ea580c;
}

.badge-valid {
    background: #dcfce7;
    color: #16a34a;
}

.badge-invalid {
    background: #fee2e2;
    color: #ef4444;
}

.heat-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 22px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
}

/* === ACTION LINKS === */
.action-link {
    color: #2563eb;
    font-size: 12px;
    font-weight: 500;
    margin-right: 4px;
}

.action-link:not(:last-child)::after {
    content: '|';
    margin-left: 4px;
    color: #e2e8f0;
}

.action-link:hover {
    text-decoration: underline;
}

.action-link--danger {
    color: #ef4444;
}

/* === EMPTY STATE === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: #94a3b8;
    text-align: center;
}

.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 15px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
}

.empty-state span {
    font-size: 13px;
}

/* === PAGINATION === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    font-size: 13px;
    color: #64748b;
}

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

.pag-current {
    font-weight: 500;
    padding: 0 8px;
}

/* === IMPORT PAGE === */
.import-section {
    margin-bottom: 24px;
}

.upload-zone {
    background: #fff;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

.upload-zone--drag {
    border-color: #2563eb;
    background: #dbeafe;
}

.upload-zone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-zone-inner svg {
    color: #94a3b8;
    margin-bottom: 4px;
}

.upload-zone-inner h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.upload-zone-inner p {
    font-size: 13px;
    color: #64748b;
}

.upload-hint {
    color: #94a3b8 !important;
    font-size: 12px !important;
}

.import-progress {
    margin-top: 16px;
}

.import-progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}

.import-progress-fill {
    height: 100%;
    background: #2563eb;
    border-radius: 9999px;
    transition: width 0.3s ease;
    width: 0;
}

.import-progress-text {
    margin-top: 8px;
    font-size: 13px;
    color: #64748b;
}

.field-description-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
}

.field-description-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
}

.field-desc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.field-desc-item {
    font-size: 12px;
    color: #64748b;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 4px;
}

.field-desc-item strong {
    color: #1e293b;
    font-weight: 600;
}

/* === CHART PAGE === */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.chart-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
}

.chart-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
}

.chart-body {
    min-height: 200px;
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #94a3b8;
    font-size: 14px;
}

/* Bar Chart */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bar-label {
    width: 80px;
    font-size: 12px;
    color: #64748b;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 20px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    border-radius: 4px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.bar-value {
    width: 36px;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    text-align: right;
    flex-shrink: 0;
}

/* === SETTINGS PAGE === */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.settings-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
}

.settings-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-label {
    font-size: 13px;
    color: #64748b;
}

.settings-value {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.settings-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.settings-warning {
    font-size: 12px;
    color: #ef4444;
}

/* === MODALS === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 200;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    z-index: 210;
    width: 860px;
    max-height: 85vh;
    flex-direction: column;
}

.modal-sm {
    width: 420px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 8px;
    cursor: pointer;
    color: #64748b;
    transition: all 0.15s;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding: 32px 20px;
}

.confirm-icon {
    margin-bottom: 4px;
}

.modal-body-center p {
    font-size: 14px;
    color: #64748b;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* === DETAIL GRID === */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.detail-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-item:nth-child(odd) {
    border-right: 1px solid #f1f5f9;
}

.detail-item-full {
    grid-column: 1 / -1;
}

.detail-item-full {
    border-right: none !important;
}

.detail-label {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.detail-value {
    font-size: 13px;
    color: #1e293b;
    word-break: break-word;
    white-space: pre-wrap;
}

/* === FORM GRID === */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

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

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.form-input,
.form-select,
.form-textarea {
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.form-textarea {
    height: auto;
    padding: 8px 10px;
    resize: vertical;
    min-height: 60px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-input[readonly] {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

/* === TOAST NOTIFICATIONS === */
#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    pointer-events: auto;
    max-width: 360px;
}

.toast--show {
    transform: translateX(0);
}

.toast--success {
    border-left: 4px solid #22c55e;
    color: #166534;
}

.toast--error {
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.toast--info {
    border-left: 4px solid #06b6d4;
    color: #155e75;
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .chart-grid {
        grid-template-columns: 1fr;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
    .field-desc-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .stats-cards {
        grid-template-columns: 1fr 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right {
        flex-wrap: wrap;
    }

    .search-input {
        width: 100%;
    }

    .modal {
        width: calc(100vw - 24px);
        max-width: 860px;
        max-height: 90vh;
    }

    .modal-sm {
        width: calc(100vw - 24px);
        max-width: 420px;
    }

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

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

    .detail-item:nth-child(odd) {
        border-right: none;
    }

    .field-desc-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-cards {
        grid-template-columns: 1fr;
    }

    .main-body {
        padding: 16px;
    }

    .tbl th:nth-child(5),
    .tbl td:nth-child(5),
    .tbl th:nth-child(6),
    .tbl td:nth-child(6) {
        display: none;
    }
}
