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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #0b0f19;
    color: #f1f5f9;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #0f172a;
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* App Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background-color: #0f172a;
    border-right: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
}

.icon-logo {
    font-size: 24px;
    color: #38bdf8;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

.logo h2 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #f8fafc 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    margin-bottom: 12px;
    font-weight: 600;
}

.pdf-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.filter-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.filter-btn {
    flex: 1;
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.filter-btn:hover {
    background-color: #334155;
    color: #f1f5f9;
}

.filter-btn.active {
    background-color: #3b82f6;
    border-color: #60a5fa;
    color: #fff;
    font-weight: 500;
}

.filter-btn .badge {
    background-color: #f59e0b;
    color: #1f2937;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

.filter-btn.active .badge {
    background-color: #fbbf24;
}

.pdf-item.has-pending {
    border-left: 3px solid #f59e0b;
}

.pdf-item.has-pending .pdf-icon {
    color: #fbbf24;
}

.pdf-item {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pdf-item:hover {
    border-color: #38bdf8;
    background-color: #243249;
    transform: translateY(-1px);
}

.pdf-item.active {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.pdf-icon {
    font-size: 20px;
    color: #ef4444;
}

.pdf-item.active .pdf-icon {
    color: #60a5fa;
}

.pdf-info {
    flex-grow: 1;
    min-width: 0;
}

.pdf-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f1f5f9;
}

.pdf-progress {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
}

.stats-panel {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 15px;
}

.progress-bar-container {
    height: 8px;
    background-color: #0f172a;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 12px;
    color: #94a3b8;
    text-align: right;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* Topbar Styling */
.topbar {
    height: 70px;
    background-color: #0f172a;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    flex-shrink: 0;
}

.doc-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    background-color: #1e293b;
    color: #38bdf8;
    margin-top: 4px;
    border: 1px solid #334155;
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-select {
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #f1f5f9;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.page-select:focus {
    border-color: #38bdf8;
}

/* Quick page-jump input (top header) */
.page-jump {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.page-jump:focus-within {
    border-color: #38bdf8;
    background-color: rgba(56, 189, 248, 0.15);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.page-jump-label {
    color: #38bdf8;
    font-weight: 700;
    font-size: 14px;
    font-family: 'Consolas', monospace;
}

.page-jump input {
    width: 70px;
    background-color: transparent;
    border: none;
    color: #f1f5f9;
    font-size: 13px;
    font-family: 'Consolas', monospace;
    font-weight: 600;
    padding: 2px 4px;
    outline: none;
    -moz-appearance: textfield;
}

.page-jump input::-webkit-outer-spin-button,
.page-jump input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.page-jump input::placeholder {
    color: #475569;
    font-style: italic;
}

.page-jump input:disabled {
    color: #475569;
    cursor: not-allowed;
}

/* STT range display (under "Danh sách giao dịch trích xuất") */
.stt-range-display {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.12), rgba(56, 189, 248, 0.12));
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 6px;
    font-size: 12px;
    color: #cbd5e1;
    font-family: 'Consolas', 'Monaco', monospace;
    max-width: fit-content;
    transition: all 0.2s ease;
}

.stt-range-display:hover {
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.1);
}

.stt-range-display i {
    color: #a855f7;
    font-size: 13px;
}

.stt-range-label {
    color: #94a3b8;
    font-weight: 600;
    letter-spacing: 0.5px;
}

#sttRangeValue {
    color: #f1f5f9;
    font-weight: 700;
    font-size: 13px;
}

#sttRangeValue.has-gaps {
    color: #f59e0b;
    font-weight: 700;
}

#sttRangeValue.no-tx {
    color: #475569;
    font-style: italic;
}

.stt-gap-pill {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    background-color: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fbbf24;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    font-family: inherit;
}

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

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

.btn-secondary {
    background-color: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #334155;
    border-color: #475569;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-success {
    background-color: #059669;
    color: #ffffff;
}

.btn-success:hover:not(:disabled) {
    background-color: #047857;
}

.btn-success:disabled {
    background-color: #1e293b;
    color: #64748b;
    cursor: not-allowed;
}

.btn-pending {
    background-color: #f59e0b;
    color: #0f172a;
    font-weight: 600;
}

