:root {
    --primary: #D4A574;
    --primary-dark: #B8824F;
    --text: #333;
    --text-light: #666;
    --white: #fff;
    --bg: #f5f5f5;
    --border: #ddd;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Sora', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; overflow-x: hidden; }

.hist-container { max-width: min(1400px, 96vw); margin: 0 auto; padding: 0 16px 40px; }

.hist-header {
    background: linear-gradient(135deg, #4e342e 0%, #6d4c41 100%);
    color: var(--white);
    padding: 20px 16px;
    margin: 0 -16px 24px;
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    max-width: min(1400px, 96vw);
    margin: 0 auto;
}
.hist-header h1 { font-size: 1.5rem; display: flex; align-items: center; gap: 10px; min-width: 0; overflow-wrap: anywhere; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-refresh { background: rgba(255,255,255,0.2); color: #fff; border: 2px solid rgba(255,255,255,0.35); }
.btn-refresh:hover { background: rgba(255,255,255,0.3); }
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    color: var(--white);
    border: 2px solid rgba(255,255,255,0.35);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}
.btn-back:hover { background: rgba(255,255,255,0.28); color: var(--white); }

.filters-section {
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.filters-section h2 { font-size: 1rem; margin-bottom: 8px; color: var(--primary-dark); }
.filters-hint { font-size: 13px; color: var(--text-light); margin-bottom: 16px; }
.filters-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.filter-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.filter-group input[type="text"],
.filter-group input[type="date"] {
    min-width: 180px;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
}
.filter-group--wide input { min-width: 260px; }
.filter-group.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.btn-borrar-filtros {
    min-height: 42px;
    padding: 10px 14px;
    border: 2px solid var(--border);
    background: #fafafa;
    color: var(--text);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-borrar-filtros:hover { background: #eee; border-color: #bbb; }

.results-section { margin-top: 8px; }
.summary-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.summary-card {
    background: var(--white);
    border-radius: 10px;
    padding: 14px 18px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    min-width: 140px;
}
.summary-card strong { display: block; font-size: 12px; color: var(--text-light); text-transform: uppercase; }
.summary-card span { font-size: 1.25rem; font-weight: 700; color: var(--primary-dark); }

.table-wrap { overflow-x: auto; background: var(--white); border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.hist-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hist-table th, .hist-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.hist-table th { background: #efebe9; font-weight: 600; }
.hist-table tbody tr:hover { background: #fafafa; }

.btn-ver {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}
.btn-ver:hover { background: var(--primary-dark); color: #fff; }

.loading, .empty-state { text-align: center; padding: 40px 20px; color: var(--text-light); }
.loading i { font-size: 32px; color: var(--primary); display: block; margin-bottom: 10px; }
.empty-state i { font-size: 48px; color: #ccc; display: block; margin-bottom: 12px; }

.hidden { display: none !important; }

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 9999;
    display: none;
}
.toast.show { display: block; }
.toast.error { background: #c62828; color: #fff; }
.toast.success { background: #2e7d32; color: #fff; }

@media (max-width: 768px) {
    .hist-container { padding: 0 12px 40px; }
    .hist-header { margin: 0 -12px 20px; }
    .header-content { flex-direction: column; align-items: stretch; }
    .hist-header h1 { font-size: 1.2rem; }
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
    .filters-section { padding: 16px; }
    .filters-grid { flex-direction: column; align-items: stretch; }
    .filter-group { width: 100%; }
    .filter-group input[type="text"],
    .filter-group input[type="date"],
    .filter-group--wide input { min-width: 0; width: 100%; }
    .filter-group .btn { width: 100%; justify-content: center; }
    .hist-table { min-width: 640px; }
    .toast { left: 12px; right: 12px; bottom: 16px; }
}

@media (max-width: 480px) {
    .hist-header h1 { font-size: 1.05rem; }
    .header-actions .btn { flex-basis: 100%; }
}
