/* ===== CSS Custom Properties for Theming ===== */

[data-theme="dark"] {
    --bg-primary: #0f0f13;
    --bg-secondary: #1a1a22;
    --bg-tertiary: #22222e;
    --bg-hover: #252533;
    --border: #2a2a3a;
    --border-subtle: #1e1e2a;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #666680;
    --accent: #6c7bf0;
    --accent-hover: #5a69d8;
    --accent-glow: rgba(108, 123, 240, 0.12);
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.12);
    --warning: #facc15;
    --warning-bg: rgba(250, 204, 21, 0.12);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --input-bg: #16161e;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eeeef2;
    --bg-hover: #e8e8ee;
    --border: #d8d8e0;
    --border-subtle: #e5e5eb;
    --text-primary: #1a1a2e;
    --text-secondary: #555570;
    --text-muted: #888899;
    --accent: #5560d0;
    --accent-hover: #444fba;
    --accent-glow: rgba(85, 96, 208, 0.08);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --input-bg: #ffffff;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* ===== Reset & Base ===== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.25s ease, color 0.25s ease;
}

.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ===== Header ===== */

header { margin-bottom: 24px; }

h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 6px;
    font-size: 14px;
}

h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Screens (login only) ===== */

.screen { display: none; }
.screen.active { display: block; }

/* ===== Tab Container ===== */

.tab-container[hidden] { display: none; }

/* ===== Tab Bar ===== */

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.tab-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

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

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ===== Tab Panels ===== */

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Dashboard Stats ===== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 22px 16px;
    text-align: center;
    transition: all 0.2s;
}

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

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.stat-accent .stat-value { color: var(--accent); }
.stat-success .stat-value { color: var(--success); }

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Dashboard Recent Activity */
.dashboard-recent { margin-top: 8px; }

.section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 12px;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.recent-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.recent-item-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.recent-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-item-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Batches Tab ===== */

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

.batch-section {
    margin-bottom: 28px;
}

.batch-section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

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

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 20px;
    font-size: 14px;
}

/* ===== Edit / Text Action Button ===== */

.btn-text-action {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 2px;
    transition: opacity 0.2s;
    font-family: inherit;
}

.btn-text-action:hover { opacity: 0.7; }

/* ===== Select Mode ===== */

.select-mode-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
}

.select-mode-bar[hidden] { display: none; }

.select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

.select-all-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.select-mode-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#selected-count {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ===== Select Mode Bottom Bar (fixed pills) ===== */

.select-bottom-bar {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 200;
    animation: slideUp 0.2s ease;
}

.select-bottom-bar[hidden] { display: none; }

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.select-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 22px;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.select-pill:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.select-pill svg { flex-shrink: 0; }

.select-pill-download {
    background: var(--accent);
    color: #fff;
}

.select-pill-download:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.select-pill-delete {
    background: var(--danger);
    color: #fff;
}

.select-pill-delete:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-1px);
}

/* ===== Delete Countdown Overlay ===== */

.delete-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.delete-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 32px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.delete-dialog h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--danger);
}

.delete-dialog p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.4;
}

.delete-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.delete-dialog .btn-confirm {
    padding: 10px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    background: var(--danger);
    color: #fff;
    transition: all 0.2s;
}

.delete-dialog .btn-confirm:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.delete-dialog .btn-confirm:not(:disabled):hover {
    background: #dc2626;
}

.delete-dialog .btn-cancel-dialog {
    padding: 10px 24px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all 0.2s;
}

.delete-dialog .btn-cancel-dialog:hover {
    background: var(--bg-hover);
}

.btn-cancel {
    margin-top: 0;
    margin-left: 0;
}

/* ===== Batch Card ===== */

.batch-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.batch-card:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.batch-checkbox {
    display: none;
    flex-shrink: 0;
}

.batch-list.select-mode .batch-checkbox {
    display: flex;
    align-items: center;
}

.batch-list.select-mode .batch-card {
    cursor: default;
}

.batch-list.select-mode .batch-card:hover {
    transform: none;
    box-shadow: none;
}

.batch-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.batch-card-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.batch-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.batch-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    align-items: center;
}

.batch-card-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.batch-card-counts {
    display: flex;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}

.batch-card-counts .count-final { color: var(--success); }
.batch-card-counts .count-edit { color: var(--warning); }
.batch-card-counts .count-review { color: var(--danger); }

.batch-action-btn {
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.batch-action-btn:hover {
    color: var(--accent);
    background: var(--accent-glow);
}

.batch-delete-btn:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* Download feedback states */
.batch-download-btn.downloading {
    color: var(--accent);
    opacity: 0.5;
    pointer-events: auto;
}

.batch-download-btn.downloading .dl-icon-arrow { display: none; }
.batch-download-btn.downloading .dl-icon-check { display: block !important; }

.bd-download-btn.downloading {
    opacity: 0.6;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    pointer-events: auto;
}

.select-pill-download.downloading {
    opacity: 0.6;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    pointer-events: none;
}

/* ===== Status Badge ===== */

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.status-created { background: var(--bg-tertiary); color: var(--text-muted); }
.status-queued { background: var(--accent-glow); color: var(--accent); }
.status-processing { background: var(--warning-bg); color: var(--warning); }
.status-completed { background: var(--success-bg); color: var(--success); }
.status-error { background: var(--danger-bg); color: var(--danger); }

/* ===== Icon Buttons ===== */

.btn-icon {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent);
}