.btn-pending:hover:not(:disabled) {
    background-color: #d97706;
    color: #0f172a;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.5);
}

.btn-pending:disabled {
    background-color: #1e293b;
    color: #64748b;
    cursor: not-allowed;
    font-weight: normal;
}

.btn-block {
    width: 100%;
}

.btn-danger-soft {
    background-color: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger-soft:hover:not(:disabled) {
    background-color: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.5);
}

.btn-danger-soft:disabled {
    background-color: #1e293b;
    color: #64748b;
    border-color: transparent;
    cursor: not-allowed;
}

/* Workspace Panels */
.workspace {
    display: flex;
    flex-grow: 1;
    min-height: 0;
    overflow: hidden;
}

/* Viewer (Left Column) */
.viewer-column {
    width: 40%;
    border-right: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    background-color: #0b0f19;
    flex-shrink: 0;
}

.viewer-header, .editor-header {
    height: 45px;
    background-color: #111827;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
}

.grid-filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    background-color: #0f172a;
    border-bottom: 1px solid #1e293b;
}

.grid-search-input {
    flex: 1;
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #f1f5f9;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.grid-search-input:focus {
    outline: none;
    border-color: #60a5fa;
}

.grid-search-input::placeholder {
    color: #64748b;
}

.grid-status-filter {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #f1f5f9;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    min-width: 130px;
}

.grid-count-label {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    min-width: 60px;
    text-align: right;
}

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

.zoom-controls button {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
}

.zoom-controls button:hover {
    color: #38bdf8;
}

.image-viewport {
    flex-grow: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background-color: #1e293b;
    padding: 15px;
    position: relative;
}

.viewport-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 400px;
    text-align: center;
    padding: 40px;
    align-self: center;
}

.image-container {
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    background-color: #ffffff;
    max-width: 100%;
    transform-origin: top center;
}

.image-container img {
    display: block;
    width: 100%;
    height: auto;
}

/* Highlight Box on Original Image */
.highlight-box {
    position: absolute;
    border: 2px solid #ef4444;
    background-color: rgba(239, 68, 68, 0.15);
    pointer-events: none;
    transition: all 0.25s ease-out;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
    z-index: 10;
}

/* Editor (Right Column) */
.editor-column {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #0f172a;
    min-width: 0;
}

.keyboard-hint {
    font-size: 11px;
    color: #64748b;
}

.keyboard-hint b {
    color: #94a3b8;
    background-color: #1e293b;
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
}

.editor-body {
    flex-grow: 1;
    overflow: auto;
}

/* Debug panel below grid */
.editor-debug-panel {
    border-top: 1px solid #334155;
    background-color: #0f172a;
    display: flex;
    flex-direction: column;
    height: 400px;
    min-height: 400px;
    transition: height 0.2s ease;
}

.editor-debug-panel.collapsed {
    height: auto;
    min-height: auto;
}

.editor-debug-panel.collapsed .debug-panel-body {
    display: none;
}

.editor-debug-panel.collapsed .toggle-icon {
    transform: rotate(0deg);
}

.editor-debug-panel:not(.collapsed) .toggle-icon {
    transform: rotate(90deg);
}

.toggle-icon {
    transition: transform 0.2s ease;
    font-size: 9px;
    color: #64748b;
}

.debug-panel-header {
    background-color: #1e293b;
    padding: 6px 16px;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.debug-panel-header span {
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.debug-status-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
}

.debug-status-badge.empty {
    background-color: #475569;
    color: #cbd5e1;
}

.debug-status-badge.has-data {
    background-color: #10b981;
    color: #052e16;
}

.no-crop-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: #64748b;
    font-size: 12px;
    font-style: italic;
    background-color: #1e293b;
    border-radius: 4px;
    min-height: 100px;
}

.no-crop-msg i {
    font-size: 24px;
    opacity: 0.5;
}

.btn-copy-json {
    background: none;
    border: none;
    color: #38bdf8;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s ease;
    padding: 2px 6px;
    border-radius: 4px;
}

.btn-copy-json:hover {
    color: #7dd3fc;
    background-color: rgba(56, 189, 248, 0.1);
}

