/* PicoPACS — charte Picoxia */
:root {
  --green: #3b9b77;
  --green-600: #31856a;
  --green-50: #eaf6f1;
  --blue: #2b4792;
  --blue-50: #ecf0fa;
  --navy: #1e2a4f;
  --navy-900: #151d38;
  --bg: #f3f6f5;
  --card: #ffffff;
  --text: #1c2433;
  --muted: #6b7380;
  --line: #e3e8e7;
  --danger: #c2413b;
  --warn: #b7791f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; color: var(--navy); letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.02rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }

/* ---------- barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 22px;
  height: 60px; padding: 0 22px; background: linear-gradient(90deg, var(--navy-900), var(--navy));
  color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { height: 36px; }
.brand .clinic { font-weight: 500; opacity: .8; border-left: 1px solid rgba(255,255,255,.25); padding-left: 12px; font-size: .92rem; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { white-space: nowrap; }
.nav a { color: rgba(255,255,255,.78); padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: .94rem; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(59,155,119,.28); box-shadow: inset 0 -2px 0 var(--green); }
.usermenu { position: relative; }
.usermenu > button { background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 999px; padding: 6px 12px 6px 6px;
  display: flex; align-items: center; gap: 8px; cursor: pointer; font: inherit; font-size: .9rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--green); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.dropdown { position: absolute; right: 0; top: 44px; background: #fff; color: var(--text); border-radius: 10px; box-shadow: var(--shadow);
  min-width: 200px; padding: 6px; border: 1px solid var(--line); }
.dropdown a { display: block; padding: 9px 12px; border-radius: 7px; color: var(--text); }
.dropdown a:hover { background: var(--bg); text-decoration: none; }
.remote-pill { font-size: .75rem; padding: 3px 9px; border-radius: 999px; background: rgba(59,155,119,.25); color: #bfe8d6; }

/* ---------- mise en page */
main { max-width: 1320px; margin: 0 auto; padding: 26px 22px 60px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 20px; }
.card + .card { margin-top: 18px; }
.grid > .card + .card { margin-top: 0; }
.card.narrow { max-width: 440px; margin: 0 auto; text-align: center; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; margin-bottom: 8px; }

/* ---------- boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--text); border-radius: 9px; padding: 9px 15px; font: inherit; font-weight: 500; font-size: .93rem; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { border-color: #c9d3d0; background: #fafcfb; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-600); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.blue:hover { background: #233b7c; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fdf2f1; border-color: #f0c9c6; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.04); }
.btn.sm { padding: 5px 10px; font-size: .84rem; border-radius: 7px; }
.btn.lg { padding: 12px 20px; font-size: 1rem; }
.btn svg { width: 17px; height: 17px; flex: none; }

/* ---------- formulaires */
label { display: block; font-size: .83rem; font-weight: 600; color: #3b4454; margin: 0 0 5px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=password], input[type=search], input[type=date], input[type=number], input[type=email],
input[type=url], select, textarea {
  width: 100%; font: inherit; font-size: .95rem; padding: 9px 12px; border: 1px solid #d5dcda; border-radius: 9px;
  background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(59,155,119,.18); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: .93rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--green); }
.help { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* ---------- recherche */
.searchbar { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; }
.searchbox { position: relative; }
.searchbox svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 19px; color: var(--muted); }
.searchbox input { padding: 12px 14px 12px 42px; font-size: 1rem; border-radius: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 13px; font-size: .85rem; cursor: pointer; color: #3b4454; }
.chip:hover { border-color: var(--green); }
.chip.on { background: var(--green-50); border-color: var(--green); color: var(--green-600); font-weight: 600; }

/* ---------- tableaux */
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfb; }
.list td { padding: 12px; border-bottom: 1px solid #eef1f0; vertical-align: middle; }
.list tr.click { cursor: pointer; }
.list tr.click:hover td { background: #f6faf8; }
.list tr:last-child td { border-bottom: 0; }
.patient { font-weight: 600; color: var(--navy); }
.sub { font-size: .82rem; color: var(--muted); }
.date-cell { white-space: nowrap; }
.date-cell b { display: block; color: var(--navy); }
.badge { display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: 6px;
  background: var(--blue-50); color: var(--blue); margin-right: 4px; }
.badge.green { background: var(--green-50); color: var(--green-600); }
.badge.grey { background: #eef0f2; color: #5b6472; }
.badge.red { background: #fdecea; color: var(--danger); }
.badge.warn { background: #fdf3e1; color: var(--warn); }
.table-wrap { overflow-x: auto; margin: -20px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; color: #c3ccc9; margin-bottom: 8px; }

/* ---------- fiche examen */
.study-head { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.pet-icon { width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, var(--green), var(--blue)); display: grid; place-items: center; color: #fff; }
.pet-icon svg { width: 34px; height: 34px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 22px; margin-top: 16px; }
.fact .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fact .v { font-weight: 600; color: var(--text); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.series-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.thumb { border-radius: 10px; overflow: hidden; background: #0d1222; position: relative; cursor: pointer; border: 2px solid transparent;
  transition: transform .15s, border-color .15s; }
.thumb:hover { transform: translateY(-2px); border-color: var(--green); }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; background: #000; }
.thumb .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 9px 7px; color: #fff; font-size: .78rem;
  background: linear-gradient(transparent, rgba(0,0,0,.85)); }
.thumb .cap b { display: block; font-size: .82rem; }
.thumb .count { position: absolute; top: 7px; right: 7px; background: rgba(0,0,0,.6); color: #fff; font-size: .72rem; padding: 2px 7px; border-radius: 999px; }
.thumb.sel { border-color: var(--green); }
.thumb .tick { position: absolute; top: 7px; left: 7px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.5);
  border: 2px solid #fff; display: grid; place-items: center; color: #fff; font-size: 14px; }
.thumb.sel .tick { background: var(--green); border-color: var(--green); }
.doc-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eef1f0; }
.doc-item:last-child { border-bottom: 0; }
.doc-ico { width: 38px; height: 38px; border-radius: 9px; background: #fdecea; color: var(--danger); display: grid; place-items: center; flex: none; }
.doc-ico svg { width: 20px; }

/* ---------- éditeur de rapport */
.editor { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.editor .side { position: sticky; top: 80px; }
.editor .imgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 55vh; overflow: auto; padding: 2px; }
.savestate { font-size: .82rem; color: var(--muted); }

/* ---------- modales & lightbox */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 22, 42, .55); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal header { padding: 18px 22px 0; display: flex; align-items: center; }
.modal header h2 { margin: 0; flex: 1; }
.modal .body { padding: 16px 22px; }
.modal footer { padding: 14px 22px 18px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }
.linkbox { display: flex; gap: 8px; }
.linkbox input { font-family: ui-monospace, monospace; font-size: .85rem; background: var(--green-50); border-color: #bfe0d2; }
.notice { border-radius: 10px; padding: 11px 14px; font-size: .88rem; background: var(--blue-50); color: #24396f; margin: 10px 0; }
.notice.warn { background: #fdf6e7; color: #7a5212; }
.notice.ok { background: var(--green-50); color: #1f5e47; }
.notice.err { background: #fdecea; color: #8a2722; }
.lightbox { position: fixed; inset: 0; background: rgba(5, 8, 18, .95); z-index: 60; display: flex; flex-direction: column; }
.lightbox .lb-top { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: #fff; }
.lightbox .lb-img { flex: 1; display: grid; place-items: center; min-height: 0; padding: 0 60px; position: relative; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; }
.lightbox .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.1); color: #fff; border: 0; width: 46px; height: 46px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.lightbox .nav-btn:hover { background: rgba(255,255,255,.2); }
.lightbox .prev { left: 10px; } .lightbox .next { right: 10px; }
.lightbox .lb-bottom { color: #aab; text-align: center; padding: 10px; font-size: .85rem; }

/* ---------- onglets admin */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--green-600); border-bottom-color: var(--green); }
.stat { padding: 16px; border-radius: 12px; background: #fafbfb; border: 1px solid var(--line); }
.stat .n { font-size: 1.6rem; font-weight: 700; color: var(--navy); }
.stat .l { font-size: .8rem; color: var(--muted); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #c3ccc9; }
.status-dot.on { background: #2fbf71; box-shadow: 0 0 0 4px rgba(47,191,113,.18); }
.status-dot.off { background: var(--danger); }
.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.radio-card { border: 1.5px solid var(--line); border-radius: 11px; padding: 13px; cursor: pointer; }
.radio-card:hover { border-color: #b6c6c0; }
.radio-card.on { border-color: var(--green); background: var(--green-50); }
.radio-card b { display: block; color: var(--navy); margin-bottom: 3px; }
.radio-card span { font-size: .82rem; color: var(--muted); }
.steps { counter-reset: s; padding: 0; list-style: none; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 36px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: #fff; font-size: .8rem; font-weight: 700; display: grid; place-items: center; }

/* ---------- connexion */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art { background: radial-gradient(circle at 30% 20%, #2b4792 0%, var(--navy) 45%, var(--navy-900) 100%); color: #fff;
  display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px; text-align: center; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 60px solid rgba(59,155,119,.12); bottom: -200px; right: -160px; }
.login-art img { width: 210px; margin-bottom: 26px; position: relative; z-index: 1; }
.login-art p { opacity: .75; max-width: 360px; position: relative; z-index: 1; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-form form { width: min(380px, 100%); }
.login-form h1 { margin-bottom: 4px; }

/* ---------- divers */
.toast-zone { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: .92rem; animation: up .2s ease; max-width: 380px; }
.toast.ok { background: var(--green-600); } .toast.err { background: var(--danger); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }
.spinner { width: 22px; height: 22px; border: 3px solid #d7e5df; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
.loading { padding: 50px; text-align: center; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 30% 20%, #2b4792 0%, var(--navy) 45%, var(--navy-900) 100%); }
.center-page .card { padding: 32px; }
.brand-logo-dark { height: 90px; background: var(--navy); border-radius: 12px; padding: 8px; margin-bottom: 10px; }
.kbd { font-size: .78rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--muted); }

/* ---------- page de partage */
.share-hero { background: linear-gradient(120deg, var(--navy-900), var(--navy) 55%, #26407f); color: #fff; padding: 26px 22px 70px; }
.share-hero .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.share-hero img { height: 46px; }
.share-main { max-width: 1100px; margin: -50px auto 40px; padding: 0 22px; }

@media (max-width: 900px) {
  .g2, .g3, .editor, .login-wrap, .radio-cards { grid-template-columns: 1fr; }
  .login-art { min-height: 220px; padding: 28px; } .login-art img { width: 120px; margin-bottom: 10px; }
  .login-art p { display: none; }
  .searchbar { grid-template-columns: 1fr 1fr; } .searchbox { grid-column: 1 / -1; }
  .brand .clinic { display: none; }
  .brand img { height: 26px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .nav a { padding: 8px 9px; font-size: .86rem; }
  .hide-sm { display: none; }
  .editor .side { position: static; }
  main { padding: 18px 12px 50px; }
}
@media print { .topbar, .actions { display: none; } }
