/* Gestion Riganel — interface d'administration */
:root {
    --c-primary: #1f4e5f;
    --c-primary-2: #2c6b80;
    --c-accent: #c8813a;
    --c-bg: #f4f6f8;
    --c-surface: #ffffff;
    --c-border: #dde3e8;
    --c-text: #1d2730;
    --c-muted: #667684;
    --c-ok: #2e7d4f;
    --c-warn: #b7791f;
    --c-err: #b3261e;
    --c-info: #2b6cb0;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    color: var(--c-text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--c-bg); }
a { color: var(--c-primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.muted { color: var(--c-muted); }
.small { font-size: .85em; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inline { display: inline; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85em; word-break: break-all; }

/* Mise en page */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--c-primary); color: #fff; flex-shrink: 0; padding: 1rem 0; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; padding: 0 1rem 1rem; font-size: 1.05rem; }
.brand-mark { width: 30px; height: 30px; border-radius: 6px; background: var(--c-accent); display: grid; place-items: center; font-weight: 800; }
.sidebar nav a { display: block; color: rgba(255, 255, 255, .85); padding: .42rem 1rem .42rem 1.25rem; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.sidebar nav a.active { background: rgba(255, 255, 255, .14); border-left-color: var(--c-accent); color: #fff; font-weight: 600; }
.nav-title { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: rgba(255, 255, 255, .5); padding: 1rem 1.25rem .3rem; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; background: var(--c-surface); border-bottom: 1px solid var(--c-border); padding: .6rem 1.5rem; position: sticky; top: 0; z-index: 5; }
.topbar-title { font-weight: 600; flex: 1; }
.topbar-user { display: flex; gap: 1rem; align-items: center; }
.burger { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }
.content { padding: 1.5rem; max-width: 1500px; width: 100%; }

/* Cartes et grilles */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.kpi-label { color: var(--c-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.45rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--c-muted); font-size: .8rem; margin-top: .15rem; }
.kpi.warn .kpi-value { color: var(--c-warn); }
.kpi.err .kpi-value { color: var(--c-err); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.props dt { color: var(--c-muted); }
dl.props dd { margin: 0; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; background: var(--c-surface); }
.table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); margin-bottom: 1rem; }
th, td { padding: .5rem .65rem; border-bottom: 1px solid var(--c-border); text-align: left; vertical-align: top; }
th { background: #f8fafb; font-weight: 600; font-size: .8rem; color: var(--c-muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tbody tr:hover { background: #fafcfd; }
tfoot td { font-weight: 700; background: #f8fafb; }
tr.row-warn td { background: #fff8e6; }
tr.row-err td { background: #fdecea; }
tr.row-muted td { color: var(--c-muted); }

/* Boutons */
.btn, button.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .85rem; border-radius: 6px; border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text); cursor: pointer; font-size: .9rem; line-height: 1.2; font-family: inherit; }
.btn:hover { background: #f1f4f6; text-decoration: none; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-2); }
.btn-danger { color: var(--c-err); border-color: #f0c4c0; }
.btn-danger:hover { background: #fdecea; }
.btn-sm { padding: .25rem .55rem; font-size: .8rem; }
button.link { background: none; border: 0; color: var(--c-primary-2); cursor: pointer; padding: 0; font: inherit; }

/* Badges et messages */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e8edf1; color: var(--c-text); white-space: nowrap; }
.badge-ok { background: #e3f3e9; color: var(--c-ok); }
.badge-warn { background: #fff1d6; color: var(--c-warn); }
.badge-err { background: #fdecea; color: var(--c-err); }
.badge-info { background: #e5effa; color: var(--c-info); }
.badge-neutral { background: #e8edf1; color: var(--c-muted); }
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #e3f3e9; border-color: #b9e0c7; color: #1e5a37; }
.flash-error, .flash-danger { background: #fdecea; border-color: #f3c1bc; color: #7f1d18; }
.flash-warning { background: #fff8e6; border-color: #f2dba6; color: #7a5310; }
.flash-info { background: #e5effa; border-color: #bcd4ef; color: #1e4a7a; }
ul.checks { margin: 0; padding-left: 1.2rem; }
ul.checks li { margin: .25rem 0; }

/* Formulaires */
form .field { margin-bottom: .85rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .88rem; }
.field-check { display: flex; align-items: center; gap: .5rem; }
.field-check label { margin: 0; font-weight: 500; }
label.check { display: flex; align-items: center; gap: .4rem; font-weight: 400; margin: .15rem 0; }
.choices-expanded { display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], input[type=search], input[type=tel], select, textarea {
    width: 100%; padding: .45rem .6rem; border: 1px solid var(--c-border); border-radius: 6px; font: inherit; background: #fff; color: var(--c-text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(44, 107, 128, .35); border-color: var(--c-primary-2); }
textarea { min-height: 80px; }
input.num { text-align: right; }
.help { display: block; color: var(--c-muted); font-size: .8rem; margin-top: .2rem; }
.errors { color: var(--c-err); margin: .25rem 0 0; padding-left: 1rem; font-size: .85rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--c-err); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 1rem; }
.form-actions { display: flex; gap: .5rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--c-border); }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; }
.filters label { font-size: .78rem; color: var(--c-muted); }
.lines-table td { padding: .3rem; }
.lines-table input, .lines-table select { padding: .3rem .4rem; }
.lines-table .field { margin: 0; }
.lines-table label { display: none; }

/* Planning */
.planning { font-size: .78rem; }
.planning th, .planning td { padding: 0; border: 1px solid var(--c-border); text-align: center; min-width: 26px; height: 30px; }
.planning th.rental { text-align: left; padding: .3rem .5rem; min-width: 160px; position: sticky; left: 0; background: #f8fafb; z-index: 1; }
.planning td.we { background: #f6f8fa; }
.planning td.closed { background: repeating-linear-gradient(45deg, #eee, #eee 4px, #f8f8f8 4px, #f8f8f8 8px); }
.planning .stay { display: block; color: #fff; border-radius: 4px; margin: 2px 0; padding: 2px 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; }
.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }

/* Pages publiques (connexion, devis en ligne) */
body.public { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.public-box { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 12px; box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 420px; }
.public-box.wide { max-width: 820px; }
.public-box h1 { text-align: center; }
.public-box .brand-mark { margin: 0 auto 1rem; width: 44px; height: 44px; font-size: 1.3rem; color: #fff; }
.qr { display: block; margin: 1rem auto; max-width: 220px; }
.codes { columns: 2; font-family: ui-monospace, Consolas, monospace; font-size: 1rem; }

@media (max-width: 960px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: -240px; top: 0; bottom: 0; z-index: 20; transition: left .2s; }
    .sidebar.open { left: 0; }
    .burger { display: block; }
    .content { padding: 1rem; }
}
@media print {
    .sidebar, .topbar, .actions, .form-actions, .filters { display: none !important; }
    .content { padding: 0; }
}
.badge-muted { background: #e8edf1; color: var(--c-muted); }
.badge-danger { background: #fdecea; color: var(--c-err); }
