/* =========================================================================
   Ordonnances — feuille de style unique (CSP stricte : aucun style inline).
   Direction : minimalisme clinique chaleureux. Titres en serif (caractère
   officiel/rassurant d'un document de santé), corps en sans système.
   ========================================================================= */

:root {
    --paper:      #f4f7f6;
    --paper-2:    #ffffff;
    --ink:        #16302d;
    --ink-soft:   #4a615e;
    --ink-faint:  #7d918e;
    --line:       #dde6e3;
    --line-2:     #eef3f1;

    --teal:       #0f6f63;
    --teal-deep:  #0a574d;
    --teal-wash:  #e6f1ee;
    --teal-ring:  rgba(15, 111, 99, .28);

    --amber:      #b9722e;
    --ok:         #1f8a5b;
    --ok-wash:    #e3f3ea;
    --warn:       #b06a12;
    --warn-wash:  #f7ecd9;
    --danger:     #b23b3b;
    --danger-wash:#f7e3e3;

    --radius:     14px;
    --radius-sm:  9px;
    --shadow:     0 1px 2px rgba(16,48,45,.05), 0 12px 32px -16px rgba(16,48,45,.22);
    --shadow-lg:  0 1px 2px rgba(16,48,45,.06), 0 30px 60px -28px rgba(16,48,45,.30);

    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, ui-serif, serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--ink);
    line-height: 1.55;
    background-color: var(--paper);
    background-image:
        radial-gradient(1100px 620px at 88% -8%, var(--teal-wash), transparent 60%),
        radial-gradient(820px 520px at -6% 108%, #eaf2ef, transparent 55%);
    background-attachment: fixed;
    min-height: 100vh;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; color: var(--ink); }

a { color: var(--teal-deep); text-underline-offset: 3px; }

/* ---- Layout shells ----------------------------------------------------- */

.shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 18px 56px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px clamp(18px, 4vw, 40px);
    background: rgba(255,255,255,.78);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--line);
}

.app-main { width: 100%; max-width: 980px; margin: 0 auto; padding: clamp(22px, 4vw, 40px) 18px 72px; }

.brandmark {
    display: inline-flex; align-items: center; gap: 11px;
    font-family: var(--serif); font-size: 1.12rem; color: var(--ink); text-decoration: none;
}
.brandmark .glyph {
    width: 30px; height: 30px; border-radius: 9px;
    display: grid; place-items: center;
    background: var(--teal); color: #fff; font-size: .92rem; font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.brandmark small { display: block; font-family: var(--sans); font-size: .72rem; color: var(--ink-faint); letter-spacing: .02em; }

/* ---- Cards ------------------------------------------------------------- */

.card {
    width: 100%;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(24px, 4vw, 38px);
}

.card-auth { max-width: 412px; animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
.card-narrow { max-width: 540px; }

.eyebrow {
    font-family: var(--sans);
    font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
    color: var(--teal-deep);
    margin: 0 0 10px;
}

.card h1 { margin: 0 0 8px; font-size: clamp(1.5rem, 4vw, 1.92rem); }
.lede { margin: 0 0 22px; color: var(--ink-soft); font-size: 1.02rem; }

/* ---- Forms ------------------------------------------------------------- */

.field { margin-bottom: 18px; }
.field > label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 7px; letter-spacing: .01em; }
.hint { display: block; font-size: .76rem; color: var(--ink-faint); margin-top: 6px; }

.input, .filebox {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: border-color .16s, box-shadow .16s;
}
.input::placeholder { color: var(--ink-faint); }
.input:focus, .filebox:focus-within, .btn:focus-visible, .linkrow a:focus-visible {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 4px var(--teal-ring);
}

.filebox {
    display: flex; align-items: center; gap: 12px;
    cursor: pointer; color: var(--ink-soft);
    border-style: dashed;
}
.filebox input[type=file] { font: inherit; color: var(--ink-soft); min-width: 0; }

.grid-2 { display: grid; gap: 18px; }
@media (min-width: 620px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---- Buttons ----------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    font: inherit; font-weight: 600;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: transform .12s, box-shadow .16s, background .16s, border-color .16s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 10px 22px -12px var(--teal-deep); }
.btn-primary:hover { background: var(--teal-deep); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink-faint); }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 22px; font-size: 1.04rem; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }

/* ---- Alerts ------------------------------------------------------------ */

.alert { border-radius: var(--radius-sm); padding: 13px 15px; font-size: .92rem; margin-bottom: 18px; border: 1px solid transparent; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-error { background: var(--danger-wash); border-color: #ecc7c7; color: #7d2727; }
.alert-info  { background: var(--teal-wash); border-color: #cfe5df; color: var(--teal-deep); }
.alert-warn  { background: var(--warn-wash); border-color: #ecd6b0; color: #7c4a0e; }

/* ---- Section title in app --------------------------------------------- */

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 0 0 16px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.32rem; margin: 0; }
.section-head .count { font-size: .82rem; color: var(--ink-faint); }
.stack { display: grid; gap: clamp(20px, 3vw, 30px); }

/* ---- History table ----------------------------------------------------- */

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
table.history { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 640px; }
table.history th { text-align: left; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--line-2); }
table.history td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.history tr:last-child td { border-bottom: none; }
table.history tbody tr { transition: background .12s; }
table.history tbody tr:hover { background: var(--teal-wash); }
.ref { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .82rem; color: var(--ink); }
.muted { color: var(--ink-faint); }
.row-link { color: var(--teal-deep); font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }

.empty { padding: 40px 20px; text-align: center; color: var(--ink-faint); }

/* ---- Badges ------------------------------------------------------------ */

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-sent { background: var(--ok-wash); color: #15694a; }
.badge-failed { background: var(--danger-wash); color: #92302f; }
.badge-pending { background: var(--warn-wash); color: #7c4a0e; }
.badge-expired { background: #eceff0; color: #5f6f6d; }

/* ---- Detail ------------------------------------------------------------ */

.detail-meta { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 1px; background: var(--line-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.detail-meta li { display: flex; justify-content: space-between; gap: 16px; background: #fff; padding: 12px 16px; }
.detail-meta dt, .detail-meta .k { color: var(--ink-faint); font-size: .82rem; }
.detail-meta .v { font-weight: 600; text-align: right; }

.linkrow { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---- Patient screen ---------------------------------------------------- */

.patient-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--teal-wash); color: var(--teal-deep); display: grid; place-items: center; margin-bottom: 18px; font-family: var(--serif); font-size: 1.5rem; }
.divider { display: flex; align-items: center; gap: 14px; margin: 24px 0; color: var(--ink-faint); font-size: .8rem; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ---- Footer note ------------------------------------------------------- */

.footnote { margin-top: 26px; font-size: .76rem; color: var(--ink-faint); text-align: center; }
.lock { display: inline-flex; align-items: center; gap: 7px; }

/* ---- Motion ------------------------------------------------------------ */

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
.stagger > *:nth-child(1) { animation-delay: .04s; }
.stagger > *:nth-child(2) { animation-delay: .12s; }
.stagger > *:nth-child(3) { animation-delay: .20s; }

@media (prefers-reduced-motion: reduce) {
    *, .card-auth, .stagger > * { animation: none !important; transition: none !important; }
}
