/* ==========================================================================
   AMIDA - Presupuestos y Mediciones de Arquitectura
   DESIGN SYSTEM & CUSTOM CSS
   ========================================================================== */

/* Variables */
:root {
    --bg-primary: #1e2024;          /* Soft cool slate gray */
    --bg-secondary: #25282e;        /* Slightly lighter slate gray for sidebars/headers */
    --bg-card: rgba(53, 58, 66, 0.45); /* Elegant gray glassmorphism card */
    --bg-card-hover: rgba(69, 75, 87, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-active: rgba(16, 185, 129, 0.5);
    
    --text-primary: #f1f5f9;        /* Off-white / light slate text */
    --text-secondary: #94a3b8;      /* Cool medium gray */
    --text-muted: #64748b;          /* Cool muted gray */
    
    /* Harmonious Accent Colors */
    --accent-orange: #f97316;       /* Capitulos */
    --accent-blue: #3b82f6;         /* Subcapitulos */
    --accent-emerald: #10b981;      /* Partidas Directas */
    --accent-purple: #a855f7;       /* Partidas Desglosadas */
    --accent-rose: #f43f5e;         /* Danger / Remove */
    
    --font-main: 'Plus Jakarta Sans', sans-serif;
    --font-heading: 'Outfit', sans-serif;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --glass-blur: blur(12px);
}

/* Light Theme Variables */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(241, 245, 249, 0.7);
    --bg-card-hover: rgba(226, 232, 240, 0.8);
    --border-color: rgba(15, 23, 42, 0.08);
    --border-color-active: rgba(16, 185, 129, 0.5);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
}


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

a {
    text-decoration: none;
    color: inherit;
}

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

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

/* Sidebar Styling */
.sidebar {
    width: 350px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.75rem;
    flex-shrink: 0;
    z-index: 10;
    transition: width var(--transition-normal), padding var(--transition-normal);
}

.sidebar.collapsed {
    width: 72px;
    padding: 1.75rem 0.6rem;
    align-items: center;
}

.sidebar.collapsed .collapse-hide {
    display: none !important;
}

.sidebar.collapsed .logo-accent {
    text-shadow: none;
}

.sidebar.collapsed .sidebar-header {
    margin-bottom: 2rem;
    width: 100%;
}

.sidebar.collapsed .sidebar-header div[style*="display: flex"] {
    flex-direction: column;
    gap: 1rem;
    align-items: center !important;
}

.sidebar.collapsed .logo {
    justify-content: center;
}

.sidebar.collapsed .btn {
    padding: 0.65rem 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.sidebar.collapsed .btn i {
    font-size: 1rem;
    margin: 0;
}

.sidebar.collapsed .btn-label {
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar.collapsed .btn-label i {
    font-size: 1rem;
    margin: 0;
}

.sidebar.collapsed .project-item {
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    justify-content: center;
    border-left: 1px solid var(--border-color);
}

.sidebar.collapsed .project-item.active {
    border-left: 1px solid var(--border-color-active);
    background-color: var(--bg-card-hover);
}

.sidebar.collapsed .project-item-icon {
    margin: 0 !important;
}

.sidebar-header {
    margin-bottom: 2.5rem;
}

.logo {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.logo-accent {
    color: var(--accent-emerald);
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

.subtitle {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-top: -0.25rem;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

/* Project List in Sidebar */
.project-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--transition-fast);
}

.project-item:hover, .project-item.active {
    background: var(--bg-card-hover);
    border-color: var(--border-color-active);
}

.project-item.active {
    border-left: 3px solid var(--accent-emerald);
}

.project-item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.project-item-delete {
    color: var(--text-muted);
    transition: var(--transition-fast);
    padding: 0.25rem;
}

.project-item-delete:hover {
    color: var(--accent-rose);
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Main Workspace */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top right, rgba(16, 185, 129, 0.05), transparent 40%),
                radial-gradient(circle at bottom left, rgba(99, 102, 241, 0.03), transparent 30%),
                var(--bg-primary);
    overflow-y: auto;
    padding: 2.25rem;
}

/* Header Area */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2rem;
}

.header-title-container {
    flex: 1;
}

.editable-title {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    outline: none;
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
    display: inline-block;
    transition: var(--transition-fast);
}

.editable-title:hover {
    border-bottom-color: rgba(255, 255, 255, 0.15);
}

.editable-title:focus {
    border-bottom-color: var(--accent-emerald);
}

.header-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Header Stats Panel */
.header-stats {
    display: flex;
    gap: 1rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

#stat-total {
    color: var(--accent-emerald);
}

/* Action Control Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 1.25rem;
}

.control-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.65rem 1.1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background-color: rgba(249, 115, 22, 0.15);
    color: var(--accent-orange);
    border: 1px solid rgba(249, 115, 22, 0.3);
}
.btn-primary:hover:not(:disabled) {
    background-color: rgba(249, 115, 22, 0.25);
}

.btn-secondary {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.btn-secondary:hover:not(:disabled) {
    background-color: rgba(59, 130, 246, 0.25);
}

.btn-accent {
    background-color: #ffffff;
    color: #000000;
    border: 1px solid var(--border-color);
}
.btn-accent:hover:not(:disabled) {
    background-color: #f1f5f9;
}

.btn-accent-alt {
    background-color: #e9eff6;
    color: #000000;
    border: 1px solid var(--border-color);
}
.btn-accent-alt:hover:not(:disabled) {
    background-color: #dbe4f0;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-outline:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-danger {
    background-color: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}
.btn-danger:hover:not(:disabled) {
    background-color: rgba(244, 63, 94, 0.25);
}

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

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.45rem 0.75rem;
    font-size: 0.775rem;
    border-radius: 6px;
}

.btn-label {
    cursor: pointer;
}

.mb-2 { margin-bottom: 0.5rem; }

/* Search Box */
.search-container {
    position: relative;
    width: 320px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.875rem;
}

.search-input, .search-container input {
    width: 100%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.55rem 1rem 0.55rem 2.25rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition-fast);
}

