:root {
  --bg: #14161c; --bg2: #1c1f27; --bg3: #262a35; --line: #313646; --txt: #eceef3; --muted: #9aa1b2;
  --claude: #e08a5b; --gpt: #3fb68b; --qwen: #9b7bf0; --ok: #3fb68b; --warn: #e7b84a; --ko: #e5616b; --accent: #6aa0ff;
  --r: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--txt); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
h3 { margin: 22px 4px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
a { color: var(--accent); }
.muted { color: var(--muted); } .center { text-align: center; } .err { color: var(--ko); min-height: 1em; }

.logo { font-weight: 800; letter-spacing: .04em; } .logo b { color: var(--accent); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(360px, 100%); display: grid; gap: 12px; padding: 24px; } .login .logo { font-size: 26px; text-align: center; }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; background: rgba(20,22,28,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .logo { margin-right: auto; font-size: 17px; }
.pill { border: 0; border-radius: 99px; padding: 7px 14px; font-weight: 700; color: #111; background: var(--ok); cursor: pointer; }
.pill.paused { background: var(--warn); } .pill.small { font-size: 12px; padding: 6px 10px; background: var(--bg3); color: var(--txt); font-weight: 600; }
select, input, textarea { width: 100%; background: var(--bg3); color: var(--txt); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; }
.top select { width: auto; padding: 6px 8px; font-size: 13px; }
textarea { resize: vertical; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }

.btn { border: 1px solid var(--line); background: var(--bg3); color: var(--txt); border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b1020; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #08140f; } .btn.ko { background: transparent; border-color: var(--ko); color: var(--ko); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

main { padding: 12px 14px calc(90px + var(--safe-b)); max-width: 1200px; margin: 0 auto; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.list { display: grid; gap: 10px; }
.item { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; cursor: pointer; }
.item .meta { font-size: 12px; color: var(--muted); }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--bg3); color: var(--muted); margin-right: 4px; }
.tag.claude { color: var(--claude); } .tag.gpt { color: var(--gpt); } .tag.qwen { color: var(--qwen); }
.tag.warn { color: var(--warn); } .tag.ko { color: var(--ko); } .tag.ok { color: var(--ok); }

/* onglets : en bas sur mobile, à gauche sur grand écran */
.tabs { position: fixed; z-index: 6; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg2); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs button { flex: 1; position: relative; display: grid; gap: 2px; justify-items: center; background: none; border: 0; color: var(--muted); padding: 8px 2px; font-size: 11px; cursor: pointer; }
.tabs button span { font-size: 20px; } .tabs button.active { color: var(--txt); }
.badge { position: absolute; top: 4px; right: calc(50% - 22px); background: var(--ko); color: #fff; font-style: normal; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 6px; }
@media (min-width: 900px) {
  .tabs { top: 58px; bottom: 0; right: auto; width: 96px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); }
  .tabs button { flex: 0; padding: 14px 4px; }
  main { padding-left: 120px; padding-bottom: 30px; }
}

/* limites */
.limits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gauge { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 12px; }
.gauge b { font-size: 13px; } .bar { height: 6px; border-radius: 9px; background: var(--bg3); margin: 6px 0 4px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 9px; }
.alert { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: #3a2a15; color: var(--warn); font-size: 13px; }
.alert.probleme { background: #3a1a1e; color: var(--ko); }

/* bureau */
.office { margin-top: 14px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.room { position: relative; border-radius: 18px; padding: 30px 12px 12px; border: 1px solid var(--line);
  background: repeating-linear-gradient(0deg, transparent 0 23px, rgba(255,255,255,.025) 23px 24px), repeating-linear-gradient(90deg, transparent 0 23px, rgba(255,255,255,.025) 23px 24px), var(--bg2); }
.room h4 { position: absolute; top: 8px; left: 14px; margin: 0; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.desks { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.desk { position: relative; background: var(--bg3); border-radius: 14px; padding: 12px 10px 10px; text-align: center; cursor: pointer; border: 1px solid transparent; transition: transform .15s; min-height: 132px; }
.desk:active { transform: scale(.97); }
.desk.travaille { border-color: var(--ok); } .desk.limite { border-color: var(--ko); } .desk.pause { opacity: .6; }
.avatar { width: 46px; height: 46px; margin: 0 auto 6px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 19px; color: #111; position: relative; image-rendering: pixelated; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); }
.avatar.claude { background: var(--claude); } .avatar.gpt { background: var(--gpt); } .avatar.qwen { background: var(--qwen); }
.desk.travaille .avatar { animation: bob 1.1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.dot { position: absolute; top: 10px; right: 10px; width: 9px; height: 9px; border-radius: 9px; background: var(--muted); }
.travaille .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(63,182,139,.2); } .limite .dot { background: var(--ko); } .pause .dot { background: var(--warn); }
.desk .name { font-weight: 700; } .desk .role { font-size: 11px; color: var(--muted); }
.bubble { margin-top: 8px; font-size: 11px; background: #fff; color: #111; border-radius: 10px; padding: 6px 8px; position: relative; text-align: left; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.bubble::before { content: ""; position: absolute; top: -6px; left: 50%; margin-left: -6px; border: 6px solid transparent; border-top: 0; border-bottom-color: #fff; }
.idle { margin-top: 8px; font-size: 11px; color: var(--muted); }

/* tickets */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.col { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 120px; }
.col h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.col .item { padding: 10px; margin-bottom: 8px; background: var(--bg3); }

/* fiche (sheet) */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-inner { position: relative; width: min(760px, 100%); max-height: 88vh; overflow: auto; background: var(--bg2); border-radius: 20px 20px 0 0; padding: 20px 16px calc(24px + var(--safe-b)); }
@media (min-width: 900px) { .sheet { align-items: center; } .sheet-inner { border-radius: 20px; } }
.close { position: sticky; top: 0; float: right; background: var(--bg3); border: 0; color: var(--txt); width: 34px; height: 34px; border-radius: 99px; cursor: pointer; }
.md h1, .md h2, .md h3 { font-size: 16px; margin: 14px 0 6px; } .md h1 { font-size: 19px; }
.md pre { background: var(--bg); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 12px; }
.md table { border-collapse: collapse; font-size: 13px; } .md td, .md th { border: 1px solid var(--line); padding: 4px 6px; }
.md img { max-width: 100%; border-radius: 10px; }
.pieces { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin: 10px 0; }
.pieces img { width: 100%; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.log { white-space: pre-wrap; font: 12px/1.4 ui-monospace, Menlo, monospace; background: var(--bg); padding: 10px; border-radius: 10px; max-height: 60vh; overflow: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chips button { background: var(--bg3); border: 1px solid var(--line); color: var(--muted); border-radius: 99px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
#ordre-form { display: grid; gap: 10px; }
.switch { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); background: var(--txt); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-weight: 600; font-size: 14px; }
.check { display: flex; gap: 8px; font-size: 13px; padding: 4px 0; } .check small { color: var(--muted); display: block; }

/* téléphone : bureau plus compact */
@media (max-width: 600px) {
  .top { gap: 6px; padding-left: 10px; padding-right: 10px; } .top .logo { font-size: 15px; }
  .pill { padding: 6px 10px; } .top select { font-size: 12px; padding: 5px 4px; }
  .office { grid-template-columns: 1fr; gap: 10px; }
  .room { padding: 26px 8px 8px; }
  .desks { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .desk { min-height: 0; padding: 10px 4px 8px; border-radius: 12px; }
  .avatar { width: 36px; height: 36px; font-size: 15px; border-radius: 10px; }
  .desk .name { font-size: 13px; } .desk .role { font-size: 10px; line-height: 1.2; }
  .idle, .bubble { font-size: 10px; } .dot { top: 7px; right: 7px; width: 7px; height: 7px; }
  .alert { padding: 8px 10px; font-size: 12px; }
  .gauge { padding: 8px; font-size: 11px; }
}

/* ---------- bureau pixel art plein écran ---------- */
.bureau { position: fixed; inset: 0; top: 0; z-index: 1; }
body:has(#tab-bureau:not(.hidden)) main { padding: 0; }
#office { position: absolute; left: 0; right: 0; top: calc(58px + env(safe-area-inset-top, 0px)); bottom: calc(62px + var(--safe-b)); width: 100%; height: calc(100% - 120px - env(safe-area-inset-top, 0px) - var(--safe-b)); touch-action: none; display: block; background: #14161c; cursor: grab; }
.hud { position: absolute; left: 8px; right: 8px; top: calc(64px + env(safe-area-inset-top, 0px)); pointer-events: none; display: grid; gap: 6px; }
.hud .limits { grid-template-columns: repeat(3, auto); justify-content: start; gap: 6px; }
.hud .gauge { padding: 4px 8px; font-size: 10px; background: rgba(28,31,39,.88); min-width: 92px; }
.hud .gauge .bar { height: 4px; margin: 3px 0 2px; }
.hud .alert { margin: 0; padding: 5px 9px; font-size: 11px; width: fit-content; max-width: 100%; background: rgba(58,42,21,.92); }
.hud .alert.probleme { background: rgba(58,26,30,.92); }
.fab { position: absolute; right: 12px; bottom: calc(124px + var(--safe-b)); width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: rgba(28,31,39,.9); color: var(--txt); font-size: 18px; cursor: pointer; }
.mission-bar { position: absolute; left: 10px; right: 10px; bottom: calc(70px + var(--safe-b)); display: flex; gap: 8px; }
.mission-bar input { background: rgba(28,31,39,.95); border-radius: 12px; }
.mission-bar .btn { border-radius: 12px; padding: 0 16px; }
@media (min-width: 900px) {
  #office { left: 96px; width: calc(100% - 96px); top: 58px; bottom: 0; height: calc(100% - 58px); }
  .hud { left: 108px; top: 68px; }
  .mission-bar { left: calc(96px + 50% - 48px - 300px); width: 600px; right: auto; bottom: 18px; }
  .fab { bottom: 18px; }
}

/* ---------- QG style Habbo ---------- */
#office { background: #8fd3ff; cursor: grab; }
.toolsbar { position: absolute; left: 0; right: 0; top: calc(58px + env(safe-area-inset-top, 0px)); display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; scrollbar-width: none; background: linear-gradient(rgba(14,30,52,.55), rgba(14,30,52,0)); }
.toolsbar::-webkit-scrollbar { display: none; }
.tool { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: 4px 9px 4px 4px; border-radius: 99px; border: 2px solid rgba(255,255,255,.55); background: rgba(255,255,255,.88); color: #1f2937; font: 700 12px system-ui; cursor: pointer; opacity: .62; transition: .25s; }
.tool.on { opacity: 1; border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.35), 0 0 14px rgba(34,197,94,.7); }
.logo { position: relative; display: inline-grid; place-items: center; border-radius: 7px; background: var(--c); color: #fff; font: 800 13px system-ui; overflow: hidden; flex: 0 0 auto; }
.logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.hud { top: calc(104px + env(safe-area-inset-top, 0px)); }
.hud .gauge { background: rgba(255,255,255,.9); color: #1f2937; border-color: rgba(0,0,0,.08); }
.hud .gauge .bar { background: #e5e7eb; }
.hud .alert { background: rgba(255,247,230,.95); color: #92400e; }
.hud .alert.probleme { background: rgba(254,226,226,.95); color: #991b1b; }
.mission-bar { align-items: center; background: rgba(255,255,255,.95); border: 3px solid #1f2937; border-radius: 16px; padding: 6px; box-shadow: 0 4px 0 #1f2937; }
#ceo-head { width: 44px; height: 44px; border-radius: 10px; background: #fde7d6; image-rendering: pixelated; flex: 0 0 auto; border: 2px solid #e8794a; }
.mission-field { position: relative; flex: 1; }
.mission-bar input { background: transparent; border: 0; color: #111827; font-weight: 600; padding: 8px 6px; }
.mission-bar input::placeholder { color: #6b7280; }
.route { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font: 700 11px system-ui; color: #fff; background: #3d7bf2; border-radius: 99px; padding: 2px 8px; pointer-events: none; }
.route:empty { display: none; }
.mission-bar .btn { background: #22c55e; border-color: #15803d; color: #052e16; border-radius: 10px; padding: 9px 14px; box-shadow: 0 3px 0 #15803d; }
.fab { background: rgba(255,255,255,.92); color: #1f2937; border: 2px solid #1f2937; bottom: calc(132px + var(--safe-b)); }

/* fiche à droite du QG (ordinateur), en bas (téléphone) */
.sheet.side { background: rgba(0,0,0,.25); }
@media (min-width: 900px) {
  .sheet.side { inset: 58px 0 0 auto; width: 420px; background: none; align-items: stretch; }
  .sheet.side .sheet-inner { max-height: none; height: 100%; border-radius: 0; border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgba(0,0,0,.35); }
  .mission-bar { width: 640px; left: calc(96px + (100% - 96px) / 2 - 320px); }
}
.fiche-head { display: flex; gap: 14px; align-items: center; }
.fiche-head canvas { width: 84px; height: 84px; border-radius: 16px; background: linear-gradient(#bfe6ff, #e8f6ff); image-rendering: pixelated; border: 2px solid var(--line); }
.fiche-head h2 { margin: 0; }
.now { margin: 12px 0 8px; padding: 10px 12px; border-radius: 10px; background: var(--bg3); font-size: 14px; }
.chips-row { margin: 6px 0; gap: 6px; }
.toolchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--bg3); border-radius: 99px; padding: 3px 10px 3px 3px; }
.ftabs { display: flex; gap: 4px; margin: 14px 0 10px; background: var(--bg3); border-radius: 10px; padding: 4px; }
.ftabs button { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px 4px; border-radius: 8px; font: 600 13px system-ui; cursor: pointer; }
.ftabs button.on { background: var(--bg); color: var(--txt); }
.item.row canvas, .chip-agent canvas { width: 40px; height: 40px; border-radius: 10px; background: #dff3ff; image-rendering: pixelated; }
.chip-agent { display: inline-flex; align-items: center; gap: 8px; background: var(--bg3); border: 1px solid var(--line); color: var(--txt); border-radius: 12px; padding: 4px 10px 4px 4px; cursor: pointer; font: 600 13px system-ui; }
.chip-agent canvas { width: 32px; height: 32px; }

@media (min-width: 900px) { .toolsbar { left: 96px; top: 58px; } .hud { top: 108px; } }
@media (max-width: 600px) { .hud .gauge { min-width: 0; } .hud .limits { grid-template-columns: repeat(3, 1fr); } }
