/* ============================================================
   Circuit Service - style.css - Estilos principales
   ============================================================ */

/* ---- CSS VARIABLES ---- */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --background: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;
    --purple: #7c3aed;
    --purple-light: #ede9fe;
    --orange: #ea580c;
    --orange-light: #ffedd5;
    --sidebar-width: 256px;
    --header-height: 64px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
    --font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font);
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--background); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--secondary); }

/* ============================================================
   LAYOUT
   ============================================================ */

/* SIDEBAR */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition), width var(--transition);
    overflow: hidden;
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--header-height);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

.sidebar-logo svg {
    width: 28px;
    height: 28px;
    color: var(--primary);
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    transition: opacity var(--transition);
}

.sidebar.collapsed .logo-text { opacity: 0; width: 0; }

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover { background: var(--background); color: var(--text); }
.sidebar-toggle-btn svg { width: 18px; height: 18px; }

/* SIDEBAR NAV */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.sidebar-nav ul { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

.nav-link svg {
    width: 20px; height: 20px;
    flex-shrink: 0;
    transition: color var(--transition);
}

.nav-link span { transition: opacity var(--transition); }

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

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.sidebar.collapsed .nav-link span { opacity: 0; width: 0; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 10px; gap: 0; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-version { font-size: 0.75rem; color: var(--text-muted); }
.sidebar.collapsed .sidebar-version { display: none; }

/* OVERLAY MOBILE */
.sidebar-overlay {
    visibility: hidden;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition), visibility var(--transition);
}

.sidebar-overlay.visible { visibility: visible; opacity: 1; }

/* MAIN WRAPPER */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

.main-wrapper.sidebar-collapsed { margin-left: 72px; }

/* HEADER */
.header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 16px;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.menu-toggle-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}

.menu-toggle-btn:hover { background: var(--background); color: var(--text); }
.menu-toggle-btn svg { width: 20px; height: 20px; }

/* GLOBAL SEARCH */
.global-search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.global-search {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--text);
    font-size: 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.global-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: var(--surface);
}

.global-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 320px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.global-search-results.open { display: block; }

.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background var(--transition);
    font-size: 0.875rem;
}

.search-result-item:hover { background: var(--background); }

.search-result-item .result-type {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--primary-light);
    color: var(--primary);
    flex-shrink: 0;
}

.search-result-item .result-info strong { display: block; font-weight: 600; }
.search-result-item .result-info span { color: var(--text-muted); font-size: 0.8rem; }

.search-no-results { padding: 20px; text-align: center; color: var(--text-muted); font-size: 0.875rem; }

/* HEADER RIGHT */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    transition: background var(--transition), transform var(--transition);
    white-space: nowrap;
}

.header-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.header-btn svg { width: 16px; height: 16px; }

/* PAGE CONTENT */
.page-content {
    flex: 1;
    padding: 24px;
    overflow-x: hidden;
}

/* ============================================================
   LOADING
   ============================================================ */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
}

.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   COMPONENTS
   ============================================================ */

/* PAGE HEADER */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header-info h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.page-header-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.page-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

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

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }

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

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }

.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #0e7490; }

.btn-ghost { background: transparent; color: var(--text-secondary); padding: 7px 10px; }
.btn-ghost:hover { background: var(--background); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-sm svg { width: 14px; height: 14px; }

.btn-icon { padding: 8px; }
.btn-icon svg { margin: 0; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* CARDS */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title svg { width: 18px; height: 18px; color: var(--primary); }

.presupuesto-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}
.presupuesto-item-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.presupuesto-item-date { font-size: 0.8rem; color: var(--text-muted); }
.presupuesto-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* STAT CARDS */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: box-shadow var(--transition), transform var(--transition);
    cursor: default;
}

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

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

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

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--orange-light); color: var(--orange); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }
.stat-icon.gray { background: var(--background); color: var(--secondary); }

.stat-info { flex: 1; min-width: 0; }

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

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.3;
}