.search-container input:focus {
    border-color: var(--accent-emerald);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

/* Table Design */
.table-outer-wrapper {
    flex: 1;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    margin-bottom: 1.5rem;
}

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

.budget-table th {
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 5;
}

.budget-table td {
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

/* Row types */
.row-chapter {
    background-color: rgba(249, 115, 22, 0.08);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}
.row-chapter td {
    border-bottom: 2px solid rgba(249, 115, 22, 0.15);
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}
.row-chapter .col-code {
    color: var(--accent-orange);
    font-size: 1.05rem;
}
.row-chapter .cell-input {
    color: var(--accent-orange);
    text-transform: uppercase;
    font-weight: 700;
    font-size: 1.05rem;
}

.row-subchapter {
    background-color: rgba(59, 130, 246, 0.08);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}
.row-subchapter td {
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}
.row-subchapter .col-code {
    color: var(--accent-blue);
    font-size: 0.95rem;
}
.row-subchapter .cell-input {
    color: var(--accent-blue);
    text-transform: uppercase;
    font-weight: 700;
    font-size: 0.95rem;
}

.row-partida {
    background-color: transparent;
    font-size: 0.85rem;
}
.row-partida:hover {
    background-color: rgba(255, 255, 255, 0.015);
}

/* Merged title columns to remove spacing between Code and Title */
.col-title-merged {
    vertical-align: middle;
}
.col-title-merged div {
    display: flex;
    align-items: center;
    gap: 8px; /* space between code and title */
}
.col-title-merged .toggle-expand-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.col-title-merged .col-code {
    white-space: nowrap;
}
.subchapter-title-merged {
    padding-left: 1.5rem !important; /* Indentation for subchapters */
}
.partida-title-merged {
    padding-left: 3rem !important; /* Indentation for partidas */
}
.partida-title-merged div {
    align-items: flex-start;
}
.partida-title-merged .col-code {
    margin-top: 4px; /* Align code with first line of textarea */
}
.row-partida .cell-input {
    font-weight: 400;
}
.row-partida .col-title-merged input.cell-input {
    text-transform: uppercase;
}
.row-partida .col-title-merged textarea.cell-textarea {
    text-transform: none;
    font-style: italic;
}

.row-partida-directa {
    background-color: #252830;
    color: var(--text-primary);
}
.row-partida-directa .col-code {
    color: var(--text-secondary);
}

.row-partida-desglosada {
    background-color: #2a2e37;
    color: var(--text-primary);
}
.row-partida-desglosada .col-code {
    color: var(--text-secondary);
}

body.light-theme .row-partida-directa {
    background-color: #ffffff;
    color: #0f172a;
}
body.light-theme .row-partida-directa .col-code {
    color: #475569;
}

body.light-theme .row-partida-desglosada {
    background-color: #ffffff;
    color: #0f172a;
}
body.light-theme .row-partida-desglosada .col-code {
    color: #475569;
}

.row-partida .cell-input:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.02);
}

