﻿@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* --- DESIGN SYSTEM & SYSTEM VARIABLES --- */
:root {
    --bg-gradient: linear-gradient(135deg, #090e1a 0%, #0e172a 100%);
    --card-bg: rgba(20, 30, 54, 0.6);
    --card-border: rgba(255, 255, 255, 0.05);
    --card-hover-border: rgba(36, 197, 179, 0.3);
    
    --accent-gold: #e5a93b;
    --accent-gold-hover: #f1bb5b;
    --accent-teal: #24c5b3;
    --accent-teal-hover: #3be2cf;
    
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- BASE STYLES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #090e1a;
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-teal);
}

/* --- APP CONTAINER --- */
#app-container {
    display: flex;
    min-height: 100vh;
}

/* --- SIDEBAR --- */
aside {
    width: 280px;
    background: rgba(10, 15, 30, 0.8);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--card-border);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--card-border);
}

.logo-icon {
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-badge {
    font-size: 0.65rem;
    background: var(--accent-teal);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

/* NAVIGATION */
nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    border-left: 3px solid var(--accent-teal);
    background: rgba(36, 197, 179, 0.1);
}

.nav-item i {
    width: 20px;
    height: 20px;
}

/* GOOGLE PROFILE SECTION */
.user-profile {
    margin-top: auto;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--accent-gold);
    object-fit: cover;
    background: #1e293b;
}

.profile-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.profile-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.profile-role {
    font-size: 0.75rem;
    color: var(--accent-teal);
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: auto;
}

.btn-primary {
    background: var(--accent-gold);
    color: #111;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-gold-hover);
    box-shadow: 0 0 15px rgba(229, 169, 59, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.btn-teal {
    background: var(--accent-teal);
    color: #111;
}

.btn-teal:hover:not(:disabled) {
    background: var(--accent-teal-hover);
    box-shadow: 0 0 15px rgba(36, 197, 179, 0.3);
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* --- MAIN CONTENT AREA --- */
main {
    margin-left: 280px;
    flex-grow: 1;
    padding: 1.25rem;
    min-height: 100vh;
    min-width: 0;        /* permet aux enfants (tables/grids) de rétrécir sans déborder */
    overflow-x: hidden;  /* évite la barre de scroll horizontale parasite */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 2rem;
}

/* SEARCH BAR */
.search-container {
    position: relative;
    flex-grow: 1;
    max-width: 600px;
}

.search-container i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.75rem;
    background: rgba(20, 30, 54, 0.5);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-teal);
    background: rgba(20, 30, 54, 0.8);
    box-shadow: 0 0 15px rgba(36, 197, 179, 0.1);
}

/* TOP STATUS BAR */
.top-status {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.sync-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.sync-dot.offline {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

/* --- DASHBOARD VIEW --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    border-color: var(--card-hover-border);
    transform: translateY(-2px);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
}

.stat-icon.gold { color: var(--accent-gold); background: rgba(229, 169, 59, 0.08); }
.stat-icon.teal { color: var(--accent-teal); background: rgba(36, 197, 179, 0.08); }
.stat-icon.danger { color: var(--danger); background: rgba(239, 68, 68, 0.08); }
.stat-icon.success { color: var(--success); background: rgba(16, 185, 129, 0.08); }

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    margin: 1rem 0 0.25rem 0;
    letter-spacing: -0.5px;
}

.stat-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* SECTION HEADERS */
.section-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title i {
    color: var(--accent-teal);
}

/* PANELS / VIEWS */
.app-panel {
    display: none;
    animation: fadeIn 0.4s ease;
}

.app-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.form-grid-full {
    grid-column: span 2;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-group label span.required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-teal);
    box-shadow: 0 0 10px rgba(36, 197, 179, 0.1);
}

.form-control:disabled {
    background: rgba(15, 23, 42, 0.3);
    color: var(--text-muted);
    cursor: not-allowed;
}

.tenant-form-grid {
    display: grid;
    gap: 1rem;
}

.tenant-form-row {
    display: grid;
    gap: 1rem;
    align-items: end;
}

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

.tenant-form-row-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tenant-form-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tenant-form-row-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tenant-form-row-5 {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 0.78fr) minmax(0, 0.78fr);
}

.tenant-search-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.tenant-form-divider {
    border-top: 1px solid var(--card-border);
    padding-top: 0.75rem;
}

.payment-form-row {
    display: grid;
    gap: 1rem;
    align-items: end;
}

.payment-form-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.payment-form-row-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.payment-section-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.payment-section-card h4 {
    font-size: 0.9rem;
    color: var(--accent-teal);
    margin-bottom: 0.75rem;
}

.payment-section-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.payment-tenant-summary {
    border: 1px solid rgba(36, 197, 179, 0.28);
    background: rgba(36, 197, 179, 0.06);
    border-radius: var(--radius-md);
    padding: 0.85rem;
}

.payment-summary-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--accent-teal);
    font-weight: 700;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.payment-summary-title svg,
.payment-summary-title i {
    width: 17px;
    height: 17px;
}

.payment-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
}

.payment-summary-item {
    min-width: 0;
    border: 1px solid var(--card-border);
    background: rgba(15, 23, 42, 0.55);
    border-radius: var(--radius-sm);
    padding: 0.6rem;
}