.debug-panel-body {
    padding: 10px 16px;
    overflow: auto;
    flex-grow: 1;
    background-color: #0b0f19;
}

.debug-panel-body pre {
    margin: 0;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    line-height: 1.5;
    color: #38bdf8;
}

/* Transaction Table Styles */
.transaction-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.transaction-table th {
    background-color: #1e293b;
    color: #94a3b8;
    padding: 12px;
    font-weight: 600;
    border-bottom: 1px solid #334155;
    position: sticky;
    top: 0;
    z-index: 10;
}

.transaction-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #1e293b;
    vertical-align: middle;
    color: #cbd5e1;
    word-break: break-word;
}

/* Cột số (STT, ngày, số chứng từ, amount): KHÔNG wrap text, canh phải */
.transaction-table th.col-num,
.transaction-table td.col-num {
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Cột ngày GD & số chứng từ cần center-align để dễ đọc */
.transaction-table td.col-num:nth-child(2),
.transaction-table td.col-num:nth-child(4) {
    text-align: center;
}

/* Cột mô tả: CHO wrap text (đọc full nội dung) */
.transaction-table th.col-desc,
.transaction-table td.col-desc {
    white-space: normal;
    word-break: break-word;
    min-width: 240px;
    line-height: 1.4;
}

/* Cột lý do: cho phép wrap nhưng font nhỏ hơn */
.transaction-table td.col-reason {
    white-space: normal;
    word-break: break-word;
    font-size: 12px;
    color: #f59e0b;
    line-height: 1.4;
}
.transaction-table td.col-reason:empty::before {
    content: "—";
    color: #475569;
}

.transaction-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.transaction-table tbody tr:hover {
    background-color: #1e293b;
}

.transaction-table tbody tr.active-row {
    background-color: #243352;
    border-left: 3px solid #3b82f6;
}

.transaction-table tbody tr.confirmed-row {
    background-color: rgba(16, 185, 129, 0.05);
}

.transaction-table tbody tr.confirmed-row:hover {
    background-color: rgba(16, 185, 129, 0.08);
}

.transaction-table tbody tr.confirmed-row.active-row {
    background-color: #1d3345;
}

.transaction-table td input[type="text"] {
    width: 100%;
    background-color: transparent;
    border: 1px solid transparent;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    padding: 4px 6px;
    border-radius: 4px;
    outline: none;
    transition: all 0.15s ease;
}

.transaction-table td input[type="text"]:focus {
    background-color: #0f172a;
    border-color: #3b82f6;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.3);
}

.amount-col {
    font-family: monospace;
    font-size: 13px;
    text-align: right;
}

.checkbox-col {
    text-align: center;
}

.btn-confirm-cell {
    background: none;
    border: none;
    color: #64748b;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.confirmed-row .btn-confirm-cell {
    color: #10b981;
}

.btn-confirm-cell:hover {
    color: #3b82f6;
}

.date-header-row {
    background-color: #111827 !important;
}

.date-header-row td {
    color: #38bdf8 !important;
    font-weight: 600;
    font-size: 12px;
    text-align: center;
    border-top: 1px solid #1e293b;
    border-bottom: 1px solid #1e293b;
    padding: 6px 12px !important;
    cursor: default;
}

.empty-state {
    text-align: center;
    padding: 60px 20px !important;
    color: #64748b;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.loading-spinner {
    text-align: center;
    padding: 20px;
    color: #64748b;
}

/* Quick Edit Drawer */
.quick-edit-panel {
    border-top: 1px solid #334155;
    background-color: #0f172a;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.quick-edit-panel[style*="display: none"] {
    display: none !important;
}

.quick-edit-panel[style*="display: flex"] {
    display: flex !important;
}

.panel-header {
    height: 40px;
    background-color: #1e293b;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 12px;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 0.5px;
}

.btn-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
}

.btn-close:hover {
    color: #ef4444;
}

