/* ===== CSS Variables ===== */
:root {
    /* Superficie y fondos */
    --bg-app: #F7F8FA;
    --bg-sidebar: #1A2332;
    --bg-surface: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-subtle: #F0F2F5;
    --bg-muted: #E8ECF0;

    /* Marca - Verde bosque */
    --brand-600: #2D6A4F;
    --brand-500: #40916C;
    --brand-400: #52B788;
    --brand-100: #D8F3DC;
    --brand-50: #F0FFF4;

    /* Legacy aliases */
    --primary: #40916C;
    --primary-dark: #2D6A4F;
    --primary-light: #D8F3DC;
    --secondary: #455A64;
    --background: #F7F8FA;
    --surface: #FFFFFF;
    --white: #FFFFFF;

    /* Sidebar */
    --sidebar-text: #94A3B8;
    --sidebar-text-hover: #E2E8F0;
    --sidebar-active-bg: #40916C;
    --sidebar-active-text: #FFFFFF;
    --sidebar-divider: #2D3748;

    /* Texto */
    --text-primary: #1A202C;
    --text-secondary: #4A5568;
    --text-tertiary: #718096;
    --text-muted: #718096;
    --text-disabled: #A0AEC0;

    /* Bordes */
    --border: #E2E8F0;
    --border-default: #E2E8F0;
    --border-strong: #CBD5E0;
    --border-focus: #40916C;

    /* Gray scale */
    --gray-50: #F7FAFC;
    --gray-100: #EDF2F7;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E0;
    --gray-400: #A0AEC0;
    --gray-500: #718096;
    --gray-600: #4A5568;
    --gray-700: #2D3748;
    --gray-800: #1A202C;
    --gray-900: #171923;

    /* Estados */
    --status-draft: #64748B;
    --status-sent: #3B82F6;
    --status-accepted: #22C55E;
    --status-rejected: #EF4444;
    --status-invoiced: #A855F7;
    --status-active: #059669;
    --status-paused: #F59E0B;
    --status-finished: #2563EB;

    /* Semánticos */
    --error: #DC2626;
    --danger: #DC2626;
    --danger-500: #DC2626;
    --danger-50: #FEF2F2;
    --warning: #D97706;
    --warning-500: #D97706;
    --warning-50: #FFFBEB;
    --warning-light: #FFFBEB;
    --info: #2563EB;
    --info-500: #2563EB;
    --info-50: #EFF6FF;
    --success: #059669;
    --success-500: #059669;
    --success-50: #ECFDF5;
    --success-light: #ECFDF5;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;

    /* Shadows (sólidas, sin glass) */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    /* Legacy glass aliases (mapped to solid equivalents) */
    --glass-heavy: var(--bg-surface);
    --glass-medium: var(--bg-surface);
    --glass-light: var(--bg-subtle);
    --glass-subtle: var(--bg-muted);
    --glass-primary: rgba(64, 145, 108, 0.08);
    --glass-primary-medium: rgba(64, 145, 108, 0.12);
    --glass-primary-strong: rgba(64, 145, 108, 0.20);
    --blur-heavy: none;
    --blur-medium: none;
    --blur-light: none;
    --blur-subtle: none;
    --border-glass: 1px solid var(--border-default);
    --border-glass-strong: 1px solid var(--border-strong);
    --shadow-glass: var(--shadow);
    --shadow-glass-lg: var(--shadow-md);

    /* Layout */
    --sidebar-width: 220px;
    --sidebar-collapsed: 56px;
    --header-height: 56px;
    --radius: 6px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
    --bg-app: #0F1419;
    --bg-sidebar: #0A0F14;
    --bg-surface: #1A1F25;
    --bg-elevated: #242930;
    --bg-subtle: #1E2329;
    --bg-muted: #2D333A;
    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --text-tertiary: #6E7681;
    --text-muted: #6E7681;
    --text-disabled: #484F58;
    --border: #2D333A;
    --border-default: #2D333A;
    --border-strong: #3D444B;
    --brand-600: #52B788;
    --brand-500: #95D5B2;
    --brand-100: #1B4332;
    --brand-50: #0F2419;
    --primary: #52B788;
    --primary-dark: #40916C;
    --primary-light: #1B4332;
    --surface: #1A1F25;
    --background: #0F1419;
    --gray-50: #0D1117;
    --gray-100: #161B22;
    --gray-200: #21262D;
    --gray-300: #30363D;
    --gray-400: #484F58;
    --gray-500: #6E7681;
    --gray-600: #8B949E;
    --gray-700: #C9D1D9;
    --gray-800: #E6EDF3;
    --gray-900: #F0F6FC;
    --glass-heavy: var(--bg-surface);
    --glass-medium: var(--bg-surface);
    --glass-light: var(--bg-subtle);
    --glass-subtle: var(--bg-muted);
    --glass-primary: rgba(82, 183, 136, 0.08);
    --glass-primary-medium: rgba(82, 183, 136, 0.12);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --shadow-glass: var(--shadow);
    --shadow-glass-lg: var(--shadow-md);
    --error: #F85149;
    --danger: #F85149;
    --warning: #D29922;
    --success: #3FB950;
    --info: #58A6FF;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== App Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* App background - no decorative pseudo-element needed */

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: none;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--sidebar-divider);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #FFFFFF;
    margin: 0;
}

.logo-subtitle {
    font-size: 0.6875rem;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.nav-menu {
    list-style: none;
    padding: 0.5rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    margin: 0.125rem 0.5rem;
}

.nav-divider {
    height: 0;
    margin: 0.25rem 0.75rem;
    border: none;
    border-top: 1px solid var(--sidebar-divider);
    list-style: none;
}

.nav-group-label {
    display: block;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sidebar-text);
    padding: 1rem 1rem 0.375rem;
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.nav-link .nav-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--sidebar-text-hover);
    text-decoration: none;
}

.nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 500;
}

.nav-icon {
    width: 20px;
    height: 20px;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Sidebar colapsado */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .logo-subtitle,
.sidebar.collapsed .alertas-badge {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.625rem;
}

.sidebar.collapsed .nav-icon {
    margin-right: 0;
    font-size: 1.25rem;
}

.sidebar.collapsed .sidebar-header {
    padding: 1.25rem 0.75rem;
    text-align: center;
}

.sidebar.collapsed .logo {
    font-size: 0.875rem;
}

.sidebar.collapsed .sidebar-footer {
    padding: 0.75rem;
}

.sidebar.collapsed .user-info,
.sidebar.collapsed #login-btn,
.sidebar.collapsed .version {
    display: none !important;
}

.sidebar.collapsed .sidebar-collapse-btn span {
    display: none;
}

/* Botón colapsar sidebar */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--sidebar-text);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8125rem;
    transition: all 0.15s;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text-hover);
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--sidebar-divider);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--brand-500);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.125rem;
}

.user-avatar svg {
    width: 20px;
    height: 20px;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    display: block;
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--sidebar-text-hover);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-logout {
    font-size: 0.6875rem;
    color: var(--sidebar-text);
}

.user-logout:hover {
    color: #F85149;
}

.version {
    font-size: 0.6875rem;
    color: var(--sidebar-text);
    display: block;
    margin-top: 0.375rem;
}

#login-btn {
    background: var(--brand-500);
    border: none;
    font-size: 0.8125rem;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sidebar toggle hamburger */
.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    padding: 0.375rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.sidebar-toggle:hover {
    background: var(--bg-subtle);
}

