/* ==========================================================================
    MODERN CSS VARIABLES & RESET
    ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Updated Core Backgrounds to match Inventory */
    --bg-base: #111827;       
    --bg-surface: #1f2937;    
    --bg-surface-hover: #374151; 
    
    /* Borders */
    --border-light: #374151;
    
    /* Typography */
    --text-main: #f8fafc;     
    --text-muted: #9ca3af;    
    
    /* DYNAMIC THEME VARIABLES (Inventory Green) */
    --theme-active: #22c55e;
    --theme-active-hover: #16a34a;
    --theme-header-bg: rgba(34, 197, 94, 0.15);
    --theme-border: rgba(34, 197, 94, 0.5);
    
    /* Static Thematic Row Colors */
    --theme-row-1: #52a755; 
    --theme-row-2: #6ba4e8; 
    --theme-row-3: #ff6b6b; 
    --theme-row-4: #9d70ff; 

    /* Dynamic Tab Identifier Color */
    --tab-border-color: #22c55e;
}

/* MAIN DASHBOARD DYNAMIC THEME OVERRIDES */
body[data-theme="theme-1"] { --theme-active: #52a755; --theme-active-hover: #428b45; --theme-header-bg: rgba(82, 167, 85, 0.2); --theme-border: #52a755; }
body[data-theme="theme-2"] { --theme-active: #6ba4e8; --theme-active-hover: #508bc9; --theme-header-bg: rgba(107, 164, 232, 0.2); --theme-border: #6ba4e8; }
body[data-theme="theme-3"] { --theme-active: #ff6b6b; --theme-active-hover: #e05555; --theme-header-bg: rgba(255, 107, 107, 0.2); --theme-border: #ff6b6b; }
body[data-theme="theme-4"] { --theme-active: #9d70ff; --theme-active-hover: #8352e8; --theme-header-bg: rgba(157, 112, 255, 0.2); --theme-border: #9d70ff; }

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Removed padding so navbar goes edge-to-edge */
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; background-color: var(--bg-base); color: var(--text-main); line-height: 1.5; transition: background-color 0.3s, color 0.3s; }

/* ==========================================================================
    NAVBAR & TOOLBAR (Inventory Style)
    ========================================================================== */
.inventory-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #1a202c; /* Deep dark blue */
    padding: 12px 32px;
    border-bottom: 1px solid var(--border-light);
}

.brand-section { display: flex; flex-direction: column; }
.brand-title { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.brand-white { color: #ffffff; }
.brand-green { color: #4ade80; }
.brand-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* INVISIBLE DATE INPUTS */
.editable-date { 
    background: transparent; border: none; padding: 0; color: inherit; 
    font-family: inherit; font-size: inherit; font-weight: inherit; 
    outline: none; cursor: pointer; position: relative;
}
.editable-date::-webkit-calendar-picker-indicator { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; 
}

/* Center Nav Links */
.nav-links { display: flex; gap: 8px; background: transparent; border: none; padding: 0; box-shadow: none; }
.nav-item {
    background: transparent; color: var(--text-muted); border: none; padding: 8px 16px;
    border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: all 0.2s; display: flex; align-items: center;
}
.nav-item:hover { color: white; background: rgba(255,255,255,0.05); }
.nav-item.active { 
    background: rgba(74, 222, 128, 0.1); color: #4ade80; 
    border: 1px solid rgba(74, 222, 128, 0.2); box-shadow: none;
}

/* Right Controls (Search & Time) */
.nav-right-controls { display: flex; align-items: center; gap: 24px; }

.nav-search {
    display: flex; align-items: center; background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-light); border-radius: 6px; padding: 8px 12px; width: 260px;
    transition: border-color 0.3s;
}
.nav-search:focus-within { border-color: var(--theme-active); }
.nav-search input {
    background: transparent; border: none; color: white; outline: none; margin-left: 8px; width: 100%; font-size: 13px; font-family: inherit;
}
.nav-search input::placeholder { color: var(--text-muted); }

.nav-time { color: white; font-size: 14px; font-weight: 600; display: flex; align-items: center; }

/* Secondary Toolbar (Filters & Add Button) */
.secondary-toolbar { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 16px 32px; background: var(--bg-base);
}
.filters-container { display: flex; gap: 12px; }
.filters-container select { 
    background: var(--bg-surface); border: 1px solid var(--border-light); color: var(--text-main); 
    border-radius: 6px; padding: 8px 12px; outline: none; cursor: pointer; font-size: 13px; font-weight: 500;
}

.btn-add { 
    background: var(--theme-active); color: white; border: none; border-radius: 6px; 
    padding: 8px 16px; font-size: 13px; cursor: pointer; font-weight: 600; 
    display: flex; align-items: center; gap: 8px; transition: background 0.3s; 
}
.btn-add:hover { background: var(--theme-active-hover); }
.btn-add .add-icon { font-size: 16px; font-weight: bold; }

/* ==========================================================================
    TABLE STRUCTURE & DESIGN
    ========================================================================== */
.table-container { width: 100%; max-height: 70vh; overflow: auto; background-color: var(--bg-surface); border: 2px solid var(--tab-border-color); border-radius: 12px; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); transition: border-color 0.3s; }
.table-container::-webkit-scrollbar { width: 8px; height: 8px; }
.table-container::-webkit-scrollbar-track { background: var(--bg-base); border-radius: 0 12px 12px 0; }
.table-container::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
.table-container::-webkit-scrollbar-thumb:hover { background: var(--theme-active); }

table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; table-layout: fixed; }

thead tr:first-child { height: 76px; }

thead th { position: sticky; top: 0; background-color: var(--bg-surface); color: var(--text-main); border-bottom: 2px solid var(--theme-border); border-right: 1px solid var(--border-light); padding: 12px 8px; text-align: center; font-weight: 600; z-index: 10; letter-spacing: 0.5px; transition: border-color 0.3s, background-color 0.3s; }
thead th:last-child { border-right: none; }

thead tr:nth-child(2) th { top: 76px; z-index: 9; font-size: 12px; color: var(--text-muted); background-color: var(--bg-base); border-bottom: 2px solid var(--theme-border); }

.clickable-header { cursor: pointer; transition: background 0.2s, opacity 0.2s; user-select: none; }
.clickable-header:hover { background-color: var(--theme-header-bg); opacity: 0.9; }
.collapsed-header { width: 45px !important; min-width: 45px !important; max-width: 45px !important; white-space: nowrap; padding: 12px 4px !important; overflow: hidden;}

tbody { background-color: var(--bg-surface); }
tbody td { border-bottom: 1px solid var(--border-light); border-right: 1px solid var(--border-light); padding: 10px 8px; vertical-align: middle; text-align: center; position: relative; color: var(--text-main); }
tbody td:last-child { border-right: none; }

.col-ppa { width: 130px; min-width: 130px; max-width: 130px; font-family: monospace; font-size: 12px; color: var(--theme-active); font-weight: bold; transition: color 0.3s;}

.col-mfo, .col-ind { width: 250px; min-width: 250px; max-width: 250px; white-space: pre-wrap; word-break: break-word; text-align: center; line-height: 1.4; }

.col-var, .col-rem { width: 170px; min-width: 170px; max-width: 170px; }

.thematic-header { font-weight: 600; text-align: left; padding: 12px 16px !important; color: white !important; cursor: pointer; transition: opacity 0.2s; text-transform: uppercase; letter-spacing: 0.5px; }
.thematic-header:hover { opacity: 0.9; }
.theme-row-1 { background-color: var(--theme-row-1) !important; } 
.theme-row-2 { background-color: var(--theme-row-2) !important; } 
.theme-row-3 { background-color: var(--theme-row-3) !important; } 
.theme-row-4 { background-color: var(--theme-row-4) !important; } 
.theme-arrow { font-size: 12px; background: rgba(0,0,0,0.2); padding: 4px 8px; border-radius: 4px; }

.classification-header { background-color: rgba(255,255,255,0.05) !important; font-weight: 600; text-align: left; padding: 10px 16px !important; color: var(--text-muted); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; position: relative; }
.item-title-row { text-align: left !important; background-color: var(--bg-surface) !important; font-weight: 500; font-size: 14px; padding: 12px 16px !important; position: relative;}

.add-ppa-btn { background-color: transparent; color: var(--theme-active); border: 1px solid var(--theme-active); border-radius: 4px; cursor: pointer; margin-right: 12px; padding: 2px 8px; font-size: 12px; font-weight: bold; transition: all 0.3s; }
.add-ppa-btn:hover { background-color: var(--theme-active); color: white; }

.quarter-box { width: 170px !important; min-width: 170px !important; max-width: 170px !important; white-space: pre-wrap !important; word-break: break-word !important; line-height: 1.4; padding: 0 !important; }

.fa-spacer, .target-spacer, .actual-spacer { background-color: var(--theme-header-bg); width: 45px !important; min-width: 45px !important; max-width: 45px !important; transition: background-color 0.3s;}

.interactive-cell { cursor: pointer; transition: background 0.2s; position: relative; }
.interactive-cell.empty:hover { background-color: var(--theme-header-bg); } 
.fa-cell { font-weight: 600; color: var(--theme-active); font-family: monospace; font-size: 14px; transition: color 0.3s;}
.attachment-icons { display: flex; gap: 4px; justify-content: center; margin-top: 8px; font-size: 14px; background: rgba(0,0,0,0.2); padding: 4px; border-radius: 4px; width: fit-content; margin-left: auto; margin-right: auto;}

.cell-action-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(2px); display: flex; flex-direction: row; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; z-index: 5; gap: 8px; }
.interactive-cell.filled:hover .cell-action-overlay { opacity: 1; }

/* ==========================================================================
    MODALS & LOCAL MODAL THEMES
    ========================================================================== */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.75); backdrop-filter: blur(4px); justify-content: center; align-items: center; z-index: 1000; animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    --local-theme: var(--theme-active); 
    background: var(--bg-surface); border-radius: 12px; width: 480px; padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.2);
    color: var(--text-main); border: 1px solid var(--local-theme);
    transform: scale(0.98); animation: scaleUp 0.2s ease-out forwards; transition: border-color 0.3s;
}
@keyframes scaleUp { to { transform: scale(1); } }

