.oiso-page {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 10px 10px 80px;
    box-sizing: border-box;
}

.oiso-top {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

.oiso-header {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.oiso-title-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-width: 0;
}

.oiso-logo {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.oiso-logo-image {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.oiso-title-block h1 {
    margin: 0;
    font-size: 1.75rem;
    color: #222;
    text-align: center;
}

.oiso-status-card {
    background: #f7f7f7;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.oiso-status-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid #ebebeb;
}

.oiso-status-row:last-child {
    border-bottom: none;
}

.oiso-status-label {
    color: #666;
    font-size: 0.95rem;
}

.oiso-status-value {
    font-weight: 600;
    color: #222;
    text-align: right;
    word-break: break-word;
}

.oiso-status-value.is-ok {
    color: #1b6b3a;
}

.oiso-status-value.is-ko {
    color: #a12828;
}

.oiso-status-value.is-wait {
    color: #8a6d1b;
}

.oiso-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.oiso-btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.oiso-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.oiso-btn-primary {
    background: #2c5f8a;
    color: #fff;
}

.oiso-btn-primary:hover:not(:disabled) {
    background: #244e72;
}

.oiso-btn-secondary {
    background: #fff;
    border-color: #c8c8c8;
    color: #333;
}

.oiso-btn-secondary:hover:not(:disabled) {
    background: #f3f3f3;
}

.oiso-btn-ghost {
    background: transparent;
    border-color: #d0d0d0;
    color: #555;
}

.oiso-progress {
    margin: 0 0 16px;
    padding: 12px 14px;
    background: #eef5fb;
    border: 1px solid #c9ddf0;
    border-radius: 8px;
}

.oiso-wait-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(18, 28, 40, 0.55);
    padding: 20px;
}
.oiso-wait-overlay[hidden] {
    display: none !important;
}
.oiso-wait-card {
    width: min(380px, 100%);
    background: #fff;
    border-radius: 12px;
    padding: 28px 24px 22px;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}
.oiso-wait-card .oiso-progress-bar {
    margin: 0 auto 16px;
    max-width: 220px;
}
.oiso-wait-card p {
    margin: 0;
    color: #1e3a54;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
}
.oiso-wait-hint {
    margin-top: 10px !important;
    font-size: 0.9rem !important;
    font-weight: 400 !important;
    color: #5a6f82 !important;
}

.oiso-progress p {
    margin: 10px 0 0;
    color: #2c5f8a;
    font-size: 0.95rem;
}

.oiso-progress-bar {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, #2c5f8a 0%, #7eb0d8 50%, #2c5f8a 100%);
    background-size: 200% 100%;
    animation: oiso-slide 1.2s linear infinite;
}

@keyframes oiso-slide {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.oiso-alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    line-height: 1.4;
}

.oiso-alert code {
    font-size: 0.9em;
}

.oiso-alert-warn {
    background: #fff8e6;
    border: 1px solid #f0d990;
    color: #6b5200;
}

.oiso-alert-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.oiso-alert-ok {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.oiso-next {
    margin-top: 22px;
    padding-top: 4px;
}

.oiso-placeholder {
    padding: 28px 16px;
    text-align: center;
    color: #777;
    background: #fafafa;
    border: 1px dashed #ccc;
    border-radius: 8px;
    margin-top: 12px;
}

/* ——— Critères de recherche ——— */
.oiso-criteres {
    border: 1px solid #9bb6d4;
    border-radius: 8px;
    overflow: hidden;
    background: #eef2f7;
    margin-bottom: 14px;
}

.oiso-criteres-head {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #2c5f8a;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
}

.oiso-criteres-foot {
    grid-column: 1 / -1;
    padding-top: 4px;
}

.oiso-search-btn {
    appearance: none;
    width: 100%;
    box-sizing: border-box;
    min-height: 42px;
    padding: 9px 12px;
    border: 0;
    border-radius: 6px;
    background: #2c5f8a;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
}

.oiso-search-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.oiso-search-btn:hover:not(:disabled) {
    background: #244e72;
}

.oiso-criteres-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    padding: 12px;
}

.oiso-crit-field {
    display: grid;
    gap: 4px;
    font-size: 0.82rem;
    color: #2c5f8a;
    font-weight: 700;
}

.oiso-crit-field.oiso-crit-full {
    grid-column: 1 / -1;
}

.oiso-crit-field input,
.oiso-crit-field select {
    font: inherit;
    font-weight: 500;
    color: #222;
    padding: 9px 10px;
    border: 1px solid #c5d0de;
    border-radius: 6px;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
}

.oiso-crit-field input[readonly] {
    background: #f3f5f8;
    color: #555;
}

/* ——— Bandeau liste ——— */
.oiso-liste-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: #2c5f8a;
    color: #fff;
    border-radius: 8px;
    margin-bottom: 12px;
}

.oiso-liste-title {
    font-weight: 700;
    font-size: 0.95rem;
    min-width: 0;
}

.oiso-liste-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.oiso-liste-add {
    appearance: none;
    width: 64px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: #3d7ab0;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.oiso-liste-add:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.oiso-liste-count {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    background: #e8edf5;
    color: #2c5f8a;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ——— Cards style OISO mobile ——— */
.oiso-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.oiso-card {
    background: #fff;
    border: 1px solid #c5d4ee;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(16, 42, 117, 0.08);
    overflow: hidden;
}

.oiso-card-head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: #2c5f8a;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
}

.oiso-card-date {
    font-size: 0.8rem;
}

.oiso-card-heure {
    font-size: 0.8rem;
    text-align: center;
}

.oiso-card-decl {
    font-size: 0.8rem;
    text-align: right;
    opacity: 0.9;
}

.oiso-card-body {
    display: grid;
    gap: 0;
    padding: 0;
    font-size: 0.8rem;
}

.oiso-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-bottom: 1px solid #eef2f8;
    padding: 6px 12px;
}

