/* RackPlan — feuille de style unique (pas de build) */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --ink: #1d2329;
  --muted: #6b7480;
  --line: #dfe3e8;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --ok: #2b8a3e;
  --warn: #b7791f;
  --err: #c92a2a;
  --radius: 8px;
  --mono: "JetBrains Mono", "DejaVu Sans Mono", Consolas, monospace;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); font-weight: normal; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12px; }

/* barre du haut */
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 52px; background: #1d2329; color: #fff; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-mark { display: inline-block; color: #4dabf7; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #c5cbd3; padding: 6px 12px; border-radius: 6px; }
.topbar nav a:hover, .topbar nav a.active { background: #2f3842; color: #fff; text-decoration: none; }
.topsearch { margin-left: auto; }
.topsearch input { width: 300px; background: #2f3842; border: 1px solid #3d4752; color: #fff; padding: 7px 12px; border-radius: 6px; }
.topsearch input::placeholder { color: #8f98a3; }
.logout .btn-ghost { color: #c5cbd3; border-color: #3d4752; }

.container { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }

/* boutons & champs */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.btn:hover { border-color: #b8c0c9; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: #1a5fcc; }
.btn-danger { color: var(--err); border-color: #f1c2c2; }
.btn-danger:hover { background: #fff5f5; border-color: var(--err); }
.btn-ghost { background: transparent; }
.btn.on { background: #e7f0ff; border-color: var(--accent); color: var(--accent); }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b6d3ff; border-color: var(--accent); }
input[type=color] { padding: 2px; height: 34px; }
input[type=checkbox] { width: auto; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: #48515b; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: normal; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.flash-ok { background: #ebfbee; color: #1e6b30; border: 1px solid #b2f2bb; }
.flash-err { background: #fff5f5; color: #a61e1e; border: 1px solid #ffc9c9; }
.badge { font-size: 11px; background: #fff3bf; color: #8a6d00; padding: 1px 7px; border-radius: 10px; margin-left: 6px; }
kbd { font-family: var(--mono); font-size: 11px; background: #f1f3f5; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }

/* formulaires */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.span-2 { grid-column: span 2; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
legend { font-weight: 600; padding: 0 6px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #f8f9fa; border-radius: 14px; padding: 3px 10px; cursor: pointer; font: inherit; font-size: 12px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; }
.danger-zone { margin-top: 10px; text-align: right; }

/* liste des baies */
.site-title { margin: 26px 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: .5px; }
.rack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.rack-card { display: flex; gap: 12px; padding: 12px; color: var(--ink); transition: border-color .15s, box-shadow .15s; margin: 0; }
.rack-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(31, 111, 235, .12); text-decoration: none; }
.rack-card-thumb { width: 70px; height: 120px; flex-shrink: 0; background: #f8f9fa; border-radius: 4px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.rack-card-thumb img { max-width: 100%; max-height: 100%; }
.rack-card-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.rack-card-title { font-weight: 600; font-size: 15px; }
.rack-card-stats { display: flex; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.meter { height: 6px; background: #e9ecef; border-radius: 3px; overflow: hidden; margin-top: auto; }
.meter span { display: block; height: 100%; background: var(--accent); }
.empty { text-align: center; padding: 40px; }
.inline-import { margin: 0; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.table tr:hover td { background: #f8f9fa; }

/* ---------- éditeur ---------- */
.editor-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.editor-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-main > .flash { margin: 10px 16px 0; }
#rack-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ed-toolbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-title { display: flex; flex-direction: column; min-width: 0; }
.ed-title h1 { font-size: 18px; }
.ed-title .muted { font-size: 12px; }
.ed-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.stat { background: #f1f3f5; border-radius: 12px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; }
.stat small { font-weight: normal; color: var(--muted); }
.stat.bad { background: #fff5f5; color: var(--err); }
.ed-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ed-tools select { width: auto; padding: 6px 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line); background: #fff; padding: 6px 11px; cursor: pointer; font: inherit; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: #e7f0ff; color: var(--accent); font-weight: 600; }
.seg button:disabled { color: #c1c7cd; cursor: default; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12); min-width: 250px; padding: 6px; display: flex; flex-direction: column; }
.menu-list a, .menu-list button { display: block; text-align: left; padding: 8px 10px; border-radius: 5px; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; width: 100%; }
.menu-list a:hover, .menu-list button:hover { background: #f1f3f5; text-decoration: none; }
.menu-list form { margin: 0; }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.ed-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 230px 1fr 340px; }
.ed-palette { border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.pal-hint { font-size: 11.5px; color: var(--muted); }
.pal-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.pal-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 4px;
  cursor: grab; user-select: none; touch-action: none; background: #fff; }
.pal-item:hover { border-color: var(--accent); background: #f5f9ff; }
.pal-swatch { width: 26px; border-radius: 2px; flex-shrink: 0; }
.pal-name { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-u { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.pal-manage { font-size: 12px; margin-top: auto; padding-top: 10px; }

.ed-canvas { overflow: auto; position: relative; background:
  radial-gradient(circle, #d6dbe0 1px, transparent 1px) 0 0 / 18px 18px, #f6f7f9; }
#rack-svg { display: block; margin: 0 auto; user-select: none; touch-action: none; }
.ed-banner { position: sticky; bottom: 14px; margin: 0 auto; width: max-content; max-width: 90%; background: #1d2329; color: #fff;
  padding: 8px 16px; border-radius: 20px; font-size: 13px; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.ed-banner[hidden] { display: none; }

.ed-panel { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 14px 16px 30px; }
.pn-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.pn-swatch { width: 10px; align-self: stretch; border-radius: 3px; flex-shrink: 0; }
.pn-kicker { font-size: 11.5px; color: var(--muted); }
.pn-title { font-size: 16px; font-weight: 700; word-break: break-word; }
.pn-form { display: flex; flex-direction: column; gap: 9px; }
.pn-section { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin: 14px 0 4px; border-top: 1px solid var(--line); padding-top: 10px; }
.pn-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pn-conns { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.pn-conns li { padding: 5px 6px; border-radius: 5px; cursor: pointer; }
.pn-conns li:hover { background: #f1f3f5; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.pn-add-conn { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.pn-remote-item { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 6px 8px; margin-bottom: 4px; cursor: pointer; font: inherit; font-size: 12.5px; }
.pn-remote-item:hover { border-color: var(--accent); }
.pn-link { font-size: 12.5px; }
.pn-notes { white-space: pre-wrap; background: #fffbe6; border: 1px solid #ffe8a3; border-radius: 6px; padding: 8px 10px; font-size: 13px; margin-bottom: 10px; }
.pn-inv { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pn-inv td { padding: 5px 4px; border-bottom: 1px solid #f1f3f5; }
.pn-inv tr[data-id] { cursor: pointer; }
.pn-inv tr[data-id]:hover td { background: #f5f9ff; }
.pn-help { font-size: 12px; color: var(--muted); line-height: 1.9; }
.ed-status { padding: 5px 16px; font-size: 12.5px; background: var(--surface); border-top: 1px solid var(--line); color: var(--muted); }
.ed-status.ok { color: var(--ok); }
.ed-status.warn { color: var(--warn); }
.ed-status.err { color: var(--err); background: #fff5f5; }

/* SVG de la baie */
#rack-svg text { font-family: Inter, "Segoe UI", Arial, sans-serif; }
.face-title { font-size: 13px; font-weight: 700; fill: #1d2329; letter-spacing: 1px; }
.u-num { font-size: 10px; fill: #6c757d; }
.u-slot:hover { fill: rgba(31, 111, 235, .07); }
.dev { cursor: grab; }
.dragging, .dragging * { cursor: grabbing !important; }
.dev-body { stroke: #1d2329; stroke-width: 1.2; }
.dev:hover .dev-body { stroke: var(--accent); stroke-width: 2; }
.dev.selected .dev-body { stroke: var(--accent); stroke-width: 3; filter: drop-shadow(0 0 4px rgba(31, 111, 235, .6)); }
.dev.ghost.selected rect { stroke: var(--accent); stroke-width: 2; }
.dev.dup-ip .dev-body { stroke: var(--err); stroke-width: 2.5; }
.dev.st-decommissioned { opacity: .45; }
.dev.link-from .dev-body { stroke: #f08c00; stroke-width: 3.5; }
.linking .dev { cursor: crosshair; }
.dev-l1 { font-size: 12px; font-weight: 700; pointer-events: none; }
.dev-l1.small { font-size: 11px; }
.dev-l2 { font-size: 11px; font-family: var(--mono); pointer-events: none; }
.note-mark { font-size: 11px; pointer-events: none; opacity: .85; }
.ghost-label { font-size: 11px; font-style: italic; fill: #343a40; pointer-events: none; }
.ghost-ok { fill: rgba(43, 138, 62, .25); stroke: #2b8a3e; stroke-width: 2; stroke-dasharray: 5 3; }
.ghost-bad { fill: rgba(201, 42, 42, .2); stroke: #c92a2a; stroke-width: 2; stroke-dasharray: 5 3; }
.ghost-text { font-size: 12px; font-weight: 700; fill: #1d2329; }
.link { cursor: pointer; }
.link-line { fill: none; stroke-width: 2; opacity: .9; pointer-events: none; }
.link-line.dashed { stroke-dasharray: 6 3; }
.link-hit { fill: none; stroke: transparent; stroke-width: 10; }
.link:hover .link-line, .link.selected .link-line { stroke-width: 3.5; opacity: 1; }
.link-label { font-size: 10px; font-weight: 700; pointer-events: none; paint-order: stroke; stroke: #f6f7f9; stroke-width: 3px; }

/* historique / catalogue */
.tpl-table input, .tpl-table select { padding: 5px 7px; font-size: 13px; }
.tpl-table td { vertical-align: middle; }

/* connexion */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 340px; display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login-card h1 { font-size: 20px; }

@media (max-width: 1100px) {
  .ed-body { grid-template-columns: 190px 1fr 290px; }
  .topsearch input { width: 200px; }
}