/* Dark mode toggle */
.dark-mode-toggle {
    background: none;
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    padding: 0.375rem 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    transition: all 0.15s;
}

.dark-mode-toggle:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

/* Header search */
.header-search {
    position: relative;
    max-width: 280px;
    flex: 1;
    margin: 0 1rem;
}

.header-search input {
    width: 100%;
    padding: 0.375rem 0.75rem 0.375rem 2rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--bg-subtle);
    transition: all 0.15s;
}

.header-search input:focus {
    outline: none;
    border-color: var(--brand-500);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.1);
}

.header-search input::placeholder {
    color: var(--text-disabled);
}

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

.header-search .search-shortcut {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.625rem;
    color: var(--text-disabled);
    background: var(--bg-muted);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-weight: 500;
    pointer-events: none;
}

/* ===== Content Area ===== */
.content {
    padding: 2rem;
    flex: 1;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.blue {
    background: rgba(25, 118, 210, 0.12);
    color: #1976D2;
    border: 1px solid rgba(25, 118, 210, 0.15);
}

.stat-icon.green {
    background: rgba(56, 142, 60, 0.12);
    color: #388E3C;
    border: 1px solid rgba(56, 142, 60, 0.15);
}

.stat-icon.purple {
    background: rgba(123, 31, 162, 0.12);
    color: #7B1FA2;
    border: 1px solid rgba(123, 31, 162, 0.15);
}

.stat-icon.orange {
    background: rgba(245, 124, 0, 0.12);
    color: #F57C00;
    border: 1px solid rgba(245, 124, 0, 0.15);
}

.stat-icon.red {
    background: rgba(211, 47, 47, 0.12);
    color: #D32F2F;
    border: 1px solid rgba(211, 47, 47, 0.15);
}

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

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

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-700);
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Cards ===== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

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

.card-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1rem 1.25rem;
}

/* ===== Tables ===== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-default);
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--bg-subtle);
    border-bottom: 2px solid var(--border-default);
}

.table tbody tr:nth-child(even) {
    background: var(--bg-app);
}

.table tbody tr:hover {
    background: var(--brand-50);
}

.table .text-right {
    text-align: right;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem !important;
}

/* ===== Status Badges ===== */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-badge.borrador {
    background: rgba(84, 110, 122, 0.12);
    color: #546E7A;
    border: 1px solid rgba(84, 110, 122, 0.15);
}

.status-badge.enviado {
    background: rgba(25, 118, 210, 0.12);
    color: #1976D2;
    border: 1px solid rgba(25, 118, 210, 0.15);
}

.status-badge.aceptado {
    background: rgba(56, 142, 60, 0.12);
    color: #388E3C;
    border: 1px solid rgba(56, 142, 60, 0.15);
}

.status-badge.rechazado {
    background: rgba(198, 40, 40, 0.12);
    color: #C62828;
    border: 1px solid rgba(198, 40, 40, 0.15);
}

.status-badge.facturado {
    background: rgba(123, 31, 162, 0.12);
    color: #7B1FA2;
    border: 1px solid rgba(123, 31, 162, 0.15);
}

/* ===== Status List ===== */
.status-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.status-dot.borrador { background: #90A4AE; }
.status-dot.enviado { background: #42A5F5; }
.status-dot.aceptado { background: #66BB6A; }
.status-dot.rechazado { background: #EF5350; }
.status-dot.facturado { background: #AB47BC; }

.status-name {
    flex: 1;
    color: var(--gray-700);
}

.status-count {
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Filters Bar ===== */
.filters-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-box {
    flex: 1;
    max-width: 400px;
    position: relative;
}

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

.search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: all 0.15s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.1);
}

.search-box-small {
    flex: 0 0 200px;
    max-width: 200px;
}

.filter-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--bg-surface);
    min-width: 160px;
    transition: all 0.15s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.1);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn i[class*="ph-"] {
    font-size: 1rem;
    margin-right: 0.375rem;
}

.btn-primary {
    background: var(--brand-600);
    color: white;
}

.btn-primary:hover {
    background: var(--brand-500);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #B91C1C;
}

/* Button loading state */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    top: 50%;
    left: 50%;
    margin: -7px 0 0 -7px;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 0.5rem;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.35);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(0, 0, 0, 0.12);
    color: var(--primary);
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

.action-btn i[class*="ph-"] {
    font-size: 1rem;
}

/* ===== Catalog Grid ===== */
.catalogo-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.categoria-section {
    background: var(--glass-medium);
    backdrop-filter: var(--blur-light);
    -webkit-backdrop-filter: var(--blur-light);
    border: var(--border-glass);
    border-radius: var(--radius);
    box-shadow: var(--shadow-glass);
    overflow: hidden;
}

.categoria-header {
    padding: 1rem 1.5rem;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.categoria-header:hover {
    background: var(--primary-dark);
}

.categoria-toggle {
    font-size: 0.75rem;
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.categoria-header h3 {
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
}

.categoria-count {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-left: auto;
}

.categoria-content {
    display: none;
    padding: 0;
}

.categoria-content.expanded {
    display: block;
}

.trabajos-lista {
    padding: 0;
}

.load-more-btn {
    display: block;
    width: 100%;
    font-size: 0.875rem;
    padding: 0.75rem;
    background: var(--glass-subtle);
    border: none;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.load-more-btn:hover:not(:disabled) {
    background: var(--glass-light);
}

.load-more-btn:disabled {
    color: var(--text-muted);
    cursor: wait;
}

.trabajos-count-footer {
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--glass-subtle);
}

.loading-spinner {
    padding: 2rem;
    text-align: center;
    color: var(--text-primary);
}

.search-results-header {
    padding: 0.75rem 1rem;
    background: rgba(25, 118, 210, 0.85);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    color: white;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.categoria-section.search-result .categoria-header {
    cursor: default;
}

.categoria-section.search-result .categoria-header:hover {
    background: var(--primary);
}

.clear-search-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.5);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    margin-left: 1rem;
}

.clear-search-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--glass-medium);
    backdrop-filter: var(--blur-light);
    -webkit-backdrop-filter: var(--blur-light);
    border: var(--border-glass);
    border-radius: var(--radius);
    box-shadow: var(--shadow-glass);
}

.page-numbers {
    display: flex;
    gap: 0.25rem;
}

.page-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.60);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

.page-btn.nav-btn {
    padding: 0.5rem 1rem;
}

.page-ellipsis {
    padding: 0.5rem 0.25rem;
    color: var(--text-muted);
}

.pagination-info {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.trabajo-item {
    display: grid;
    grid-template-columns: 80px 1fr 80px 100px 60px 80px;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    align-items: center;
}

.trabajo-item:last-child {
    border-bottom: none;
}

.trabajo-codigo {
    font-family: monospace;
    font-weight: 600;
    color: var(--primary);
}

.trabajo-descripcion {
    color: var(--text-primary);
}

.trabajo-unidad,
.trabajo-iva {
    color: var(--gray-700);
    font-size: 0.875rem;
    text-align: center;
}

.trabajo-precio {
    font-weight: 600;
    text-align: right;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border-default);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--bg-subtle);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: all 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
}