/* GRIDS */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* TABLES */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 0.875rem;
}

.table thead {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
}

.table th:hover { color: var(--primary); }
.table th.sorted { color: var(--primary); }

.table th .sort-icon {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.7rem;
    opacity: 0.5;
}

.table th.sorted .sort-icon { opacity: 1; }

.table td {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}

.table tr:hover td { background: var(--surface-2); }

.table td .td-label {
    display: none;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.table td.actions { white-space: nowrap; }

.table-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.empty-state svg {
    width: 56px; height: 56px;
    margin: 0 auto 16px;
    opacity: 0.4;
}

.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.empty-state p { font-size: 0.875rem; }

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-gray { background: var(--background); color: var(--secondary); border: 1px solid var(--border); }
.badge-cyan { background: var(--info-light); color: var(--info); }

/* FORMS */
.form { display: flex; flex-direction: column; gap: 16px; }

.form-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

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

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

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-label .required { color: var(--danger); margin-left: 3px; }

.form-control {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    width: 100%;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control.error { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-light); }
.form-control::placeholder { color: var(--text-muted); }

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

select.form-control { cursor: pointer; }

.form-hint { font-size: 0.75rem; color: var(--text-muted); }
.form-error { font-size: 0.75rem; color: var(--danger); display: none; }
.form-group.has-error .form-error { display: block; }
.form-group.has-error .form-control { border-color: var(--danger); }

/* SEARCH & FILTERS BAR */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 350px;
}

.search-input-wrapper svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px; height: 15px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
}

.filter-select:focus { border-color: var(--primary); }

.results-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: auto;
}

/* MODAL */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 500;
    opacity: 0;
    transition: opacity var(--transition);
}

.modal-backdrop.open { display: block; opacity: 1; }

.modal-container {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 501;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    flex-direction: column;
    transition: transform var(--transition), opacity var(--transition);
    opacity: 0;
}

.modal-container.open {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.modal-container.modal-lg { max-width: 800px; }
.modal-container.modal-xl { max-width: 1000px; }
.modal-container.modal-sm { max-width: 420px; }

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

.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }

.modal-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
}

.modal-close-btn:hover { background: var(--background); color: var(--danger); }
.modal-close-btn svg { width: 18px; height: 18px; }

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    max-height: calc(90dvh - 130px); /* header + footer height */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-footer:empty { display: none; }

/* CONFIRM DIALOG */
.confirm-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 600;
}

.confirm-backdrop.open { display: block; }

.confirm-dialog {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 601;
    width: 90%;
    max-width: 380px;
    padding: 28px 24px;
    text-align: center;
}

.confirm-dialog.open { display: block; }

.confirm-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--warning-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.confirm-icon svg { width: 28px; height: 28px; color: var(--warning); }

.confirm-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.confirm-message { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 24px; line-height: 1.5; }

.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* TOAST */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 700;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border-left: 4px solid;
    min-width: 280px;
    max-width: 380px;
    pointer-events: all;
    animation: toastIn 0.3s ease forwards;
    position: relative;
    overflow: hidden;
}

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

@keyframes toastOut {
    to { transform: translateX(120%); opacity: 0; }
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

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

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-icon svg { width: 18px; height: 18px; }
.toast-success .toast-icon svg { color: var(--success); }
.toast-error .toast-icon svg { color: var(--danger); }
.toast-warning .toast-icon svg { color: var(--warning); }
.toast-info .toast-icon svg { color: var(--info); }

.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: 0.875rem; margin-bottom: 2px; color: var(--text); }
.toast-message { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }

.toast-close { flex-shrink: 0; color: var(--text-muted); transition: color var(--transition); margin-top: -2px; margin-right: -4px; }
.toast-close:hover { color: var(--text); }
.toast-close svg { width: 16px; height: 16px; }

.toast-progress {
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.25;
    animation: toastProgress linear forwards;
}

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

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

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-stats { margin-bottom: 24px; }
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* PROGRESS STEPS */
.progress-steps {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 8px 0;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 70px;
    position: relative;
}

