:root {
    --bg: #f7f8f9;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #667085;
    --line: #d9dee5;
    --line-strong: #aeb7c2;
    --primary: #0f766e;
    --primary-strong: #0b5f59;
    --primary-soft: #e6f4f2;
    --warn: #a15c05;
    --warn-soft: #fff4df;
    --danger: #a72323;
    --danger-soft: #fde8e8;
    --info-soft: #edf2ff;
    --radius: 2px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.35;
}

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 52px;
    padding: 7px 18px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar-main {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.brand {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    color: var(--primary-strong);
    font-size: 18px;
    font-weight: 760;
    letter-spacing: 0;
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.nav::-webkit-scrollbar { display: none; }

.logout {
    margin: 0 0 0 auto;
    flex: 0 0 auto;
}

.nav a,
.logout button,
.actions a,
button,
.primary,
.filters a {
    min-height: 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 7px 11px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 620;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}

.nav a {
    border-color: transparent;
    color: #3b4754;
}

.nav a:hover,
.actions a:hover,
.logout button:hover,
button:hover,
.filters a:hover {
    border-color: var(--line-strong);
    background: #f4f6f8;
}

.nav a:first-child {
    background: var(--primary-soft);
    border-color: #b8ddd8;
    color: var(--primary-strong);
}

.primary,
button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.primary:hover,
button.primary:hover {
    background: var(--primary-strong);
    border-color: var(--primary-strong);
}

.page {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 16px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
}

.page-head > div { min-width: 0; }

h1 {
    margin: 0;
    font-size: 21px;
    font-weight: 720;
    line-height: 1.2;
}

h2 {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 700;
}

h3 {
    margin: 12px 0 4px;
    font-size: 14px;
    font-weight: 730;
}

p { line-height: 1.45; }

.page-head p,
small,
.hint,
.empty {
    color: var(--muted);
}

.grid { display: grid; gap: 14px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.content-grid { align-items: start; }
.section-block { min-width: 0; }
#interventions-recentes { scroll-margin-top: 68px; }
#parc-equipements { scroll-margin-top: 68px; }

.notification-vignette.grid-mode {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card,
.panel,
.login-panel,
.action-tile,
.scan-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.stat-card {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "value label"
        "value hint";
    column-gap: 14px;
    align-items: center;
    min-height: 74px;
    padding: 12px 14px;
}

.stat-card:hover {
    border-color: var(--line-strong);
    background: #f9fafb;
}

.stat-card::after {
    content: "Ouvrir";
    position: absolute;
    right: 12px;
    top: 10px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
}

.stat-card strong {
    grid-area: value;
    min-width: 50px;
    color: var(--primary-strong);
    font-size: 30px;
    line-height: 1;
    font-weight: 780;
    text-align: center;
}

.stat-meta {
    grid-area: label;
    padding-right: 52px;
    font-size: 14px;
    font-weight: 700;
}

.stat-card small {
    grid-area: hint;
    color: var(--muted);
    font-size: 13px;
}

.dashboard-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    margin-bottom: 16px;
}

.dashboard-overview.with-notifications {
    grid-template-columns: minmax(0, 1fr) 240px;
}

.visual-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    min-width: 0;
}

.chart-panel {
    min-width: 0;
    min-height: 0;
}

.notification-vignette {
    display: grid;
    gap: 10px;
    align-content: start;
}

.notice-card {
    display: grid;
    align-content: center;
    min-height: 76px;
    padding: 10px 11px;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
}

.notice-card:hover {
    border-color: var(--line-strong);
    border-left-color: var(--primary-strong);
    background: #f9fafb;
}

.notice-card span {
    font-weight: 700;
}

.notice-card strong {
    margin: 3px 0;
    font-size: 25px;
    line-height: 1;
}

.notice-card small {
    color: var(--muted);
    line-height: 1.25;
}

.notice-card.warning {
    border-left-color: var(--warn);
    background: #fffdf8;
}

.notice-card.danger {
    border-left-color: var(--danger);
    background: #fffafa;
}

.notice-card.ok {
    border-left-color: var(--primary);
}

.bar-list {
    display: grid;
    gap: 8px;
}

.bar-row {
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr) 38px;
    align-items: center;
    gap: 10px;
    min-height: 28px;
}

.bar-row:hover .bar-label {
    color: var(--primary-strong);
}

.bar-label {
    color: #344054;
    font-weight: 640;
    overflow-wrap: anywhere;
}

.bar-track {
    height: 12px;
    overflow: hidden;
    background: #e6ebf1;
    border: 1px solid #d9e0e8;
    border-radius: var(--radius);
}

.bar-fill {
    display: block;
    min-width: 4px;
    height: 100%;
    background: var(--primary);
}

.bar-fill.ok { background: var(--primary); }
.bar-fill.warning { background: #d9822b; }
.bar-fill.danger { background: var(--danger); }
.bar-fill.info { background: #4f6fb3; }
.bar-fill.muted { background: #98a2b3; }

.bar-row strong {
    text-align: right;
    font-size: 14px;
    font-weight: 760;
}

.park-panel {
    margin-bottom: 16px;
}

.service-equipment-board {
    display: grid;
    gap: 16px;
}

.service-equipment-group {
    display: grid;
    gap: 8px;
}

.park-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1px;
    border: 1px solid var(--line);
    background: var(--line);
}

.park-tile {
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 5px;
    min-height: 104px;
    padding: 10px 11px;
    background: #fff;
    border: 0;
    border-left: 3px solid #98a2b3;
    border-radius: 0;
}

.park-tile:hover {
    background: #f9fafb;
}

.park-tile.ok { border-left-color: var(--primary); }
.park-tile.danger { border-left-color: var(--danger); }
.park-tile.warning { border-left-color: var(--warn); }
.park-tile.info { border-left-color: #4f6fb3; }
.park-tile.muted { border-left-color: #98a2b3; }

.park-code {
    font-weight: 780;
    color: #344054;
    font-size: 12px;
}

.park-main {
    min-width: 0;
}

.park-main b,
.park-main small {
    display: block;
    overflow-wrap: anywhere;
}

.park-main b {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 680;
    line-height: 1.2;
}

.park-secondary {
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.park-status {
    justify-self: start;
    max-width: 100%;
    padding: 3px 6px;
    background: #eef1f5;
    border: 1px solid #dde3eb;
    border-radius: var(--radius);
    font-size: 12px;
    font-style: normal;
    font-weight: 750;
    text-align: center;
}

.park-tile.ok .park-status { background: var(--primary-soft); color: var(--primary-strong); }
.park-tile.danger .park-status { background: var(--danger-soft); color: var(--danger); }
.park-tile.warning .park-status { background: var(--warn-soft); color: var(--warn); }
.park-tile.info .park-status { background: var(--info-soft); color: #304f9f; }

.action-tile {
    display: grid;
    gap: 4px;
    min-width: 0;
    min-height: 74px;
    padding: 12px 13px;
}

.action-tile:hover {
    border-color: var(--line-strong);
    background: #f9fafb;
}

.action-tile b,
.action-tile span {
    overflow-wrap: anywhere;
}

.action-tile span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.panel,
.login-panel {
    padding: 12px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 4px 0 8px;
}

.section-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.section-title > a,
.section-actions > a,
.filter-menu summary {
    color: var(--primary);
    font-weight: 650;
    white-space: nowrap;
}

.filter-menu {
    position: relative;
}

.filter-menu summary {
    min-height: 30px;
    display: flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px 10px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    list-style: none;
}

.filter-menu summary::-webkit-details-marker {
    display: none;
}

.filter-menu summary::after {
    content: "";
    width: 6px;
    height: 6px;
    margin-left: 8px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}

.filter-menu[open] summary {
    border-color: var(--line-strong);
    background: #f4f6f8;
}

.filter-options {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 8;
    display: grid;
    min-width: 150px;
    border: 1px solid var(--line-strong);
    background: #fff;
}

.filter-options a {
    display: block;
    min-height: 0;
    width: 100%;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font-weight: 620;
    text-align: left;
}

.filter-options a:last-child {
    border-bottom: 0;
}

.filter-options a:hover {
    background: #f4f6f8;
}

.filter-options a.active {
    box-shadow: inset 3px 0 0 var(--primary);
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.actions form { margin: 0; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.filters a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.status-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    background: var(--line);
}

.status-strip span {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.status-strip span.active {
    box-shadow: inset 0 -3px 0 var(--primary);
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.list {
    display: grid;
    gap: 1px;
    border: 1px solid var(--line);
    background: var(--line);
}

.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 10px 11px;
    background: #fff;
    border: 0;
    border-radius: 0;
}

.row:hover {
    background: #f9fafb;
}

.row span { min-width: 0; }
.row b,
.row small {
    display: block;
    overflow-wrap: anywhere;
}

.row b {
    font-size: 14px;
    font-weight: 660;
}

.row small {
    margin-top: 2px;
    font-size: 12.5px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    max-width: 100%;
    border-radius: var(--radius);
    padding: 3px 6px;
    background: #eef1f5;
    border: 1px solid #dde3eb;
    color: #344054;
    font-size: 12px;
    font-style: normal;
    font-weight: 660;
    text-align: center;
}

.urgent,
.warning {
    background: var(--warn-soft);
    color: var(--warn);
}

.critical,
.broken {
    background: var(--danger-soft);
    color: var(--danger);
}

.in_service {
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.maintenance {
    background: var(--info-soft);
    color: #304f9f;
}

.form {
    display: grid;
    gap: 11px;
}

.form p {
    display: grid;
    gap: 5px;
    margin: 0;
}

.form.panel { max-width: 840px; }

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 9px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 2px solid rgba(15, 118, 110, 0.12);
}

.inline { grid-template-columns: 1fr auto; }
.compact { margin-top: 8px; }
.login-panel { max-width: 420px; margin: 48px auto; }
.search { margin-bottom: 12px; }

.qr { text-align: center; }
.qr img {
    width: 170px;
    max-width: 100%;
    image-rendering: pixelated;
}

dl {
    display: grid;
    grid-template-columns: 138px 1fr;
    gap: 7px 10px;
    margin: 0;
}

dt { color: var(--muted); }
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.messages {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.message {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--info-soft);
}

.message.success { background: var(--primary-soft); }
.message.error { background: var(--danger-soft); }
.message.warning { background: var(--warn-soft); }

.scan-panel {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.assigned-services,
.alert-panel {
    margin-top: 14px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chips span {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px 7px;
    background: #fff;
    font-weight: 620;
}

.qr-sheet {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.qr-sheet.single {
    grid-template-columns: minmax(240px, 360px);
    justify-content: center;
}

.qr-sheet.single .qr-label { min-height: 300px; }
.qr-sheet.single .qr-label img { width: 190px; }

.qr-label {
    min-height: 230px;
    display: grid;
    align-content: start;
    justify-items: center;
    gap: 6px;
    padding: 12px;
    background: #fff;
    border: 1px solid #222;
    border-radius: var(--radius);
    text-align: center;
    break-inside: avoid;
}

.qr-label img {
    width: 132px;
    image-rendering: pixelated;
}

.qr-label strong { font-size: 16px; }
.qr-label span { font-weight: 700; overflow-wrap: anywhere; }
.qr-label small { line-height: 1.25; }

video {
    width: 100%;
    max-height: 380px;
    background: #101828;
    border: 1px solid var(--line-strong);
    border-radius: 0;
}

.hidden { display: none; }

@media (max-width: 760px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 7px;
        padding: 7px 10px;
    }

    .topbar-main {
        justify-content: space-between;
        width: 100%;
    }

    .logout {
        position: absolute;
        top: 8px;
        right: 10px;
    }

    .brand {
        min-height: 32px;
        padding-right: 132px;
    }

    .nav {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1px;
        width: 100%;
        overflow: visible;
    }

    .nav a {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 0;
        padding: 7px 5px;
        border-color: var(--line);
        font-size: 13px;
        text-align: center;
    }

    .page {
        padding: 12px 8px 22px;
    }

    .page-head {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 14px;
    }

    .page-head .primary,
    .page-head button,
    .page-head .actions a {
        width: 100%;
        text-align: center;
    }

    .actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .actions form,
    .actions button {
        width: 100%;
    }

    h1 { font-size: 19px; }
    h2 { font-size: 15px; }

    .notification-vignette.grid-mode {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 14px;
    }

    .stat-card { padding: 10px; min-height: 66px; }
    .stat-card strong { font-size: 25px; min-width: 42px; }
    .stat-meta { font-size: 13px; padding-right: 46px; }
    .stat-card small {
        display: block;
        font-size: 12.5px;
        line-height: 1.25;
    }

    .dashboard-overview {
        grid-template-columns: minmax(0, 1fr);
    }

    .dashboard-overview.with-notifications {
        grid-template-columns: minmax(0, 1fr) 180px;
    }

    .visual-stats {
        grid-template-columns: 1fr;
    }

    .notification-vignette {
        grid-template-columns: 1fr;
    }

    .bar-row {
        grid-template-columns: 92px minmax(0, 1fr) 30px;
        gap: 8px;
    }

    .park-grid {
        grid-template-columns: 1fr;
        gap: 1px;
    }

    .dashboard-park-grid {
        max-height: 421px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .park-tile {
        min-height: 104px;
        padding: 9px 10px;
    }

    .action-tile {
        min-height: 0;
        padding: 11px;
    }

    .two { grid-template-columns: 1fr; }
    .grid { gap: 12px; }
    .panel,
    .login-panel { padding: 10px; }

    .row {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
        padding: 10px;
    }

    .badge {
        justify-self: start;
        min-width: 0;
    }

    .section-title {
        align-items: flex-start;
        margin-top: 4px;
    }

    .section-actions {
        align-items: flex-start;
    }

    .filter-options {
        right: auto;
        left: 0;
        min-width: 176px;
    }

    .filters {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1px;
        border: 1px solid var(--line);
        background: var(--line);
    }

    .filters a {
        display: flex;
        align-items: center;
        justify-content: center;
        border: 0;
        border-radius: 0;
        text-align: center;
    }

    .status-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .qr-sheet { grid-template-columns: 1fr; }
    .inline { grid-template-columns: 1fr; }
    dl { grid-template-columns: 1fr; }
    video { max-height: 300px; }
}

@media (max-width: 390px) {
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .notification-vignette.grid-mode { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
    .row {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 7px;
    }

    .badge {
        justify-self: start;
    }
}

@media (max-width: 560px) {
    .dashboard-overview.with-notifications {
        grid-template-columns: 1fr;
    }
}

@media print {
    body { background: #fff; }
    .topbar,
    .no-print,
    .messages {
        display: none !important;
    }
    .page {
        width: 100%;
        padding: 0;
    }
    .qr-sheet {
        grid-template-columns: repeat(3, 1fr);
        gap: 8mm;
    }
    .qr-sheet.single {
        grid-template-columns: 70mm;
        justify-content: start;
    }
    .qr-label {
        min-height: 52mm;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}
