/* ===========================
   VARIABLES CSS - Portal Client (estil Admin)
   =========================== */
:root {
    --primary-color: #7CB342;
    --primary-dark: #558B2F;
    --primary-light: #9CCC65;
    --color-primary: #7CB342;
    --color-primary-dark: #558B2F;
    --color-accent: #8BC34A;
    --color-primary-rgb: 124, 179, 66;

    --text-dark: #1a1a1a;
    --text-gray: #666666;
    --text-light: #999999;

    --bg-white: #FFFFFF;
    --bg-light: #f5f7fa;
    --bg-gray: #eceff1;

    --border-color: #e0e0e0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: all 0.3s ease;
    --sidebar-width: 200px;
    --header-height: 60px;
}

.branding-loading, .branding-loading * { transition: none !important; animation: none !important; }

/* ===========================
   RESET I BASE
   =========================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
}

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

/* ===========================
   LOGIN PAGE
   =========================== */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}
.login-container {
    width: 100%; max-width: 400px; background: var(--bg-white);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 30px; animation: fadeIn 0.5s ease;
}
.logo-container { text-align: center; margin-bottom: 30px; }
.logo { max-width: 120px; height: auto; margin-bottom: 15px; }
.logo-container h1 { font-size: 24px; font-weight: 700; margin-bottom: 5px; }
.subtitle { font-size: 14px; color: var(--text-gray); }
.login-form { margin-bottom: 20px; }
.login-page .form-group { margin-bottom: 20px; }
.login-page .form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.login-page .form-group label i { margin-right: 5px; color: var(--primary-color); }
.login-page .form-group input { width: 100%; height: 56px; padding: 0 16px; font-size: 18px; border: 2px solid var(--border-color); border-radius: var(--radius); background: var(--bg-white); }
.login-page .form-group input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1); }
.password-input { position: relative; }
.toggle-password { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: transparent; border: none; color: var(--text-gray); font-size: 20px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-login { width: 100%; height: 56px; background: var(--primary-color); color: white; border: none; border-radius: var(--radius); font-size: 18px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; box-shadow: var(--shadow); }
.btn-login:active { transform: scale(0.98); background: var(--primary-dark); }
.version { text-align: center; margin-top: 15px; font-size: 12px; color: var(--text-light); }
.login-branding { position: fixed; bottom: 20px; left: 0; right: 0; text-align: center; font-size: 12px; color: rgba(255,255,255,0.6); }
.login-branding strong { font-weight: 700; }

/* ===========================
   LAYOUT ADMIN-STYLE
   =========================== */
.client-body { background: var(--bg-light); min-height: 100vh; }

/* HEADER */
.client-header {
    background: var(--bg-white); border-bottom: 1px solid var(--border-color);
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    box-shadow: var(--shadow-sm); height: var(--header-height);
}
.client-header-content {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; height: 100%;
}
.client-header-left { display: flex; align-items: center; gap: 14px; }
.sidebar-toggle { display: none; background: none; border: none; font-size: 20px; color: var(--text-dark); cursor: pointer; padding: 8px; }
.client-header-title { display: flex; align-items: center; gap: 10px; }
.client-header-name { font-size: 16px; font-weight: 700; color: var(--text-dark); }
.client-header-badge {
    padding: 4px 10px; background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.client-header-right { display: flex; align-items: center; gap: 16px; }
.client-header-welcome { font-size: 13px; font-weight: 500; color: var(--text-gray); }
.btn-logout-admin {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px; background: #f44336; color: white;
    border: none; border-radius: var(--radius-sm); font-size: 13px;
    font-weight: 600; cursor: pointer; transition: var(--transition);
}
.btn-logout-admin:hover { background: #d32f2f; transform: translateY(-1px); box-shadow: var(--shadow); }

/* SIDEBAR */
.client-sidebar {
    background: var(--bg-white); border-right: 1px solid var(--border-color);
    position: fixed; left: 0; top: var(--header-height); bottom: 0;
    width: var(--sidebar-width); padding: 15px 0;
    display: flex; flex-direction: column; z-index: 900;
}
.sidebar-logo { display: flex; justify-content: center; padding: 0 20px 12px; margin-bottom: 8px; border-bottom: 1px solid #eee; }
.sidebar-logo img { height: 65px; }
.client-nav { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; }
.client-nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; color: var(--text-dark);
    transition: var(--transition);
}
.client-nav-item i { font-size: 16px; width: 22px; text-align: center; color: var(--text-gray); }
.client-nav-item:hover { background: rgba(var(--color-primary-rgb), 0.08); color: var(--primary-color); }
.client-nav-item:hover i { color: var(--primary-color); }
.client-nav-item.active { background: rgba(var(--color-primary-rgb), 0.12); color: var(--primary-color); font-weight: 600; }
.client-nav-item.active i { color: var(--primary-color); }

.client-sidebar-footer {
    margin-top: auto; padding: 16px; text-align: center;
    border-top: 1px solid #eee;
}
.sidebar-brand-text { font-size: 10px; color: var(--text-light); margin-bottom: 2px; }
.sidebar-brand-name { font-size: 13px; font-weight: 700; color: var(--primary-color); }
.sidebar-brand-sub { font-size: 10px; color: var(--text-light); }

/* MAIN */
.client-main {
    margin-left: var(--sidebar-width); margin-top: var(--header-height);
    padding: 28px; min-height: calc(100vh - var(--header-height));
}

/* Section header */
.section-header-client {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; gap: 20px;
}
.section-header-client h1 {
    font-size: 28px; font-weight: 800; margin-bottom: 6px;
    display: flex; align-items: center; gap: 10px;
}
.section-header-client h1 i { color: var(--primary-color); }
.section-header-client p { color: var(--text-light); font-size: 14px; margin: 0; }
.btn-primary-admin {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 22px; background: var(--primary-color); color: white;
    border: none; border-radius: var(--radius-sm); font-size: 14px;
    font-weight: 600; cursor: pointer; transition: var(--transition);
    box-shadow: var(--shadow-sm); white-space: nowrap;
}
.btn-primary-admin:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }

/* Controls bar */
.client-controls {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}

/* ===========================
   STAT BLOCKS (filtres amb comptador)
   =========================== */
.stat-blocks {
    display: flex; gap: 14px; margin-bottom: 18px; flex-wrap: wrap;
}
.stat-block {
    flex: 1; min-width: 140px; background: var(--bg-white);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 14px 18px; display: flex; align-items: center; gap: 12px;
    cursor: pointer; transition: var(--transition);
    border: 2px solid transparent;
}
.stat-block:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-block.active { border-color: var(--primary-color); box-shadow: var(--shadow); }
.stat-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon i { font-size: 16px; }
.stat-info { flex: 1; }
.stat-count { font-size: 22px; font-weight: 800; color: var(--text-dark); line-height: 1.1; }
.stat-label { font-size: 10px; color: var(--text-light); text-transform: uppercase; font-weight: 600; letter-spacing: 0.3px; }

@media (max-width: 640px) {
    .stat-blocks { gap: 8px; }
    .stat-block { min-width: 0; padding: 10px 12px; gap: 8px; }
    .stat-icon { width: 32px; height: 32px; }
    .stat-icon i { font-size: 14px; }
    .stat-count { font-size: 18px; }
}

/* ===========================
   VIEW TOGGLE
   =========================== */
.view-toggle {
    display: inline-flex; background: var(--bg-gray); border-radius: var(--radius-sm);
    padding: 3px; gap: 2px;
}
.view-btn {
    padding: 8px 16px; border: none; border-radius: 6px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    background: transparent; color: var(--text-gray);
    transition: var(--transition); display: flex; align-items: center; gap: 6px;
}
.view-btn.active { background: var(--bg-white); color: var(--primary-color); box-shadow: var(--shadow-sm); }

/* ===========================
   FILTER TABS
   =========================== */
.filter-tabs {
    display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.filter-tab {
    padding: 7px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
    border: 2px solid var(--border-color); background: var(--bg-white); color: var(--text-gray);
    cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.filter-tab.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }

/* ===========================
   RESERVES TABLE (estil taula + card)
   =========================== */
.reserves-list {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--bg-white); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 0; overflow: hidden;
}

/* Capçalera de taula */
.reserves-table-header {
    display: grid;
    grid-template-columns: 56px minmax(180px, 2fr) 1.1fr 1.2fr 1.3fr 90px;
    gap: 12px; align-items: center;
    padding: 12px 16px;
    background: linear-gradient(180deg, #F7FAFC 0%, #EDF2F7 100%);
    border-bottom: 2px solid #E2E8F0;
    font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
    text-transform: uppercase; color: #64748B;
}
.reserves-table-header > div {
    text-align: center;
}

/* Fila de reserva */
.reserve-row {
    display: grid;
    grid-template-columns: 56px minmax(180px, 2fr) 1.1fr 1.2fr 1.3fr 90px;
    gap: 12px; align-items: center;
    padding: 12px 16px;
    border-left: 4px solid transparent;
    border-bottom: 1px solid #F1F5F9;
    cursor: pointer; transition: all 0.15s ease;
    background: var(--bg-white);
}
.reserve-row:last-child { border-bottom: none; }
.reserve-row:hover {
    background: #F8FAFC;
    border-left-width: 4px;
}

/* Colors vora segons estat */
.reserve-row.estat-pendent_validacio { border-left-color: #FFA726; }
.reserve-row.estat-acceptada { border-left-color: #66BB6A; }
.reserve-row.estat-rebutjada { border-left-color: #EF5350; }
.reserve-row.estat-completada { border-left-color: #9E9E9E; }
.reserve-row.estat-cancellada { border-left-color: #BDBDBD; }
.reserve-row.estat-planificada { border-left-color: #42A5F5; }
.reserve-row.estat-en_proces { border-left-color: #AB47BC; }

/* Col·lumnes */
.col-type {
    display: flex; align-items: center; justify-content: center;
}
.type-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.type-icon i { font-size: 17px; }

.col-ref { min-width: 0; text-align: center; }
.row-title {
    font-size: 14px; font-weight: 700; color: var(--text-dark);
    line-height: 1.3; margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-subtitle {
    font-size: 12px; color: var(--text-gray); line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.col-date { min-width: 0; text-align: center; }
.row-date-main {
    font-size: 13px; font-weight: 600; color: var(--text-dark);
    line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-date-main i { color: #64748B; margin-right: 4px; font-size: 11px; }
.row-date-sub {
    font-size: 11px; color: var(--text-light); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-estada {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--text-light);
    margin-top: 3px; font-weight: 500;
    white-space: nowrap;
}
.row-estada i { font-size: 10px; opacity: 0.75; }
.row-estada .estada-sep { opacity: 0.5; margin: 0 2px; }

.col-service { min-width: 0; text-align: center; }
.service-pill {
    display: inline-block;
    background: #F3E5F5; color: #7B1FA2;
    padding: 4px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

.col-status { min-width: 0; text-align: center; }
.status-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 700;
    white-space: nowrap;
}
.status-pill i { font-size: 10px; }
.status-pendent_validacio { background: #FFF3E0; color: #E65100; }
.status-acceptada { background: #E8F5E9; color: #2E7D32; }
.status-rebutjada { background: #FFEBEE; color: #C62828; }
.status-completada { background: #ECEFF1; color: #455A64; }
.status-cancellada { background: #FAFAFA; color: #757575; }
.status-planificada { background: #E3F2FD; color: #1565C0; }
.status-en_proces { background: #F3E5F5; color: #7B1FA2; }
.row-cancel-by { font-size: 10px; color: #999; margin-top: 3px; }

/* Accions */
.col-actions {
    display: flex; gap: 4px; justify-content: center; align-items: center;
}
.row-action-btn {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    border: none; cursor: pointer;
    transition: all 0.15s ease; font-size: 13px;
}
.row-action-btn:hover { transform: scale(1.1); }
.row-action-primary { background: #E3F2FD; color: #1565C0; }
.row-action-primary:hover { background: #1565C0; color: white; }
.row-action-danger { background: #FFEBEE; color: #C62828; }
.row-action-danger:hover { background: #C62828; color: white; }
.row-action-cancel { background: #FFF3E0; color: #E65100; }
.row-action-cancel:hover { background: #E65100; color: white; }
.row-action-view { background: #E8F5E9; color: #2E7D32; }
.row-action-view:hover { background: #2E7D32; color: white; }

/* Responsive: col·lapsa a card a mòbil */
@media (max-width: 900px) {
    .reserves-table-header { display: none; }
    .reserves-list {
        background: transparent; box-shadow: none;
        gap: 10px; padding: 0;
    }
    .reserve-row {
        grid-template-columns: 48px 1fr auto;
        grid-template-areas:
            "type ref status"
            "type date service"
            "actions actions actions";
        gap: 8px 12px;
        padding: 12px; border-radius: var(--radius);
        background: var(--bg-white); box-shadow: var(--shadow-sm);
        border-bottom: none; border-left-width: 4px;
    }
    .reserve-row:hover { transform: none; }
    .col-type { grid-area: type; align-self: start; }
    .col-ref { grid-area: ref; min-width: 0; }
    .col-date { grid-area: date; min-width: 0; }
    .col-service { grid-area: service; min-width: 0; text-align: right; }
    .col-status { grid-area: status; min-width: 0; text-align: right; }
    .col-actions { grid-area: actions; justify-content: flex-end; padding-top: 6px; border-top: 1px solid #F1F5F9; }
    .col-actions:empty { display: none; }
    .type-icon { width: 36px; height: 36px; }
    .type-icon i { font-size: 15px; }
}
@media (max-width: 480px) {
    .reserve-row {
        grid-template-columns: 42px 1fr;
        grid-template-areas:
            "type ref"
            "type date"
            "service status"
            "actions actions";
    }
    .col-service { text-align: left; }
}

/* Card tiles — versió compacta */
.card-tiles {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
    padding: 8px 10px;
}
.card-tile {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-light); border-radius: 8px;
    padding: 8px 10px;
}
.card-tile-icon {
    width: 28px; height: 28px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 0;
}
.card-tile-icon i { font-size: 13px; }
.card-tile-info { flex: 1; min-width: 0; }
.card-tile-value {
    font-size: 13px; font-weight: 700; color: var(--text-dark);
    line-height: 1.25; margin-bottom: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-tile-label {
    font-size: 10px; font-weight: 500; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 0.3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-tile-detail {
    font-size: 11px; color: var(--text-gray); margin-top: 1px;
    line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-tile-detail span { font-weight: 600; color: var(--text-light); }

.card-tile-actions {
    display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap;
}
.card-tile-actions .card-btn {
    font-size: 11px; padding: 5px 8px;
}

@media (max-width: 768px) {
    .card-tiles { grid-template-columns: 1fr; gap: 6px; padding: 8px; }
    .card-tile { padding: 8px 10px; }
}

.card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.card-type { display: flex; align-items: center; gap: 8px; }
.card-type i { font-size: 18px; color: var(--primary-color); }
.card-type span { font-weight: 700; font-size: 15px; }

.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-pendent { background: #FFF3E0; color: #E65100; }
.badge-acceptada { background: #E8F5E9; color: #2E7D32; }
.badge-rebutjada { background: #FFEBEE; color: #C62828; }
.badge-cancellada { background: #F5F5F5; color: #757575; }
.badge-planificada { background: #E3F2FD; color: #1565C0; }
.badge-servei { background: #F3E5F5; color: #7B1FA2; }

.card-body { font-size: 14px; color: var(--text-gray); }
.card-body .card-date { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 16px; color: var(--text-dark); }
.card-body .card-date i { width: 16px; text-align: center; font-size: 14px; color: var(--primary-color); }
.card-body .card-date strong { font-weight: 700; }
.card-body .card-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.card-body .card-row i { width: 16px; text-align: center; font-size: 13px; color: var(--text-light); }

.card-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--bg-gray);
    font-size: 12px; color: var(--text-light);
}

.card-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.card-actions {
    display: flex; gap: 8px; margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--bg-gray);
}
.card-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px; border: none; border-radius: 6px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: var(--transition);
}
.card-btn:hover { transform: translateY(-1px); }
.card-btn-cancel { background: #FFF3E0; color: #E65100; }
.card-btn-cancel:hover { background: #FFE0B2; }
.card-btn-primary { background: var(--primary-color); color: white; }
.card-btn-primary:hover { background: var(--primary-dark); }
.card-btn-danger { background: #FFEBEE; color: #C62828; }
.card-btn-danger:hover { background: #FFCDD2; }

/* ===========================
   EMPTY STATE
   =========================== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 16px; }

/* ===========================
   VISTA DETALL (admin-card style)
   =========================== */
.detail-view { padding: 0; }
.detail-header { display: none; }
.detail-section { margin-bottom: 20px; }
.detail-section h3 { font-size: 14px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-field label { display: block; font-size: 12px; color: var(--text-light); margin-bottom: 2px; }
.detail-field .value { font-size: 15px; font-weight: 500; }
.detail-field.full-width { grid-column: 1 / -1; }

.det-header {
    display: flex; align-items: flex-start; gap: 14px;
    background: var(--bg-white); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm); padding: 22px 24px; margin-bottom: 16px;
}
.det-header .btn-back { flex-shrink: 0; margin-top: 2px; }
.btn-back {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--bg-gray); border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: var(--text-dark); cursor: pointer; transition: var(--transition);
}
.btn-back:hover { background: var(--border-color); }
.det-header-info { flex: 1; }
.det-header-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.det-header-top h2 { font-size: 20px; font-weight: 800; margin: 0; }
.det-header-summary { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-gray); font-weight: 500; }
.det-header-summary span { display: flex; align-items: center; gap: 5px; }
.det-header-summary i { font-size: 12px; color: var(--primary-color); }

.det-card {
    background: var(--bg-white); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm); padding: 22px 24px; margin-bottom: 16px;
}
.det-card-highlight {
    background: linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.04) 0%, var(--bg-white) 100%);
    border: 1px solid rgba(var(--color-primary-rgb), 0.12);
}
.det-card-title {
    font-size: 11px; font-weight: 700; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--bg-gray);
}
.det-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .det-card-grid { grid-template-columns: 1fr; } }

.det-field { display: flex; align-items: flex-start; gap: 12px; }
.det-field-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--bg-light); display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.det-field-icon i { font-size: 14px; color: var(--primary-color); }
.det-field-content { flex: 1; min-width: 0; }
.det-field-label { font-size: 11px; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.det-field-value { font-size: 15px; font-weight: 600; }

.det-card-highlight .det-field:first-child .det-field-icon { background: var(--primary-color); }
.det-card-highlight .det-field:first-child .det-field-icon i { color: white; }
.det-card-highlight .det-field:first-child .det-field-value { font-size: 16px; font-weight: 700; }

.det-desc { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--bg-gray); }
.det-desc label { font-size: 11px; font-weight: 600; color: var(--text-light); text-transform: uppercase; margin-bottom: 4px; display: block; }
.det-desc p { font-size: 14px; color: var(--text-gray); line-height: 1.5; }

.det-obs {
    font-size: 14px; color: var(--text-gray); line-height: 1.6;
    white-space: pre-wrap; background: var(--bg-light);
    padding: 16px; border-radius: var(--radius-sm); border: 1px solid var(--bg-gray);
}

.det-meta { text-align: center; font-size: 12px; color: var(--text-light); padding: 8px 0; }
.det-branding { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; font-size: 11px; color: var(--text-light); opacity: 0.5; }
.det-branding img { height: 16px; opacity: 0.5; }

.detail-warning {
    background: #FFF3E0; border: 1px solid #FFB74D; border-radius: var(--radius-lg);
    padding: 12px 16px; font-size: 13px; color: #E65100; line-height: 1.5;
    margin-bottom: 12px;
}
.detail-warning i { margin-right: 6px; }

.detail-actions {
    display: flex; gap: 12px;
    background: var(--bg-white); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm); padding: 18px 24px;
}

/* ===========================
   FORMULARI
   =========================== */
.form-view {
    background: var(--bg-white); border-radius: var(--radius-xl);
    box-shadow: 0 8px 24px rgba(0,0,0,0.06); padding: 28px;
}
.form-header {
    display: flex; align-items: flex-start; gap: 14px;
    margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--bg-gray);
}
.form-header-info h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.form-header-info p { font-size: 13px; color: var(--text-light); margin: 0; }

#view-form { max-width: 800px; }

.form-block {
    background: #f9fafb; border-radius: var(--radius);
    padding: 18px 20px; margin-bottom: 16px;
}
.form-block-title {
    font-size: 13px; font-weight: 700; color: var(--text-gray);
    letter-spacing: 0.03em; margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.form-block-title i { font-size: 14px; color: var(--primary-color); }

.form-section { margin-bottom: 22px; }
.form-section h3 {
    font-size: 11px; font-weight: 700; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: 14px;
    padding-bottom: 10px; border-bottom: 1px solid var(--bg-gray);
}
.form-hint {
    font-size: 12px; color: var(--text-light); margin-top: 6px;
    display: flex; align-items: center; gap: 6px;
}
.form-hint i { font-size: 11px; color: var(--primary-color); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.form-group { margin-bottom: 14px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group label i { margin-right: 4px; color: var(--primary-color); }
.required { color: #EF5350; font-weight: 700; }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 10px 14px; font-size: 14px;
    border: 2px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-white); color: var(--text-dark);
    transition: var(--transition); font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group select {
    height: 44px; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
.form-group input[type="date"], .form-group input[type="time"], .form-group input[type="number"] { height: 44px; }

.field-error { border-color: #EF5350 !important; box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.15) !important; }
.form-error-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; margin-bottom: 14px;
    background: #FFF3E0; border: 1px solid #FFB74D; border-radius: var(--radius-sm);
    color: #E65100; font-size: 14px; font-weight: 500;
}
.form-disclaimer { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-light); }
.success-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px; margin-bottom: 16px;
    background: #E8F5E9; border: 1px solid #A5D6A7; border-radius: var(--radius);
    color: #2E7D32; font-size: 15px; font-weight: 600; transition: opacity 0.5s;
}

.form-actions {
    display: flex; gap: 12px; margin-top: 20px;
    padding-top: 16px; border-top: 1px solid var(--bg-gray);
}
.form-actions .btn-primary { flex: 1; justify-content: center; }

.type-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.type-btn {
    flex: 1; padding: 14px; border: 2px solid var(--border-color);
    border-radius: var(--radius); background: var(--bg-white);
    text-align: center; cursor: pointer; transition: var(--transition);
    font-size: 14px; font-weight: 600; color: var(--text-gray);
}
.type-btn.active { border-color: var(--primary-color); color: var(--primary-color); background: rgba(var(--color-primary-rgb), 0.04); }
.type-btn i { display: block; font-size: 24px; margin-bottom: 6px; }

.inline-add { display: flex; gap: 8px; margin-top: 8px; }
.inline-add input { flex: 1; }
.btn-sm { padding: 8px 14px; font-size: 13px; font-weight: 600; border: none; border-radius: var(--radius-sm); cursor: pointer; }
.btn-sm.btn-primary { background: var(--primary-color); color: white; }
.checkbox-group { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.checkbox-group input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary-color); }
.checkbox-group label { font-size: 14px; font-weight: 500; margin-bottom: 0; }

/* Buttons */
.btn-primary {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--primary-color); color: white;
    border: none; border-radius: var(--radius-sm);
    padding: 12px 20px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: var(--transition); box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--bg-gray); color: var(--text-dark);
    border: none; border-radius: var(--radius-sm);
    padding: 12px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-danger {
    display: inline-flex; align-items: center; gap: 8px;
    background: #FFEBEE; color: #C62828;
    border: none; border-radius: var(--radius-sm);
    padding: 12px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* ===========================
   CALENDARI
   =========================== */
.calendar-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 16px; }
.calendar-nav h3 { font-size: 18px; font-weight: 700; min-width: 160px; text-align: center; }
.cal-nav-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-gray); border: none; display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--text-dark); cursor: pointer; }
.cal-nav-btn:hover { background: var(--border-color); }
.calendar-grid { background: var(--bg-white); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); overflow: hidden; }
.cal-header-row { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--bg-gray); border-bottom: 1px solid var(--border-color); }
.cal-header-cell { padding: 10px 4px; text-align: center; font-size: 12px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }
.cal-body { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell { min-height: 90px; padding: 4px; border-right: 1px solid var(--bg-gray); border-bottom: 1px solid var(--bg-gray); position: relative; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-empty { background: var(--bg-light); opacity: 0.5; }
.cal-today { background: rgba(var(--color-primary-rgb), 0.05); }
.cal-today .cal-day-num { color: var(--primary-color); font-weight: 800; }
.cal-day-num { font-size: 13px; font-weight: 600; color: var(--text-gray); margin-bottom: 4px; padding: 2px 4px; }
.cal-event { display: block; padding: 4px 6px; margin-bottom: 3px; border-radius: 4px; font-size: 11px; line-height: 1.45; cursor: pointer; overflow: hidden; }
.cal-event:hover { opacity: 0.85; transform: scale(1.02); }
.cal-evt-time { font-weight: 700; }
.cal-evt-title { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cal-evt-pendent_validacio { background: #FFF3E0; color: #E65100; border-left: 3px solid #FFA726; }
.cal-evt-acceptada { background: #DCEDC8; color: #2E7D32; border-left: 3px solid #4CAF50; }
.cal-evt-planificada { background: #E3F2FD; color: #1565C0; border-left: 3px solid #42A5F5; }
.cal-evt-cancellada { background: #F5F5F5; color: #9E9E9E; border-left: 3px solid #BDBDBD; }
.cal-evt-rebutjada { background: #FFEBEE; color: #C62828; border-left: 3px solid #EF5350; }
.cal-evt-ocupat { background: #E0E7FF; color: #3949AB; border-left: 3px solid #7986CB; opacity: 0.75; }
.cal-evt-ocupat .cal-evt-title { font-weight: 600; }
.cal-evt-sub { display: block; font-size: 9px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; opacity: 0.55; line-height: 1.2; }
.cal-evt-hoste { display: block; font-size: 10px; font-weight: 500; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.cal-evt-servei { display: flex; align-items: center; gap: 3px; font-size: 9px; font-weight: 600; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.cal-more { font-size: 11px; color: var(--text-light); font-weight: 600; padding: 2px 6px; }

/* ===========================
   NOTIFICACIONS
   =========================== */
#notifications { position: fixed; top: 80px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.notification { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; font-size: 14px; font-weight: 500; }
.notification.success { background: #E8F5E9; color: #2E7D32; }
.notification.error { background: #FFEBEE; color: #C62828; }

/* ===========================
   CONFIRM DIALOG
   =========================== */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9998; display: flex; align-items: center; justify-content: center; padding: 20px; }
.confirm-dialog { background: var(--bg-white); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 24px; max-width: 380px; width: 100%; text-align: center; }
.confirm-dialog h3 { font-size: 18px; margin-bottom: 8px; }
.confirm-dialog p { font-size: 14px; color: var(--text-gray); margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 12px; }
.confirm-actions button { flex: 1; }

/* ===========================
   LOADING
   =========================== */
.loading { text-align: center; padding: 40px; color: var(--text-light); }
.loading i { font-size: 32px; margin-bottom: 12px; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
    .client-sidebar { transform: translateX(-100%); transition: transform 0.3s ease; z-index: 1100; }
    .sidebar-open .client-sidebar { transform: translateX(0); }
    .sidebar-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1050; }
    .sidebar-toggle { display: block; }
    .client-main { margin-left: 0; padding: 20px; }
    .client-header-content { padding: 0 16px; }
    .section-header-client { flex-direction: column; align-items: flex-start; }
    .section-header-client h1 { font-size: 22px; }
    .client-controls { flex-direction: column; align-items: flex-start; }
    .cal-cell { min-height: 70px; padding: 2px; }
    .cal-day-num { font-size: 11px; }
    .cal-event { font-size: 10px; padding: 2px 4px; }
    .cal-evt-time { display: none; }
    .cal-header-cell { font-size: 10px; padding: 8px 2px; }
}

@media (max-width: 480px) {
    .cal-cell { min-height: 55px; }
    .det-card-grid { grid-template-columns: 1fr; }
}

/* ===========================
   ANIMATIONS
   =========================== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