.btn-icon.active {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

/* ===== Back Button ===== */

.btn-back {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 0;
    margin-bottom: 20px;
    transition: color 0.2s;
    display: inline-block;
}

.btn-back:hover { color: var(--accent); }

/* ===== Batch Detail Header ===== */

.batch-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

/* ===== Warning Banner ===== */

.warning-banner {
    padding: 12px 16px;
    margin-bottom: 16px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
}

[data-theme="dark"] .warning-banner {
    background: #78350f;
    color: #fde68a;
    border-color: #b45309;
}


/* ===== Timer Display ===== */

.timer-display {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}

.timer-display #bd-elapsed {
    font-size: 32px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.timer-eta {
    font-size: 14px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ===== Progress ===== */

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-size: 14px;
    color: var(--text-secondary);
}

#bd-progress-text {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.progress-bar-container {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.current-status {
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-muted);
    min-height: 18px;
}

/* ===== Queued Message ===== */

.queued-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 15px;
}

.queued-message p {
    animation: pulse-opacity 2s ease-in-out infinite;
}

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

/* ===== Tally Cards ===== */

.tally {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    margin-bottom: 24px;
}

.tally-item {
    flex: 1;
    text-align: center;
    padding: 18px 12px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    transition: background 0.2s;
}

.tally-count {
    display: block;
    font-size: 30px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tally-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.tally-item.final .tally-count { color: var(--success); }
.tally-item.edit .tally-count { color: var(--warning); }
.tally-item.review .tally-count { color: var(--danger); }

/* ===== Results Table ===== */

.results-table {
    width: 100%;
    margin-top: 8px;
    border-collapse: collapse;
}

.results-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

.results-table td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.results-table tr:hover { background: var(--bg-hover); }

.results-table tr.row-error td { color: var(--danger); opacity: 0.8; }

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-final { background: var(--success-bg); color: var(--success); }
.badge-edit { background: var(--warning-bg); color: var(--warning); }
.badge-review { background: var(--danger-bg); color: var(--danger); }
.badge-error { background: var(--danger-bg); color: var(--danger); }

.actions { margin-top: 24px; text-align: center; }

/* ===== Buttons ===== */

.btn-primary {
    display: inline-block;
    margin-top: 20px;
    padding: 11px 28px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: var(--bg-tertiary); color: var(--text-muted); cursor: not-allowed; transform: none; }

.btn-small {
    padding: 8px 18px;
    font-size: 13px;
    margin-top: 0;
}

.btn-secondary {
    display: inline-block;
    margin-top: 20px;
    margin-left: 10px;
    padding: 11px 28px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-danger-text {
    color: var(--danger);
    border-color: var(--danger);
}

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

/* ===== New Batch Form ===== */

.new-batch-form {
    margin-bottom: 20px;
}

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

.text-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.text-input:focus { border-color: var(--accent); }

.textarea {
    resize: vertical;
    min-height: 60px;
    font-size: 14px;
}

/* ===== Drop Zone ===== */

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 14px;
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    color: var(--text-muted);
    background: var(--bg-secondary);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--text-secondary);
}

.drop-zone-content svg { margin-bottom: 14px; opacity: 0.6; }
.drop-zone-content p { margin: 4px 0; }
.drop-zone-content .small { font-size: 13px; color: var(--text-muted); }

/* ===== File List (New Batch) ===== */

.file-list {
    margin-top: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 14px 16px;
}

.file-list h3 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.file-list ul {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    color: var(--text-secondary);
}

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

.file-thumb {
    width: 48px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.file-item-info { flex: 1; min-width: 0; }
.file-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item-size { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.file-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
}

.file-item-remove:hover { color: var(--danger); }

/* ===== Batch Upload Toggle ===== */

.dedup-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 4px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.dedup-toggle input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.dedup-hint {
    color: var(--text-muted);
    font-size: 11px;
}

.batch-upload-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
    font-family: inherit;
}

.batch-upload-toggle:hover {
    color: var(--accent);
}

.batch-upload-toggle.open {
    color: var(--accent);
}

.batch-upload-toggle .chevron {
    transition: transform 0.2s;
}

.batch-upload-toggle.open .chevron {
    transform: rotate(180deg);
}

/* ===== Batch Upload Section ===== */

.batch-upload-section[hidden] { display: none; }

.batch-upload-section {
    margin-top: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}

.batch-upload-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.folder-drop-zone {
    padding: 28px 20px;
    background: var(--bg-primary);
}

/* ===== Folder Queue ===== */

.folder-queue {
    margin-top: 16px;
}

