/* ==========================================================================
   SSO Debt Report System - Design System & Stylesheet (Vanilla CSS)
   Aesthetics: Deep Executive Slate, Electric Blue, Vivid Emerald & Amber
   ========================================================================== */

:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(18, 26, 43, 0.75);
    --bg-card-hover: rgba(26, 36, 60, 0.85);
    --bg-surface: #141e33;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #3b82f6;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --primary-blue: #2563eb;
    --primary-blue-glow: rgba(37, 99, 235, 0.35);
    --primary-indigo: #4f46e5;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #ef4444;

    --font-thai: 'Kanit', sans-serif;
    --font-inter: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
    --glass-blur: blur(12px);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-thai);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(79, 70, 229, 0.1) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(16, 185, 129, 0.04) 0px, transparent 50%);
    background-attachment: fixed;
}

.app-container {
    max-width: 1560px;
    margin: 0 auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 18px;
}

.logo-badge {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-indigo));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px var(--primary-blue-glow);
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: #ffffff;
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-subtitle {
    font-size: 13.5px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

#wcf-status-badge:hover {
    filter: brightness(1.15);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.badge-loading {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-loading .status-dot {
    background: var(--text-muted);
    animation: pulse 1.5s infinite;
}

.badge-connected {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-connected .status-dot {
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-error .status-dot {
    background: #ef4444;
}

.btn-icon-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-thai);
    background: rgba(37, 99, 235, 0.12);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-action:hover {
    background: rgba(37, 99, 235, 0.25);
    border-color: var(--primary-blue);
    color: #ffffff;
    transform: translateY(-1px);
}

.action-svg {
    width: 16px;
    height: 16px;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: #111a2e;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 580px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.modal-title {
    font-size: 16.5px;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s ease;
}

.modal-close:hover {
    color: #ffffff;
}

.modal-body {
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.master-info-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
}

.info-label {
    color: var(--text-secondary);
}

.info-val {
    color: var(--text-primary);
}

.text-bold {
    font-weight: 600;
    color: #34d399;
}

.master-upload-zone {
    background: rgba(20, 30, 51, 0.4);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 18px;
    text-align: center;
}

.master-upload-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.master-action-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.master-status-msg {
    font-size: 13.5px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.master-status-msg.success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.master-status-msg.error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-icon {
    width: 20px;
    height: 20px;
    color: var(--primary-blue);
}

.file-format-hint {
    font-size: 13px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

/* Upload Grid */
.upload-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
}

@media (max-width: 992px) {
    .upload-grid {
        grid-template-columns: 1fr;
    }
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-md);
    padding: 40px 24px;
    text-align: center;
    background: rgba(20, 30, 51, 0.4);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary-blue);
    background: rgba(37, 99, 235, 0.08);
    transform: translateY(-2px);
}

.file-input-hidden {
    display: none;
}

.upload-icon-wrapper {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-blue);
    transition: all 0.2s ease;
}

.drop-zone:hover .upload-icon-wrapper {
    background: var(--primary-blue);
    color: #ffffff;
    box-shadow: 0 0 20px var(--primary-blue-glow);
}

.upload-icon {
    width: 32px;
    height: 32px;
}

.drop-text-main {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.drop-text-sub {
    font-size: 13px;
    color: var(--text-muted);
}

.link-btn {
    background: none;
    border: none;
    color: #60a5fa;
    text-decoration: underline;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    font-weight: 500;
    padding: 0 4px;
}

.link-btn:hover {
    color: #93c5fd;
}

.selected-file-info {
    margin-top: 14px;
    font-size: 14px;
    color: #34d399;
    font-weight: 500;
    background: rgba(16, 185, 129, 0.1);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    display: inline-block;
}

/* Existing Files Panel */
.existing-files-panel {
    background: rgba(20, 30, 51, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.panel-subtitle {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.files-list {
    max-height: 170px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
    padding-right: 4px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-item:hover {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.4);
}

.file-item.selected {
    background: rgba(37, 99, 235, 0.25);
    border-color: var(--primary-blue);
}

.file-item-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.file-item-size {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.loading-placeholder {
    font-size: 13px;
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: var(--font-thai);
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-indigo));
    color: #ffffff;
    box-shadow: 0 4px 14px var(--primary-blue-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-blue-glow);
}

.btn-primary:disabled {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-success {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* Progress Bar */
.progress-container {
    margin-top: 20px;
}

.progress-bar-wrapper {
    height: 6px;
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar.indeterminate {
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue), var(--accent-emerald));
    border-radius: var(--radius-full);
    position: absolute;
    animation: indeterminate 1.5s infinite ease-in-out;
}

.progress-status-text {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-top: 10px;
    text-align: center;
}

/* KPI Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.4s ease;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.18);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
}

.card-blue::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.card-indigo::before { background: linear-gradient(90deg, #6366f1, #818cf8); }
.card-amber::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.card-emerald::before { background: linear-gradient(90deg, #10b981, #34d399); }

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.kpi-label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

.kpi-badge {
    font-size: 11.5px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.kpi-value-wrapper {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-inter);
    color: #ffffff;
    letter-spacing: -0.5px;
}

.kpi-unit {
    font-size: 14px;
    color: var(--text-muted);
}

.kpi-subtext {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* Table Toolbar */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

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

.table-meta-badge {
    font-size: 12.5px;
    background: rgba(37, 99, 235, 0.18);
    color: #93c5fd;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

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

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

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-thai);
    font-size: 13.5px;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Table */
.table-container {
    max-height: 580px;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.6);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.data-table th {
    position: sticky;
    top: 0;
    background: #132238;
    color: #93c5fd;
    font-weight: 600;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
    z-index: 10;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.data-table tbody tr {
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.08);
}

.text-right {
    text-align: right !important;
}

.text-center {
    text-align: center !important;
}

.cell-mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.cell-debt {
    font-weight: 600;
    color: #60a5fa;
    font-family: var(--font-inter);
}

.cell-total {
    font-weight: 700;
    color: #34d399;
    font-family: var(--font-inter);
}

.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.status-A { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-C { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.status-S { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

/* Footer */
.app-footer {
    text-align: center;
    padding: 20px 0 10px;
    color: var(--text-muted);
    font-size: 12.5px;
    border-top: 1px solid var(--border-color);
}

/* Utilities */
.hidden {
    display: none !important;
}

@keyframes indeterminate {
    0% { left: -40%; }
    50% { left: 40%; width: 60%; }
    100% { left: 100%; width: 40%; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.letter-card { margin-top: 8px; }
.letter-controls, .letter-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin: 12px 0;
}
.letter-field label, .letter-check, .letter-scope label {
    color: var(--text-secondary);
    font-size: 13px;
}
.letter-field input, .letter-field select {
    width: 100%;
    margin-top: 4px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-family: var(--font-thai);
}
.letter-field input:focus, .letter-field select:focus {
    outline: none;
    border-color: var(--border-focus);
}
.letter-hint { color: var(--text-muted); font-size: 12.5px; margin: 4px 0 10px; }
.letter-scope { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 12px; }
.letter-check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.letter-summary-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 14px;
}
.letter-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.letter-actions .btn { width: auto; }

/* Workspace split: ledger desk vs letter desk */
.desk-nav { display: flex; gap: 6px; padding: 4px; border-radius: 10px; background: rgba(23, 32, 51, 0.06); }
.desk-tab {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-thai);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
}
.desk-tab.is-active { background: #1d4e89; color: #fff; }

body.desk-ledger {
    --bg-main: #e7eef4;
    --bg-card: #f8f6f1;
    --bg-card-hover: #fff;
    --bg-surface: #fff;
    --border-color: #c5d2de;
    --text-primary: #172033;
    --text-secondary: #3d4d60;
    --text-muted: #4e5e70;
    --primary-blue: #1d4e89;
    --primary-indigo: #1d4e89;
    --primary-blue-glow: transparent;
    --border-focus: #1d4e89;
    background-image: none;
    background-color: #e7eef4;
}
body.desk-letter {
    --bg-main: #f3e7d4;
    --bg-card: #fffaf3;
    --bg-surface: #fff;
    --border-color: #e0d0b8;
    --text-primary: #2c2118;
    --text-secondary: #5c4636;
    --text-muted: #6a5344;
    --primary-blue: #8c2f2f;
    --primary-indigo: #8c2f2f;
    --primary-blue-glow: transparent;
    --border-focus: #8c2f2f;
    background-image: none;
    background-color: #f3e7d4;
}
body.desk-ledger .app-header,
body.desk-letter .app-header {
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    padding: 8px 0 4px;
}
body.desk-ledger .logo-badge { background: #1d4e89; box-shadow: none; }
body.desk-letter .logo-badge { background: #8c2f2f; box-shadow: none; }
body.desk-ledger .header-title,
body.desk-letter .header-title { color: var(--text-primary); }
.btn-primary, .btn-success {
    background: var(--primary-blue);
    box-shadow: none;
    color: #fff;
}
.btn-primary:hover:not(:disabled), .btn-success:hover { transform: none; box-shadow: none; filter: brightness(1.08); }
.btn-primary:disabled { background: #d5dee7; color: #4e5e70; }
body.desk-letter .btn-success { background: #8c2f2f; }
body.desk-letter .desk-tab.is-active { background: #8c2f2f; }
.card { background: var(--bg-card); backdrop-filter: none; box-shadow: none; }
.card-title { color: var(--text-primary); }
.file-format-hint { background: rgba(23, 32, 51, 0.06); }
.drop-zone {
    border-color: #9eb0c2;
    background: #fff;
}
.existing-files-panel { background: #fff; }
.file-item { background: #f4f7fa; }
.search-input, .search-input:focus { background: #fff; box-shadow: none; }
.btn-secondary { background: #eef3f8; color: #172033; border-color: #c5d2de; }
.btn-outline:hover { color: #172033; border-color: #1d4e89; }
.drop-zone:hover, .drop-zone.drag-over { transform: none; background: #f3f7fb; }
body.desk-letter .drop-zone:hover { background: #fff4e6; }
.modal-card { background: #fffaf3; color: #2c2118; }
.modal-title, .modal-close { color: #2c2118; }
.kpi-card { background: #fff; backdrop-filter: none; box-shadow: none; }
.kpi-card:hover { transform: none; }
.kpi-card::before { height: 3px; }
.kpi-value, .cell-debt, .cell-total { font-family: var(--font-thai); color: #172033; }
.cell-total { color: #0f6b45; }
.kpi-badge { background: #eef3f8; color: #3d4d60; }
.table-container { background: #fff; }
body.desk-ledger .data-table th { background: #1d4e89; color: #fff; border-bottom: 0; }
body.desk-letter .data-table th { background: #8c2f2f; color: #fff; border-bottom: 0; }
.data-table td { border-bottom: 1px solid #e6edf3; }
body.desk-letter .data-table td { border-bottom: 1px solid #efe2cf; }
.data-table tbody tr:hover { background: #f3f7fb; }
body.desk-letter .data-table tbody tr:hover { background: #fff4e6; }
.status-A { background: #e5f6ee; color: #0f6b45; }
.status-C { background: #fde8e8; color: #9f2d2d; }
.status-S { background: #fff4d6; color: #8a5a00; }
.letter-sheet {
    background: #fffaf3;
    border: 1px solid #e0d0b8;
    border-radius: 4px;
    padding: 28px 32px 20px;
    box-shadow: 0 1px 0 #e7d7bf;
}
.letter-mast { border-bottom: 2px solid #8c2f2f; margin-bottom: 18px; padding-bottom: 12px; }
.letter-kicker { color: #8c2f2f; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; }
.letter-mast h2 { font-size: 32px; line-height: 1.2; font-weight: 600; color: #2c2118; }
.letter-mast p:last-child { color: #6a5344; }
.letter-controls { background: #fff; border: 1px solid #eadcc6; padding: 14px; }
.letter-summary-bar { background: #fff; border-color: #e0d0b8; }
@media (max-width: 720px) {
    .app-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .letter-sheet { padding: 18px 14px; }
    .letter-mast h2 { font-size: 26px; }
}
body.desk-ledger .badge-connected,
body.desk-letter .badge-connected,
body.desk-ledger .master-status-msg.success,
body.desk-letter .master-status-msg.success,
body.desk-ledger .selected-file-info,
body.desk-letter .selected-file-info,
body.desk-ledger .text-bold,
body.desk-letter .text-bold {
    color: #0f6b45;
    background: #e5f6ee;
    border-color: #b7e4c7;
}
body.desk-ledger .badge-connected .status-dot,
body.desk-letter .badge-connected .status-dot { background: #0f6b45; box-shadow: none; }
body.desk-ledger .table-meta-badge,
body.desk-letter .table-meta-badge { color: #1d4e89; background: #e7f0fa; }
body.desk-ledger .master-upload-zone,
body.desk-letter .master-upload-zone {
    background: #fff;
    border-color: #c5d2de;
}