/* Form field error state */
.form-field.error .form-input,
.form-field.error .form-select,
.form-field.error .form-textarea {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.field-error {
    font-size: 0.6875rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* Form section */
.form-section {
    margin-bottom: 1.5rem;
}

.form-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-default);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Color Picker Options */
.color-picker-options {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    padding: 0;
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-option.selected {
    border-color: var(--gray-800);
    box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--gray-400);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

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

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.875rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 420px;
    animation: slideIn 0.3s ease;
    position: relative;
    overflow: hidden;
}

.toast-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

/* Toast progress bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    animation: toastProgress 5s linear forwards;
}

.toast.success .toast-progress { background: var(--success); }
.toast.error .toast-progress { background: var(--danger); }
.toast.warning .toast-progress { background: var(--warning); }
.toast.info .toast-progress { background: var(--info); }

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* Toast undo action */
.toast-undo {
    background: none;
    border: none;
    color: var(--brand-500);
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.toast-undo:hover {
    background: var(--brand-50);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

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

.toast.warning {
    border-left: 4px solid var(--warning);
}

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

.toast-message {
    flex: 1;
}

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

/* ===== Tipo Badge ===== */
.tipo-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.tipo-badge.particular {
    background: rgba(46, 125, 50, 0.12);
    color: #2E7D32;
    border: 1px solid rgba(46, 125, 50, 0.15);
}

.tipo-badge.empresa {
    background: rgba(21, 101, 192, 0.12);
    color: #1565C0;
    border: 1px solid rgba(21, 101, 192, 0.15);
}

.tipo-badge.comunidad {
    background: rgba(239, 108, 0, 0.12);
    color: #EF6C00;
    border: 1px solid rgba(239, 108, 0, 0.15);
}

/* ===== Utilities ===== */
.link {
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
}

.link:hover {
    color: var(--primary-dark);
}

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

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--error);
}

.text-error {
    color: var(--error);
}

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

.text-right {
    text-align: right;
}

.span-full {
    grid-column: 1 / -1;
}

/* ===== Badge (generic) ===== */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(69, 90, 100, 0.12);
    color: #455A64;
    border: 1px solid rgba(69, 90, 100, 0.15);
}

/* ===== Button variants (unified) ===== */
.btn-success {
    background: rgba(56, 142, 60, 0.90);
    color: white;
}

.btn-success:hover {
    background: #2E7D32;
}

.btn-icon {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(0, 0, 0, 0.12);
    color: var(--primary);
}

.btn-icon.btn-danger {
    background: rgba(198, 40, 40, 0.12);
    color: #C62828;
    border-color: rgba(198, 40, 40, 0.10);
}

.btn-icon.btn-danger:hover {
    background: rgba(198, 40, 40, 0.20);
}

.btn-icon.btn-success {
    background: rgba(46, 125, 50, 0.12);
    color: #2E7D32;
    border-color: rgba(46, 125, 50, 0.10);
}

.btn-icon.btn-success:hover {
    background: rgba(46, 125, 50, 0.20);
}

.btn-icon i[class*="ph-"] {
    font-size: 1rem;
}

/* ===== Focus Visible (Accessibility) ===== */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn:focus-visible,
.action-btn:focus-visible,
.btn-icon:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.15);
}

.nav-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible,
.filter-select:focus-visible,
.filter-input:focus-visible {
    outline: none;
}

/* ===== Reusable Modal/Detail Layout Classes ===== */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.detail-header h3,
.detail-header h4 {
    margin: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.detail-grid.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.detail-grid .span-2 {
    grid-column: span 2;
}

.detail-field-label {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.detail-field-value {
    margin: 0;
}

.detail-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    text-align: center;
}

.detail-stat {
    text-align: center;
}

.detail-stat .label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.total-row {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.total-row td {
    color: white !important;
}

.section-actions {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.summary-totals {
    width: 60%;
    margin-left: auto;
}

.editor-totals {
    width: 50%;
    margin-left: auto;
    margin-top: 1.5rem;
}

.presupuesto-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.cost-chart-bar {
    height: 24px;
    display: flex;
    border-radius: 4px;
    overflow: hidden;
}

.cost-chart-legend {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 11px;
    flex-wrap: wrap;
}

.cost-chart-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 4px;
}

.detail-avatar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-avatar h3,
.detail-avatar h4 {
    margin: 0;
}

.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.detail-divider {
    margin: 1rem 0;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.resumen-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.progress-text {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.costes-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1rem;
}

.stat-value-large {
    font-size: 1.25rem;
}

.info-table-total {
    font-weight: bold;
    border-top: 2px solid var(--border);
}

.pre-wrap {
    white-space: pre-wrap;
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.input-with-action {
    display: flex;
    gap: 0.5rem;
}

.input-with-action > :first-child {
    flex: 1;
}

.autosave-indicator {
    font-size: 0.75rem;
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 1rem; }
.mb-15 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 1rem; }
.mt-15 { margin-top: 1.5rem; }

/* ===== Loading State ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: var(--blur-medium);
    -webkit-backdrop-filter: var(--blur-medium);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 500;
}

/* ===== Sortable Table ===== */
.sortable-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem;
}

.sortable-table th.sortable:hover {
    background: var(--glass-primary);
}

.sortable-table th.sortable::after {
    content: '';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text-muted);
    opacity: 0.3;
}

.sortable-table th.sortable.asc::after {
    border-top-color: var(--primary);
    opacity: 1;
}

.sortable-table th.sortable.desc::after {
    border-top: none;
    border-bottom: 4px solid var(--primary);
    opacity: 1;
}

/* ===== Filter Input ===== */
.filter-input {
    padding: 0.75rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    transition: all 0.2s ease;
}

.filter-input:focus {
    outline: none;
    border-color: rgba(46, 125, 50, 0.5);
    background: rgba(255, 255, 255, 0.85);
}

/* ===== Draggable ===== */
.draggable {
    cursor: move;
}

.draggable.dragging {
    opacity: 0.5;
    background: var(--glass-light);
}

.drag-handle {
    cursor: move;
    color: var(--text-muted);
    padding: 0.25rem;
}

.drag-handle:hover {
    color: var(--text-primary);
}

/* Legacy responsive - moved to bottom */

/* ===== Obras Module Styles ===== */

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 1rem;
}

.tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: rgba(255, 255, 255, 0.30);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.tab:hover {
    color: var(--primary-dark);
    background: rgba(255, 255, 255, 0.50);
}

.tab.active {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.45);
    border-bottom-color: var(--primary);
}

/* Progress bar */
.progress-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.progress-bar-large {
    height: 24px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: inherit;
    transition: width 0.3s ease;
}

/* Rentabilidad indicators */
.rentabilidad-ok {
    color: var(--success);
}

.rentabilidad-warning {
    color: var(--warning);
}

.rentabilidad-danger {
    color: var(--error);
}

/* Gallery for photos */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-glass);
}

.gallery-item:hover {
    box-shadow: var(--shadow-glass-lg);
}

