/* ==========================================================================
   1. CORE VARIABLES, FONTS & RESET BOILERPLATE
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

:root {
    --bg-system: #F4F7F6;
    --surface-white: #FFFFFF;
    --primary-brand: #2E4A47;
    --primary-brand-hover: #1F3331;
    
    /* Typography Palette Tones */
    --text-dark: #2D3748;
    --text-muted: #718096;
    --text-light: #A0AEC0;
    --text-placeholder: #CBD5E0;
    
    /* UI Borders & Elements */
    --border-color: #E2E8F0;
    --border-input-focus: #CBD5E0;
    --table-header-bg: #F8FAFA;
    --line-row-border: #F4F7F6;
    
    /* Semantic Status Indicators */
    --bg-linked: #D1FAE5;
    --text-linked: #059669;
    --bg-unlinked: #FEE2E2;
    --text-unlinked: #EF4444;
    --bg-pending: #FEF3C7;
    --text-pending: #D97706;
    --bg-renewing: #FFEDD5;
    --text-renewing: #EA580C;
}

body {
    background-color: var(--bg-system);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

/* ==========================================================================
   9. SLIDING SIDE WORKSPACE DRAWER
   ========================================================================== */
.side-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 55, 72, 0.3);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.side-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.side-drawer-panel {
    position: fixed;
    top: 0;
    right: -550px;
    width: 520px;
    height: 100vh;
    background: var(--surface-white);
    box-shadow: -4px 0 25px rgba(0,0,0,0.08);
    padding: 32px;
    overflow-y: auto;
    transition: right 0.25s ease;
    z-index: 201;
}

.side-drawer-overlay.active .side-drawer-panel {
    right: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

/* ==========================================================================
   8. SYSTEM NOTIFICATION MODALS (AJAX INTERACTIONS)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(45, 55, 72, 0.4); /* Subtle transparent tint matching text color */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--surface-white);
    width: 440px;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    text-align: center;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

.modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin: 0 auto 18px auto;
}

.modal-icon.success {
    background-color: var(--bg-linked);
    color: var(--text-linked);
}

.modal-icon.error {
    background-color: var(--bg-unlinked);
    color: var(--text-unlinked);
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.modal-body-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ==========================================================================
   2. SCREEN BASE WIRE STRUCTURE (SPLIT LAYOUT)
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;          /* Fallback fluid container width */
    max-width: 1440px;    /* Locks max design scale matching Figma spec */
    margin: 0 auto;
    position: relative;
}

/* LEFT SIDEBAR PANEL NAVIGATION */
.sidebar {
    width: 240px;
    background-color: var(--bg-system);
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: max(0px, calc((100vw - 1440px) / 2)); /* Centers perfectly on large viewports */
    border-right: 1px solid var(--border-color);
    z-index: 100;
}

@media screen and (max-width: 1200px) {
    .form-grid-workspace {
        grid-template-columns: 1fr; /* Stack columns vertically on smaller screens */
        gap: 20px;
    }
}

.brand-logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-brand);
    margin-bottom: 50px;
    padding-left: 20px;
    text-decoration: none;
}



.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nav-item a {
    display: block;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.nav-item a:hover {
    color: var(--primary-brand);
    background-color: rgba(46, 74, 71, 0.05);
}

.nav-item.active a {
    background-color: var(--primary-brand);
    color: var(--surface-white);
    font-weight: 600;
}

/* MAIN WORKSPACE WRAPPER */
/* MAIN WORKSPACE WRAPPER */
.main-workspace {
    margin-left: 240px;   /* Reserves layout space for the fixed sidebar */
    flex: 1;              /* Automatically fills remaining fluid screen width */
    min-width: 0;         /* Crucial layout guard: prevents grid contents from forcing element overflow */
    padding: 28px 40px 40px 40px;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   3. TOP RUNTIME APP HEADER COMPONENT
   ========================================================================== */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    height: 54px;
}

.header-title-block .breadcrumb {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.header-title-block h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
}

.header-actions-block {
    display: flex;
    align-items: center;
    gap: 24px;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: right;
}

.user-profile-badge .user-meta-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.user-profile-badge .user-meta-role {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.user-profile-badge .avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #2E4A47;
}

/* ==========================================================================
   4. CONTEXT FILTERING & METRIC SUB-BARS
   ========================================================================== */
.filtering-sub-bar {
    background-color: var(--surface-white);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.search-wrapper-input {
    position: relative;
    width: 260px;
}

.search-wrapper-input input {
    width: 100%;
    height: 36px;
    background-color: var(--bg-system);
    border: none;
    border-radius: 8px;
    padding: 0 16px;
    font-size: 13px;
    color: var(--text-dark);
}

.search-wrapper-input input::placeholder {
    color: var(--text-light);
}

.dropdown-selector-filter {
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--surface-white);
    cursor: pointer;
    outline: none;
}

.dropdown-selector-filter.entity-select {
    color: var(--primary-brand);
}

.filter-shortcut-chip {
    height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

.filter-shortcut-chip.alert-chip {
    background-color: var(--bg-unlinked);
    color: var(--text-unlinked);
}

.filter-shortcut-chip.success-chip {
    background-color: var(--bg-linked);
    color: var(--text-linked);
}

/* ==========================================================================
   5. CENTRAL DATA TABLES & DATA RECORDS DIRECTORIES
   ========================================================================== */
.data-ledger-card {
    background-color: var(--surface-white);
    border-radius: 16px;
    padding: 0;
    min-height: 684px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.01);
    overflow: hidden;
}

.data-ledger-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-ledger-table th {
    background-color: var(--table-header-bg);
    padding: 18px 24px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-ledger-table td {
    padding: 20px 24px;
    vertical-align: middle;
    border-bottom: 1px solid var(--line-row-border);
}

.title-meta-cell .primary-line {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.title-meta-cell .secondary-sub {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-brand);
}

.title-meta-cell .secondary-sub span {
    font-weight: 500;
    color: var(--text-light);
}

.text-data-bold {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-brand);
}

.text-data-regular {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dark);
}

