:root {
    /* CPS Corporate Light Palette */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-input: #ffffff;
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;
    --border-hover: #cbd5e1;
    --border-highlight: #f97316;

    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverted: #ffffff;

    /* CPS Corporate Brand Accent (Orange) */
    --accent-primary: #ea580c;
    --accent-primary-hover: #c2410c;
    --accent-primary-light: #fff7ed;
    --accent-primary-border: #ffedd5;

    /* State Accents */
    --accent-emerald: #10b981;
    --accent-emerald-light: #ecfdf5;
    --accent-emerald-text: #047857;

    --accent-cyan: #0284c7;
    --accent-cyan-light: #f0f9ff;
    --accent-cyan-text: #0369a1;

    --accent-amber: #d97706;
    --accent-amber-light: #fffbeb;
    --accent-amber-text: #b45309;

    --accent-rose: #e11d48;
    --accent-rose-light: #fff1f2;
    --accent-rose-text: #be123c;

    --accent-purple: #7c3aed;
    --accent-purple-light: #f5f3ff;
    --accent-purple-text: #6d28d9;

    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* ==========================================================================
   Sidebar (CPS Corporate Style)
   ========================================================================== */

.sidebar {
    width: 270px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    gap: 24px;
    flex-shrink: 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.02);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #ea580c, #f97316);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
}

.brand-text h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-main);
    color: var(--text-primary);
    transform: translateX(3px);
}

.nav-item.active {
    background: var(--accent-primary-light);
    color: var(--accent-primary);
    font-weight: 700;
    border-left-color: var(--accent-primary);
}

.nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* Engine Status Widget */
.engine-status-widget {
    margin-top: auto;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.status-dot.online {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-metric {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
}

.status-metric .label {
    color: var(--text-muted);
}

.status-metric .val {
    font-weight: 600;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.status-metric .val.highlight {
    color: var(--accent-primary);
    font-weight: 700;
}

/* ==========================================================================
   Main Content Area & Topbar
   ========================================================================== */

.main-content {
    flex: 1;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
}

.page-title h1 {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.page-title p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

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

/* ==========================================================================
   Buttons (CPS Corporate)
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    font-family: var(--font-family);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: linear-gradient(135deg, #ea580c, #f97316);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(234, 88, 12, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #c2410c, #ea580c);
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
}

.btn-gradient {
    background: linear-gradient(135deg, #ea580c, #f97316);
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(234, 88, 12, 0.25);
}

.btn-gradient:hover {
    background: linear-gradient(135deg, #c2410c, #ea580c);
    box-shadow: 0 5px 15px rgba(234, 88, 12, 0.35);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.btn-outline {
    background: #ffffff;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary-border);
}

.btn-outline:hover {
    background: var(--accent-primary-light);
    border-color: var(--accent-primary);
}

.btn-sat {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-sat:hover {
    background: linear-gradient(135deg, #047857, #059669);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-amber {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.btn-amber:hover {
    background: #fef3c7;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
}

.btn-large {
    padding: 12px 24px;
    font-size: 0.95rem;
}

/* ==========================================================================
   Cards, Forms & Controls
   ========================================================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

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

.control-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-header h3 i {
    color: var(--accent-primary);
}

.control-grid-advanced {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    align-items: flex-end;
}

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

.input-group.flex-2 { grid-column: span 2; }
.input-group.flex-3 { grid-column: span 3; }
.input-group.flex-fill { flex: 1; }

.input-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-group label i {
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    background: var(--bg-input);
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.88rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    transition: all 0.2s ease;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

.checkbox-group {
    justify-content: center;
    padding-bottom: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
}

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

.action-buttons-search {
    display: flex;
    align-items: flex-end;
}

.prealert-selector-row {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-subtle);
}

.select-large {
    font-weight: 600;
    color: var(--text-primary);
    height: 44px;
}

/* ==========================================================================
   Manifest Banner
   ========================================================================== */

.manifest-banner {
    background: #ffffff;
    border: 1px solid #fed7aa;
    border-left: 5px solid var(--accent-primary);
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 4px;
}

.banner-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.banner-item .b-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.banner-item .b-val {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.banner-item .b-val.highlight {
    color: var(--accent-primary);
}

.banner-actions {
    margin-left: auto;
    flex-direction: row;
    gap: 10px;
}

/* ==========================================================================
   KPI Metrics Grid (CPS Cards Style)
   ========================================================================== */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.metric-icon.blue { background: #f0f9ff; color: #0284c7; }
.metric-icon.green { background: #ecfdf5; color: #10b981; }
.metric-icon.amber { background: #fffbeb; color: #d97706; }
.metric-icon.rose { background: #fff1f2; color: #e11d48; }
.metric-icon.cyan { background: #ecfeff; color: #0891b2; }

.metric-info {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.metric-info h3 {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin-top: 2px;
}

.metric-sub {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ==========================================================================
   Table Card & Filters
   ========================================================================== */

.table-card {
    padding: 0;
    overflow: hidden;
}

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

.table-title h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-title h3 i {
    color: var(--accent-primary);
}

.table-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.search-input {
    width: 280px;
}

.table-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.filter-btn {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--text-primary);
    color: #ffffff;
    border-color: var(--text-primary);
}

.filter-btn.filter-rose.active { background: #e11d48; border-color: #e11d48; color: #ffffff; }
.filter-btn.filter-green.active { background: #10b981; border-color: #10b981; color: #ffffff; }
.filter-btn.filter-amber.active { background: #d97706; border-color: #d97706; color: #ffffff; }
.filter-btn.filter-cyan.active { background: #0284c7; border-color: #0284c7; color: #ffffff; }

.table-responsive {
    overflow-x: auto;
    max-height: 600px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.data-table thead {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 10;
}

.data-table th {
    padding: 12px 14px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr.row-incomplete {
    background: #fff1f2 !important;
}

.data-table tbody tr.row-high-conf {
    background: #ffffff;
}

.cell-editable {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 8px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    width: 100%;
}

.cell-editable:focus {
    border-color: var(--accent-primary);
    background: #ffffff;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.badge-route {
    background: var(--accent-primary-light);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary-border);
}

.conf-high { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.conf-med { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.conf-low { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.badge-auto { background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd; }

/* Rule Badges (CAUCA / Historical / AI) */
.rule-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}
.rule-tag.rule-1 { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.rule-tag.rule-hist { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.rule-tag.rule-3b { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.rule-tag.rule-3c { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }
.rule-tag.rule-4 { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.rule-tag.rule-ai { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
.rule-tag.rule-manual { background: #fefce8; color: #a16207; border-color: #fef08a; }


.empty-state {
    padding: 60px 20px !important;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 14px;
}

.manifest-footer-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
}

.footer-summary {
    display: flex;
    gap: 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.footer-summary strong {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.footer-actions {
    display: flex;
    gap: 12px;
}

/* ==========================================================================
   Manifest Editor & SAT Error Correction Styles
   ========================================================================== */

.editor-controls-card {
    margin-bottom: 24px;
}

.header-badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.badge-filename {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    padding: 4px 10px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-id {
    background: var(--accent-primary-light);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary-border);
    padding: 4px 10px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
}

.editor-header-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    align-items: flex-end;
}

.radio-group-correlativo {
    grid-column: span 2;
}

.radio-options {
    display: flex;
    gap: 16px;
    background: #f8fafc;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-primary);
}

.radio-label input[type="radio"] {
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.goto-line-group {
    grid-column: span 2;
}

.goto-input-wrapper {
    display: flex;
    gap: 8px;
}

.goto-input-wrapper input {
    width: 140px;
}

.editor-card {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.editor-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-weight: 600;
}

.editor-info .separator {
    color: #cbd5e1;
}

.editor-quick-actions {
    display: flex;
    gap: 8px;
}

.code-editor-wrapper {
    display: flex;
    height: 520px;
    background: #0f172a;
    position: relative;
    overflow: hidden;
}

.editor-line-numbers {
    width: 65px;
    background: #090e1a;
    border-right: 1px solid #1e293b;
    color: #64748b;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.45rem;
    padding: 14px 10px;
    text-align: right;
    user-select: none;
    overflow-y: hidden;
    white-space: pre;
}

.edi-code-editor {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #f8fafc;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.45rem;
    padding: 14px;
    resize: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    overflow-y: scroll;
    tab-size: 4;
}

.edi-code-editor:focus {
    box-shadow: none;
}

/* ==========================================================================
   Simulator & Catalog
   ========================================================================== */

.content-section {
    display: none;
    animation: fadeIn 0.25s ease;
}

.content-section.active {
    display: block;
}

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

.simulator-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    align-items: center;
}

.preset-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
}

.btn-chip {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-chip:hover {
    background: var(--accent-primary-light);
    color: var(--accent-primary);
    border-color: var(--accent-primary-border);
}

.sim-result-box {
    margin-top: 24px;
    background: #ffffff;
    border: 1px solid #fed7aa;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.result-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.result-badge-code h2 { color: #0284c7; font-family: var(--font-mono); }
.result-badge-dai h2 { color: #10b981; font-family: var(--font-mono); }
.result-badge-confidence h2 { color: #7c3aed; font-family: var(--font-mono); }

.result-body {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-row {
    display: flex;
    gap: 12px;
    font-size: 0.9rem;
}

.d-label {
    color: var(--text-muted);
    width: 180px;
    font-weight: 600;
    flex-shrink: 0;
}

.d-val.highlight {
    color: var(--accent-primary);
    font-weight: 700;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal-content {
    background: #ffffff;
    border-radius: 18px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-content.modal-large {
    max-width: 950px;
}

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.cuscar-meta-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.cuscar-meta-bar strong {
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.edi-viewer {
    background: #0f172a;
    color: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.5;
    max-height: 480px;
    overflow: auto;
    white-space: pre;
}

/* ==========================================================================
   Tariff Lookup Modal & CAUCA AI Assistant
   ========================================================================== */

.tariff-lookup-context {
    display: flex;
    gap: 16px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 16px;
}

.context-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.context-item .c-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.context-item .c-val {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}

.context-item .c-val.highlight {
    color: var(--accent-primary);
}

.tariff-ai-recommendation-box {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}

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

.rec-score {
    font-size: 0.8rem;
    font-weight: 700;
    color: #047857;
    background: #ecfdf5;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #a7f3d0;
}

.rec-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.rec-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.rec-code {
    font-size: 1.4rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--accent-primary);
    background: #ffffff;
    padding: 4px 12px;
    border-radius: 8px;
    border: 1px solid #fed7aa;
}

.rec-dai {
    font-size: 0.95rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: #047857;
    background: #ffffff;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid #a7f3d0;
}

.rec-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.rec-explanation {
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-style: italic;
    border-top: 1px dashed #fed7aa;
    padding-top: 8px;
}

.tariff-search-bar {
    margin-bottom: 14px;
}

.tariff-catalog-scroll {
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.tariff-table th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 5;
}

.tariff-select-btn {
    padding: 5px 12px;
    font-size: 0.78rem;
    background: var(--accent-primary-light);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary-border);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.15s;
}

.tariff-select-btn:hover {
    background: var(--accent-primary);
    color: #ffffff;
}

/* ==========================================================================
   Expandable Row & Lupa Buttons
   ========================================================================== */

.btn-lupa {
    width: 28px;
    height: 28px;
    background: #fff7ed;
    color: #ea580c;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
    margin-left: 4px;
}

.btn-lupa:hover {
    background: #ea580c;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(234, 88, 12, 0.3);
}

.cell-with-lupa {
    display: flex;
    align-items: center;
}

.btn-toggle-row {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.2s, color 0.2s;
}

.btn-toggle-row:hover {
    color: var(--accent-primary);
}

.btn-toggle-row.expanded {
    transform: rotate(180deg);
    color: var(--accent-primary);
}

.row-expanded-detail {
    background: #fcfdfe;
    border-left: 4px solid var(--accent-primary);
}

.row-expanded-detail td {
    padding: 16px 20px !important;
}

.accordion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    background: #ffffff;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.accordion-grid .input-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.accordion-grid .input-group input,
.accordion-grid .input-group select {
    padding: 6px 10px;
    font-size: 0.82rem;
    height: 36px;
}

.accordion-grid .input-group.flex-2 {
    grid-column: span 2;
}

@media (max-width: 900px) {
    .accordion-grid .input-group.flex-2 {
        grid-column: span 1;
    }
}

/* ==========================================================================
   Cache Recovery Alert & Auto-Save Indicator
   ========================================================================== */
.cache-alert {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-left: 5px solid #2563eb;
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
    animation: fadeInSlide 0.3s ease-out;
}

.cache-alert-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.cache-alert-icon {
    font-size: 1.6rem;
    color: #2563eb;
}

.cache-alert-left strong {
    color: #1e3a8a;
    font-size: 0.95rem;
    display: block;
    margin-bottom: 2px;
}

.cache-alert-left p {
    margin: 0;
    font-size: 0.82rem;
    color: #3b82f6;
}

.cache-alert-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cache-time-badge {
    background: #ffffff;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.auto-save-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #059669;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 5px 12px;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.auto-save-indicator.saving {
    color: #d97706;
    background: #fffbeb;
    border-color: #fde68a;
}

.btn-outline-danger {
    background: #ffffff;
    color: #dc2626;
    border: 1px solid #fca5a5;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-outline-danger:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
}