.payment-summary-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-bottom: 0.25rem;
}

.payment-summary-value {
    display: block;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.payment-tenant-info-card .payment-summary-grid {
    grid-template-columns: 1fr;
}

.payment-summary-placeholder {
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.5;
}

.payment-visibility-check {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.75rem;
    color: var(--accent-gold);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.payment-visibility-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-teal);
}

.payment-secret-note {
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1.35;
}

.payment-calculated-display {
    border: 1px solid var(--card-border);
    background: rgba(15, 23, 42, 0.42);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
}

.payment-calculated-display span {
    display: block;
    color: var(--text-muted);
    font-size: 0.76rem;
    margin-bottom: 0.35rem;
}

.payment-calculated-display strong {
    display: block;
    color: var(--accent-teal);
    font-size: 1rem;
    font-weight: 800;
    white-space: nowrap;
}

.tenant-rent-compact {
    white-space: nowrap;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-teal);
}

.tenant-info-action-row td {
    padding-top: 0;
    border-bottom: 1px solid var(--card-border);
    background: rgba(15, 23, 42, 0.22);
}

.tenant-info-bottom-btn {
    width: 100%;
    justify-content: center;
    font-weight: 700;
    color: #07111d;
}

#panel-billing .form-grid,
#panel-billing .payment-form-row,
#panel-billing .payment-section-card,
#panel-billing .payment-section-fields,
#panel-billing .form-group,
#panel-billing .form-control {
    width: 100%;
    min-width: 0;
}

#panel-billing .form-grid {
    grid-template-columns: 1fr !important;
}

#panel-billing .payment-form-row {
    grid-column: 1 / -1;
}

#panel-billing .payment-form-row-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#panel-billing .payment-section-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Radio groups */
.radio-tile-group {
    display: flex;
    gap: 1rem;
}

.radio-tile-label {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.radio-tile-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.4);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
    color: var(--text-secondary);
}

.radio-tile-input:checked + .radio-tile {
    border-color: var(--accent-teal);
    background: rgba(36, 197, 179, 0.08);
    color: var(--accent-teal);
}

.radio-tile-group {
    margin-top: 0;
}

.rental-type-block {
    max-width: 560px;
    width: 100%;
    justify-self: center;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-top: 1px dashed var(--card-border);
    padding-top: 0.75rem;
}

.rental-type-block > label {
    width: 100%;
    text-align: center !important;
}

.rental-type-block .radio-tile-group {
    justify-content: center;
}

.limited-table-scroll {
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

.limited-table-scroll-15 {
    max-height: 690px;
}

.limited-table-scroll-10 {
    max-height: 475px;
}

.limited-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #111b2d;
}

.limited-table-scroll tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 2;
}

/* Warning & Alerts */
.alert-box {
    padding: 1rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.alert-danger {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #a7f3d0;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fde68a;
}

/* --- TABLES & GRID DATA --- */
.data-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    overflow: hidden;
    margin-bottom: 2rem;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

th {
    background: rgba(10, 15, 30, 0.5);
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--card-border);
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-primary);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-muted { background: rgba(255, 255, 255, 0.05); color: var(--text-secondary); }

/* --- ACCOUNTING COMPONENT C1 / C2 --- */
.accounting-layout {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 1.5rem;
    min-width: 0; /* permet aux colonnes de rétrécir et aux tables de scroller */
}
.accounting-layout > * {
    min-width: 0; /* empêche le débordement des tables/grids internes */
}

/* La création et la liste sont deux vues distinctes qui utilisent toute la largeur. */
.accounting-layout.accounting-layout-tenants {
    grid-template-columns: 1fr;
}

/* Variant: Accounting C1/C2 panel — C1 (règlement propriétaires) occupe 2/3,
   C2 (trésorerie & réconciliation) occupe 1/3. Chaque colonne peut scroller
   horizontalement via min-width:0 pour rester lisible. */
.accounting-layout.accounting-layout-c2 {
    grid-template-columns: 2fr 1fr;
}

.accounting-layout.accounting-layout-billing {
    grid-template-columns: 2fr 1fr;
}

.accounting-layout-billing > .reconciliation-card {
    width: 100%;
}

@media(max-width: 1024px) {
    .accounting-layout,
    .accounting-layout.accounting-layout-tenants,
    .accounting-layout.accounting-layout-c2,
    .accounting-layout.accounting-layout-billing {
        grid-template-columns: 1fr;
    }
}

/* Les sous-grilles inline (grid-template-columns: 1fr 1fr / repeat(3,1fr))
   dans les formulaires d'encaissement et de fiche admin doivent pouvoir
   s'adapter et scroller horizontalement plutôt que de déborder l'écran.
   On leur impose min-width:0 et un comportement auto-fit. */
.reconciliation-card [style*="grid-template-columns: 1fr 1fr"],
.reconciliation-card [style*="grid-template-columns:1fr 1fr"],
.reconciliation-card [style*="grid-template-columns: repeat(2, 1fr)"],
.reconciliation-card [style*="grid-template-columns:repeat(2,1fr)"],
.reconciliation-card [style*="grid-template-columns: repeat(3, 1fr)"],
.reconciliation-card [style*="grid-template-columns:repeat(3,1fr)"] {
    min-width: 0;
}