.progress-step::after {
    content: '';
    position: absolute;
    top: 14px;
    left: 50%;
    right: -50%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.progress-step:last-child::after { display: none; }

.step-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 1;
    position: relative;
    transition: all var(--transition);
}

.progress-step.done .step-dot {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.progress-step.done::after { background: var(--success); }
.progress-step.active .step-dot { background: var(--primary); border-color: var(--primary); color: white; }
.progress-step.pending .step-dot { background: var(--surface); border-color: var(--border); color: var(--text-muted); }

.step-label { font-size: 0.7rem; color: var(--text-secondary); text-align: center; line-height: 1.3; }
.progress-step.done .step-label { color: var(--success); font-weight: 600; }
.progress-step.active .step-label { color: var(--primary); font-weight: 600; }

/* RECENT ITEMS */
.recent-list { display: flex; flex-direction: column; gap: 0; }

.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
    cursor: pointer;
}

.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: var(--surface-2); padding-left: 6px; border-radius: var(--radius); margin: 0 -6px; padding-right: 6px; }

.recent-item-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--primary-light);
    color: var(--primary);
}

.recent-item-icon svg { width: 18px; height: 18px; }

.recent-item-info { flex: 1; min-width: 0; }
.recent-item-info .title { font-size: 0.875rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.recent-item-info .subtitle { font-size: 0.78rem; color: var(--text-muted); }

.recent-item-meta { text-align: right; flex-shrink: 0; }
.recent-item-meta .value { font-size: 0.875rem; font-weight: 700; color: var(--text); }
.recent-item-meta .label { font-size: 0.72rem; color: var(--text-muted); }

/* TIMELINE / HISTORY */
.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
    display: flex;
    gap: 12px;
    position: relative;
    padding-bottom: 16px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 5px;
    position: relative;
    z-index: 1;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 12px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item:last-child::before { display: none; }

.timeline-content { flex: 1; }
.timeline-time { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 3px; }
.timeline-text { font-size: 0.875rem; color: var(--text); font-weight: 500; }
.timeline-note { font-size: 0.8rem; color: var(--text-secondary); margin-top: 3px; }

/* PRESUPUESTO ITEMS */
.presupuesto-items-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }

.presupuesto-items-table th {
    padding: 8px 10px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.presupuesto-items-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.presupuesto-items-table td input,
.presupuesto-items-table td select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
}

.presupuesto-items-table td input:focus { border-color: var(--primary); }

.presupuesto-totales {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.presupuesto-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
    min-width: 280px;
}

.presupuesto-total-row span { font-size: 0.875rem; color: var(--text-secondary); }
.presupuesto-total-row strong { font-size: 0.875rem; font-weight: 600; }
.presupuesto-total-row.total-final span { font-size: 1rem; font-weight: 700; color: var(--text); }
.presupuesto-total-row.total-final strong { font-size: 1.1rem; font-weight: 700; color: var(--primary); }

/* PAGOS */
.pagos-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.pago-summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
}

.pago-summary-card .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.pago-summary-card .amount { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.pago-summary-card.total .amount { color: var(--primary); }
.pago-summary-card.pagado .amount { color: var(--success); }
.pago-summary-card.saldo .amount { color: var(--warning); }

/* STOCK ALERT */
.stock-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--warning-light);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--warning);
    font-weight: 600;
    margin-bottom: 4px;
}

.stock-alert svg { width: 14px; height: 14px; flex-shrink: 0; }

/* GARANTIA STATUS */
.garantia-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.garantia-activa { background: var(--success-light); color: var(--success); }
.garantia-vencida { background: var(--danger-light); color: var(--danger); }
.garantia-proxima { background: var(--warning-light); color: var(--warning); }

/* SEGUIMIENTO */
.seguimiento-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.seguimiento-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 24px;
    color: white;
}