.panel-body {
    padding: 15px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.quick-edit-row-label {
    font-weight: 500;
    color: #94a3b8;
    font-size: 11px;
    margin-left: 8px;
    text-transform: none;
    letter-spacing: 0;
}

.edit-form-grid {
    display: grid;
    grid-template-columns: 0.5fr 3fr 1.5fr 1fr 1fr 1fr;
    gap: 12px;
}

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

.form-group label {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
}

.form-group input, .form-group textarea {
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #f1f5f9;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: all 0.15s ease;
}

.form-group input:focus, .form-group textarea:focus {
    border-color: #3b82f6;
    background-color: #0f172a;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.form-group-desc textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.5;
}

.amount-input {
    font-family: monospace;
    font-weight: 500;
    color: #60a5fa !important;
}

.panel-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

/* Toast Messages */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards, fadeOut 0.35s ease 2.65s forwards;
}

.toast-success {
    border-left: 4px solid #10b981;
}

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

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

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

/* Modal Overlay & Modal Window */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content.debug-modal {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 800px;
    max-height: 85%;
    overflow: hidden;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-modal {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.15s ease;
    padding: 0;
    line-height: 1;
}

.btn-close-modal:hover {
    color: #f8fafc;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.debug-desc {
    font-size: 13px;
    color: #94a3b8;
    margin: 0;
    line-height: 1.5;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #182232;
}

/* ============================================================================
   Missing-Date Filler Modal
   ============================================================================ */
.modal-content.fill-modal {
    background-color: #1e293b;
    border-radius: 12px;
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    border: 1px solid #334155;
}

.fill-modal-body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    min-height: 0;
}

.fill-image-pane {
    background-color: #0f172a;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #334155;
}

.fill-image-header {
    padding: 10px 16px;
    background-color: #1e293b;
    border-bottom: 1px solid #334155;
    color: #cbd5e1;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#fillPageImage {
    flex: 1;
    object-fit: contain;
    width: 100%;
    height: 100%;
    background-color: #1e293b;
}

.fill-rows-pane {
    background-color: #1e293b;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fill-rows-header {
    padding: 10px 16px;
    background-color: #182232;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #f59e0b;
    font-size: 13px;
    font-weight: 500;
}

.fill-rows-help {
    padding: 8px 16px;
    background-color: #182232;
    color: #94a3b8;
    font-size: 11px;
    border-bottom: 1px solid #334155;
    line-height: 1.5;
}

.fill-rows-help kbd {
    background-color: #334155;
    color: #cbd5e1;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 10px;
}

.fill-rows-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.fill-row {
    background-color: #182232;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
    transition: border-color 0.15s ease;
}

.fill-row:focus-within {
    border-color: #3b82f6;
    background-color: #1e293b;
}

.fill-row-dirty {
    border-color: #f59e0b;
}

