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

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #fafafa;
    color: #1a1a1a;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
}

/* Side Nav */
.side-nav {
    width: 56px;
    background: #fff;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    flex-shrink: 0;
}

.nav-top {
    flex: 1;
}

.nav-bottom {
    margin-top: auto;
}

a.nav-icon {
    text-decoration: none;
}

.nav-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    color: #999;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.nav-icon:hover {
    background: #f5f5f5;
    color: #666;
}

.nav-icon.active {
    background: #f0f0f0;
    color: #1a1a1a;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Font Panel */
.font-panel {
    width: 280px;
    background: #fff;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.panel-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.panel-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.charset-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

.charset-select:focus {
    outline: none;
    border-color: #1a1a1a;
}

.font-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.font-item {
    background: #fafafa;
    border-radius: 8px;
    overflow: hidden;
}

.font-header {
    display: flex;
    align-items: center;
    padding: 12px;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.font-header:hover {
    background: rgba(0, 0, 0, 0.03);
}

.font-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1a1a1a;
}

.font-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: #1a1a1a;
}

.font-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.font-remove {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #ccc;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.font-remove:hover {
    background: #eee;
    color: #999;
}

.master-list {
    padding: 0 12px 12px 38px;
}

.master-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
    border-radius: 4px;
    margin: 0 -4px;
    padding-left: 4px;
    padding-right: 4px;
    transition: background 0.15s;
}

.master-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.master-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #1a1a1a;
}

.master-name {
    font-size: 0.85rem;
    color: #666;
    flex: 1;
}

.master-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.reference-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #ddd;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
    opacity: 0;
}

.master-item:hover .reference-btn {
    opacity: 1;
}

.reference-btn:hover {
    color: #999;
    background: rgba(0, 0, 0, 0.05);
}

.reference-btn.active {
    opacity: 1;
    color: #1a1a1a;
}

.reference-btn.active:hover {
    background: rgba(0, 0, 0, 0.08);
}

.add-font-btn {
    padding: 10px;
    border: 1px dashed #ddd;
    border-radius: 8px;
    background: none;
    color: #999;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}

.add-font-btn:hover {
    border-color: #bbb;
    color: #666;
    background: #fafafa;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ddd;
    border-top-color: #999;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Chart Area */
.chart-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow: hidden;
}

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

.chart-header-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: #1a1a1a;
}

.chart-subtitle {
    font-size: 0.85rem;
    color: #999;
}

.chart-type-toggle {
    display: flex;
    background: #f0f0f0;
    border-radius: 6px;
    padding: 3px;
}

.chart-type-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border: none;
    background: none;
    border-radius: 4px;
    cursor: pointer;
    color: #999;
    transition: all 0.2s;
}

.chart-type-btn:hover {
    color: #666;
}

.chart-type-btn.active {
    background: white;
    color: #1a1a1a;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.chart-type-btn svg {
    width: 16px;
    height: 16px;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.bin-control {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #666;
}

.bin-control.active {
    display: flex;
}

.bin-control label {
    color: #999;
}

.bin-control input {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.8rem;
    text-align: center;
}

.bin-control input:focus {
    outline: none;
    border-color: #1a1a1a;
}

.chart-container {
    flex: 1;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #eee;
    min-height: 0;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    align-items: center;
    justify-content: center;
    z-index: 100;
}

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

.modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 320px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.modal-list {
    flex: 1;
    overflow-y: auto;
    margin: 0 -24px;
    padding: 0 24px;
}

.modal-item {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-item:hover {
    background: #fafafa;
    margin: 0 -24px;
    padding: 12px 24px;
}

.modal-item.loading {
    pointer-events: none;
    color: #999;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-item.loading .spinner {
    width: 14px;
    height: 14px;
}

.modal-item.added {
    pointer-events: none;
    color: #999;
}

.modal-item:last-child {
    border-bottom: none;
}

.modal-close {
    margin-top: 16px;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #fafafa;
}

.no-fonts {
    color: #999;
    text-align: center;
    padding: 24px;
}

/* Settings Modal */
.settings-modal {
    width: 360px;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #fafafa;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-item:hover {
    background: #f5f5f5;
}

.settings-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: #1a1a1a;
}

.settings-desc {
    font-size: 0.75rem;
    color: #999;
    line-height: 1.4;
}

.settings-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #1a1a1a;
}