.modal[data-modal-theme="theme-1"] { --local-theme: #52a755; }
.modal[data-modal-theme="theme-2"] { --local-theme: #6ba4e8; }
.modal[data-modal-theme="theme-3"] { --local-theme: #ff6b6b; }
.modal[data-modal-theme="theme-4"] { --local-theme: #9d70ff; }

.modal-header { font-size: 18px; font-weight: 600; margin-bottom: 12px; border-bottom: 1px solid var(--border-light); padding-bottom: 12px; display: flex; justify-content: space-between; align-items: center; color: var(--local-theme); transition: color 0.3s;}

.theme-display-badge {
    background-color: var(--local-theme); color: white; padding: 6px 12px; border-radius: 6px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    display: inline-block; margin-bottom: 20px; opacity: 0; transition: opacity 0.3s, background-color 0.3s;
    max-height: 0; overflow: hidden; padding-top: 0; padding-bottom: 0; margin-bottom: 0; 
}
.theme-display-badge.visible {
    opacity: 1; max-height: 40px; padding-top: 6px; padding-bottom: 6px; margin-bottom: 20px;
}

.close-btn { cursor: pointer; font-size: 18px; color: var(--text-muted); background: none; border: none; padding: 4px; transition: color 0.2s; }
.close-btn:hover { color: #ef4444; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 13px; color: var(--text-muted); }
.form-group select, .form-group input[type="text"], .form-group input[type="number"], .form-group textarea {
    width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-light);
    background: var(--bg-base); color: var(--text-main); outline: none; font-family: inherit; font-size: 14px; transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group select:focus, .form-group input:focus, .form-group textarea:focus { 
    border-color: var(--local-theme); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05); 
}
.form-group textarea { resize: vertical; min-height: 80px; }

.btn-done { background-color: var(--local-theme); color: white; border: none; padding: 10px 0; border-radius: 8px; font-weight: 600; cursor: pointer; display: block; width: 100%; margin-top: 24px; font-size: 15px; transition: background-color 0.3s, opacity 0.2s; }
.btn-done:hover { opacity: 0.9; }

/* Form E Specifics */
.upload-section { margin-top: 20px; background: rgba(0,0,0,0.2); padding: 16px; border-radius: 8px; border: 1px dashed var(--local-theme); transition: border-color 0.3s;}
.upload-label { font-weight: 500; font-size: 13px; color: var(--text-muted); margin-bottom: 12px; display: block; }
.upload-buttons-container { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.btn-upload { flex: 1; padding: 8px; border: none; border-radius: 6px; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; color: white; font-size: 13px; transition: opacity 0.2s, background-color 0.3s; background-color: var(--bg-surface-hover); border: 1px solid var(--border-light);}
.btn-upload:hover { opacity: 0.85; background-color: var(--local-theme); border-color: var(--local-theme);}

.link-input-container { display: flex; gap: 8px; margin-bottom: 12px; }
.link-input-container input { flex-grow: 1; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border-light); background: var(--bg-base); color: white; outline: none; font-size: 13px; }
.btn-add-link { padding: 8px 16px; background-color: var(--local-theme); color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; }

.attachment-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.attachment-list li { display: flex; justify-content: space-between; background: var(--bg-base); padding: 8px 12px; margin-bottom: 8px; border-radius: 6px; align-items: center; border: 1px solid var(--border-light); }
.attachment-remove { color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 4px; transition: background 0.2s, color 0.2s; }
.attachment-remove:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.attachment-link-item { word-break: break-all; flex-grow: 1; margin-right: 12px; color: var(--text-main); }
.attachment-link-item a { color: var(--local-theme); text-decoration: none; transition: color 0.3s; font-weight: 600;}
.attachment-link-item a:hover { text-decoration: underline; }

#view-content { background: var(--bg-base); padding: 16px; border-radius: 8px; border: 1px solid var(--border-light); line-height: 1.6; word-break: break-word; font-size: 14px; }
#view-quarter-label { color: var(--text-main); font-size: 16px; margin-bottom: 16px; text-align: center; font-weight: bold; text-transform: uppercase;}

/* ==========================================================================
    ROW HOVER ACTIONS (EDIT & DELETE)
    ========================================================================== */
.row-actions { display: none; position: absolute; top: 50%; transform: translateY(-50%); gap: 4px; z-index: 10; }
.col-ppa .row-actions { right: 4px; }
.classification-header .row-actions { right: 16px; }
.item-title-row .row-actions { right: 16px; }
.col-ppa:hover .row-actions, .classification-header:hover .row-actions, .item-title-row:hover .row-actions { display: flex; }

.btn-action { background: var(--theme-active); color: white; border: none; border-radius: 4px; cursor: pointer; padding: 4px 6px; font-size: 12px; display: flex; align-items: center; justify-content: center; transition: background 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.btn-action:hover { background: var(--theme-active-hover); }
.btn-delete { background: #ef4444; }
.btn-delete:hover { background: #dc2626; }