/* Type court → Agent démarre plus à gauche, nom sur une ligne */
.oiso-card-grid-type {
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 14px;
}

.oiso-card-grid-lieu {
    grid-template-columns: minmax(0, 1fr) max-content;
    column-gap: 10px;
}

/* Mobile : ville sous le lieu */
.oiso-card-grid-lieu .oiso-card-ville {
    grid-column: 1 / -1;
}

@media (min-width: 701px) {
    .oiso-card-grid-lieu {
        grid-template-columns: minmax(0, 1.4fr) max-content minmax(0, 1fr);
        column-gap: 12px;
        align-items: baseline;
    }

    .oiso-card-grid-lieu .oiso-card-ville {
        grid-column: auto;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .oiso-card-grid-lieu .oiso-card-cp {
        white-space: nowrap;
    }
}

.oiso-card-grid:last-of-type {
    border-bottom: none;
}

.oiso-card-cell {
    min-width: 0;
    font-size: 0.8rem;
    line-height: 1.35;
    padding-right: 6px;
}

.oiso-card-grid-type .oiso-card-cell:last-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.oiso-card-lieu {
    display: flex;
    align-items: baseline;
    min-width: 0;
    gap: 6px;
}

.oiso-card-lieu .oiso-card-label {
    flex-shrink: 0;
    margin-right: 2px;
}

.oiso-card-lieu-trunc {
    appearance: none;
    border: 0;
    background: none;
    padding: 0;
    margin: 0;
    font: inherit;
    font-weight: 600;
    color: #111;
    text-align: left;
    cursor: pointer;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.oiso-card-lieu-trunc:hover,
.oiso-card-lieu-trunc:focus {
    color: #2c5f8a;
}

.oiso-lieu-pop {
    position: fixed;
    z-index: 1200;
    max-width: min(320px, calc(100vw - 24px));
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #c5d4ee;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(16, 42, 117, 0.18);
    color: #111;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}

.oiso-lieu-pop[hidden] {
    display: none !important;
}

.oiso-card-cell.oiso-card-span {
    grid-column: 1 / -1;
}

.oiso-card-label {
    color: #2c5f8a;
    font-weight: 700;
}

.oiso-card-value {
    color: #111;
    font-weight: 600;
    word-break: break-word;
}

.oiso-card-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    background: #f6f8fc;
    border-top: 1px solid #eef2f8;
}

.oiso-act {
    appearance: none;
    border: 0;
    border-right: 1px solid #eef2f8;
    background: transparent;
    padding: 5px 4px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    color: #3d4f7a;
    font-size: 0.72rem;
    font-weight: 700;
}

.oiso-act:last-child {
    border-right: 0;
}

.oiso-act svg {
    display: block;
}

.oiso-act-view {
    color: #2c5f8a;
}

.oiso-act-copy {
    color: #5a6578;
}

.oiso-act-delete {
    color: #c62828;
}

.oiso-act-print {
    color: #222;
}

.oiso-act:hover {
    background: #eef3fa;
}

@media (max-width: 600px) {
    .oiso-criteres-body {
        grid-template-columns: 1fr;
    }
}

.oiso-dialog {
    border: 1px solid #c5d4ee;
    border-radius: 14px;
    padding: 0;
    max-width: min(920px, calc(100vw - 28px));
    width: min(920px, calc(100vw - 28px));
    /* Laisse de la place pour la barre Android (triangle / rond / carré) */
    max-height: calc(100vh - 72px - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 72px - env(safe-area-inset-bottom, 0px));
    margin: auto;
    margin-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    box-shadow: 0 12px 40px rgba(16, 42, 117, 0.2);
    overflow: hidden;
}

.oiso-dialog::backdrop {
    background: rgba(16, 42, 117, 0.4);
}

.oiso-agent-picker {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: stretch;
    min-width: 0;
    width: 100%;
}

.oiso-agent-picker input {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    cursor: pointer;
    background: #f8fafc;
}

.oiso-agent-pick-btn,
.oiso-agent-picker .oiso-agent-pick-btn {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: 7.5rem;
    white-space: nowrap;
    padding: 8px 10px;
    font-size: 0.85rem;
}

.oiso-agent-dialog {
    max-width: min(520px, calc(100vw - 28px));
    width: min(520px, calc(100vw - 28px));
    z-index: 1100;
}

.oiso-agent-form {
    max-height: calc(100dvh - 72px - env(safe-area-inset-bottom, 0px));
}

.oiso-agent-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 16px 8px;
    flex-shrink: 0;
}

.oiso-agent-toolbar input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #c5d0de;
    border-radius: 8px;
    font: inherit;
}

