:root {
    --bg: #fff7ed;
    --bg-soft: #ffffff;
    --card: rgba(255, 255, 255, 0.95);
    --text: #431407;
    --muted: #9a3412;
    --primary: #f97316;
    --primary-strong: #ea580c;
    --success: #22c55e;
    --danger: #dc2626;
    --warning: #f59e0b;
    --ring: rgba(249, 115, 22, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    min-height: 100vh;
    background: radial-gradient(circle at 10% 10%, #fed7aa, transparent 38%),
                radial-gradient(circle at 90% 8%, #fdba74, transparent 28%),
                linear-gradient(160deg, #ffffff, var(--bg));
}

.app-shell {
    width: min(1150px, 94vw);
    margin: 1.2rem auto 2rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.9rem;
    padding: 1rem 1.2rem;
    border: 1px solid rgba(249, 115, 22, 0.28);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    margin-bottom: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.08rem;
    font-weight: 700;
}

.brand-copy {
    display: grid;
    gap: 0.1rem;
}

.brand-name {
    line-height: 1.1;
}

.brand-corporate {
    font-size: 0.67rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #9a3412;
    font-weight: 700;
    opacity: 0.9;
    line-height: 1.1;
}

.brand-dot {
    width: 11px;
    height: 11px;
    background: linear-gradient(130deg, #fb923c, #f97316);
    border-radius: 999px;
    box-shadow: 0 0 16px rgba(249, 115, 22, 0.65);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar-menu {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.topbar-utilities {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.menu-dropdown {
    position: relative;
}

.menu-dropdown-summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid rgba(249, 115, 22, 0.34);
    border-radius: 12px;
    padding: 0.52rem 0.76rem;
    background: transparent;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    color: var(--text);
}

.menu-dropdown-summary::-webkit-details-marker {
    display: none;
}

.menu-dropdown-summary::after {
    content: '▾';
    font-size: 0.75rem;
    opacity: 0.85;
}

.menu-dropdown[open] .menu-dropdown-summary::after {
    content: '▴';
}

.menu-dropdown-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid rgba(249, 115, 22, 0.28);
    border-radius: 12px;
    box-shadow: 0 14px 30px rgba(194, 65, 12, 0.17);
    padding: 0.35rem;
    z-index: 26;
}

.menu-dropdown-link {
    display: block;
    text-decoration: none;
    color: var(--text);
    border-radius: 9px;
    padding: 0.5rem 0.65rem;
    font-weight: 600;
}

.menu-dropdown-link:hover {
    background: #fff7ed;
}

.alerts-menu {
    position: relative;
}

.alerts-summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid rgba(249, 115, 22, 0.34);
    border-radius: 12px;
    padding: 0.52rem 0.76rem;
    background: #fff7ed;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
}

.alerts-summary::-webkit-details-marker {
    display: none;
}

.alerts-icon {
    font-size: 1rem;
}

.alerts-badge {
    min-width: 1.2rem;
    height: 1.2rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.74rem;
    color: #ffffff;
    background: #dc2626;
    padding: 0 0.3rem;
}

.alerts-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: min(360px, 88vw);
    background: #fff;
    border: 1px solid rgba(249, 115, 22, 0.28);
    border-radius: 14px;
    box-shadow: 0 14px 30px rgba(194, 65, 12, 0.17);
    padding: 0.75rem;
    z-index: 25;
}

.alerts-title {
    margin: 0 0 0.5rem;
    font-size: 0.86rem;
    color: #9a3412;
    font-weight: 700;
}

.alerts-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow: auto;
    display: grid;
    gap: 0.5rem;
}

.alerts-item {
    border: 1px solid rgba(249, 115, 22, 0.18);
    border-radius: 10px;
    padding: 0.45rem 0.55rem;
    background: #fffaf5;
}

.alerts-link {
    color: #9a3412;
    font-weight: 700;
    text-decoration: none;
}

.alerts-link:hover {
    text-decoration: underline;
}

.alerts-meta {
    display: block;
    font-size: 0.8rem;
    color: #7c2d12;
    margin-top: 0.2rem;
}

.alerts-empty {
    margin: 0;
    font-size: 0.9rem;
    color: #9a3412;
}

.is-hidden {
    display: none !important;
}

.page-content {
    display: grid;
    gap: 1rem;
}

.card {
    background: var(--card);
    border: 1px solid rgba(251, 146, 60, 0.26);
    border-radius: 18px;
    padding: 1.25rem;
    box-shadow: 0 10px 30px rgba(194, 65, 12, 0.14);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.7rem;
    margin-bottom: 1rem;
}

.section-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: flex-end;
}

h1 {
    margin: 0;
    font-size: clamp(1.35rem, 2.4vw, 1.85rem);
}

.muted {
    color: var(--muted);
    margin-top: 0.3rem;
}

.tiny {
    font-size: 0.86rem;
}

.btn {
    appearance: none;
    border: none;
    text-decoration: none;
    cursor: pointer;
    border-radius: 12px;
    padding: 0.62rem 0.95rem;
    font-weight: 600;
    font-size: 0.92rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    color: #ffffff;
    background: linear-gradient(140deg, var(--primary), var(--primary-strong));
}

.btn-secondary {
    color: var(--text);
    background: #fff7ed;
    border: 1px solid rgba(249, 115, 22, 0.35);
}

.btn-outline,
.btn-ghost {
    color: var(--text);
    background: transparent;
    border: 1px solid rgba(249, 115, 22, 0.34);
}

.btn-danger {
    color: white;
    background: linear-gradient(140deg, #f43f5e, #fb7185);
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.alert {
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.45);
}

.alert-error {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.38);
}

.table-wrapper {
    overflow: auto;
}

.filters-form {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.9rem;
    border: 1px solid rgba(249, 115, 22, 0.24);
    background: #fffaf5;
    border-radius: 14px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
}

.filters-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.reservations-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

.reservations-table th,
.reservations-table td {
    padding: 0.72rem;
    border-bottom: 1px solid rgba(251, 146, 60, 0.2);
    vertical-align: top;
    text-align: left;
}

.reservations-table tr.reservation-row-non-hebergement td {
    background: rgba(249, 115, 22, 0.12);
}

.reservations-table th {
    font-size: 0.84rem;
    color: #9a3412;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.actions-stack {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.name-link {
    color: #9a3412;
    font-weight: 700;
    text-decoration: none;
}

.name-link:hover {
    text-decoration: underline;
}

.comment-preview {
    cursor: help;
    border-bottom: 1px dotted rgba(249, 115, 22, 0.55);
    font-weight: 600;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
}

.badge-upcoming {
    color: #7c2d12;
    background: rgba(251, 146, 60, 0.26);
    border: 1px solid rgba(249, 115, 22, 0.45);
}

.badge-active {
    color: #14532d;
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.5);
}

.badge-past {
    color: #78350f;
    background: rgba(245, 158, 11, 0.22);
    border: 1px solid rgba(245, 158, 11, 0.5);
}

.badge-cancelled {
    color: #ffe4e6;
    background: rgba(244, 63, 94, 0.33);
    border: 1px solid rgba(244, 63, 94, 0.56);
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    display: grid;
    gap: 0.8rem;
    justify-items: center;
    color: var(--muted);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0.9rem 0 1rem;
}

.kpi-card {
    border: 1px solid rgba(249, 115, 22, 0.24);
    background: #fffaf5;
    border-radius: 14px;
    padding: 0.8rem 0.9rem;
    display: grid;
    gap: 0.3rem;
}

.kpi-card h3 {
    margin: 0;
    font-size: 0.86rem;
    color: #9a3412;
}

.kpi-card p {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #7c2d12;
}

.kpi-card-danger {
    border-color: rgba(220, 38, 38, 0.45);
    background: rgba(220, 38, 38, 0.11);
}

.kpi-card-danger h3,
.kpi-card-danger p {
    color: #991b1b;
}

.kpi-card-positive {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.12);
}