.reconciliation-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    margin-bottom: 1.5rem;
}

.settings-plus-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    width: 100%;
    grid-column: 1 / -1;
    align-items: start;
    box-sizing: border-box;
}

.settings-card-slot {
    min-width: 0;
    width: 100%;
}

.settings-card-slot > .reconciliation-card,
#google-integration-slot > .reconciliation-card {
    width: 100%;
    margin: 0;
    box-sizing: border-box;
}

.settings-plus-main,
.settings-plus-side {
    min-width: 0;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.settings-plus-main .table-responsive,
.settings-plus-side .table-responsive,
.settings-plus-main input,
.settings-plus-main textarea,
.settings-plus-side input,
.settings-plus-side textarea {
    max-width: 100%;
    box-sizing: border-box;
}

.settings-plus-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-plus-side {
    justify-self: stretch;
}

/* --- DIRECTION & AGENCIES --- */
.agencies-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 1rem;
}

.agency-page-card {
    position: relative;
    overflow: hidden;
    min-height: 220px;
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    background: linear-gradient(145deg, rgba(25,39,65,0.92), rgba(14,25,43,0.92));
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 35px rgba(0,0,0,0.18);
}

.agency-page-card.main-agency {
    grid-column: 1 / -1;
    min-height: 190px;
    background: linear-gradient(125deg, rgba(13,70,67,0.92), rgba(18,38,59,0.94) 65%, rgba(96,65,13,0.82));
    border-color: rgba(36,197,179,0.35);
}

.agency-page-card::after {
    content: "";
    position: absolute;
    width: 150px;
    height: 150px;
    right: -55px;
    bottom: -70px;
    border-radius: 50%;
    background: rgba(36,197,179,0.08);
}

.agency-card-top { display:flex; align-items:flex-start; justify-content:space-between; gap:0.75rem; }
.agency-icon-box { width:46px; height:46px; display:grid; place-items:center; border-radius:14px; color:#07111d; background:var(--accent-teal); }
.agency-icon-box svg { width:23px; height:23px; }
.agency-page-card h3 { margin: 1rem 0 0.3rem; font-size:1.15rem; }
.agency-page-card p { color:var(--text-secondary); font-size:0.82rem; }
.agency-page-meta { display:flex; flex-wrap:wrap; gap:0.45rem 0.8rem; margin:0.9rem 0 1rem; color:#cbd5e1; font-size:0.76rem; }
.agency-page-meta span { display:flex; align-items:center; gap:0.3rem; }
.agency-page-meta svg { width:14px; height:14px; color:var(--accent-gold); }
.agency-page-card .btn { margin-top:auto; position:relative; z-index:1; }
.agency-card-actions { display:flex; flex-wrap:wrap; gap:0.55rem; margin-top:auto; position:relative; z-index:1; }
.agency-card-actions .btn { margin-top:0; }
.agency-eyebrow { display:block; color:var(--accent-teal); font-size:0.68rem; font-weight:800; letter-spacing:0.12em; text-transform:uppercase; }
.agency-card-heading { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:1rem; }
.agency-create-card { border-color:rgba(36,197,179,0.22); }
.agency-detail-hero { margin-bottom:1rem; padding:1.5rem; border-radius:var(--radius-lg); background:linear-gradient(120deg, rgba(13,70,67,0.9), rgba(19,34,56,0.95)); border:1px solid rgba(36,197,179,0.28); }
.agency-detail-hero h2 { margin:0.35rem 0; font-size:1.7rem; }
.agency-detail-layout { display:grid; grid-template-columns:minmax(0,2fr) minmax(290px,1fr); gap:1rem; align-items:start; }
.agency-managers-list { display:grid; gap:0.65rem; }
.agency-manager-row { display:flex; align-items:center; justify-content:space-between; gap:0.8rem; padding:0.8rem; background:rgba(255,255,255,0.035); border:1px solid var(--card-border); border-radius:var(--radius-md); }
.agency-manager-row strong { display:block; }
.agency-manager-row small { color:var(--text-secondary); }
.agency-list-section-title { grid-column:1/-1; display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-top:0.4rem; padding-bottom:0.6rem; border-bottom:1px solid var(--card-border); }
.agency-list-section-title h3 { margin:0; }
.direction-access-card { grid-column:1/-1; min-height:175px; background:linear-gradient(120deg,rgba(79,57,18,0.92),rgba(18,34,55,0.96)); border-color:rgba(229,169,59,0.35); }
.direction-stats-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:0.75rem; margin-bottom:1rem; }
.direction-stat-card { padding:1rem; border:1px solid var(--card-border); border-radius:var(--radius-md); background:rgba(255,255,255,0.035); }
.direction-stat-card strong { display:block; margin-top:0.25rem; color:var(--accent-teal); font-size:1.35rem; }
.direction-mother-code { padding:1rem; border-radius:var(--radius-md); background:rgba(229,169,59,0.1); border:1px solid rgba(229,169,59,0.28); }
.direction-code-value { display:flex; align-items:center; justify-content:space-between; gap:0.7rem; margin-top:0.35rem; }
.direction-code-value code { color:#fff; font-size:0.95rem; letter-spacing:0.07em; word-break:break-all; }
.direction-users-group { margin-bottom:1rem; border:1px solid var(--card-border); border-radius:var(--radius-md); overflow:hidden; }
.direction-users-group h4 { padding:0.75rem 0.9rem; margin:0; background:rgba(255,255,255,0.045); color:var(--accent-gold); }
.direction-user-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:0.35rem; }

@media (max-width: 900px) {
    .agency-detail-layout { grid-template-columns:1fr; }
}

@media (max-width: 820px) {
    .settings-plus-layout {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .settings-plus-layout .reconciliation-card {
        padding: 1rem;
    }
}

/* --- VIRTUAL DRIVE TREE (Simulation Dossier Virtuel Google Drive) --- */
.virtual-drive-tree {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}
.virtual-drive-tree .tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #a7f3d0;
    cursor: default;
}
.virtual-drive-tree .tree-item[ondblclick] {
    cursor: pointer;
    border-radius: 4px;
}
.virtual-drive-tree .tree-item[ondblclick]:hover {
    background: rgba(36, 197, 179, 0.12);
}
.virtual-drive-tree .tree-item i,
.virtual-drive-tree .tree-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--accent-teal);
}
.virtual-drive-tree .tree-item-l1 { padding-left: 18px; }
.virtual-drive-tree .tree-item-l2 { padding-left: 36px; }
.virtual-drive-tree .tree-item-leaf { padding-left: 54px; color: var(--text-secondary); }
.virtual-drive-tree .tree-item-leaf i,
.virtual-drive-tree .tree-item-leaf svg { color: var(--accent-gold); }
.virtual-drive-years-scroll {
    max-height: 62px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    padding-right: 4px;
    border-left: 1px dashed rgba(229, 169, 59, 0.35);
}