.oiso-agent-status {
    margin: 0 16px 8px;
    font-size: 0.85rem;
    color: #2c5f8a;
}

.oiso-agent-list {
    flex: 1 1 auto;
    min-height: 180px;
    max-height: min(50vh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 8px 8px;
    overscroll-behavior: contain;
}

.oiso-agent-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid #eef2f8;
    background: #fff;
    padding: 10px 12px;
    cursor: pointer;
    font: inherit;
    color: #222;
    border-radius: 8px;
}

.oiso-agent-item:hover,
.oiso-agent-item:focus {
    background: #eef5fb;
    outline: none;
}

.oiso-agent-item.is-selected {
    background: #d9eaf8;
}

.oiso-agent-item-name {
    font-weight: 700;
    color: #2c5f8a;
}

.oiso-agent-item-tel {
    font-size: 0.85rem;
    color: #555;
}

.oiso-agent-empty {
    padding: 24px 12px;
    text-align: center;
    color: #777;
    font-size: 0.9rem;
}

.oiso-form {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 72px - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 72px - env(safe-area-inset-bottom, 0px));
    min-height: 0;
}

.oiso-form-head {
    flex-shrink: 0;
    padding: 14px 16px 12px;
    background: #2c5f8a;
    color: #fff;
}

.oiso-form-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.oiso-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px 12px;
    /* Padding bas généreux : sinon marque / nb / classe / portée passent sous les boutons */
    padding: 14px 16px 96px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #9bb4cc transparent;
    overscroll-behavior: contain;
}

.oiso-form-grid::-webkit-scrollbar {
    width: 6px;
}
.oiso-form-grid::-webkit-scrollbar-thumb {
    background: #9bb4cc;
    border-radius: 4px;
}

.oiso-fg-instrument {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    scroll-margin-bottom: 32px;
}
@media (max-width: 420px) {
    .oiso-fg-instrument {
        grid-template-columns: 1fr;
    }
}

.oiso-form label,
.oiso-fg {
    display: grid;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #2c5f8a;
    min-width: 0;
}

/* display:grid ci-dessus écrase sinon l’attribut HTML hidden */
.oiso-form label[hidden],
.oiso-fg[hidden],
#oisoMotifWrap[hidden],
#oisoMethodeWrap[hidden],
#oisoActionsCopy[hidden],
#oisoActionsEdit[hidden] {
    display: none !important;
}

.oiso-form input,
.oiso-form textarea,
.oiso-form select,
.oiso-fg input,
.oiso-fg textarea,
.oiso-fg select {
    padding: 8px 10px;
    border: 1px solid #c5d0de;
    border-radius: 8px;
    font: inherit;
    font-weight: 500;
    color: #222;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
}

.oiso-form-foot {
    flex-shrink: 0;
    padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #eef2f8;
    background: #f6f8fc;
}

.oiso-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.oiso-form-actions .oiso-btn {
    flex: 1 1 auto;
    min-width: 120px;
    box-sizing: border-box;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
    padding: 12px 14px;
}