.seguimiento-header h2 { font-size: 1.3rem; font-weight: 700; }
.seguimiento-header p { opacity: 0.85; font-size: 0.875rem; margin-top: 4px; }

.seguimiento-body { padding: 24px; }

.seguimiento-search { margin-bottom: 24px; }

.seguimiento-result { display: none; }
.seguimiento-result.visible { display: block; }

.seguimiento-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.seguimiento-info-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.seguimiento-info-item .label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px; }
.seguimiento-info-item .value { font-size: 0.9rem; font-weight: 600; color: var(--text); }

/* PRINT ONLY */
.print-only { display: none; }

/* FICHA CLIENTE */
.ficha-header { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.ficha-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
}
.ficha-info { flex: 1; }
.ficha-info h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.ficha-info .ficha-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.875rem; color: var(--text-secondary); }
.ficha-meta span { display: flex; align-items: center; gap: 4px; }
.ficha-meta svg { width: 14px; height: 14px; }

/* TABS */
.tabs { margin-bottom: 20px; }
.tabs-nav { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 0; }
.tab-btn {
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* PRINT TEMPLATE */
@media print {
    .sidebar,
    .header,
    .toast-container,
    .modal-backdrop,
    .confirm-backdrop,
    .btn,
    .filters-bar,
    .page-header-actions,
    .table-actions,
    .sidebar-overlay,
    #printTemplate ~ *:not(.print-only) { display: none !important; }

    .print-only { display: block !important; }
    .main-wrapper { margin-left: 0 !important; }
    body { background: white; }

    .print-doc { max-width: 800px; margin: 0 auto; padding: 20px; font-family: sans-serif; }
    .print-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid #333; }
    .print-company h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
    .print-company p { font-size: 0.85rem; color: #555; }
    .print-doc-info { text-align: right; }
    .print-doc-info .doc-number { font-size: 1.2rem; font-weight: 700; color: #1d4ed8; }
    .print-doc-info .doc-date { font-size: 0.85rem; color: #555; }
    .print-section { margin-bottom: 20px; }
    .print-section h3 { font-size: 0.9rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; color: #333; border-bottom: 1px solid #ccc; padding-bottom: 6px; }
    .print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .print-field { margin-bottom: 8px; }
    .print-field .label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: #777; }
    .print-field .value { font-size: 0.9rem; color: #111; }
    .print-table { width: 100%; border-collapse: collapse; }
    .print-table th { padding: 8px; text-align: left; font-size: 0.8rem; background: #f0f0f0; border: 1px solid #ccc; }
    .print-table td { padding: 8px; font-size: 0.85rem; border: 1px solid #ccc; }
    .print-totals { margin-left: auto; width: 280px; }
    .print-total-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #eee; font-size: 0.9rem; }
    .print-total-row.final { font-weight: 700; font-size: 1.1rem; color: #1d4ed8; border-top: 2px solid #333; border-bottom: none; padding-top: 10px; }
    .print-footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid #ccc; font-size: 0.8rem; color: #555; text-align: center; }
    .print-conditions { font-size: 0.82rem; color: #555; margin-top: 16px; line-height: 1.6; }
    .print-signature { display: flex; justify-content: space-between; margin-top: 48px; }
    .print-signature-line { text-align: center; flex: 1; }
    .print-signature-line .line { border-top: 1px solid #333; margin-bottom: 6px; }
    .print-signature-line p { font-size: 0.8rem; color: #555; }
}

/* MISC */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-mono { font-family: 'Courier New', monospace; }
.fw-700 { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.section-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ============================================================
   CLIENTE SEARCH DROPDOWN (modal de orden)
   ============================================================ */

/* Dropdown container */
.cliente-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 600;
    max-height: 260px;
    overflow-y: auto;
}

.cliente-dropdown.open { display: block; }

/* Each result row */
.cd-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
}

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

.cd-item:hover { background: var(--background); }

.cd-item-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

.cd-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* "No results" state */
.cd-empty {
    padding: 14px 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}