.reconciliation-formula {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1.5rem;
}

.formula-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.formula-row.total {
    border-top: 1px solid var(--card-border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.formula-row.total.balanced {
    color: var(--success);
}

.formula-row.total.unbalanced {
    color: var(--danger);
}

/* --- RECENT ACTIVITY & ALERTS --- */
.alert-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--danger-bg);
    border-left: 4px solid var(--danger);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.alert-strip-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-strip-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.alert-strip-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* --- PREVIEW AND PRINT MODAL --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Reçu & aperçu bilan : z-index supérieur pour qu'ils s'affichent AU-DESSUS
   des autres modales (ex. fiche locataire) lorsqu'ils sont ouverts depuis
   celles-ci. Corrige le bug du reçu qui apparaissait en arrière-plan. */
#receipt-modal.modal-backdrop,
#bilan-preview-modal.modal-backdrop,
#virtual-folder-modal.modal-backdrop {
    z-index: 1100;
}

#legal-letter-draft-modal.modal-backdrop {
    z-index: 1300;
}

#professional-message-modal.modal-backdrop {
    z-index: 1400;
}

.professional-message-card {
    max-width: 460px;
    padding: 2rem;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.professional-message-icon {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--accent-teal);
    background: rgba(36, 197, 179, 0.12);
    border: 1px solid rgba(36, 197, 179, 0.35);
}

.professional-message-icon.error {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
}

.professional-message-icon.success {
    color: var(--accent-teal);
}

.professional-message-card h3,
.professional-message-card p {
    margin: 0;
}

.professional-message-card p {
    color: var(--text-secondary);
    line-height: 1.55;
    white-space: pre-line;
}

.legal-letter-draft-card {
    width: min(920px, 96vw);
    max-width: 920px;
}

.legal-letter-editor {
    overflow-y: auto;
}

#legal-letter-body {
    min-height: 360px;
    resize: vertical;
    line-height: 1.55;
    font-family: Georgia, "Times New Roman", serif;
}

.legal-letter-save-status {
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 700;
}

.legal-letter-save-status.pending {
    color: var(--accent-gold);
    background: rgba(229, 169, 59, 0.1);
}

.legal-letter-save-status.saved {
    color: var(--accent-teal);
    background: rgba(36, 197, 179, 0.1);
}

.legal-letter-actions {
    flex-wrap: wrap;
    gap: 0.6rem;
}

.modal-content {
    background: #0f172a;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-backdrop.active .modal-content {
    transform: scale(1);
}

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

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

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: rgba(10, 15, 30, 0.4);
}

/* A6 Receipt Preview styling (for window preview) */
.receipt-card {
    background: white;
    color: black;
    padding: 1.5rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-width: 100%;
    margin: 0 auto;
}

.receipt-header {
    text-align: center;
    border-bottom: 2px dashed #000;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
}

