/* Même palette que l'app Android (style Anycubic) */
:root {
  --bg: #F3F5F8; --card: #FFFFFF; --soft: #F5F6F8; --line: #E8EBF0;
  --text: #1F2329; --text2: #4E5969; --muted: #86909C;
  --accent: #1677FF; --accentSoft: #EAF3FF; --violet: #8B5CF6;
  --good: #00B42A; --busy: #FF8A00; --critical: #F53F3F; --nozzle: #FF7D00; --bed: #1677FF;
  --radius: 20px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
svg { display: block; }
a { color: var(--accent); }

/* ---------- Barre du haut ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: 18px 24px 8px; max-width: 1400px; margin: 0 auto; }
.top .titles { flex: 1; min-width: 0; }
@media (max-width: 520px) { .top h1 { font-size: 24px; } .userchip { display: none; } }
.top h1 { font-size: 28px; margin: 0; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sub { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); display: inline-block; flex: none; }
.back { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text); margin-left: -10px; }
.back:hover { background: #E9ECF1; }

/* Icônes rondes (comme dans l'app) */
.ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accentSoft); color: var(--accent); flex: none; transition: filter .15s; }
.ico:hover { filter: brightness(.96); }
.ico svg { width: 21px; height: 21px; }
.ico.grey { background: #F2F3F5; color: var(--muted); }
.ico.dark { background: rgba(0,0,0,.45); color: #fff; }
.ico.dark:hover { background: rgba(0,0,0,.6); }
.userchip { font-size: 13px; color: var(--text2); background: #E9ECF1; padding: 6px 12px; border-radius: 16px; white-space: nowrap; }

/* ---------- Liste ---------- */
.wrap { max-width: 1400px; margin: 0 auto; padding: 8px 24px 32px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); }
.grid > * { min-width: 0; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } .top, .wrap { padding-left: 16px; padding-right: 16px; } }
.banner { background: var(--soft); border-radius: 12px; padding: 12px; color: var(--text2); font-size: 13px; margin-bottom: 12px; }

.pcard { background: var(--card); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: box-shadow .15s; }
.pcard:hover { box-shadow: 0 4px 18px rgba(31,35,41,.07); }
.phead { display: flex; align-items: center; gap: 8px; }
.phead .left { flex: 1; min-width: 0; }
.pname { font-size: 19px; font-weight: 700; display: inline-flex; align-items: center; gap: 2px; max-width: 100%; }
.pname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pname svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px; border-radius: 12px; margin-top: 6px; white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.job { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
.thumb { width: 68px; height: 68px; border-radius: 12px; background: var(--soft) center/contain no-repeat; flex: none; display: grid; place-items: center; color: var(--muted); }
.thumb svg { width: 26px; height: 26px; }
.jmain { flex: 1; min-width: 0; }
.file { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file.off { font-weight: 600; color: var(--muted); white-space: normal; }
.times { color: var(--text2); font-size: 13px; margin-top: 3px; }
.times .eta { color: var(--good); }
.layers { color: var(--muted); font-size: 12px; margin-top: 2px; }
.prog { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.bar { flex: 1; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--violet)); transition: width .5s; }
.pct { font-weight: 700; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.temps { display: flex; gap: 22px; background: var(--soft); border-radius: 12px; padding: 9px 12px; margin-top: 12px; color: var(--text2); font-size: 14px; font-variant-numeric: tabular-nums; }
.temps span { display: inline-flex; align-items: center; gap: 6px; }
.temps svg { width: 20px; height: 20px; color: var(--muted); }

/* ---------- Vue détaillée ---------- */
.dgrid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .dgrid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; } }
.col { display: grid; gap: 14px; min-width: 0; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h2 { font-size: 17px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 small { font-weight: 400; color: var(--muted); font-size: 13px; }
.cam { position: relative; background: #1F2329; border-radius: 16px; overflow: hidden; aspect-ratio: 16 / 9; cursor: pointer; }
.cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .msg { position: absolute; inset: 0; display: grid; place-items: center; color: #B0B6BF; font-size: 13px; pointer-events: none; }
.cam .over { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 8px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-size: 15px; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: 12px; margin-top: 12px; }
.blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.big .l { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.big .l svg { width: 18px; height: 18px; }
.big .val { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.big .s { font-size: 12px; color: var(--muted); }
.chart { position: relative; height: 180px; margin-top: 14px; }
.chart canvas { width: 100%; height: 100%; display: block; }
.tip { position: absolute; top: 4px; background: rgba(31,35,41,.94); color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 8px; pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.spools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.spool { width: 56px; height: 56px; border-radius: 50%; background: #F2F3F5; margin: 0 auto; position: relative; }
.spool.active { box-shadow: 0 0 0 2.5px var(--accent); }
.spool b { position: absolute; inset: 6px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.spool em { position: absolute; inset: 17px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px #E5E6EB; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 12px; color: var(--text2); }
.spool + .m { font-size: 13px; margin-top: 5px; }
.spool ~ .t { font-size: 11px; color: var(--muted); }
.mesh { display: grid; gap: 3px; }
.mesh div { aspect-ratio: 1.6; border-radius: 4px; display: grid; place-items: center; font-size: 11px; font-variant-numeric: tabular-nums; }
.hist { display: flex; align-items: center; gap: 10px; padding: 10px 0 0; }
.hist .hm { flex: 1; min-width: 0; }
.hist .hf { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .hs { font-size: 12px; color: var(--muted); }
.console { background: var(--soft); border-radius: 12px; padding: 10px; font: 11.5px/1.5 ui-monospace, Menlo, Consolas, monospace; color: var(--text2); max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console .t { color: var(--muted); }
.console .c { color: var(--accent); }

/* ---------- Écran VNC et webcam plein écran ---------- */
body.dark { background: #000; }
.full { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; }
.fullbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: #fff; background: rgba(0,0,0,.6); z-index: 2; }
.fullbar h1 { flex: 1; font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fullbar .back { color: #fff; margin-left: 0; }
.fullbar .back:hover { background: rgba(255,255,255,.12); }
.fullbar .info { color: #B0B6BF; font-size: 12px; }
.stage { flex: 1; position: relative; min-height: 0; }
.stage > div, .stage > img { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage > img { object-fit: contain; }
.stage .msg { position: absolute; inset: 0; display: grid; place-items: center; color: #B0B6BF; text-align: center; padding: 20px; pointer-events: none; }

/* ---------- Fenêtre de paramètres ---------- */
.modal { position: fixed; inset: 0; background: rgba(31,35,41,.35); display: grid; place-items: center; z-index: 10; padding: 16px; }
.dialog { background: #fff; border-radius: 20px; padding: 22px; width: min(420px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.15); }
.dialog h3 { margin: 0 0 6px; font-size: 19px; }
.dialog label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.dialog input { width: 100%; height: 46px; border: 0; background: var(--soft); border-radius: 10px; padding: 0 12px; font: inherit; color: var(--text); outline: none; }
.dialog input:focus { box-shadow: 0 0 0 2px var(--accent); }
.dialog .err { color: var(--critical); font-size: 13px; margin-top: 10px; min-height: 18px; }
.dialog .row { display: flex; gap: 10px; margin-top: 10px; }
.btn { height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 600; background: #F2F3F5; color: var(--text); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { color: var(--critical); }
.btn:disabled { opacity: .6; cursor: default; }
.spacer { flex: 1; }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .dialog { padding: 28px; }
.login .logo { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(315deg, var(--accent), var(--violet)); display: grid; place-items: center; color: #fff; margin-bottom: 14px; }
.login .logo svg { width: 34px; height: 34px; }
.login .hint { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.check { display: flex !important; align-items: center; gap: 8px; color: var(--text2) !important; font-size: 13px !important; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.login .btn { width: 100%; margin-top: 18px; }