.kpi-card-positive h3,
.kpi-card-positive p {
    color: #166534;
}

.kpi-card-negative {
    border-color: rgba(220, 38, 38, 0.45);
    background: rgba(220, 38, 38, 0.12);
}

.kpi-card-negative h3,
.kpi-card-negative p {
    color: #991b1b;
}

.accounting-table {
    min-width: 980px;
}

.accounting-filters-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.money-cell {
    font-weight: 700;
}

.money-positive {
    color: #166534;
}

.money-negative {
    color: #b91c1c;
}

.expenses-group-row td {
    background: rgba(249, 115, 22, 0.14);
    border-top: 2px solid rgba(249, 115, 22, 0.35);
    font-weight: 700;
}

.consumption-details-builder {
    border: 1px dashed rgba(249, 115, 22, 0.45);
    border-radius: 14px;
    padding: 0.8rem;
    background: #fffdf9;
    display: grid;
    gap: 0.7rem;
}

.consumption-details-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.6rem;
    align-items: center;
}

.consumption-total-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
    background: #fff7ed;
    border: 1px solid rgba(249, 115, 22, 0.35);
    padding: 0.35rem 0.65rem;
    font-size: 0.84rem;
}

.consumption-lines-editor-table {
    min-width: 720px;
}

.consumption-details-readonly-box {
    border: 1px solid rgba(249, 115, 22, 0.23);
    border-radius: 10px;
    background: #fffaf5;
    padding: 0.7rem;
}