.row-partida .cell-input:focus:not(:disabled) {
    border-color: var(--accent-blue);
    background: var(--bg-secondary);
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.3);
}

body.light-theme .row-partida .cell-input:hover:not(:disabled) {
    border-color: rgba(0, 0, 0, 0.15);
    background: rgba(0, 0, 0, 0.02);
}

body.light-theme .row-partida .cell-input:focus:not(:disabled) {
    border-color: var(--accent-blue);
    background: #ffffff;
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.2);
}

/* Inputs and editable areas inside table */
.cell-input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    color: inherit;
    font-family: inherit;
    font-weight: inherit;
    font-size: inherit;
    outline: none;
    transition: var(--transition-fast);
}

.cell-input:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.cell-input:focus:not(:disabled) {
    border-color: var(--accent-indigo);
    background: var(--bg-secondary);
    box-shadow: 0 0 5px rgba(99, 102, 241, 0.2);
}

/* Custom Textarea for concepts */
.cell-textarea {
    resize: vertical;
    min-height: 24px;
    height: 28px;
    overflow-y: hidden;
}

.cell-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%236b7280' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 16px;
    padding-right: 20px !important;
}

.cell-select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

body.light-theme .cell-select option {
    background-color: #ffffff;
    color: #0f172a;
}

/* Text alignment & Formatting */
.col-right {
    text-align: right;
}
.col-center {
    text-align: center;
}

.cell-number-display {
    font-family: monospace;
    font-size: 0.9rem;
}

/* Hierarchy tree codes */
.col-code {
    font-family: var(--font-heading);
    font-weight: 700;
}

/* Percent Pill Badge */
.pct-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

.row-chapter .pct-badge {
    background: rgba(249, 115, 22, 0.15);
    color: var(--accent-orange);
    border-color: rgba(249, 115, 22, 0.3);
}

.row-subchapter .pct-badge {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.3);
}

.row-partida-directa .pct-badge,
.row-partida-desglosada .pct-badge {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.light-theme .row-partida-directa .pct-badge,
body.light-theme .row-partida-desglosada .pct-badge {
    background: rgba(0, 0, 0, 0.05);
    color: #0f172a;
    border-color: rgba(0, 0, 0, 0.15);
}

.row-partida .action-icon-btn {
    color: var(--text-secondary);
}
.row-partida .action-icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}
.row-partida-directa:hover, .row-partida-desglosada:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

body.light-theme .row-partida .action-icon-btn {
    color: #475569;
}
body.light-theme .row-partida .action-icon-btn:hover {
    color: #0f172a;
    background: rgba(0, 0, 0, 0.06);
}
body.light-theme .row-partida-directa:hover, body.light-theme .row-partida-desglosada:hover {
    background-color: #f1f5f9;
}

/* Action icons */
.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    padding-right: 0.5rem;
}

.action-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 4px;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    text-decoration: none;
}

.action-icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.action-icon-btn.delete-btn:hover {
    color: var(--accent-rose);
    background: rgba(244, 63, 94, 0.1);
}

.action-icon-btn.convert-btn:hover {
    color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.1);
}

/* Breakdown Row & Table styling */
.row-breakdown {
    background-color: transparent;
}
.row-breakdown td {
    padding: 0 !important;
}

.breakdown-container {
    padding: 0.5rem 0.6rem 1rem 10.2rem;
    margin: 0.25rem 0;
}

.breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.breakdown-title {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-purple);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breakdown-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: transparent;
    border: none;
    overflow: hidden;
    font-size: 0.75rem;
}

.breakdown-table th {
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.7rem;
    padding: 0.5rem 0.5rem;
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.breakdown-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.breakdown-table tr:last-child td {
    border-bottom: none;
}

.breakdown-table .cell-input {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.breakdown-table .cell-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 5px rgba(139, 92, 246, 0.2);
}

/* Hover Add Row Cross & Placeholders */
.desc-cell-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    padding-left: 22px; /* Align input and reserve space for the plus button inside the cell */
}