.receipt-title {
    font-weight: bold;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.receipt-logo-sub {
    font-size: 0.7rem;
    text-transform: uppercase;
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    margin: 0.35rem 0;
}

.receipt-row.bold {
    font-weight: bold;
    font-size: 0.95rem;
}

.receipt-divider {
    border-top: 1px dashed #000;
    margin: 0.5rem 0;
}

.receipt-footer {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.7rem;
    border-top: 2px dashed #000;
    padding-top: 0.5rem;
}

/* Custom Owners list styling */
.landlord-list li {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.landlord-list li:hover {
    background: rgba(36, 197, 179, 0.1);
    border-color: var(--accent-teal);
    transform: translateX(3px);
}

/* Red Highlight status */
.status-unpaid {
    color: var(--danger) !important;
    font-weight: 700;
}

.status-paid {
    color: var(--success) !important;
    font-weight: 700;
}

.status-warning {
    color: var(--accent-gold) !important;
    font-weight: 700;
}

/* --- PRINT & EXPORT MEDIA CSS --- */
@media print {
    body * {
        visibility: hidden;
    }
    .receipt-print-area, .receipt-print-area * {
        visibility: visible;
    }
    .receipt-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}

/* Collapse animation states */
.collapsed-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 0;
    margin-top: 0 !important;
}

.expanded-body {
    max-height: 2000px;
    overflow: visible;
    transition: max-height 0.3s ease-in, opacity 0.3s ease-in;
    opacity: 1;
}

.optional {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: normal;
    margin-left: 4px;
}

/* --- LOGIN OVERLAY STYLING --- */
.login-overlay-backdrop {
    position: fixed;
    inset: 0;
    width: 100%;
    min-height: 100vh;
    padding: 2rem 1rem;
    background:
        linear-gradient(rgba(6, 13, 24, 0.82), rgba(6, 13, 24, 0.94)),
        radial-gradient(circle at 18% 16%, rgba(36, 197, 179, 0.24), transparent 34%),
        radial-gradient(circle at 82% 84%, rgba(229, 169, 59, 0.18), transparent 30%),
        #08111f;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    overflow-y: auto;
    isolation: isolate;
}

.login-overlay-backdrop::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 42px 42px;
    pointer-events: none;
    z-index: -2;
}

.loyer-auth-orb {
    position: fixed;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.2;
    pointer-events: none;
    z-index: -1;
}

.loyer-auth-orb-one { top: -60px; left: 8%; background: var(--accent-teal); }
.loyer-auth-orb-two { right: 6%; bottom: -80px; background: var(--accent-gold); }

.login-card {
    background: linear-gradient(145deg, rgba(22, 35, 58, 0.9), rgba(12, 22, 39, 0.94));
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px;
    padding: 2.25rem;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 28px 70px rgba(0,0,0,0.48), inset 0 1px 0 rgba(255,255,255,0.04);
    backdrop-filter: blur(22px);
    text-align: left;
    animation: loyerAuthEnter 0.45s ease both;
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-header.compact { margin-bottom: 1.35rem; }
.login-header h1 { font-size: 1.85rem; margin: 0.35rem 0 0.4rem; letter-spacing: -0.04em; }
.login-header p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.55; max-width: 420px; margin: 0 auto; }

.loyer-auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 66px;
    height: 66px;
    margin-bottom: 0.8rem;
    border-radius: 20px;
    color: #07111d;
    background: linear-gradient(135deg, var(--accent-teal), #78eadc);
    box-shadow: 0 14px 35px rgba(36,197,179,0.28);
    transform: rotate(-4deg);
}