.fill-row-stt {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fill-row-stt .stt-num {
    color: #f59e0b;
    font-weight: 600;
    margin-right: 4px;
}

.fill-row-desc {
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 6px;
    line-height: 1.4;
    word-break: break-word;
}

.fill-row-date {
    display: flex;
    gap: 6px;
    align-items: center;
}

.fill-row-date input {
    flex: 1;
    padding: 6px 10px;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #cbd5e1;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.fill-row-date input:focus {
    outline: none;
    border-color: #3b82f6;
    background-color: #182232;
}

.fill-row-date input.dirty {
    border-color: #f59e0b;
}

.fill-row-save {
    padding: 6px 12px;
    background-color: #10b981;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

.fill-row-save:disabled {
    background-color: #475569;
    cursor: not-allowed;
    opacity: 0.5;
}

.fill-row-save:hover:not(:disabled) {
    background-color: #059669;
}

.btn-warning-soft {
    background-color: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.btn-warning-soft:hover:not(:disabled) {
    background-color: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.5);
}

.btn-warning-soft:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-small {
    padding: 6px 12px !important;
    font-size: 12px !important;
}

/* ============================================================================
   Printed page column (Trang in) - extracted from PDF footer
   ============================================================================ */
.printed-page-cell {
    text-align: center !important;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    white-space: nowrap;
}

.printed-page-cell .printed-current {
    font-weight: 700;
}

.printed-page-cell .printed-total {
    color: #64748b;
    font-weight: 400;
}

.printed-ok {
    color: #10b981;
    background-color: rgba(16, 185, 129, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.printed-warn {
    color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.printed-bad {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.4);
    font-weight: 700;
}

.printed-na {
    color: #475569;
    font-style: italic;
}

/* === DASHBOARD === */
.dashboard-container { display: flex; flex-direction: column; height: 100vh; }
.dashboard-main { flex: 1; overflow: auto; padding: 20px; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.kpi-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 14px 18px;
}
.kpi-card.kpi-in { border-left: 4px solid #10b981; }
.kpi-card.kpi-out { border-left: 4px solid #ef4444; }
.kpi-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 20px; font-weight: 700; color: #f1f5f9; margin-top: 4px; }

.dashboard-split { display: flex; gap: 20px; min-height: 600px; }
.dashboard-filters {
    width: 280px; flex-shrink: 0;
    background: #1e293b; border: 1px solid #334155; border-radius: 8px;
    padding: 16px; overflow-y: auto; max-height: 80vh;
}
.dashboard-filters h4 { margin-top: 0; color: #cbd5e1; font-size: 13px; }
.filter-label { display: block; font-size: 11px; color: #94a3b8; margin: 12px 0 4px; text-transform: uppercase; }
.filter-input, .filter-multi {
    width: 100%; padding: 6px 8px; background: #0f172a; color: #f1f5f9;
    border: 1px solid #334155; border-radius: 4px; font-size: 12px;
}
.filter-multi { height: auto; }
.btn-block { display: block; width: 100%; margin-top: 12px; }

.dashboard-results { flex: 1; min-width: 0; }
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid #334155; margin-bottom: 12px; }
.tab-btn {
    background: transparent; border: none; color: #94a3b8; padding: 10px 16px;
    cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent;
}
.tab-btn.active { color: #38bdf8; border-bottom-color: #38bdf8; }
.tab-btn:hover { color: #cbd5e1; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.dashboard-table { width: 100%; border-collapse: collapse; font-size: 12px; background: #0f172a; }
.dashboard-table th, .dashboard-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid #1e293b; }
.dashboard-table th { background: #1e293b; color: #94a3b8; font-weight: 600; font-size: 11px; text-transform: uppercase; }
.dashboard-table tr:hover { background: #1e293b; }
.dashboard-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tag-desc { display: inline-block; background: #1e293b; padding: 1px 6px; border-radius: 3px; margin-right: 4px; font-size: 11px; }

/* Column header filter (counterparty) */
.dashboard-table th.col-filterable { padding: 4px 6px; }
.col-header-label { display: flex; align-items: center; gap: 4px; font-size: 11px; text-transform: uppercase; }
.col-header-label i { color: #64748b; font-size: 10px; }
.col-header-label i.col-filter-active { color: #f59e0b; }
.col-filter-input {
    width: 100%;
    box-sizing: border-box;
    margin-top: 4px;
    background: #0f172a;
    border: 1px solid #334155;
    color: #f1f5f9;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    outline: none;
}
.col-filter-input:focus { border-color: #f59e0b; }

/* Vietnamese tag pill */
.tag-pill {
    display: inline-block;
    background: #1e3a5f;
    color: #93c5fd;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

/* Date picker styling */
input[type="date"].filter-input {
    color-scheme: dark;
    font-family: inherit;
}
input[type="date"].filter-input::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

/* Right-click quick filter */
.dashboard-table tbody td[data-filter-field] { cursor: context-menu; }
.dashboard-table tbody td[data-filter-field]:hover {
    background: #1e3a5f !important;
    outline: 1px dashed #3b82f6;
}

/* Context menu */
.context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 240px;
    max-width: 360px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    padding: 4px;
    font-size: 12px;
    color: #f1f5f9;
}
.ctx-header {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #334155;
    margin-bottom: 4px;
}
.ctx-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: #f1f5f9;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.4;
}
.ctx-item:hover { background: #334155; }
.ctx-item i {
    margin-right: 8px;
    color: #60a5fa;
    width: 14px;
    text-align: center;
}
.ctx-item strong { color: #fbbf24; }
.ctx-sep {
    height: 1px;
    background: #334155;
    margin: 4px 0;
}

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.pagination span { color: #94a3b8; font-size: 12px; margin-right: auto; }

.dashboard-footer { padding: 8px 20px; background: #1e293b; color: #94a3b8; font-size: 11px; border-top: 1px solid #334155; }
.empty-state { padding: 40px; text-align: center; color: #94a3b8; }

/* ============================================================ */
/* === GOV DASHBOARD THEME (Phase 1) === */
/* ============================================================ */

:root {
    --gov-blue-900: #1e40af;
    --gov-blue-700: #1d4ed8;
    --gov-blue-500: #3b82f6;
    --gov-blue-100: #dbeafe;
    --gov-blue-50: #eff6ff;

    --gov-success: #15803d;
    --gov-success-bg: #dcfce7;
    --gov-danger: #dc2626;
    --gov-danger-bg: #fee2e2;
    --gov-warning: #92400e;
    --gov-warning-bg: #fef3c7;

    --gov-gray-900: #0f172a;
    --gov-gray-700: #334155;
    --gov-gray-500: #64748b;
    --gov-gray-300: #cbd5e1;
    --gov-gray-100: #f1f5f9;
    --gov-gray-50: #f8fafc;

    --gov-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --gov-shadow-md: 0 2px 8px rgba(15, 23, 42, 0.08);
    --gov-radius-md: 6px;
    --gov-radius-lg: 8px;
    --gov-radius-pill: 999px;
}

.gov-page {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gov-gray-50);
    color: var(--gov-gray-900);
    min-height: 100vh;
}

/* --- Top bar --- */
.gov-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(90deg, var(--gov-blue-900), var(--gov-blue-500));
    color: #fff;
    box-shadow: var(--gov-shadow-md);
}
.gov-topbar-row1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    min-height: 56px;
}
.gov-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.gov-brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gov-brand-logo img { width: 32px; height: 32px; }
.gov-brand-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.gov-brand-subtitle {
    font-size: 11px;
    opacity: 0.85;
}
.gov-topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
}
.gov-topbar-link {
    color: #fff;
    text-decoration: none;
    opacity: 0.9;
}
.gov-topbar-link:hover { opacity: 1; text-decoration: underline; }

.gov-topbar-row2 {
    background: #fff;
    border-bottom: 1px solid var(--gov-gray-300);
    padding: 0 24px;
    display: flex;
    gap: 4px;
    min-height: 44px;
}
.gov-menu-item {
    padding: 12px 16px;
    color: var(--gov-gray-700);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.gov-menu-item:hover {
    background: var(--gov-blue-50);
    color: var(--gov-blue-900);
}
.gov-menu-item.active {
    color: var(--gov-blue-900);
    border-bottom-color: var(--gov-blue-900);
}

/* --- Sections --- */
.gov-section {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}
.gov-section[hidden] { display: none; }
.gov-loading {
    padding: 40px;
    text-align: center;
    color: var(--gov-gray-500);
    font-size: 14px;
}
.gov-section-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 16px;
    color: var(--gov-gray-900);
}

/* --- KPI grid --- */
.gov-kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.gov-kpi {
    background: #fff;
    border: 1px solid var(--gov-gray-300);
    border-left: 4px solid var(--gov-blue-900);
    border-radius: var(--gov-radius-lg);
    padding: 14px 16px;
}
.gov-kpi.gov-kpi-in { border-left-color: var(--gov-success); }
.gov-kpi.gov-kpi-out { border-left-color: var(--gov-danger); }
.gov-kpi.gov-kpi-neutral { border-left-color: var(--gov-gray-300); }
.gov-kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gov-gray-500);
    margin-bottom: 4px;
}
.gov-kpi-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--gov-gray-900);
}
.gov-kpi-sub {
    font-size: 11px;
    color: var(--gov-gray-500);
    margin-top: 2px;
}
@media (max-width: 1279px) {
    .gov-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767px) {
    .gov-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Cards --- */
.gov-card {
    background: #fff;
    border: 1px solid var(--gov-gray-300);
    border-radius: var(--gov-radius-lg);
    padding: 16px;
    box-shadow: var(--gov-shadow-sm);
}

/* --- Pills --- */
.gov-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--gov-radius-pill);
    font-size: 11px;
    font-weight: 500;
    background: var(--gov-gray-100);
    color: var(--gov-gray-700);
}
.gov-pill-success { background: var(--gov-success-bg); color: var(--gov-success); }
.gov-pill-danger  { background: var(--gov-danger-bg); color: var(--gov-danger); }
.gov-pill-warning { background: var(--gov-warning-bg); color: var(--gov-warning); }
.gov-pill-info    { background: var(--gov-blue-100); color: var(--gov-blue-900); }

/* --- Buttons --- */
.gov-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--gov-radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    font-family: inherit;
    text-decoration: none;
    line-height: 1;
}
.gov-btn-primary {
    background: var(--gov-blue-900);
    color: #fff;
}
.gov-btn-primary:hover { background: var(--gov-blue-700); }
.gov-btn-secondary {
    background: #fff;
    color: var(--gov-gray-700);
    border-color: var(--gov-gray-300);
}
.gov-btn-secondary:hover { background: var(--gov-gray-100); }
.gov-btn-block { display: flex; width: 100%; justify-content: center; }

/* --- Filter form (Transactions section) --- */
.gov-filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--gov-gray-700);
}
.gov-filter-field > span {
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-size: 11px;
    color: var(--gov-gray-500);
}
.gov-filter-field input,
.gov-filter-field select {
    padding: 6px 8px;
    border: 1px solid var(--gov-gray-300);
    border-radius: var(--gov-radius-md);
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: var(--gov-gray-900);
}
.gov-filter-field input:focus,
.gov-filter-field select:focus {
    outline: none;
    border-color: var(--gov-blue-900);
    box-shadow: 0 0 0 2px var(--gov-blue-100);
}
@media (max-width: 1023px) {
    .gov-filter-form { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 767px) {
    .gov-filter-form { grid-template-columns: 1fr !important; }
}

/* --- Aggregation table (Đối tác / Phân loại) --- */
.gov-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.gov-table thead {
    background: var(--gov-gray-100);
    border-bottom: 2px solid var(--gov-gray-300);
}
.gov-table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gov-gray-700);
    font-weight: 600;
}
.gov-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gov-gray-100);
    color: var(--gov-gray-900);
}
.gov-table tr:hover {
    background: var(--gov-blue-50) !important;
}

/* --- Responsive: tablet --- */
@media (max-width: 1023px) {
    .gov-topbar-row1 { padding: 10px 16px; }
    .gov-brand-title { font-size: 14px; }
    .gov-brand-subtitle { font-size: 10px; }
    .gov-section { padding: 16px; }
    .gov-tx-card > div[style*="grid-template-columns:repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* --- Responsive: mobile --- */
@media (max-width: 767px) {
    .gov-topbar-row2 {
        overflow-x: auto;
        white-space: nowrap;
    }
    .gov-menu-item {
        padding: 10px 12px;
        font-size: 13px;
        flex-shrink: 0;
    }
    .gov-brand-title { font-size: 13px; }
    .gov-brand-subtitle { display: none; }
    .gov-topbar-actions { gap: 8px; font-size: 12px; }
    .gov-tx-card > div[style*="grid-template-columns:repeat(4"] {
        grid-template-columns: 1fr 1fr !important;
    }
    .gov-table { font-size: 12px; }
    .gov-table th, .gov-table td { padding: 6px 8px; }
}

/* --- Print stylesheet --- */
@media print {
    .gov-topbar, #loginModal, #exportModalContainer, button, .gov-pagination { display: none !important; }
    .gov-section { padding: 0; max-width: 100%; }
    .gov-section[hidden] { display: block !important; page-break-before: always; }
    .gov-card { box-shadow: none; border: 1px solid #999; }
    .gov-kpi { break-inside: avoid; }
    .gov-tx-card { break-inside: avoid; margin-bottom: 12px; }
    body { background: #fff; color: #000; font-size: 11pt; }
    .gov-pill { border: 1px solid #666; }
}

/* --- Skeleton (loading) --- */
.gov-skeleton {
    background: linear-gradient(90deg, var(--gov-gray-100) 0%, var(--gov-gray-50) 50%, var(--gov-gray-100) 100%);
    background-size: 200% 100%;
    animation: gov-skeleton-shimmer 1.5s infinite;
    border-radius: var(--gov-radius-md);
}
@keyframes gov-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.gov-skeleton-line {
    height: 14px;
    margin: 8px 0;
}
.gov-skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
