:root {
  --bg: #05080f;
  --panel: #0f1626;
  --panel2: #152036;
  --panel3: #1b2944;
  --line: #243049;
  --text: #e7edf9;
  --muted: #8d9bb8;
  --blue: #3b82f6;
  --blue2: #2563eb;
  --red: #ef4444;
  --green: #22c55e;
  --amber: #f59e0b;
  --violet: #8b5cf6;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Segoe UI', -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at 50% -10%, #12234d 0, transparent 55%), var(--bg);
  color: var(--text); font-size: 15px; line-height: 1.45;
}
a { color: #7cb0ff; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
::selection { background: var(--blue2); }
* { scrollbar-width: thin; scrollbar-color: #2b3a5c transparent; }

/* ------------------------------------------------ tablette */
.stage { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.tablet {
  width: min(1480px, 100%); height: min(920px, calc(100vh - 44px));
  background: #02050b; border-radius: 34px; padding: 12px;
  box-shadow: 0 0 0 2px #1a2335, 0 0 0 5px #0a0f1b, 0 40px 90px rgba(0, 0, 0, .7), 0 0 80px rgba(37, 99, 235, .12);
  display: flex; flex-direction: column; position: relative;
}
.tablet::before {
  content: ''; position: absolute; top: 5px; left: 50%; width: 8px; height: 8px; border-radius: 50%;
  background: #0d1424; box-shadow: inset 0 0 2px #2a3b63; transform: translateX(-50%);
}
.display {
  flex: 1; min-height: 0; border-radius: 24px; overflow: hidden; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0a1020, #0c1428);
  position: relative;
}
.statusbar {
  display: flex; align-items: center; gap: 14px; padding: 9px 20px; background: rgba(8, 13, 25, .92);
  border-bottom: 1px solid var(--line); font-size: 13.5px; flex: none;
}
.statusbar .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .02em; }
.statusbar .brand svg { width: 24px; height: 24px; }
.statusbar .brand small { color: var(--muted); font-weight: 500; }
.statusbar .clock { flex: 1; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.statusbar .right { display: flex; align-items: center; gap: 10px; }
.me { display: flex; align-items: center; gap: 9px; padding: 3px 12px 3px 4px; background: var(--panel2); border-radius: 22px; border: 1px solid var(--line); }
.me img, .avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--blue2); display: grid; place-items: center; font-weight: 700; }
.me b { display: block; line-height: 1.1; font-size: 13px; }
.me small { display: block; color: var(--muted); font-size: 11px; line-height: 1.1; }
.bell { position: relative; background: var(--panel2); border: 1px solid var(--line); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; }
.bell .dot { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

.screen { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 26px 26px; }
.navbar {
  display: flex; align-items: center; justify-content: center; gap: 46px; padding: 8px; background: rgba(5, 8, 15, .95);
  border-top: 1px solid var(--line); flex: none;
}
.navbar button {
  background: none; border: 0; color: #c3cee6; font-size: 20px; cursor: pointer; width: 54px; height: 34px; border-radius: 17px;
}
.navbar button:hover { background: var(--panel3); }
.navbar .crumb { position: absolute; left: 26px; color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------ ecran de connexion */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: 0 30px 70px rgba(0, 0, 0, .6); }
.tricolore { height: 6px; background: linear-gradient(90deg, #1d4ed8 0 33.3%, #f1f5f9 33.3% 66.6%, #ef4444 66.6% 100%); }
.login-body { padding: 34px 32px 30px; text-align: center; }
.login-body svg { width: 76px; height: 76px; }
.login-body h1 { font-size: 23px; margin: 14px 0 4px; }
.login-body p { color: var(--muted); margin: 0 0 22px; }
.btn-discord {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 13px 18px;
  background: #5865f2; color: #fff; border: 0; border-radius: 12px; font-weight: 600; cursor: pointer; font-size: 15px;
}
.btn-discord:hover { background: #4752c4; text-decoration: none; }
.login-error { background: #3a1218; color: #ffb4bd; border: 1px solid #6b2430; border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; text-align: left; }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------ accueil / applications */
.hello { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.hello h1 { font-size: 26px; }
.hello .sub { color: var(--muted); }
.hello .grow { flex: 1; }
.widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.widget { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.widget b { display: block; font-size: 26px; line-height: 1.1; }
.widget span { color: var(--muted); font-size: 12.5px; }
.widget.green b { color: var(--green); } .widget.red b { color: var(--red); } .widget.amber b { color: var(--amber); } .widget.blue b { color: #6ea8ff; }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 22px 14px; justify-items: center; }
.app { text-align: center; width: 112px; cursor: pointer; color: var(--text); display: block; }
.app:hover { text-decoration: none; }
.app .icon {
  width: 82px; height: 82px; border-radius: 24px; margin: 0 auto 8px; display: grid; place-items: center; font-size: 38px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .25); transition: transform .12s;
  position: relative;
}
.app:hover .icon { transform: translateY(-3px) scale(1.04); }
.app .badge { position: absolute; top: -6px; right: -6px; background: var(--red); font-size: 12px; font-weight: 700; min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; padding: 0 5px; border: 2px solid #0a1020; }
.app span { font-size: 13px; font-weight: 600; line-height: 1.2; display: block; }

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 6px 0 14px; font-weight: 700; }

/* ------------------------------------------------ en-tetes de page */
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 23px; }
.page-head .sub { color: var(--muted); }
.page-head .grow { flex: 1; }
.backlink { color: var(--muted); font-size: 13px; display: inline-block; margin-bottom: 8px; }

/* ------------------------------------------------ composants */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 15.5px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel2); cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text);
}
.btn:hover { background: var(--panel3); text-decoration: none; }
.btn.primary { background: var(--blue2); border-color: var(--blue2); color: #fff; }
.btn.primary:hover { background: #1d4fc9; }
.btn.danger { background: #b4232f; border-color: #b4232f; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: #7cb0ff; }
.btn.small { padding: 4px 11px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chip { display: inline-block; padding: 2px 11px; border-radius: 12px; font-size: 12.5px; font-weight: 600; background: #1f2d4d; color: #b9cdf5; white-space: nowrap; }
.chip.green { background: #12351f; color: #6ee79a; }
.chip.red { background: #3d1519; color: #ff8d98; }
.chip.orange { background: #3d2a0c; color: #ffc15e; }
.chip.blue { background: #16295a; color: #8db6ff; }
.chip.grey { background: #232c40; color: #aeb9d0; }
.chip.violet { background: #2c1f55; color: #c0a6ff; }
.chip.link { cursor: pointer; }
.chip .x { margin-left: 7px; cursor: pointer; opacity: .65; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid #1b2640; vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #121c33; }
.table-wrap { overflow-x: auto; }
.empty { color: var(--muted); padding: 22px; text-align: center; }
.mono { font-family: Consolas, 'Courier New', monospace; font-size: 13px; }
.muted { color: var(--muted); }
.check { display: inline-flex; gap: 6px; align-items: center; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input, .toolbar select { padding: 9px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel2); }
.toolbar input { min-width: 240px; flex: 1; max-width: 460px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; color: var(--muted); }

input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=url], input[type=search], select, textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #2f5fc4; border-color: var(--blue); }
.toolbar input[type=search] { width: auto; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--blue); }

/* formulaires */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 15px 20px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; color: #a9bddf; text-transform: uppercase; letter-spacing: .04em; }
.field label .req { color: var(--red); }
.field textarea { min-height: 110px; resize: vertical; }
.picker { position: relative; }
.picker .menu {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #0d1527; border: 1px solid #2e3f66; border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .6); max-height: 290px; overflow-y: auto; margin-top: 4px;
}
.picker .menu div { padding: 9px 13px; cursor: pointer; border-bottom: 1px solid #172138; }
.picker .menu div:hover { background: #18274a; }
.picker .menu small { display: block; color: var(--muted); }
.timeline-row { display: grid; grid-template-columns: 210px 1fr auto; gap: 8px; margin-bottom: 6px; }
.penal-total { margin-top: 8px; padding: 8px 12px; background: var(--panel2); border-radius: 10px; font-size: 13.5px; color: #c6d3ef; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.thumb { position: relative; width: 108px; height: 108px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #000; cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, .75); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-size: 12px; }
.dropzone { border: 2px dashed #2e3f66; border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); }

/* fiches */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px 24px; }
.kv .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.kv .v { white-space: pre-wrap; word-break: break-word; }
.fiche-head { display: flex; gap: 20px; align-items: flex-start; }
.photo { width: 120px; height: 150px; border-radius: 12px; object-fit: cover; background: var(--panel2); border: 1px solid var(--line); flex: none; }
.photo.ph { display: grid; place-items: center; font-size: 46px; }
.alert { padding: 11px 15px; border-radius: 11px; margin-bottom: 14px; font-weight: 700; }
.alert.red { background: #3d1519; color: #ff9aa4; border: 1px solid #7a2630; }
.alert.orange { background: #3a280c; color: #ffc76a; border: 1px solid #6b4a14; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 8px 0 8px 18px; border-left: 3px solid var(--line); position: relative; margin-left: 6px; }
.history li::before { content: ''; position: absolute; left: -7px; top: 14px; width: 11px; height: 11px; border-radius: 50%; background: var(--blue); }
.history .chg { font-size: 13px; color: var(--muted); }
.timeline-view li::before { background: var(--red); }

/* rapport PVI (feuille) */
.sheet { background: #0d1527; border: 1px solid #2c3d63; border-radius: 16px; padding: 0; overflow: hidden; margin-bottom: 16px; }
.sheet-head { padding: 16px 22px; background: linear-gradient(90deg, #14306f, #0f1f45); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sheet-head h2 { font-size: 18px; letter-spacing: .04em; margin: 0; }
.sheet-head .grow { flex: 1; }
.sheet-body { padding: 8px 22px 18px; }
.sheet-row { padding: 11px 0; border-bottom: 1px solid #1b2742; }
.sheet-row:last-child { border-bottom: 0; }
.sheet-row .k { font-weight: 700; color: #cfe0ff; margin-bottom: 3px; }
.sheet-row .v { color: #e7edf9; white-space: pre-wrap; }
.sheet-row .v.big { font-size: 17px; font-weight: 700; }

/* statistiques */
.bars .bar { display: grid; grid-template-columns: 160px 1fr 40px; gap: 10px; align-items: center; margin: 7px 0; }
.bars .track { background: var(--panel2); border-radius: 7px; height: 14px; overflow: hidden; }
.bars .fill { background: linear-gradient(90deg, var(--blue2), #60a5fa); height: 100%; }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.spark div { flex: 1; background: linear-gradient(180deg, #60a5fa, var(--blue2)); border-radius: 5px 5px 0 0; min-height: 3px; position: relative; }
.spark small { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); }

/* plaque d'immatriculation */
.plate {
  display: inline-flex; align-items: stretch; background: #f8fafc; color: #111; border: 3px solid #111; border-radius: 9px; overflow: hidden;
  font-family: 'Arial Black', Impact, sans-serif; font-size: 30px; letter-spacing: .08em; height: 56px; box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}
.plate i { background: #1d4ed8; color: #fff; font-style: normal; font-size: 11px; width: 26px; display: grid; place-items: end center; padding-bottom: 4px; font-family: Arial, sans-serif; font-weight: 700; }
.plate span { padding: 0 16px; display: grid; place-items: center; }
.plate-search { display: flex; justify-content: center; margin: 14px 0 22px; }
.plate-search input {
  text-align: center; text-transform: uppercase; font-family: 'Arial Black', Impact, sans-serif; font-size: 32px; letter-spacing: .1em; width: min(520px, 100%);
  padding: 12px; background: #f8fafc; color: #111; border: 3px solid #111; border-radius: 12px;
}
.plate-search input::placeholder { color: #9aa5b8; }
.vcard { display: flex; gap: 18px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel2); margin-bottom: 10px; cursor: pointer; }
.vcard:hover { background: var(--panel3); }

/* code penal */
.law-nature { font-weight: 700; }
.law-detail .big { font-size: 22px; font-weight: 800; }

/* prison */
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: #ffc15e; }

/* modales & toasts */
.overlay { position: fixed; inset: 0; background: rgba(0, 4, 12, .72); display: grid; place-items: center; z-index: 100; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--panel); border: 1px solid #2c3d63; border-radius: 18px; width: min(580px, 100%); max-height: 92vh; overflow-y: auto; padding: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .7); }
.modal.wide { width: min(780px, 100%); }
.modal h2 { margin-bottom: 14px; }
.modal .row { margin-bottom: 12px; }
.modal .row label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 4px; color: #a9bddf; text-transform: uppercase; letter-spacing: .04em; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.permgrid { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; font-size: 13.5px; }
.permgrid select { padding: 4px 6px; width: auto; }
.lightbox img { max-width: min(92vw, 1100px); max-height: 88vh; border-radius: 12px; display: block; }
#toasts { position: fixed; right: 22px; bottom: 22px; display: grid; gap: 8px; z-index: 200; }
.toast { background: #17306b; color: #fff; padding: 11px 17px; border-radius: 11px; box-shadow: 0 10px 28px rgba(0, 0, 0, .55); max-width: 380px; border: 1px solid #2f5fc4; }
.toast.err { background: #5b1620; border-color: #9b2536; }
.toast.ok { background: #0f4026; border-color: #1f8a4d; }
.notif-pop { position: absolute; right: 18px; top: 52px; width: 370px; max-height: 70%; overflow-y: auto; background: #0d1527; border: 1px solid #2c3d63; border-radius: 14px; box-shadow: 0 18px 44px rgba(0, 0, 0, .65); z-index: 60; }
.notif-pop div { padding: 11px 15px; border-bottom: 1px solid #1b2742; cursor: pointer; }
.notif-pop div.unread { background: #13214a; }
.notif-pop small { color: var(--muted); display: block; }

@media (max-width: 900px) {
  .stage { padding: 0; }
  .tablet { height: 100vh; border-radius: 0; padding: 0; box-shadow: none; }
  .tablet::before { display: none; }
  .display { border-radius: 0; }
  .statusbar .clock, .statusbar .brand small, .me small { display: none; }
  .screen { padding: 16px; }
  .timeline-row { grid-template-columns: 1fr; }
  .fiche-head { flex-direction: column; }
  .navbar .crumb { display: none; }
}

.toolbar select { width: auto; }

/* code penal : lignes de choix */
.tablines { display: grid; gap: 10px; }
.tabline { display: flex; align-items: center; gap: 16px; padding: 16px 18px; background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; color: var(--text); }
.tabline:hover { background: var(--panel3); text-decoration: none; border-color: #35508d; }
.tabline .ico { font-size: 30px; width: 44px; text-align: center; }
.tabline .txt { flex: 1; }
.tabline b { display: block; font-size: 16px; }
.tabline small { color: var(--muted); }
.tabline .arrow { font-size: 26px; color: var(--muted); }

/* casier : photos d'identite */
.idphotos { display: flex; gap: 12px; flex: none; }
.idphoto { text-align: center; }
.idphoto small { display: block; color: var(--muted); margin-top: 4px; font-size: 12px; }
.thumb.big { width: 132px; height: 168px; }
.thumb.ph { display: grid; place-items: center; font-size: 42px; cursor: default; background: var(--panel2); }

/* RIB */
.rib { font-size: 20px; font-weight: 700; letter-spacing: .06em; padding: 8px 16px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; }