.amount-numeric-bold {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
}

/* SYSTEM SEMANTIC BADGES */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 11px;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    text-transform: capitalize;
}

.status-badge.linked, .status-badge.active, .status-badge.approved, .status-badge.filed {
    background-color: var(--bg-linked);
    color: var(--text-linked);
}

.status-badge.unlinked, .status-badge.error, .status-badge.upload-pending {
    background-color: var(--bg-unlinked);
    color: var(--text-unlinked);
}

.status-badge.pending, .status-badge.filing {
    background-color: var(--bg-pending);
    color: var(--text-pending);
}

.status-badge.renewing, .status-badge.progress, .status-badge.draft {
    background-color: var(--bg-renewing);
    color: var(--text-renewing);
}

.file-link-trigger {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-unlinked);
    text-decoration: none;
}

.file-link-trigger.none {
    color: var(--text-placeholder);
    font-weight: 400;
}

/* ==========================================================================
   6. SPLIT FORM GRID PANEL WORKSPACE & INPUTS
   ========================================================================== */
.form-grid-workspace {
    display: grid;
    /* Use fractions (fr) instead of fixed pixels so columns scale proportionally */
    grid-template-columns: 1.1fr 1fr; 
    gap: 24px;
    align-items: start;
    width: 100%;
}

.form-panel-card {
    background: var(--surface-white);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    min-width: 0; /* Prevents long text inputs from forcing layout blowout */
    box-sizing: border-box;
}

.form-panel-card h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 24px;
}

.form-sub-header-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-top: -18px;
    margin-bottom: 24px;
    line-height: 1.4;
}

.form-group-row {
    margin-bottom: 18px;
}

.form-group-row.row-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.form-group-row.currency-amount {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 16px;
}

.field-label-text {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.form-field-input, .form-field-select, .form-field-textarea {
    width: 100%;
    height: 34px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 14px;
    font-size: 13px;
    color: var(--text-dark);
    background-color: var(--surface-white);
    outline: none;
    transition: border-color 0.15s ease;
}

.form-field-input:focus, .form-field-select:focus, .form-field-textarea:focus {
    border-color: var(--border-input-focus);
}

.form-field-input::placeholder, .form-field-textarea::placeholder {
    color: var(--text-placeholder);
}

.form-field-input.static-currency {
    background-color: var(--bg-system);
    font-weight: 700;
    color: var(--primary-brand);
    text-align: center;
}

.form-field-textarea {
    height: 50px;
    padding: 8px 14px;
    resize: none;
}

.form-field-textarea.tall-box {
    height: 74px;
}

.character-budget-counter {
    display: block;
    text-align: right;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-light);
    margin-top: 4px;
}

/* DRAG & DROP ZONE */
.file-dropzone-area {
    background-color: var(--table-header-bg);
    border: 2px dashed var(--text-placeholder);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.file-dropzone-area:hover {
    background-color: rgba(46, 74, 71, 0.02);
}

.file-dropzone-area h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-brand);
    margin-bottom: 4px;
}

.file-dropzone-area p {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 12px;
}

.file-dropzone-area .browse-trigger-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
}

.queued-registry-section {
    margin-top: 24px;
}

.queued-file-row {
    background-color: var(--bg-system);
    border-radius: 8px;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.queued-file-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
}

.queued-file-size {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-light);
    margin-left: auto;
    margin-right: 24px;
}

.remove-queue-trigger {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-unlinked);
    cursor: pointer;
}

/* BUTTON SYSTEMS */
.form-actions-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 16px;
}

/* ==========================================================================
   7. GLOBAL EXECUTABLE BUTTON PRIMITIVES
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 24px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    border: none;
}

.btn-primary {
    background-color: var(--primary-brand);
    color: var(--surface-white);
}

.btn-primary:hover {
    background-color: var(--primary-brand-hover);
}

.btn-secondary {
    background-color: var(--surface-white);
    border: 1px solid var(--text-placeholder);
    color: var(--text-muted);
}

.btn-secondary:hover {
    border-color: var(--border-input-focus);
    color: var(--text-dark);
}

.btn-tall {
    height: 42px;
    border-radius: 10px;
    font-size: 14px;
}

/* Disabled form state styling tweaks */
#drawerForm.view-mode .form-field-input[readonly],
#drawerForm.view-mode .form-field-textarea[readonly],
#drawerForm.view-mode .form-field-select[disabled] {
    background-color: #F8FAFC !important;
    color: var(--text-muted) !important;
    border-color: #E2E8F0 !important;
    cursor: not-allowed;
}

.file-link-trigger.none {
    color: #ccc;
    font-style: italic;
    cursor: default;
}
.file-link-trigger.active:hover {
    text-decoration: underline !important;
    font-weight: bold;
}
/* Consistent list container */
.attached-files-list {
    margin-bottom: 15px;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
}

/* Row styling for each file entry */
.file-row-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: white;
    border: 1px solid var(--border-color);
    margin-bottom: 5px;
    border-radius: 4px;
    font-size: 13px;
}

/* Compact dropzone styling */
.file-dropzone-compact {
    padding: 12px;
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    color: var(--primary-brand);
    font-weight: 600;
}