.add-row-trigger-btn {
    position: absolute;
    left: 0px; /* Positioned inside the reserved padding space of the cell */
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
    padding: 0;
    z-index: 10;
}

.add-row-trigger-btn i {
    font-size: 0.65rem;
}

.desc-cell-container:hover .add-row-trigger-btn,
.add-row-trigger-btn:hover {
    opacity: 1;
    color: var(--text-primary);
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

.subtotal-placeholder {
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.5;
    font-style: italic;
}

.breakdown-total-row {
    background: transparent;
    font-weight: 700;
}

.breakdown-total-row td {
    padding: 0.6rem 0.5rem;
    color: var(--accent-purple);
    font-size: 0.75rem;
}

/* Selected row helper */
.row-selected {
    outline: 2px solid var(--border-color-active);
    outline-offset: -2px;
}

/* Empty State Styling */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    text-align: center;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: auto 0;
}

.empty-icon {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    opacity: 0.7;
    animation: pulse 3s infinite ease-in-out;
}

.empty-state h2 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    max-width: 400px;
}

/* Toast Notification Styling */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 100;
}

.toast {
    background: rgba(19, 26, 38, 0.9);
    border: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    border-radius: 8px;
    padding: 0.85rem 1.25rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-md);
    transform: translateY(20px);
    opacity: 0;
    animation: slideUp 0.3s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success {
    border-left: 4px solid var(--accent-emerald);
}
.toast.success i {
    color: var(--accent-emerald);
}

.toast.error {
    border-left: 4px solid var(--accent-rose);
}
.toast.error i {
    color: var(--accent-rose);
}

.toast.info {
    border-left: 4px solid var(--accent-indigo);
}
.toast.info i {
    color: var(--accent-indigo);
}

/* Keyframes animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

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

/* Hide spin buttons for inputs of type number */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 14, 23, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal.show .modal-content {
    transform: translateY(0);
}

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

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-header h2 span {
    color: var(--accent-emerald);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.75rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-fast);
}

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

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-node-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.4;
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--accent-blue);
}

.modal-textarea {
    width: 100%;
    height: 150px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.875rem;
    resize: none;
    outline: none;
    transition: var(--transition-fast);
}

.modal-textarea:focus {
    border-color: var(--accent-emerald);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Drag and Drop Container */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.01);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.03);
}

.drop-zone-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.drop-zone:hover .drop-zone-icon, .drop-zone.dragover .drop-zone-icon {
    color: var(--accent-emerald);
    transform: translateY(-2px);
}

.drop-zone-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Files List inside Modal */
.files-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.files-list-container h3 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.files-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.8125rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    flex: 1;
    color: var(--text-primary);
    text-decoration: none;
}

.file-info:hover {
    color: var(--accent-emerald);
}

.file-icon {
    font-size: 1rem;
    color: var(--text-muted);
}

.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.file-size {
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.file-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition-fast);
}

.file-delete:hover {
    color: var(--accent-rose);
    background: rgba(244, 63, 94, 0.1);
}

/* Indicators in main table */
.has-indicator {
    position: relative;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition-fast);
    color: var(--text-muted);
    text-decoration: none;
}

.row-partida .has-indicator {
    color: #4b5563; /* slightly darker on partidas rows */
}

.has-indicator:hover {
    color: var(--accent-blue) !important;
}

.has-indicator.active {
    color: var(--accent-emerald) !important;
}

.indicator-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--accent-emerald);
    color: white;
    font-size: 0.55rem;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 1px solid var(--bg-secondary);
}
.indicator-badge.dot {
    width: 7px;
    height: 7px;
    top: -3px;
    right: -3px;
    border-radius: 50%;
}