.loyer-auth-logo svg { width: 32px; height: 32px; }
.loyer-auth-kicker { display: block; color: var(--accent-gold); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.loyer-auth-actions { display: grid; gap: 0.75rem; }

.btn-auth-loyer {
    width: 100%;
    min-height: 50px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    border: 0;
    border-radius: 13px;
    color: #07111d;
    background: linear-gradient(135deg, var(--accent-teal), #5be0d0);
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-auth-loyer.secondary { color: #fff; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); }
.btn-auth-loyer.developer { color:#fff; background:linear-gradient(135deg,#f59e0b,#ea580c); box-shadow:0 10px 28px rgba(245,158,11,0.2); }
.loyer-developer-access-dock {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000001;
    width: auto;
    min-width: 300px;
    border: 1px solid rgba(255,255,255,0.3);
}
.btn-auth-loyer:hover { transform: translateY(-2px); filter: brightness(1.06); box-shadow: 0 10px 28px rgba(36,197,179,0.2); }
.btn-auth-loyer svg { width: 19px; height: 19px; }

@media (max-width: 600px) {
    .loyer-developer-access-dock { top:0.65rem; right:0.65rem; left:0.65rem; width:auto; min-width:0; }
}

.auth-form-group-loyer { margin-bottom: 1rem; }
.auth-form-group-loyer label { display: block; color: #cbd5e1; margin-bottom: 0.45rem; font-size: 0.75rem; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; }
.auth-form-group-loyer input {
    width: 100%;
    min-height: 46px;
    padding: 0.75rem 0.9rem;
    color: #fff;
    background: rgba(255,255,255,0.065);
    border: 1px solid rgba(255,255,255,0.13);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.auth-form-group-loyer input:focus { border-color: var(--accent-teal); background: rgba(36,197,179,0.08); box-shadow: 0 0 0 3px rgba(36,197,179,0.13); }
.auth-form-group-loyer input::placeholder { color: #64748b; }
.loyer-auth-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.loyer-auth-password-wrap { position: relative; }
.loyer-auth-password-wrap input { padding-right: 3rem; }
.loyer-auth-password-wrap button { position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%); display: flex; padding: 0.35rem; color: var(--text-secondary); border: 0; background: transparent; cursor: pointer; }
.loyer-auth-password-wrap button svg { width: 18px; height: 18px; }
.loyer-auth-checkbox { display: flex; align-items: center; gap: 0.5rem; margin: -0.25rem 0 1rem; color: var(--text-secondary); font-size: 0.8rem; cursor: pointer; }
.loyer-auth-checkbox input { width: auto; accent-color: var(--accent-teal); }
.loyer-setup-progress { display: flex; align-items: flex-start; margin: 0 0 1.4rem; }
.loyer-setup-progress > div:not(.loyer-setup-progress-line) { width: 118px; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; color: var(--text-muted); text-align: center; }
.loyer-setup-progress > div > span { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; color: var(--text-secondary); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.13); font-size: 0.78rem; font-weight: 800; }
.loyer-setup-progress > div > small { font-size: 0.66rem; font-weight: 700; line-height: 1.2; }
.loyer-setup-progress > div.active { color: #fff; }
.loyer-setup-progress > div.active > span { color: #07111d; background: var(--accent-teal); border-color: var(--accent-teal); box-shadow: 0 0 0 4px rgba(36,197,179,0.12); }
.loyer-setup-progress > div.completed > span { color: #07111d; background: var(--accent-gold); border-color: var(--accent-gold); }
.loyer-setup-progress-line { flex: 1; height: 1px; margin-top: 15px; background: rgba(255,255,255,0.13); }
.loyer-auth-error { display: none; margin-bottom: 0.8rem; padding: 0.7rem 0.8rem; color: #fecaca; background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); border-radius: 10px; font-size: 0.82rem; }
.loyer-auth-error.show { display: block; }
.loyer-auth-back { width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.4rem; margin-top: 0.75rem; padding: 0.6rem; color: var(--text-secondary); background: transparent; border: 0; cursor: pointer; font-weight: 650; }
.loyer-auth-back:hover { color: #fff; }
.loyer-auth-back svg { width: 16px; height: 16px; }
.loyer-auth-existing-agency { width: 100%; justify-content: center; margin-top: 0.85rem; padding: 0.7rem; border: 1px solid rgba(94, 234, 212, 0.25); border-radius: 10px; background: rgba(15, 118, 110, 0.08); color: #99f6e4; }
.loyer-auth-existing-agency:hover { background: rgba(15, 118, 110, 0.18); color: #fff; }
.loyer-preauth-fullscreen { display: flex; width: max-content; align-items: center; justify-content: center; gap: 0.45rem; margin: 0.75rem 0 1rem auto; padding: 0.55rem 0.8rem; border: 1px solid rgba(94, 234, 212, 0.3); border-radius: 10px; background: rgba(15, 118, 110, 0.12); color: #99f6e4; font: inherit; font-size: 0.75rem; font-weight: 700; cursor: pointer; }
.loyer-preauth-fullscreen:hover { background: rgba(15, 118, 110, 0.25); color: #fff; }
.loyer-preauth-fullscreen svg { width: 16px; height: 16px; }
.loyer-auth-global-tools { position: fixed; top: 1rem; left: 1rem; z-index: 1000001; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.loyer-auth-global-tools .loyer-preauth-fullscreen { margin: 0; }
.loyer-auth-separator { display: flex; align-items: center; gap: 0.65rem; margin: 1.1rem 0 0.8rem; color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.loyer-auth-separator::before, .loyer-auth-separator::after { content: ""; height: 1px; flex: 1; background: rgba(255,255,255,0.1); }
.loyer-google-login { display: flex; justify-content: center; min-height: 42px; }
.loyer-auth-default-hint { margin-top: 0.75rem; color: var(--text-muted); font-size: 0.72rem; text-align: center; }
.auth-signature { margin-top: 1.5rem; color: var(--text-muted); font-size: 0.72rem; text-align: center; }
.auth-signature a { color: #5eead4; text-decoration: none; }
.auth-signature a:hover { text-decoration: underline; }
.loyer-trust-note { display: grid; gap: 0.3rem; margin: 0 0 1rem; padding: 0.8rem 0.9rem; border: 1px solid rgba(45, 212, 191, 0.3); border-radius: 12px; background: rgba(13, 148, 136, 0.1); color: #cbd5e1; font-size: 0.75rem; line-height: 1.45; }
.loyer-trust-note strong { color: #5eead4; font-size: 0.78rem; }
.loyer-trust-note.compact { margin: 0.85rem 0 0; padding: 0.65rem 0.75rem; font-size: 0.7rem; }

.loyer-auth-online { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 1.1rem; padding: 0.8rem; border: 1px solid rgba(229,169,59,0.22); border-radius: 13px; background: rgba(229,169,59,0.07); }
.loyer-auth-online > div { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.loyer-auth-online > div > svg { width: 21px; color: var(--accent-gold); flex-shrink: 0; }
.loyer-auth-online span { display: flex; min-width: 0; flex-direction: column; }
.loyer-auth-online strong { font-size: 0.8rem; }
.loyer-auth-online small { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.loyer-auth-online button { padding: 0.45rem 0.75rem; border: 1px solid rgba(229,169,59,0.35); border-radius: 9px; color: var(--accent-gold); background: rgba(229,169,59,0.1); cursor: pointer; }
.loyer-auth-online button:disabled { opacity: 0.4; cursor: not-allowed; }

@keyframes loyerAuthEnter {
    from { opacity: 0; transform: translateY(22px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 600px) {
    .login-overlay-backdrop { align-items: flex-start; padding: 1rem 0.75rem; }
    .login-card { padding: 1.35rem; border-radius: 19px; margin: 3.2rem 0 auto; }
    .loyer-auth-global-tools { top: 0.55rem; left: 0.55rem; right: 0.55rem; }
    .login-header h1 { font-size: 1.55rem; }
    .loyer-auth-form-grid { grid-template-columns: 1fr; gap: 0; }
    .loyer-auth-online small { max-width: 175px; }
}

/* Tenant form distinction styles */
#tenant-form-card.habitation-style {
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.10), rgba(59, 130, 246, 0.04)) !important;
    border: 1px solid rgba(37, 99, 235, 0.35) !important;
    box-shadow: inset 0 0 0 1px rgba(147, 197, 253, 0.15);
}
#tenant-form-card.professionnel-style {
    background: linear-gradient(180deg, rgba(180, 83, 9, 0.12), rgba(251, 146, 60, 0.05)) !important;
    border: 1px solid rgba(180, 83, 9, 0.35) !important;
    box-shadow: inset 0 0 0 1px rgba(253, 186, 116, 0.15);
}

/* =====================================================================
   ACTIONS 6 & 7 — Fiche d'Administration : 16 fixed rows + modern tables
   Aerated, high-contrast layout that renders perfectly on screen AND in
   the PDF export sent to owners (print-safe, no white pages).
   ===================================================================== */

/* The PDF element is rendered on a white background; the on-screen inline
   fiche is injected inside #bilan-sheet-inline-container which itself sits
   on a dark card, so we scope the table styling to .admin-sheet explicitly. */
table.admin-sheet {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 18px 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    line-height: 1.35;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* Header row "Local / Rubrique" + local columns */
table.admin-sheet thead th {
    background: #0f766e;
    color: #ffffff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 9px;
    padding: 8px 6px;
    border: 1px solid #0f766e;
    text-align: center;
}
table.admin-sheet thead th.col-rubrique {
    text-align: left;
    width: 150px;
    background: #134e4a;
}

/* Body cells (base) — generous padding for an aerated, modern feel */
table.admin-sheet tbody td {
    padding: 7px 6px;
    border: 1px solid #e2e8f0;
    text-align: center;
    vertical-align: middle;
}
table.admin-sheet tbody tr:nth-child(even) td {
    background: #f8fafc;
}

/* Left rubrique label column */
table.admin-sheet .fat-row-label {
    text-align: left;
    font-weight: 600;
    color: #1e293b;
    background: #f1f5f9 !important;
    border-right: 2px solid #cbd5e1;
}

/* Row 1 — Nom et Prénom (highlighted) */
table.admin-sheet tbody tr.row-name td {
    background: #ecfdf5;
    font-weight: 700;
    color: #064e3b;
    border-bottom: 2px solid #14b8a6;
}
table.admin-sheet tbody tr.row-name td.cell-name.vacant {
    color: #94a3b8;
    font-weight: 600;
}
table.admin-sheet tbody tr.row-name td.fat-row-label {
    background: #d1fae5 !important;
    color: #064e3b;
}

/* Rows 2-4 — Cautions */
table.admin-sheet tbody tr.row-caution td.cell-amount.paid {
    color: #0f766e;
    font-weight: 700;
}
table.admin-sheet tbody tr.row-caution td.cell-amount.empty {
    color: #cbd5e1;
}

/* Rows 5-16 — Monthly status badges */
table.admin-sheet tbody tr.row-month td.cell-status.paid {
    background: #dcfce7;
    color: #15803d;
    font-weight: 700;
    border: 1px solid #bbf7d0;
}
table.admin-sheet tbody tr.row-month td.cell-status.unpaid {
    background: #fee2e2;
    color: #b91c1c;
    font-weight: 700;
    border: 1px solid #fecaca;
}
table.admin-sheet tbody tr.row-month td.cell-status.vacant-cell {
    color: #cbd5e1;
}
/* Tâche 1 — months strictly after the current date: neutral, not unpaid. */
table.admin-sheet tbody tr.row-month td.cell-status.future-cell {
    color: #94a3b8;
    background: #f1f5f9;
    font-style: italic;
    border: 1px solid #e2e8f0;
}

/* Single-column variant (no locals configured) */
table.admin-sheet.single .fat-row-value.empty {
    color: #cbd5e1;
    font-style: italic;
}

/* Level title above each per-level table */
.admin-level-title {
    margin: 14px 0 6px 0;
    font-size: 12px;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    padding-bottom: 4px;
    border-bottom: 2px solid #14b8a6;
}

.admin-sheet-note {
    font-size: 10px;
    color: #64748b;
    font-style: italic;
    margin-bottom: 20px;
}

/* Responsive: on narrow screens, allow horizontal scroll so the 16-row
   structure is never broken. The wrapping container handles overflow. */
@media (max-width: 768px) {
    table.admin-sheet {
        font-size: 9px;
    }
    table.admin-sheet tbody td,
    table.admin-sheet thead th {
        padding: 5px 4px;
    }
    table.admin-sheet thead th.col-rubrique {
        width: 110px;
    }
}

/* Print hardening: ensure the administrative sheet always prints with full
   borders and contrasting colours, avoiding the "white page" PDF bug. */
@media print {
    table.admin-sheet,
    table.admin-sheet thead th,
    table.admin-sheet tbody td {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        border: 1px solid #94a3b8 !important;
    }
    table.admin-sheet {
        page-break-inside: auto;
    }
    table.admin-sheet tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    table.admin-sheet thead {
        display: table-header-group;
    }
}

/* ACTIONS 1 & 2 — A/B receipt tab switcher in the receipt modal */
.receipt-tab {
    opacity: 0.55;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.receipt-tab.active-tab {
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: 0 0 0 2px var(--accent-teal);
}

/* Virtual folder modal items (double-clic Simulation Drive). */
.vd-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0,0,0,0.25);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}
.vd-item svg,
.vd-item i {
    width: 16px;
    height: 16px;
    color: var(--accent-teal);
    flex-shrink: 0;
}

/* ===================================================================== */
/* Tâche 4 — AFFICHAGE RESPONSIF COMPLET (PC / tablettes / mobiles)      */
/* ===================================================================== */

/* Hamburger button — hidden on desktop, visible on small screens. */
.btn-toggle-sidebar {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--accent-teal);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-toggle-sidebar svg,
.btn-toggle-sidebar i {
    width: 22px;
    height: 22px;
}

/* Overlay shown when the mobile drawer is open. */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}
#app-container.sidebar-open .sidebar-overlay {
    display: block;
}

/* --- Responsive form grids: make fixed multi-column grids auto-collapse --- */
/* Convert the hardcoded inline 2/3-column grids to a flexible auto-fit grid
   so they collapse gracefully on narrow screens. */
.form-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
}
.form-grid-full {
    grid-column: 1 / -1;
}
.rental-type-block {
    max-width: min(560px, 100%);
}

/* Header becomes wrap-friendly. */
header {
    flex-wrap: wrap;
    gap: 0.75rem;
}
.top-status {
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ===== BREAKPOINT: TABLET & MOBILE (≤ 1024px) ===== */
@media (max-width: 1024px) {
    /* Sidebar becomes an off-canvas drawer. */
    aside {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.4);
    }
    #app-container.sidebar-open aside {
        transform: translateX(0);
    }
    main {
        margin-left: 0;
        padding: 1.25rem;
    }
    .btn-toggle-sidebar {
        display: inline-flex;
    }

    /* Dashboard / house admin two-column summary collapses. */
    .dashboard-grid[style*="grid-template-columns: 1fr 1fr"],
    #house-details-view .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    /* Modal widths adapt. */
    .modal-content {
        width: 95% !important;
        max-width: 95vw !important;
    }
}

/* ===== BREAKPOINT: LARGE MOBILE (≤ 768px) ===== */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    .tenant-form-row-2,
    .tenant-form-row-3,
    .tenant-form-row-4,
    .tenant-form-row-5,
    .tenant-search-grid,
    .payment-form-row-2,
    .payment-form-row-3,
    .payment-section-fields,
    .payment-summary-grid {
        grid-template-columns: 1fr;
    }

    /* The internal 2-column grid of the tenant fiche collapses to 1 column. */
    #tenant-fiche-modal .modal-body > div[style*="grid-template-columns: 180px 1fr"],
    #tenant-fiche-modal .modal-body > div[style*="grid-template-columns:180px 1fr"] {
        grid-template-columns: 1fr !important;
    }
    #tenant-fiche-id-card {
        margin: 0 auto;
        max-width: 180px;
    }

    /* Section title bars stack vertically. */
    .section-title-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .section-title-bar > div {
        width: 100%;
    }

    /* Stat values slightly smaller to avoid overflow. */
    .stat-value {
        font-size: 1.4rem;
    }

    /* Reconciliation cards less padding. */
    .reconciliation-card {
        padding: 1rem;
    }

    /* Search input takes full width. */
    .search-container {
        max-width: 100% !important;
        flex: 1 1 100%;
    }
}

/* ===== BREAKPOINT: SMALL MOBILE (≤ 480px) ===== */
@media (max-width: 480px) {
    main {
        padding: 0.75rem;
    }
    header {
        gap: 0.5rem;
    }
    .top-status .sync-status,
    #btn-fullscreen,
    #active-agency-badge {
        font-size: 0.72rem;
    }
    /* Buttons in title bars go full-width stacked. */
    .section-title-bar > div[style*="display: flex"],
    .section-title-bar > div[style*="display:flex"] {
        flex-direction: column;
    }
    .section-title-bar > div[style*="display: flex"] > *,
    .section-title-bar > div[style*="display:flex"] > * {
        width: 100%;
    }
    .stat-value {
        font-size: 1.2rem;
    }
    /* Modals nearly full-screen on small phones. */
    .modal-content {
        width: 98% !important;
        max-height: 94vh !important;
    }
    .modal-body {
        padding: 1rem !important;
    }
}