/* ============================================================================
   Upload Page Styles
   ============================================================================ */

/* Upload Panel */
.upload-panel {
    width: 360px;
    background: #fff;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 24px;
    gap: 20px;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed #ddd;
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
}

.drop-zone:hover {
    border-color: #bbb;
    background: #f5f5f5;
}

.drop-zone.drag-over {
    border-color: #1a1a1a;
    background: #f0f0f0;
}

.drop-zone.has-file {
    border-style: solid;
    border-color: #1a1a1a;
    background: #fff;
    padding: 24px;
}

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

.drop-zone.has-file .drop-zone-content {
    display: none;
}

.drop-zone-icon {
    width: 48px;
    height: 48px;
    color: #ccc;
    margin-bottom: 8px;
}

.drop-zone-text {
    font-size: 0.95rem;
    color: #666;
}

.drop-zone-hint {
    font-size: 0.85rem;
    color: #999;
}

.drop-zone-formats {
    font-size: 0.75rem;
    color: #bbb;
    margin-top: 8px;
}

/* Selected Files */
.selected-files {
    margin-top: -12px;
}

.selected-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 8px;
}

.file-icon {
    width: 20px;
    height: 20px;
    color: #666;
    flex-shrink: 0;
}

.file-name {
    flex: 1;
    font-size: 0.9rem;
    color: #1a1a1a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-remove {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.file-remove:hover {
    background: #e0e0e0;
    color: #666;
}

.add-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px dashed #ccc;
    background: none;
    border-radius: 8px;
    color: #666;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.add-more-btn:hover {
    border-color: #999;
    color: #333;
    background: #fafafa;
}

/* Metrics Section */
.metrics-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #fafafa;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.metric-item:hover {
    background: #f0f0f0;
}

.metric-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #1a1a1a;
    cursor: pointer;
}

.metric-name {
    font-size: 0.9rem;
    color: #1a1a1a;
}

/* Submit Button */
.submit-btn {
    padding: 14px 24px;
    background: #1a1a1a;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.submit-btn:hover:not(:disabled) {
    background: #333;
}

.submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.submit-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Jobs Panel */
.jobs-panel {
    flex: 1;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.jobs-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.refresh-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #f0f0f0;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: #e0e0e0;
    color: #1a1a1a;
}

.refresh-btn svg {
    width: 16px;
    height: 16px;
}

.jobs-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-jobs {
    color: #999;
    text-align: center;
    padding: 48px 24px;
    font-size: 0.9rem;
}

/* Job Item */
.job-item {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: #1a1a1a;
}

.job-delete {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #ccc;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.job-delete:hover {
    background: #f0f0f0;
    color: #999;
}

.job-metrics {
    font-size: 0.8rem;
    color: #999;
}

.job-progress {
    height: 4px;
    background: #eee;
    border-radius: 2px;
    overflow: hidden;
    margin: 4px 0;
}

.job-progress-bar {
    height: 100%;
    background: #1a1a1a;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.job-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-status-text {
    font-size: 0.8rem;
    color: #666;
}

.job-time {
    font-size: 0.75rem;
    color: #bbb;
}

/* Job Status Colors */
.job-item.job-status-pending .job-status-text {
    color: #999;
}

.job-item.job-status-processing .job-status-text {
    color: #0066cc;
}

.job-item.job-status-completed .job-status-text {
    color: #22863a;
}

.job-item.job-status-failed .job-status-text {
    color: #cb2431;
}