/* Presets Tree Styling */
.presets-tree {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.preset-chapter-item {
    font-weight: 700;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}
.preset-subchapter-item {
    font-weight: 500;
    margin-left: 1.75rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.preset-subchapter-item label {
    font-size: 0.85rem;
}

/* Budget Index Navigation Styling */
.budget-index-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.budget-index-list-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.25rem 0;
    cursor: pointer;
    font-size: 0.85rem;
    transition: opacity var(--transition-fast);
    border: none;
    background: transparent;
}

.budget-index-list-item:hover {
    opacity: 0.8;
}

.budget-index-list-item.chapter {
    color: #ef4444; /* red color */
    font-weight: 700;
}

body.light-theme .budget-index-list-item.chapter {
    color: #dc2626; /* darker red for contrast in light theme */
}

.budget-index-list-item.subchapter {
    color: var(--text-primary);
    font-weight: 700;
    padding-left: 1rem;
}

.budget-index-list-item .item-left {
    display: flex;
    gap: 0.35rem;
    align-items: baseline;
    flex: 1;
}

.budget-index-list-item .item-title {
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
}

.budget-index-list-item .item-total {
    font-family: inherit;
    font-weight: inherit;
    text-align: right;
    white-space: nowrap;
    margin-left: 0.75rem;
}

/* Row Flash Highlight Animation */
@keyframes flash-highlight {
    0% {
        background-color: rgba(16, 185, 129, 0.4);
    }
    100% {
        background-color: transparent;
    }
}

.row-flash {
    animation: flash-highlight 2s ease-out;
}

/* Screen/Print helpers */
.print-only {
    display: none;
}

@media print {
    /* Hide everything that is not the main table content and header */
    .sidebar,
    .action-bar,
    .modal,
    .toast-container,
    .sidebar-footer,
    #btn-theme-toggle,
    #btn-sidebar-toggle,
    .empty-state {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
        overflow: visible !important;
        height: auto !important;
    }

    .app-container {
        display: block !important;
        height: auto !important;
    }

    .main-content {
        padding: 0 !important;
        background: none !important;
        overflow: visible !important;
        height: auto !important;
        display: block !important;
    }

    /* Print Header */
    .main-header {
        margin-bottom: 2rem !important;
        display: block !important;
    }
    
    .editable-title {
        border: none !important;
        font-size: 2rem !important;
        color: black !important;
    }

    .header-stats {
        display: flex !important;
        gap: 0.5rem !important;
        margin-top: 1rem !important;
    }
    
    .stat-card {
        padding: 0.5rem 1rem !important;
        border: 1px solid #ddd !important;
        background: none !important;
        min-width: 120px !important;
    }

    /* Table styling for printing */
    .table-outer-wrapper {
        border: none !important;
        background: none !important;
        overflow: visible !important;
        margin-bottom: 3rem !important;
    }

    .budget-table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    /* Hide columns: checkbox, expand-toggle, percent total, actions */
    .budget-table th:nth-child(1),
    .budget-table td:nth-child(1),
    .budget-table th:nth-child(2),
    .budget-table td:nth-child(2),
    .budget-table th:nth-child(9),
    .budget-table td:nth-child(9),
    .budget-table th:last-child,
    .budget-table td:last-child {
        display: none !important;
    }

    /* Print helpers to hide input boxes and show plain text values */
    .no-print {
        display: none !important;
    }
    .print-only {
        display: inline-block !important;
        color: black !important;
    }

    /* Format colors for print */
    .row-chapter {
        background-color: #f3f4f6 !important;
        color: black !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .row-chapter .col-code {
        color: black !important;
    }

    .row-subchapter {
        background-color: #f9fafb !important;
        color: black !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .row-subchapter .col-code {
        color: black !important;
    }

    .row-partida-directa, .row-partida-desglosada {
        background-color: white !important;
        color: black !important;
    }

    .row-partida .col-code {
        color: black !important;
    }

    /* Indicators */
    .has-indicator {
        color: #374151 !important;
        text-decoration: none !important;
    }

    /* Annex Section */
    .print-annex-section {
        display: block !important;
        page-break-before: always;
        margin-top: 3rem;
    }

    .print-annex-title {
        font-family: var(--font-heading);
        font-size: 1.5rem;
        font-weight: 700;
        border-bottom: 2px solid black;
        padding-bottom: 0.5rem;
        margin-bottom: 1.5rem;
        color: black !important;
    }

    .print-annex-item {
        margin-bottom: 1.5rem;
        page-break-inside: avoid;
    }

    .print-annex-item-header {
        font-weight: 700;
        font-size: 1rem;
        margin-bottom: 0.25rem;
        color: #111827;
    }

    .print-annex-item-content {
        font-size: 0.875rem;
        color: #374151;
        margin-left: 1rem;
        white-space: pre-wrap;
    }
}

/* Hide print annex section on screen */
.print-annex-section {
    display: none;
}