.gallery-delete {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-item:hover .gallery-delete {
    opacity: 1;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.lightbox img {
    max-width: 90%;
    max-height: 80%;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
}

/* Info table */
.info-table {
    width: 100%;
}

.info-table td {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.info-table td:first-child {
    width: 40%;
}

/* Obra status badges */
.status-badge.en_ejecucion {
    background: rgba(46, 125, 50, 0.12);
    color: #2E7D32;
    border: 1px solid rgba(46, 125, 50, 0.15);
}

.status-badge.pausada {
    background: rgba(239, 108, 0, 0.12);
    color: #EF6C00;
    border: 1px solid rgba(239, 108, 0, 0.15);
}

.status-badge.finalizada {
    background: rgba(21, 101, 192, 0.12);
    color: #1565C0;
    border: 1px solid rgba(21, 101, 192, 0.15);
}

.status-badge.garantia {
    background: rgba(123, 31, 162, 0.12);
    color: #7B1FA2;
    border: 1px solid rgba(123, 31, 162, 0.15);
}

/* Certificacion status badges */
.status-badge.emitida {
    background: rgba(46, 125, 50, 0.12);
    color: #2E7D32;
    border: 1px solid rgba(46, 125, 50, 0.15);
}

.status-badge.cobrada {
    background: rgba(21, 101, 192, 0.12);
    color: #1565C0;
    border: 1px solid rgba(21, 101, 192, 0.15);
}

/* Tipo badges additional styles */
.tipo-badge.warning {
    background: rgba(239, 108, 0, 0.12);
    color: #EF6C00;
    border: 1px solid rgba(239, 108, 0, 0.15);
}

.tipo-badge.info {
    background: rgba(21, 101, 192, 0.12);
    color: #1565C0;
    border: 1px solid rgba(21, 101, 192, 0.15);
}

/* Success action button */
.action-btn.btn-success {
    background: rgba(46, 125, 50, 0.12);
    color: #2E7D32;
}

.action-btn.btn-success:hover {
    background: rgba(46, 125, 50, 0.2);
}

/* Primary action button */
.action-btn.btn-primary {
    background: rgba(21, 101, 192, 0.12);
    color: #1565C0;
}

.action-btn.btn-primary:hover {
    background: rgba(21, 101, 192, 0.2);
}

/* Danger action button */
.action-btn.btn-danger {
    background: rgba(198, 40, 40, 0.12);
    color: #C62828;
}

.action-btn.btn-danger:hover {
    background: rgba(198, 40, 40, 0.2);
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}

.breadcrumbs a {
    color: var(--primary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs .separator {
    margin: 0 0.5rem;
    color: var(--text-muted);
}

.breadcrumbs .current {
    color: var(--text-primary);
    font-weight: 500;
}

/* Alert styles for dashboard */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    border: 1px solid;
}

.alert-info {
    background: rgba(21, 101, 192, 0.08);
    color: #1565C0;
    border-color: rgba(21, 101, 192, 0.15);
}

.alert-warning {
    background: rgba(239, 108, 0, 0.08);
    color: #EF6C00;
    border-color: rgba(239, 108, 0, 0.15);
}

.alert-error {
    background: rgba(198, 40, 40, 0.08);
    color: #C62828;
    border-color: rgba(198, 40, 40, 0.15);
}

/* ===== BCCA Explorer ===== */
.bcca-explorer {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1rem;
    height: calc(100vh - 280px);
    min-height: 400px;
}

.bcca-panel-left,
.bcca-panel-right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bcca-panel-left .card-body,
.bcca-panel-right .card-body {
    flex: 1;
    overflow-y: auto;
}

/* Capitulos Tree */
.capitulo-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.capitulo-item:hover {
    background: var(--glass-primary);
}

.capitulo-item.selected {
    background: rgba(46, 125, 50, 0.85);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    color: white;
    border-radius: var(--radius-sm);
}

.capitulo-item.selected .capitulo-codigo,
.capitulo-item.selected .text-muted {
    color: rgba(255,255,255,0.8);
}

.capitulo-toggle {
    width: 16px;
    min-width: 16px;
    font-family: monospace;
    font-size: 0.7rem;
    text-align: center;
    color: var(--text-secondary);
    cursor: pointer;
}

.capitulo-content {
    flex: 1;
    min-width: 0;
}

.capitulo-codigo {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

.capitulo-nombre {
    font-size: 0.875rem;
    line-height: 1.4;
}

.capitulo-hijos {
    margin-left: 0;
}

/* Partidas Table in BCCA */
.bcca-panel-right .data-table {
    font-size: 0.875rem;
}

.bcca-panel-right .data-table td {
    vertical-align: top;
}

.bcca-panel-right .descripcion-cell {
    max-width: 400px;
}

/* Partida Detalle Modal */
.partida-detalle {
    max-height: 70vh;
    overflow-y: auto;
}

.partida-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.partida-codigo code {
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    background: var(--glass-light);
    border-radius: var(--radius-sm);
}

.partida-info {
    margin-bottom: 1.5rem;
}

.partida-info p {
    margin-bottom: 0.5rem;
}

/* Descompuesto Table */
.data-table-sm {
    font-size: 0.8rem;
}

.data-table-sm th,
.data-table-sm td {
    padding: 0.4rem 0.5rem;
}

/* Tipo badges for descompuestos */
.tipo-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 3px;
    text-transform: uppercase;
}

.tipo-badge.mano_obra,
.tipo-badge.mano-obra {
    background: rgba(21, 101, 192, 0.12);
    color: #1565C0;
    border: 1px solid rgba(21, 101, 192, 0.12);
}

.tipo-badge.material {
    background: rgba(46, 125, 50, 0.12);
    color: #2E7D32;
    border: 1px solid rgba(46, 125, 50, 0.12);
}

.tipo-badge.maquinaria {
    background: rgba(239, 108, 0, 0.12);
    color: #EF6C00;
    border: 1px solid rgba(239, 108, 0, 0.12);
}

.tipo-badge.auxiliar {
    background: rgba(123, 31, 162, 0.12);
    color: #7B1FA2;
    border: 1px solid rgba(123, 31, 162, 0.12);
}

.tipo-badge.indirecto {
    background: rgba(84, 110, 122, 0.12);
    color: #546E7A;
    border: 1px solid rgba(84, 110, 122, 0.12);
}

.tipo-badge.partida {
    background: rgba(46, 125, 50, 0.12);
    color: #2E7D32;
    border: 1px solid rgba(46, 125, 50, 0.12);
}

.tipo-badge.simple {
    background: rgba(84, 110, 122, 0.12);
    color: #546E7A;
    border: 1px solid rgba(84, 110, 122, 0.12);
}

/* Versiones Manager */
.versiones-manager {
    max-height: 70vh;
    overflow-y: auto;
}

.versiones-list table {
    width: 100%;
    margin-bottom: 1rem;
}

.versiones-list .row-active {
    background: rgba(46, 125, 50, 0.08);
}

.versiones-import {
    padding-top: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.precio-final {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

/* BCCA responsive */
@media (max-width: 900px) {
    .bcca-explorer {
        grid-template-columns: 1fr;
        height: auto;
    }

    .bcca-panel-left {
        max-height: 300px;
    }

    .bcca-panel-right {
        max-height: 400px;
    }
}

/* ===== BCCA Integration Styles ===== */

/* BCCA badge for catalog items */
.bcca-badge {
    display: inline-block;
    background: rgba(0, 102, 204, 0.85);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Mini badge for presupuesto partidas */
.bcca-mini-badge {
    display: inline-block;
    background: rgba(0, 102, 204, 0.85);
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: 600;
    text-align: center;
    line-height: 16px;
    margin-left: 4px;
}

/* Linked to BCCA indicator */
.trabajo-item.vinculado-bcca {
    border-left: 3px solid #0066cc;
}

.trabajo-item .bcca-ref {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Partida from BCCA in presupuesto */
tr.from-bcca {
    background: linear-gradient(to right, rgba(0, 102, 204, 0.05), transparent);
}

/* Filter checkboxes */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.filter-checkbox:hover {
    border-color: rgba(46, 125, 50, 0.4);
    background: rgba(255, 255, 255, 0.80);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

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

/* Highlight search term */
mark {
    background: #fff59d;
    padding: 0 2px;
    border-radius: 2px;
}

/* Descompuesto groups in partida detail */
.descompuesto-grupo {
    margin-bottom: 1.5rem;
}

.tipo-grupo-header {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
}

.tipo-grupo-header.mano_obra {
    background: rgba(21, 101, 192, 0.1);
    color: #1565C0;
}

.tipo-grupo-header.material {
    background: rgba(46, 125, 50, 0.1);
    color: #2E7D32;
}

.tipo-grupo-header.maquinaria {
    background: rgba(239, 108, 0, 0.1);
    color: #EF6C00;
}

.tipo-grupo-header.medio_auxiliar {
    background: rgba(123, 31, 162, 0.1);
    color: #7B1FA2;
}

.tipo-grupo-header.otro {
    background: rgba(84, 110, 122, 0.1);
    color: #546E7A;
}

.subtotal-row {
    background: var(--glass-subtle);
    font-weight: 500;
}

.total-final {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-top: 1rem;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
}

.total-final .precio-total {
    font-size: 1.25rem;
    font-weight: 700;
}

/* BC3 Preview styles */
.bc3-stats {
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: flex;
    gap: 1rem;
}

.bc3-stats .stat-item {
    flex: 1;
    text-align: center;
    padding: 1rem;
    background: var(--glass-light);
    border-radius: var(--radius);
}

.bc3-stats .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.bc3-stats .stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Import result styles */
.import-result .result-stats {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.import-result .stat-item {
    text-align: center;
    padding: 1rem 1.5rem;
    background: var(--glass-light);
    border-radius: var(--radius);
}

.import-result .stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
}

.import-result .stat-value.text-success {
    color: var(--success);
}

.import-result .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.log-list {
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.75rem;
    background: var(--glass-subtle);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
}

.log-list li {
    margin-left: 1rem;
    margin-bottom: 0.25rem;
}

/* Modal large variant */
.modal.modal-large {
    max-width: 900px;
    width: 90%;
}

/* Mapeo table */
#mapeo-table .form-select {
    width: 100%;
}

/* ========================================
   PLANIFICACION MODULE - Fase 4
   ======================================== */

/* Vista Tabs */
.vista-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 0.5rem;
}

.vista-tab {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-weight: 500;
    transition: all 0.2s;
}

.vista-tab:hover {
    color: var(--primary-dark);
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(46, 125, 50, 0.25);
}

.vista-tab.active {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
    border-bottom: 2px solid var(--primary);
    margin-bottom: -2px;
}

/* Planificacion Header */
.planificacion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.planificacion-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.planificacion-nav span {
    min-width: 200px;
    text-align: center;
    font-weight: 600;
}

.planificacion-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Calendario Container */
.calendario-container {
    background: var(--glass-medium);
    backdrop-filter: var(--blur-light);
    -webkit-backdrop-filter: var(--blur-light);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    overflow: hidden;
    min-height: 400px;
    box-shadow: var(--shadow-glass);
}

/* Calendario Semana */
.calendario-semana {
    display: flex;
    flex-direction: column;
    min-height: 450px;
}

.calendario-semana .calendario-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--glass-subtle);
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.calendario-semana .calendario-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    flex: 1;
    min-height: 350px;
}

/* Header de cada dia */
.calendario-dia-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 0.5rem;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: background 0.2s;
    gap: 0.25rem;
}

.calendario-dia-header:last-child {
    border-right: none;
}

.calendario-dia-header:hover {
    background: var(--glass-light);
}

.calendario-dia-header.hoy {
    background: var(--glass-primary-medium);
}

.calendario-dia-header .dia-semana {
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendario-dia-header .dia-numero {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--gray-800);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.calendario-dia-header.hoy .dia-numero {
    background: var(--primary);
    color: white;
}

.calendario-dia-header .dia-meteo {
    font-size: 1rem;
}

/* Celda de cada dia */
.calendario-dia {
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    min-height: 120px;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.40);
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.calendario-dia:nth-child(7n) {
    border-right: none;
}

.calendario-dia:hover {
    background: rgba(255, 255, 255, 0.58);
}

.calendario-dia.hoy {
    background: var(--glass-primary);
}

.calendario-dia.fin-semana {
    background: rgba(0, 0, 0, 0.02);
}

/* Contenido vacio y boton agregar */
.dia-vacio {
    color: var(--gray-600);
    font-size: 0.75rem;
    text-align: center;
    padding: 1rem 0;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add-asignacion {
    position: absolute;
    bottom: 0.25rem;
    right: 0.25rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.calendario-dia:hover .btn-add-asignacion {
    opacity: 1;
}

.btn-add-asignacion:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
}

/* Asignacion Bloque */
.asignacion-bloque {
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.asignacion-bloque:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.asignacion-bloque .asignacion-obra {
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asignacion-bloque .asignacion-recurso {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asignacion-bloque .asignacion-nombre {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asignacion-bloque .asignacion-horas {
    font-size: 0.65rem;
    color: var(--gray-700);
    font-weight: 500;
}

.mas-asignaciones {
    font-size: 0.7rem;
    color: var(--gray-700);
    text-align: center;
    padding: 0.25rem;
    cursor: pointer;
    font-weight: 500;
}

.mas-asignaciones:hover {
    color: var(--primary);
}

/* Fecha Label en navegacion */
.fecha-label {
    min-width: 220px;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--gray-800);
}

/* Planificacion Filtros */
.planificacion-filtros {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Meteo Row (semana) */
.planificacion-meteo {
    margin-bottom: 1rem;
}

.meteo-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    padding: 0.5rem;
    background: linear-gradient(135deg, rgba(227, 242, 253, 0.7), rgba(187, 222, 251, 0.7));
    backdrop-filter: var(--blur-light);
    -webkit-backdrop-filter: var(--blur-light);
    border: var(--border-glass);
    border-radius: var(--radius-md);
}

.meteo-dia {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.65);
}

.meteo-dia.alerta {
    background: rgba(255, 152, 0, 0.2);
    border: 1px solid var(--warning);
}

.meteo-dia .meteo-icono {
    font-size: 1.5rem;
}

.meteo-dia .meteo-temp {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-700);
}

/* Alertas Mini (planificacion) */
.planificacion-alertas {
    margin-bottom: 1rem;
}

.alerta-mini {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 243, 224, 0.7);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.alerta-mini .alerta-icono {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.alerta-mini .alerta-mensaje {
    flex: 1;
    font-size: 0.85rem;
    color: var(--gray-700);
}

/* Vista Dia */
.calendario-dia-detalle {
    background: var(--glass-medium);
    backdrop-filter: var(--blur-light);
    -webkit-backdrop-filter: var(--blur-light);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.dia-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dia-header h3 {
    margin: 0;
    color: var(--gray-800);
}

.dia-meteo-detalle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(227, 242, 253, 0.7), rgba(187, 222, 251, 0.7));
    backdrop-filter: var(--blur-subtle);
    -webkit-backdrop-filter: var(--blur-subtle);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.meteo-icono-grande {
    font-size: 1.75rem;
}

.dia-resumen {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.40);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.dia-resumen span {
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Asignaciones Lista (vista dia) */
.asignaciones-lista {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.asignacion-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.60);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    transition: box-shadow 0.2s;
}

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

.asignacion-card .asignacion-info {
    flex: 1;
}

.asignacion-card .asignacion-principal {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.asignacion-card .asignacion-recurso-nombre {
    font-weight: 600;
    font-size: 1rem;
}

.asignacion-card .asignacion-obra-info {
    color: var(--gray-700);
    font-size: 0.875rem;
}

.asignacion-card .asignacion-tarea {
    color: var(--gray-700);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    font-style: italic;
}

.asignacion-card .asignacion-horas-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.asignacion-card .horas-plan {
    font-weight: 600;
    font-size: 1rem;
    color: var(--gray-800);
}

.asignacion-card .horas-real {
    font-size: 0.85rem;
    color: var(--success);
}

.asignacion-card .asignacion-actions {
    display: flex;
    gap: 0.25rem;
}

/* Cuadrilla Bloque (en calendario semanal) */
.cuadrilla-bloque {
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.7)) !important;
}

.cuadrilla-bloque .cuadrilla-icon {
    font-weight: 600;
}

/* Cuadrilla Card (en vista dia) */
.cuadrilla-card {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.60);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.cuadrilla-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.cuadrilla-titulo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.cuadrilla-titulo .cuadrilla-icon {
    font-size: 1.2rem;
}

.cuadrilla-total {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.cuadrilla-miembros-lista {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cuadrilla-miembro {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.cuadrilla-miembro .miembro-nombre {
    font-weight: 500;
    min-width: 120px;
}

.cuadrilla-miembro .miembro-horas {
    font-weight: 600;
    color: var(--primary);
    margin-left: auto;
}

.cuadrilla-miembro .miembro-tarea {
    flex-basis: 100%;
    font-size: 0.8rem;
    color: var(--gray-700);
    font-style: italic;
    margin-top: 0.25rem;
}

.badge-sm {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
}

.btn-xs {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}

.dia-asignaciones-lista {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.asignacion-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
    border-left: 4px solid;
}

.asignacion-item .trabajador-info {
    flex: 1;
}

.asignacion-item .trabajador-nombre {
    font-weight: 600;
}

.asignacion-item .obra-info {
    color: var(--gray-700);
    font-size: 0.875rem;
}

/* Trabajador Color Circle */
.trabajador-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.trabajador-color-large {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Alertas Badge */
.alertas-badge {
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.5rem;
    font-weight: 600;
}

/* Alerta Item */
.alerta-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.60);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 0.5rem;
    transition: background 0.2s;
}

.alerta-item.no-leida {
    background: rgba(255, 243, 224, 0.7);
    border-color: var(--warning);
}

.alerta-item .alerta-icono {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.alerta-item .alerta-contenido {
    flex: 1;
}

.alerta-item .alerta-mensaje {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.alerta-item .alerta-fecha {
    font-size: 0.8rem;
    color: var(--gray-700);
}

.alerta-item .alerta-actions {
    display: flex;
    gap: 0.5rem;
}

/* Cuadrante */
.cuadrante-modal {
    max-height: 70vh;
    overflow-y: auto;
}

.cuadrante-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.cuadrante-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cuadrante-resumen {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
}

.resumen-item {
    text-align: center;
}

.resumen-valor {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.resumen-label {
    font-size: 0.8rem;
    color: var(--gray-700);
}

.cuadrante-tabla-container {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.cuadrante-tabla {
    width: 100%;
    font-size: 0.875rem;
}

.horas-real-input {
    width: 60px;
    padding: 0.25rem 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-sm);
    text-align: center;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.65);
}

.horas-real-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Gantt / Cronograma */
.cronograma-modal {
    max-height: 70vh;
    overflow-y: auto;
}

.cronograma-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.cronograma-actions {
    display: flex;
    gap: 0.5rem;
}

.cronograma-progreso {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.progreso-bar {
    flex: 1;
    min-width: 200px;
    height: 8px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    overflow: hidden;
}

.progreso-fill {
    height: 100%;
    background: var(--success);
    border-radius: 4px;
    transition: width 0.3s;
}

.fase-actual {
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 500;
}

.gantt-container {
    background: var(--glass-medium);
    backdrop-filter: var(--blur-light);
    -webkit-backdrop-filter: var(--blur-light);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.gantt {
    position: relative;
    min-height: 200px;
}

.gantt-header {
    display: flex;
    background: var(--glass-subtle);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-weight: 600;
    font-size: 0.8rem;
}

.gantt-fase-header {
    width: 200px;
    padding: 0.75rem;
    flex-shrink: 0;
}

.gantt-timeline-header {
    flex: 1;
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    color: var(--gray-800);
}

.gantt-body {
    position: relative;
}

.gantt-row {
    display: flex;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    min-height: 40px;
}

.gantt-row.completada {
    background: rgba(56, 142, 60, 0.06);
}

.gantt-fase-info {
    width: 200px;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.fase-orden {
    background: var(--glass-light);
    color: var(--gray-700);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.fase-nombre {
    flex: 1;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fase-duracion {
    font-size: 0.75rem;
    color: var(--gray-700);
}

.gantt-timeline {
    flex: 1;
    position: relative;
    padding: 0.5rem;
    display: flex;
    align-items: center;
}

.gantt-barra {
    position: absolute;
    height: 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.gantt-barra .check {
    font-size: 1rem;
}

.sin-fechas {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

.gantt-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 0.5rem;
}

.gantt-hoy {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--danger);
    z-index: 10;
}

.gantt-hoy::before {
    content: 'Hoy';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--danger);
    font-weight: 600;
}

/* Fases Lista (sin fechas) */
.fases-lista {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fase-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
}

.fase-item.completada {
    background: rgba(56, 142, 60, 0.06);
}

.fase-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fase-check {
    color: var(--success);
    font-weight: bold;
}

/* Meteo Widget */
.meteo-widget {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(135, 206, 235, 0.7), rgba(70, 130, 180, 0.7));
    backdrop-filter: var(--blur-light);
    -webkit-backdrop-filter: var(--blur-light);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    color: white;
    margin-bottom: 1rem;
}

.meteo-widget .meteo-icono {
    font-size: 2.5rem;
}

.meteo-widget .meteo-temp {
    font-size: 2rem;
    font-weight: 700;
}

.meteo-widget .meteo-desc {
    font-size: 0.875rem;
    opacity: 0.9;
}

.meteo-widget .meteo-extra {
    font-size: 0.8rem;
    opacity: 0.8;
}

.meteo-alerta {
    background: var(--warning);
    color: var(--gray-900);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Stats Mini */
.stats-mini {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.stat-mini {
    text-align: center;
    padding: 0.5rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
}

.stat-mini .stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-mini .stat-label {
    font-size: 0.75rem;
    color: var(--gray-700);
}

/* Asignacion Form */
.asignacion-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Vista Mes Placeholder */
.calendario-mes-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--gray-700);
    gap: 1rem;
}

.calendario-mes-placeholder p {
    margin: 0;
    font-size: 1rem;
}

/* Asignacion Detalle Modal */
.asignacion-detalle {
    padding: 0.5rem;
}

.asignacion-detalle .info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
}

/* ===== Phosphor Icons Integration ===== */
.nav-link i[class*="ph-"] {
    font-size: 1.25rem;
}

.stat-icon i[class*="ph-"] {
    font-size: 1.5rem;
}

.action-btn i[class*="ph-"] {
    font-size: 1rem;
}

/* ===== Mobile responsive for planificacion ===== */
@media (max-width: 768px) {
    .asignacion-form-row {
        grid-template-columns: 1fr;
    }

    .calendario-semana .calendario-header,
    .calendario-semana .calendario-body {
        grid-template-columns: repeat(7, minmax(40px, 1fr));
        overflow-x: auto;
    }

    .calendario-dia {
        min-height: 100px;
        padding: 0.35rem;
    }

    .calendario-dia-header {
        padding: 0.5rem 0.25rem;
    }

    .calendario-dia-header .dia-semana {
        font-size: 0.6rem;
    }

    .calendario-dia-header .dia-numero {
        font-size: 1rem;
        width: 26px;
        height: 26px;
    }

    .asignacion-bloque {
        padding: 0.25rem;
        font-size: 0.65rem;
    }

    .asignacion-bloque .asignacion-recurso {
        display: none;
    }

    .gantt-fase-info {
        width: 120px;
    }

    .planificacion-header {
        flex-direction: column;
        align-items: stretch;
    }

    .planificacion-nav {
        justify-content: center;
    }

    .vista-tabs {
        justify-content: center;
    }

    .planificacion-filtros {
        justify-content: center;
    }

    .meteo-row {
        grid-template-columns: repeat(7, 1fr);
        gap: 0.25rem;
        padding: 0.25rem;
    }

    .meteo-dia {
        padding: 0.25rem;
    }

    .meteo-dia .meteo-icono {
        font-size: 1.2rem;
    }

    .meteo-dia .meteo-temp {
        font-size: 0.75rem;
    }

    .cuadrante-resumen {
        flex-wrap: wrap;
    }

    .asignacion-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .asignacion-card .asignacion-horas-info {
        flex-direction: row;
        gap: 1rem;
    }
}

/* ===== Proveedores y Compras (Fase 5) ===== */

/* Tabs reutilizables */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
}

.tabs .tab {
    padding: 0.625rem 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.tabs .tab:hover {
    color: var(--text-primary);
}

.tabs .tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Pedido editor grid layout */
.pedido-editor-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 900px) {
    .pedido-editor-grid {
        grid-template-columns: 1fr;
    }
}

/* Resumen grid para productos */
.resumen-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.resumen-grid .span-full {
    grid-column: 1 / -1;
}

@media (max-width: 768px) {
    .resumen-grid {
        grid-template-columns: 1fr;
    }
}

/* Price chart SVG */
.price-chart {
    display: block;
    margin: 0 auto;
}

/* Estado badges para pedidos */
.status-badge.borrador {
    background: rgba(158, 158, 158, 0.15);
    color: #616161;
}

.status-badge.enviado {
    background: rgba(33, 150, 243, 0.15);
    color: #1565C0;
}

.status-badge.recibido_parcial {
    background: rgba(255, 152, 0, 0.15);
    color: #E65100;
}

.status-badge.recibido {
    background: rgba(76, 175, 80, 0.15);
    color: #2E7D32;
}

.status-badge.cancelado {
    background: rgba(244, 67, 54, 0.15);
    color: #C62828;
}

/* Info table total row */
.info-table-total {
    border-top: 2px solid var(--primary);
}

.info-table-total td {
    padding-top: 0.5rem;
}

/* ===== Responsive Tablet - Fase 5 ===== */
@media (max-width: 1024px) {
    .pedido-editor-grid {
        grid-template-columns: 1fr;
    }

    .resumen-grid {
        grid-template-columns: 1fr;
    }

    .filters-bar {
        flex-wrap: wrap;
    }

    .filters-bar .search-box,
    .filters-bar .form-select,
    .filters-bar .filter-input {
        min-width: 150px;
        flex: 1 1 auto;
    }
}

@media (max-width: 768px) {
    .pedido-editor-grid {
        grid-template-columns: 1fr;
    }

    /* Tablas con scroll horizontal en tablet/movil */
    .table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .detail-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .tab {
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

/* ========================================
   TAREAS DE OBRA - Fase 4.1
   ======================================== */

/* Prioridad Badges */
.prioridad-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 3px;
    text-transform: uppercase;
}

.prioridad-badge.alta {
    background: rgba(198, 40, 40, 0.15);
    color: #C62828;
    border: 1px solid rgba(198, 40, 40, 0.2);
}

.prioridad-badge.media {
    background: rgba(239, 108, 0, 0.15);
    color: #EF6C00;
    border: 1px solid rgba(239, 108, 0, 0.2);
}

.prioridad-badge.baja {
    background: rgba(46, 125, 50, 0.15);
    color: #2E7D32;
    border: 1px solid rgba(46, 125, 50, 0.2);
}

/* Estado badges para tareas */
.status-badge.pendiente {
    background: rgba(158, 158, 158, 0.15);
    color: #616161;
    border: 1px solid rgba(158, 158, 158, 0.2);
}

.status-badge.en_progreso {
    background: rgba(33, 150, 243, 0.15);
    color: #1565C0;
    border: 1px solid rgba(33, 150, 243, 0.2);
}

.status-badge.completada {
    background: rgba(76, 175, 80, 0.15);
    color: #2E7D32;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.status-badge.bloqueada {
    background: rgba(198, 40, 40, 0.15);
    color: #C62828;
    border: 1px solid rgba(198, 40, 40, 0.2);
}

/* Tareas Grid (cards en obra) */
.tareas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.tarea-card {
    background: rgba(255, 255, 255, 0.60);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: box-shadow 0.2s;
}

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

.tarea-card.tarea-vencida {
    border-left: 3px solid #C62828;
}

.tarea-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.tarea-card-titulo {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.tarea-card-fechas {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tarea-card-responsables {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.tarea-card-actions {
    display: flex;
    gap: 0.5rem;
}

/* Responsable Chip */
.responsable-chip {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-primary);
}

.responsable-chip-removable {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.5rem;
    background: var(--glass-subtle);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    margin-right: 0.25rem;
}

.responsable-chip-removable button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.responsable-chip-removable button:hover {
    color: #C62828;
}

/* Responsables Grid (checkboxes en formulario) */
.responsables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.25rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Tarea Detalle */
.tarea-detalle {
    max-height: 75vh;
    overflow-y: auto;
}

.tarea-detalle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Comentario Item */
.comentario-item {
    padding: 0.75rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--primary);
}

.comentario-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.comentario-header button {
    margin-left: auto;
}

.comentario-item p {
    margin: 0;
    font-size: 0.9rem;
}

/* Documento Item */
.documento-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--glass-subtle);
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
}

.documento-item span:first-child {
    flex: 1;
    font-size: 0.875rem;
}

/* Tarea Bloque (en calendario semanal) */
.tarea-bloque {
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
    font-size: 0.65rem;
    cursor: pointer;
    transition: transform 0.1s;
    border-left: 3px solid;
}

.tarea-bloque:hover {
    transform: translateY(-1px);
}

.tarea-bloque-alta {
    background: rgba(198, 40, 40, 0.1);
    border-color: #C62828;
}

.tarea-bloque-media {
    background: rgba(239, 108, 0, 0.1);
    border-color: #EF6C00;
}

.tarea-bloque-baja {
    background: rgba(46, 125, 50, 0.1);
    border-color: #2E7D32;
}

.tarea-bloque-titulo {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Tarea row vencida en tabla */
.tarea-row-vencida {
    background: rgba(198, 40, 40, 0.05);
}

@media (max-width: 768px) {
    .tareas-grid {
        grid-template-columns: 1fr;
    }

    .responsables-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   SLIDE PANEL
   ======================================== */

.slide-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 190;
    display: none;
}

.slide-panel-overlay.active {
    display: block;
}

.slide-panel {
    position: fixed;
    top: 0;
    right: -500px;
    width: 480px;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-default);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-panel.open {
    right: 0;
}

.slide-panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.slide-panel-header h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0;
}

.slide-panel-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 1.375rem;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-panel-close:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.slide-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

.slide-panel-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border-default);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--bg-subtle);
    flex-shrink: 0;
}

/* ========================================
   COMMAND PALETTE
   ======================================== */

.command-palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.command-palette-overlay.active {
    display: flex;
}

.command-palette {
    width: 100%;
    max-width: 560px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.command-palette input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    border-bottom: 1px solid var(--border-default);
    font-size: 1rem;
    color: var(--text-primary);
    background: transparent;
    outline: none;
}

.command-palette input::placeholder {
    color: var(--text-disabled);
}

.command-palette-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 0.5rem;
}

.command-palette-group {
    padding: 0.25rem 0;
}

.command-palette-group-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 0.375rem 0.75rem;
}

.command-palette-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background 0.1s;
}

.command-palette-item:hover,
.command-palette-item.active {
    background: var(--brand-50);
}

.command-palette-item i {
    color: var(--text-tertiary);
    font-size: 1rem;
}

.command-palette-item .item-meta {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.command-palette-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* ========================================
   STATUS PILL BADGES (nuevo diseño)
   ======================================== */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-pill.borrador { background: #F1F5F9; color: #64748B; }
.status-pill.enviado { background: #EFF6FF; color: #3B82F6; }
.status-pill.aceptado { background: #ECFDF5; color: #059669; }
.status-pill.rechazado { background: #FEF2F2; color: #EF4444; }
.status-pill.facturado { background: #F5F3FF; color: #7C3AED; }
.status-pill.en_ejecucion { background: #ECFDF5; color: #059669; }
.status-pill.pausada { background: #FFFBEB; color: #D97706; }
.status-pill.finalizada { background: #EFF6FF; color: #2563EB; }
.status-pill.garantia { background: #F5F3FF; color: #7C3AED; }
.status-pill.emitida { background: #ECFDF5; color: #059669; }
.status-pill.cobrada { background: #EFF6FF; color: #2563EB; }
.status-pill.pendiente { background: #F1F5F9; color: #64748B; }
.status-pill.en_progreso { background: #EFF6FF; color: #3B82F6; }
.status-pill.completada { background: #ECFDF5; color: #059669; }
.status-pill.bloqueada { background: #FEF2F2; color: #EF4444; }
.status-pill.cancelado { background: #FEF2F2; color: #EF4444; }
.status-pill.recibido { background: #ECFDF5; color: #059669; }
.status-pill.recibido_parcial { background: #FFFBEB; color: #D97706; }
.status-pill.activo { background: #ECFDF5; color: #059669; }
.status-pill.inactivo { background: #FEF2F2; color: #EF4444; }

/* Dark mode pills */
[data-theme="dark"] .status-pill.borrador { background: #1E293B; color: #94A3B8; }
[data-theme="dark"] .status-pill.enviado { background: #1E3A5F; color: #60A5FA; }
[data-theme="dark"] .status-pill.aceptado { background: #064E3B; color: #34D399; }
[data-theme="dark"] .status-pill.rechazado { background: #450A0A; color: #FCA5A5; }
[data-theme="dark"] .status-pill.facturado { background: #2E1065; color: #C4B5FD; }

/* ========================================
   KPI CARDS
   ======================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

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

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.kpi-icon.blue { background: #EFF6FF; color: #3B82F6; }
.kpi-icon.green { background: #ECFDF5; color: #059669; }
.kpi-icon.orange { background: #FFFBEB; color: #D97706; }
.kpi-icon.purple { background: #F5F3FF; color: #7C3AED; }
.kpi-icon.red { background: #FEF2F2; color: #EF4444; }

[data-theme="dark"] .kpi-icon.blue { background: #1E3A5F; }
[data-theme="dark"] .kpi-icon.green { background: #064E3B; }
[data-theme="dark"] .kpi-icon.orange { background: #451A03; }
[data-theme="dark"] .kpi-icon.purple { background: #2E1065; }
[data-theme="dark"] .kpi-icon.red { background: #450A0A; }

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

.kpi-trend.trend-up { color: #059669; background: #ECFDF5; }
.kpi-trend.trend-down { color: #EF4444; background: #FEF2F2; }
.kpi-trend.trend-flat { color: #64748B; background: #F1F5F9; }

/* Sparkline (CSS-only mini bar chart) */
.sparkline {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 32px;
    margin-top: 0.75rem;
}

.sparkline-bar {
    flex: 1;
    background: var(--brand-100);
    border-radius: 2px;
    min-height: 2px;
    transition: height 0.3s;
}

.sparkline-bar:last-child {
    background: var(--brand-500);
}

/* ========================================
   EMPTY STATE
   ======================================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
}

.empty-state-icon {
    font-size: 2.5rem;
    color: var(--text-disabled);
    margin-bottom: 0.75rem;
}

.empty-state-message {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 1rem;
}

/* ========================================
   TABLE CONTAINER (sticky headers)
   ======================================== */

.table-container {
    max-height: 70vh;
    overflow-y: auto;
    border-radius: var(--radius-md);
}

.table-container .table thead {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-subtle);
}

/* ========================================
   PROGRESS BAR (new component)
   ======================================== */

.progress-bar-container {
    height: 6px;
    background: var(--bg-muted);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-bar-container .progress-bar {
    height: 100%;
    background: var(--brand-500);
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ========================================
   SIDEBAR OVERLAY (mobile)
   ======================================== */

.sidebar-mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
}

.sidebar-mobile-overlay.active {
    display: block;
}

/* ========================================
   RESPONSIVE - Mejorado
   ======================================== */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: var(--sidebar-width);
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: var(--sidebar-width);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    .header {
        padding: 0 1rem;
    }

    .header-search {
        display: none;
    }

    .content {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters-bar {
        flex-direction: column;
    }

    .search-box {
        max-width: none;
    }

    .trabajo-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    /* Slide panel full width on mobile */
    .slide-panel {
        width: 100%;
        right: -100%;
    }

    /* Table horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Minimum tap target size */
    .action-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .stats-grid,
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus trap indicators */
.slide-panel[role="dialog"]:focus,
.command-palette[role="dialog"]:focus {
    outline: none;
}

/* Aria live region */
.toast-container[aria-live="polite"] {
    pointer-events: none;
}

.toast-container > * {
    pointer-events: auto;
}

/* Focus visible improvements */
:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

.btn:focus-visible,
.action-btn:focus-visible,
.btn-icon:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(64, 145, 108, 0.15);
}

.nav-link:focus-visible {
    outline: 2px solid var(--brand-400);
    outline-offset: -2px;
}

.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible,
.filter-select:focus-visible,
.filter-input:focus-visible {
    outline: none;
}

/* ===== Print Styles ===== */
@media print {
    .sidebar, .header, .filters-bar, .action-buttons,
    .btn, .nav-link, .breadcrumbs, .slide-panel,
    .command-palette-overlay, .toast-container {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #e0e0e0 !important;
        break-inside: avoid;
    }
}