/* Copie : les 3 actions principales toujours bleues (comme Valider) */
.oiso-form-actions-copy .oiso-btn:not(.oiso-btn-ghost),
.oiso-form-actions-copy .oiso-btn-primary,
.oiso-form-actions-copy .oiso-btn-secondary {
    flex: 1 1 calc(50% - 10px);
    background: #2c5f8a !important;
    color: #fff !important;
    border: 1px solid #2c5f8a !important;
    min-height: 46px;
    padding: 12px 10px;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
}

.oiso-form-actions-copy .oiso-btn:not(.oiso-btn-ghost):hover:not(:disabled) {
    background: #244e72 !important;
    border-color: #244e72 !important;
}

.oiso-form-actions-copy .oiso-btn-ghost {
    flex: 1 1 100%;
    min-height: 44px;
    padding: 12px 14px;
}

/* Mobile : marge autour du cadre + espace barre Android */
@media (max-width: 700px) {
    .oiso-dialog {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 88px - env(safe-area-inset-bottom, 0px));
        max-height: calc(100dvh - 88px - env(safe-area-inset-bottom, 0px));
        margin: 12px auto calc(56px + env(safe-area-inset-bottom, 0px));
        border-radius: 14px;
    }

    .oiso-form {
        max-height: calc(100vh - 88px - env(safe-area-inset-bottom, 0px));
        max-height: calc(100dvh - 88px - env(safe-area-inset-bottom, 0px));
    }

    .oiso-form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px 10px;
        padding: 12px;
    }

    .oiso-fg-wide,
    .oiso-fg-type,
    .oiso-fg-agent {
        grid-column: 1 / -1;
    }

    /* Agent : le nom doit rester lisible, « Choisir » compact */
    .oiso-agent-picker {
        flex-wrap: nowrap;
    }
    .oiso-agent-picker input {
        flex: 1 1 65% !important;
        min-width: 9rem !important;
    }
    .oiso-agent-pick-btn,
    .oiso-agent-picker .oiso-agent-pick-btn,
    .oiso-form-actions .oiso-agent-pick-btn {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: 5.5rem;
        padding: 8px 8px;
        font-size: 0.8rem;
    }

    /* Boutons copie toujours bleus aussi en mobile */
    .oiso-form-actions-copy .oiso-btn:not(.oiso-btn-ghost) {
        background: #2c5f8a !important;
        color: #fff !important;
        border-color: #2c5f8a !important;
        width: auto;
    }
}

@media (max-width: 420px) {
    .oiso-form-grid {
        grid-template-columns: 1fr;
    }
}

/* PC : plusieurs colonnes, peu/pas besoin d’ascenseur */
@media (min-width: 701px) {
    .oiso-dialog {
        width: min(920px, calc(100vw - 48px));
        max-width: min(920px, calc(100vw - 48px));
        max-height: calc(100vh - 48px);
        max-height: calc(100dvh - 48px);
        margin-bottom: auto;
    }

    .oiso-form {
        max-height: calc(100vh - 48px);
        max-height: calc(100dvh - 48px);
    }

    .oiso-form-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px 14px;
        padding: 16px 18px;
        overflow: visible;
    }

    .oiso-fg-type {
        grid-column: span 2;
    }

    .oiso-fg-agent {
        grid-column: span 2;
    }

    .oiso-fg-wide {
        grid-column: 1 / -1;
    }

    /* PC : CP | Ville | Tél lieu | (vide) puis Correspondant | Tél fixe | Tél portable */
    .oiso-fg-corr {
        grid-column: 1;
    }

    .oiso-fg-motif,
    .oiso-fg-methode {
        grid-column: span 2;
    }
}

@media (max-width: 600px) {
    .oiso-criteres-body {
        grid-template-columns: 1fr;
    }

    .oiso-actions {
        flex-direction: column;
    }

    .oiso-btn {
        width: 100%;
    }

    .oiso-agent-pick-btn,
    .oiso-agent-picker .oiso-agent-pick-btn {
        width: auto !important;
        max-width: 5.5rem !important;
    }

    .oiso-status-row {
        flex-direction: column;
        gap: 2px;
    }

    .oiso-status-value {
        text-align: left;
    }

    .oiso-form-actions .oiso-btn {
        width: 100%;
    }

    .oiso-form-actions-copy .oiso-btn:not(.oiso-btn-ghost) {
        width: auto;
        background: #2c5f8a !important;
        color: #fff !important;
    }
}