.folder-queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.folder-queue-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.folder-queue-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
}

.folder-queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    transition: all 0.2s;
}

.folder-queue-item.uploading {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.folder-queue-item.done {
    border-color: var(--success);
    opacity: 0.7;
}

.folder-queue-item.error {
    border-color: var(--danger);
}

.folder-queue-icon {
    flex-shrink: 0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.folder-queue-icon.done { color: var(--success); }
.folder-queue-icon.error { color: var(--danger); }
.folder-queue-icon.uploading { color: var(--accent); }

.folder-queue-info {
    flex: 1;
    min-width: 0;
}

.folder-queue-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-queue-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.folder-queue-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
}

.folder-queue-remove:hover { color: var(--danger); }

/* ===== Batch Upload Progress ===== */

.batch-upload-progress-section {
    margin-top: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 16px;
}

/* ===== Upload Progress ===== */

.upload-progress {
    margin-top: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 16px;
}

.upload-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 500;
}

.upload-progress-header span:first-child { color: var(--text-primary); }
.upload-progress-header span:last-child { color: var(--accent); font-variant-numeric: tabular-nums; }

.upload-detail {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Settings Tab ===== */

.settings-section {
    margin-bottom: 36px;
}

.settings-section > h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.settings-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 16px;
    margin-top: -8px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.setting-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.settings-footer {
    margin-top: 24px;
    text-align: right;
}

.settings-footer .btn-primary { margin-top: 0; }

/* ===== Flags List ===== */

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

.flag-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

.flag-item-info { flex: 1; min-width: 0; }

.flag-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.flag-item-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.flag-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.flag-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    transition: color 0.2s;
    line-height: 1;
}

.flag-delete-btn:hover { color: var(--danger); }

/* ===== Toggle Switch ===== */

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 11px;
    transition: all 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: #fff;
}

/* ===== Add Flag Form ===== */

.add-flag-form {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
}

.add-flag-form h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.add-flag-form .text-input {
    margin-bottom: 8px;
}

/* ===== Login ===== */

.login-box {
    max-width: 360px;
    margin: 60px auto 0;
    text-align: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 36px 32px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 6px;
    margin-bottom: 24px;
}

.password-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.password-input:focus { border-color: var(--accent); }

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
}

/* ===== Scrollbar ===== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Responsive ===== */

@media (max-width: 600px) {
    .container { padding: 20px 16px; }
    h1 { font-size: 22px; }
    .tab-btn span { font-size: 11px; }
    .tab-btn { padding: 10px 4px 8px; }
    .stats-grid { gap: 8px; }
    .stat-card { padding: 16px 12px; }
    .stat-value { font-size: 22px; }
    .tally { gap: 8px; }
    .tally-item { padding: 14px 8px; }
    .tally-count { font-size: 24px; }
    .results-table { font-size: 12px; }
    .results-table th, .results-table td { padding: 8px 6px; }
    .batch-card { padding: 12px 14px; }
    .timer-display #bd-elapsed { font-size: 24px; }
    .select-mode-bar { flex-direction: column; gap: 10px; align-items: stretch; }
    .select-mode-actions { justify-content: space-between; }
    .storage-indicator { right: 12px; bottom: 12px; padding: 6px 10px; font-size: 11px; }
}


/* ===== Storage Indicator (bottom-right) ===== */

.storage-indicator {
    position: fixed;
    bottom: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-muted);
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: background 0.2s;
}

.storage-indicator svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.storage-indicator #storage-text {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.storage-bar-container {
    width: 48px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.storage-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s, background 0.3s;
    width: 0%;
}

.storage-bar.warning {
    background: #f59e0b;
}

.storage-bar.danger {
    background: #ef4444;
}

/* ===== Download Notifications ===== */

.download-notifications {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    max-width: 340px;
    width: 100%;
}

.download-notification {
    background: #1a1a2e;
    color: #e0e0e0;
    border-radius: 10px;
    padding: 14px 16px 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: dn-slide-in 0.25s ease-out;
    position: relative;
    overflow: hidden;
}

.download-notification.dn-removing {
    animation: dn-fade-out 0.3s ease-in forwards;
}

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

.dn-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.dn-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    font-size: 18px;
    flex-shrink: 0;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dn-close:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.dn-status {
    font-size: 11px;
    color: #999;
    margin-bottom: 6px;
}

.dn-bar-track {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.dn-bar-fill {
    height: 100%;
    background: #6366f1;
    border-radius: 2px;
    transition: width 0.2s ease;
    width: 0%;
}

.download-notification.dn-complete .dn-bar-fill {
    background: #22c55e;
}

.download-notification.dn-error .dn-bar-fill {
    background: #ef4444;
}

.dn-preparing .dn-bar-fill {
    width: 100%;
    animation: dn-pulse 1.5s ease-in-out infinite;
    opacity: 0.4;
}

@keyframes dn-slide-in {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes dn-fade-out {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(10px); opacity: 0; }
}

@keyframes dn-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}