.consumption-details-list {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.35rem;
}

.consumption-details-modal-card {
    width: min(860px, 96vw);
}

.consumption-details-modal-table {
    min-width: 640px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(67, 20, 7, 0.44);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1200;
}

.modal-card {
    width: min(980px, 96vw);
    max-height: 92vh;
    overflow: auto;
    background: var(--card);
    border: 1px solid rgba(249, 115, 22, 0.35);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 18px 38px rgba(67, 20, 7, 0.3);
}

.grouped-expense-lines-panel {
    border: 1px dashed rgba(249, 115, 22, 0.45);
    border-radius: 14px;
    padding: 0.8rem;
    background: #fffdf9;
    display: grid;
    gap: 0.7rem;
}

.grouped-expense-lines-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.grouped-expense-total-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid rgba(249, 115, 22, 0.35);
    background: #fff7ed;
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    font-size: 0.84rem;
}

.grouped-expense-lines-table {
    min-width: 760px;
}

.stats-chart-card {
    margin-top: 1rem;
}

.stats-chart-card h2 {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
}

.stats-chart-wrap {
    overflow-x: auto;
    padding-bottom: 0.2rem;
}

.stats-chart {
    width: 100%;
    min-width: 760px;
    height: auto;
    display: block;
}

.stats-chart-grid-line {
    stroke: rgba(154, 52, 18, 0.22);
    stroke-width: 1;
}

.stats-chart-axis-text {
    fill: #9a3412;
    font-size: 11px;
    font-weight: 600;
}

.stats-chart-area {
    fill: rgba(249, 115, 22, 0.2);
}

.stats-chart-line {
    fill: none;
    stroke: #ea580c;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stats-chart-point {
    fill: #f97316;
    stroke: #ffffff;
    stroke-width: 1.4;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.date-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.phone-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.hebergement-field {
    display: grid;
    gap: 0.38rem;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    width: fit-content;
}

.checkbox-inline input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--primary);
}

.phone-input-wrap > input[type="tel"] {
    flex: 1;
}

.copy-phone-btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.phone-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.copy-inline-btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    border-radius: 10px;
}

.date-input-wrap > input[type="text"] {
    flex: 1;
}

.date-picker-btn {
    flex-shrink: 0;
    min-width: 2.5rem;
    padding: 0.58rem 0.62rem;
}

.date-picker-native {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
    bottom: 0;
    right: 0;
}

label {
    display: grid;
    gap: 0.38rem;
    font-weight: 600;
    font-size: 0.93rem;
}

input,
select,
textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(251, 146, 60, 0.35);
    background: #ffffff;
    color: var(--text);
    padding: 0.72rem 0.78rem;
    font: inherit;
}

select:disabled,
input:read-only,
textarea:read-only {
    background: #fffaf5;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}

.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.auth-card {
    max-width: 520px;
    margin-inline: auto;
}

@media (max-width: 880px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-shell {
        width: min(96vw, 700px);
    }

    .card {
        padding: 1rem;
    }

    .reservations-table {
        min-width: 0;
    }

    .reservations-table thead {
        display: none;
    }

    .reservations-table,
    .reservations-table tbody,
    .reservations-table tr,
    .reservations-table td {
        display: block;
        width: 100%;
    }

    .reservations-table tr {
        border: 1px solid rgba(249, 115, 22, 0.28);
        border-radius: 14px;
        margin-bottom: 0.7rem;
        background: #fffaf5;
    }

    .reservations-table tr.reservation-row-non-hebergement {
        background: #ffedd5;
        border-color: rgba(249, 115, 22, 0.45);
    }

    .reservations-table td {
        border-bottom: 1px dashed rgba(249, 115, 22, 0.2);
        padding: 0.66rem;
    }

    .reservations-table td:last-child {
        border-bottom: none;
    }

    .reservations-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        color: #9a3412;
        text-transform: uppercase;
        margin-bottom: 0.2rem;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .accounting-filters-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .alerts-panel {
        right: auto;
        left: 0;
    }

    .topbar {
        align-items: stretch;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 0.65rem;
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-menu {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
    }

    .topbar-menu .btn,
    .menu-dropdown-summary {
        width: 100%;
        justify-content: center;
    }

    .topbar-utilities {
        width: 100%;
        justify-content: space-between;
    }

    .menu-dropdown-panel {
        left: auto;
        right: 0;
        width: min(260px, 86vw);
    }

    .consumption-details-modal-table {
        min-width: 0;
    }
}
