/* Trots Pellissier Fault Reporting. Tokens first; components read only tokens. */
:root {
  --bg: #f0f4f8; --surface: #ffffff; --surface-2: #f8fafc; --border: #e2e8f0;
  --text: #1e293b; --muted: #64748b;
  --accent: #65a30d; --accent-ink: #ffffff; --accent-soft: #ecfccb;
  --blue: #2563eb; --blue-soft: #dbeafe;
  --ok: #059669; --ok-soft: #d1fae5; --warn: #d97706; --warn-soft: #fef3c7;
  --danger: #dc2626; --danger-soft: #fee2e2;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
  --pad: 16px; --row-pad: 12px; --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f172a; --surface: #1e293b; --surface-2: #172033; --border: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --accent: #84cc16; --accent-ink: #14210a; --accent-soft: #263a10;
  --blue: #60a5fa; --blue-soft: #1e3a5f; --ok: #34d399; --ok-soft: #064e3b;
  --warn: #fbbf24; --warn-soft: #422006; --danger: #f87171; --danger-soft: #450a0a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a; --surface: #1e293b; --surface-2: #172033; --border: #334155;
    --text: #e2e8f0; --muted: #94a3b8; --accent: #84cc16; --accent-ink: #14210a; --accent-soft: #263a10;
    --blue: #60a5fa; --blue-soft: #1e3a5f; --ok: #34d399; --ok-soft: #064e3b;
    --warn: #fbbf24; --warn-soft: #422006; --danger: #f87171; --danger-soft: #450a0a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-density="compact"] { --pad: 10px; --row-pad: 6px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); min-height: 100vh; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.boot { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Banners */
.banner { position: sticky; top: 0; z-index: 50; text-align: center; padding: 8px 12px; font-size: .9rem; font-weight: 500; }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.banner-info { background: var(--blue-soft); color: var(--blue); }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font-weight: 700; }

/* Shell */
.shell { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.shell.wide { max-width: 1200px; }
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 8px 0 16px; }
.brand img { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); background: var(--surface); }
.brand h1 { margin: 0; font-size: 1.35rem; } .brand p { margin: 0; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: calc(var(--pad) + 4px); margin-bottom: 16px; }
.card h2 { margin-bottom: .25em; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 12px 0 0; }
.footer a { color: inherit; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(.95); background: var(--accent); }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; } .btn-blue:hover { background: var(--blue); filter: brightness(.95); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; } .btn-danger:hover { background: var(--danger); filter: brightness(.95); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; } .btn-sm { min-height: 34px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }

/* Forms */
.field { margin-bottom: 14px; }
.field label, .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
.req::after { content: ' *'; color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=tel], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
textarea { min-height: 96px; resize: vertical; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.err { color: var(--danger); font-size: .85rem; margin-top: 4px; }
.alert { padding: 10px 12px; border-radius: 12px; margin-bottom: 14px; font-size: .92rem; }
.alert-err { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-info { background: var(--blue-soft); color: var(--blue); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; } .row > .grow { flex: 1 1 200px; }
.check { display: flex; gap: 10px; align-items: flex-start; } .check input { margin-top: 4px; width: 20px; height: 20px; flex: none; }

/* Mode picker, steps, chips */
.modes { display: grid; gap: 12px; }
.mode { display: flex; gap: 14px; align-items: center; text-align: left; padding: 18px; border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface); cursor: pointer; width: 100%; box-shadow: var(--shadow); }
.mode:hover { border-color: var(--accent); }
.mode .ico { font-size: 1.8rem; line-height: 1; } .mode strong { display: block; font-size: 1.05rem; } .mode span.d { color: var(--muted); font-size: .9rem; }
.steps { display: flex; gap: 6px; margin-bottom: 16px; }
.steps li { flex: 1; list-style: none; text-align: center; font-size: .78rem; color: var(--muted); border-top: 4px solid var(--border); padding-top: 6px; }
.steps li.on { border-color: var(--accent); color: var(--text); font-weight: 600; } .steps { padding: 0; margin: 0 0 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 500; }
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 700; }
.prio-note { font-size: .85rem; color: var(--muted); margin-top: 6px; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(15,23,42,.75); color: #fff; cursor: pointer; }
.otp { letter-spacing: .5em; text-align: center; font-size: 1.5rem; font-weight: 700; }
.success { text-align: center; } .success .tick { width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 2rem; }
.refbox { font-size: 1.4rem; font-weight: 700; letter-spacing: .03em; background: var(--accent-soft); border-radius: 12px; padding: 12px; margin: 12px 0; word-break: break-all; }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.timeline li { display: flex; gap: 10px; align-items: center; color: var(--muted); } .timeline li.done { color: var(--text); font-weight: 600; }
.timeline .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); flex: none; } .timeline li.done .dot { background: var(--accent); border-color: var(--accent); }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.b-Open { background: var(--blue-soft); color: var(--blue); } .b-In-Progress { background: var(--warn-soft); color: var(--warn); }
.b-Resolved { background: var(--ok-soft); color: var(--ok); } .b-Closed { background: var(--border); color: var(--muted); }
.b-Normal { background: var(--border); color: var(--muted); } .b-Urgent { background: var(--warn-soft); color: var(--warn); } .b-Critical { background: var(--danger-soft); color: var(--danger); }

/* Admin */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.topbar .in { max-width: 1200px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.topbar img { width: 34px; height: 34px; border-radius: 50%; }
.topbar .name { font-weight: 700; margin-right: auto; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; }
.nav a.on { background: var(--accent-soft); color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.9rem; line-height: 1.1; } .stat span { color: var(--muted); font-size: .85rem; }
.bars { display: grid; gap: 8px; } .bar { display: grid; grid-template-columns: 130px 1fr 40px; gap: 8px; align-items: center; font-size: .9rem; }
.bar .track { background: var(--surface-2); border-radius: 8px; height: 14px; overflow: hidden; } .bar .fill { height: 100%; background: var(--accent); border-radius: 8px; min-width: 2px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 110px; } .spark i { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; display: block; }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; } .toolbar .grow { flex: 1 1 220px; } .toolbar select { width: auto; min-width: 130px; }
.tablewrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); max-height: 70vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
th, td { padding: var(--row-pad) 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.wrap td { white-space: normal; min-width: 140px; }
th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); cursor: default; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--text); }
tbody tr { cursor: pointer; } tbody tr:hover td { background: var(--surface-2); }
th.c1, td.c1 { position: sticky; left: 0; z-index: 1; min-width: 150px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
th.c2, td.c2 { position: sticky; left: 150px; z-index: 1; box-shadow: 2px 0 0 var(--border); }
th.c1, th.c2 { z-index: 3; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 12px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; white-space: pre-wrap; }
.menu { position: relative; } .menu .pop { position: absolute; right: 0; top: 100%; z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 10px; min-width: 190px; }
.menu label { display: flex; gap: 8px; padding: 4px 0; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; } .tabs a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; border: 1px solid var(--border); background: var(--surface); } .tabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.flash { color: var(--ok); font-weight: 600; margin-left: 8px; opacity: 0; transition: opacity .2s; } .flash.show { opacity: 1; }
.big-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; } .big-photos img { width: 100%; border-radius: 12px; border: 1px solid var(--border); display: block; aspect-ratio: 4/3; object-fit: cover; }
code.key { display: block; padding: 10px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; word-break: break-all; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .bar { grid-template-columns: 100px 1fr 32px; } }
@media print { .topbar, .banner, .toolbar, .btn { display: none !important; } }
tbody tr.static { cursor: default; }
