:root {
  --bg: #f2f8f9; --surface: #ffffff; --surface-2: #f5fafb; --border: #d9e8ea; --border-strong: #bfd5d9;
  --text: #132226; --muted: #546e74; --primary: #0c727a; --primary-2: #095d64; --primary-soft: #e0f3f4;
  --danger: #dc2626; --danger-soft: #fef2f2; --ok: #16a34a; --ok-soft: #f0fdf4;
  --shadow: 0 1px 2px rgba(19,34,38,.06), 0 4px 16px rgba(19,34,38,.06);
  --shadow-lg: 0 20px 50px rgba(19,34,38,.18);
  --radius: 12px; --radius-sm: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #182830; --surface: #1f323b; --surface-2: #1b2d35; --border: #2f4954; --border-strong: #406270;
  --text: #e5f1f3; --muted: #9cb3b9; --primary: #6fd3dc; --primary-2: #095d64; --primary-soft: #1b4249;
  --danger: #f87171; --danger-soft: #3a1620; --ok: #4ade80; --ok-soft: #0f2e1d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ---------- Icons ---------- */
i[data-icon] { display: inline-flex; width: 18px; height: 18px; flex: none; }
i[data-icon] svg { width: 100%; height: 100%; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 76px 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: stretch; padding: 14px 8px; gap: 4px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 11px; margin-bottom: 14px; }
.nav-link { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 10px; color: var(--muted); text-decoration: none; font: 600 11px var(--font); background: none; border: 0; cursor: pointer; transition: background .15s, color .15s; }
.nav-link i[data-icon] { width: 21px; height: 21px; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-spacer { flex: 1; }
.view { overflow: auto; min-width: 0; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 13px var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: #0c727a; border-color: transparent; color: #fff; box-shadow: 0 1px 3px rgba(19,34,38,.2); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn.on { color: #f59e0b; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
input[type="color"] { padding: 2px; height: 38px; width: 60px; }
textarea { resize: vertical; min-height: 70px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
label > input, label > select, label > textarea { font-weight: 400; font-size: 14px; }
.search { position: relative; flex: 1; min-width: 0; }
.search input { width: 100%; padding-left: 34px; }
.search i[data-icon] { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }

/* ---------- Page layout ---------- */
.page { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty i[data-icon] { width: 40px; height: 40px; opacity: .5; margin-bottom: 8px; }

/* ---------- Accueil ---------- */
.shell.is-home .nav-link[data-nav]:not([data-nav="admin"]) { display: none; }
.home { max-width: 1100px; }
.hero { display: flex; align-items: center; gap: 18px; padding: 34px 32px; margin-bottom: 22px; border-radius: 18px; border: 1px solid var(--border);
  background: radial-gradient(700px 260px at 0% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent), radial-gradient(600px 240px at 100% 100%, color-mix(in srgb, var(--primary) 9%, transparent), transparent), var(--surface); }
.hero img { border-radius: 14px; box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 30%, transparent); }
.hero h1 { font-size: 28px; }
.hero p { margin: 4px 0 0; font-size: 15px; }
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 22px; }
.tool-card { display: flex; align-items: center; gap: 18px; padding: 24px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
.tool-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow); }
.tool-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); flex: none; }
.tool-icon i[data-icon] { width: 30px; height: 30px; }
.tool-body { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.tool-body b { font-size: 18px; }
.tool-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.tool-stats span { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.tool-go { color: var(--muted); transform: rotate(180deg); transition: color .15s, transform .15s; }
.tool-card:hover .tool-go { color: var(--primary); transform: rotate(180deg) translateX(-2px); }
.recent { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.recent .card { padding: 18px; }
.recent h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.recent h2 i[data-icon] { width: 17px; height: 17px; color: var(--primary); }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; margin: 0 -10px; border-radius: 9px; color: var(--text); text-decoration: none; }
.recent-item:hover { background: var(--surface-2); }
.recent-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ri-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ri-main b, .ri-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-main span { font-size: 12px; }
.ri-date { font-size: 12px; white-space: nowrap; }
.recent-empty { padding: 10px 0; font-size: 13px; }
@media (max-width: 720px) { .hero { padding: 22px 18px; } .hero h1 { font-size: 22px; } .ri-date { display: none; } }

/* ---------- Onglets de section ---------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13px; }
.tab i[data-icon] { width: 16px; height: 16px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.on { background: var(--primary-soft); color: var(--primary); }

/* ---------- Data table ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.tcp { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.badge.udp { background: #fef3c7; color: #b45309; border-color: #fde68a; }
[data-theme="dark"] .badge.tcp { background: #0c2a3f; color: #7dd3fc; border-color: #164e74; }
[data-theme="dark"] .badge.udp { background: #3a2a0a; color: #fcd34d; border-color: #6b4c0f; }
.badge.custom { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

/* ---------- Lecture seule ---------- */
.ro [data-w] { display: none !important; }
.ro .ql-toolbar { display: none; }
.view.ro::after { content: 'Lecture seule'; position: fixed; right: 18px; bottom: 18px; z-index: 50; padding: 6px 14px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border); box-shadow: var(--shadow); pointer-events: none; }
.ro input:disabled, .ro select:disabled, .ro textarea:disabled { opacity: 1; background: var(--surface-2); color: var(--text); cursor: default; }

/* ---------- Utilisateurs ---------- */
.users-table th i[data-icon] { width: 14px; height: 14px; vertical-align: -2px; }
.u-cell { display: flex; align-items: center; gap: 10px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; flex: none; }
select.perm { padding: 5px 8px; font-size: 13px; font-weight: 600; }
select.perm-none { color: var(--muted); }
select.perm-read { color: #b45309; }
select.perm-write { color: var(--primary); }
[data-theme="dark"] select.perm-read { color: #fcd34d; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.perm-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; padding: 16px 18px; margin-top: 16px; }
.perm-help div { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.perm-help b { display: flex; align-items: center; gap: 6px; }
.perm-help i[data-icon] { width: 15px; height: 15px; color: var(--primary); }

/* ---------- Notes ---------- */
.notes { display: grid; grid-template-columns: 250px 320px 1fr; height: 100%; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); }
.pane.tree { background: var(--surface); }
.pane.list { background: var(--surface-2); }
.pane.editor { border-right: 0; background: var(--surface); }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 14px; border-bottom: 1px solid var(--border); min-height: 64px; }
.pane-head h2 { flex: 1; }
.tree-body, .note-list { overflow: auto; flex: 1; padding: 8px; }
.tree-item { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px; border-radius: 8px; cursor: pointer; color: var(--text); user-select: none; }
.tree-item:hover { background: var(--surface-2); }
.tree-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tree-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item .count { font-size: 11px; color: var(--muted); }
.tree-item .tools { display: none; gap: 0; }
.tree-item:hover .tools { display: flex; }
.tree-item:hover .count { display: none; }
.tree-item .tools .icon-btn { width: 24px; height: 24px; }
.tree-item .tools i[data-icon] { width: 14px; height: 14px; }
.tree-item.folder { padding-left: calc(4px + var(--depth, 0) * 18px); position: relative; }
.tree-item .twist { display: inline-flex; width: 16px; justify-content: center; flex: none; cursor: pointer; }
.tree-item .f-ic { display: inline-flex; flex: none; }
.tree-item .f-ic i[data-icon] { width: 17px; height: 17px; }
.tree-item.active .f-ic { filter: saturate(1.2); }
/* Glisser-déposer */
.tree-item.dragging, .note-card.dragging { opacity: .45; }
.tree-item.drop-inside { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.tree-item.drop-before::before, .tree-item.drop-after::after { content: ''; position: absolute; left: calc(8px + var(--depth, 0) * 18px); right: 6px; height: 2px; border-radius: 2px; background: var(--primary); pointer-events: none; }
.tree-item.drop-before::before { top: -1px; } .tree-item.drop-after::after { bottom: -1px; }
.tree-item.drop-before::before, .tree-item.drop-after::after { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent); }
.tree-item { position: relative; }
.note-card[draggable="true"] { cursor: grab; }
.tree-hint { padding: 10px 14px; font-size: 11px; border-top: 1px solid var(--border); }
@media (hover: none) { .tree-hint { display: none; } }
.tree-item .caret { width: 14px; height: 14px; color: var(--muted); transition: transform .15s; }
.tree-item.collapsed .caret { transform: rotate(-90deg); }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.tree-sep { height: 1px; background: var(--border); margin: 8px 4px; }
.list-title { padding: 10px 16px 2px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.note-card { padding: 12px 14px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; margin-bottom: 4px; }
.note-card:hover { background: var(--surface); border-color: var(--border); }
.note-card.active { background: var(--surface); border-color: var(--primary); box-shadow: var(--shadow); }
.note-card h3 { font-size: 14px; font-weight: 650; display: flex; gap: 6px; align-items: center; overflow: hidden; }
.note-card h3 span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card h3 i[data-icon] { width: 13px; height: 13px; color: #f59e0b; }
.note-card p { margin: 4px 0 6px; color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.tag { background: var(--primary-soft); color: var(--primary); padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.editor-head { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--border); min-height: 64px; }
.title-input { flex: 1; font-size: 20px; font-weight: 700; border: 0; background: none; padding: 6px 0; letter-spacing: -.01em; }
.title-input:focus { box-shadow: none; }
.save-state { font-size: 12px; color: var(--muted); white-space: nowrap; }
.save-state.saving { color: #d97706; }
.editor-meta { display: flex; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.editor-meta select { max-width: 260px; }
.editor-meta input { flex: 1; min-width: 160px; }
.editor-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-body .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--border); padding: 8px 14px; background: var(--surface-2); }
.editor-body .ql-container.ql-snow { border: 0; flex: 1; overflow: auto; font: 15px/1.65 var(--font); }
.editor-body .ql-editor { padding: 20px 28px 80px; max-width: 900px; }
.ql-editor pre.ql-syntax, .ql-editor .ql-code-block-container { background: #132226; color: #e5f1f3; border-radius: 8px; font-family: var(--mono); }
[data-theme="dark"] .ql-snow .ql-stroke { stroke: var(--text); }
[data-theme="dark"] .ql-snow .ql-fill { fill: var(--text); }
[data-theme="dark"] .ql-snow .ql-picker { color: var(--text); }
[data-theme="dark"] .ql-snow .ql-picker-options { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .ql-editor.ql-blank::before { color: var(--muted); }
.ql-snow .ql-tooltip { z-index: 5; }
.ql-editor table { border-collapse: collapse; width: 100%; margin: 10px 0; table-layout: auto; }
.ql-editor td { border: 1px solid var(--border-strong); padding: 6px 10px; vertical-align: top; }
.ql-editor tr:first-child td { background: var(--surface-2); font-weight: 600; }
.ql-snow .ql-toolbar button.ql-table i[data-icon], .ql-toolbar.ql-snow button.ql-table i[data-icon] { width: 16px; height: 16px; color: var(--text); }
.mobile-only { display: none; }

/* ---------- Matrices list ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.m-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.m-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow); }
.m-card .top { display: flex; gap: 12px; align-items: center; }
.m-card .logo { width: 46px; height: 46px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; flex: none; color: var(--muted); font-weight: 700; }
.m-card .logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.m-card h3 { font-size: 15px; }
.m-card .stats { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.m-card .foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding-top: 10px; font-size: 12px; color: var(--muted); }

/* ---------- Matrix editor ---------- */
.mx-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.mx-head .title-input { min-width: 200px; }
.mx-info { padding: 18px; margin-bottom: 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.mx-info .wide { grid-column: 1 / -1; }
.logo-drop { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1.5px dashed var(--border-strong); border-radius: 10px; min-height: 70px; cursor: pointer; position: relative; }
.logo-drop:hover { border-color: var(--primary); background: var(--primary-soft); }
.logo-drop img { max-height: 48px; max-width: 120px; object-fit: contain; }
.logo-drop .ph { color: var(--muted); font-size: 12px; font-weight: 500; }
.logo-drop .rm { position: absolute; right: 6px; top: 6px; }
.logo-drop input { display: none; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
table.flow-table td { padding: 5px 3px; }
table.flow-table td:first-child { padding-left: 8px; }
table.flow-table th { padding: 10px 6px; }
.flow-table input, .flow-table select, .flow-table textarea { width: 100%; padding: 6px 8px; font-size: 13px; border-color: transparent; background: transparent; }
.flow-table input:hover, .flow-table select:hover, .flow-table textarea:hover { border-color: var(--border); }
.flow-table input:focus, .flow-table select:focus, .flow-table textarea:focus { background: var(--surface); border-color: var(--primary); }
.flow-table textarea.cmt { resize: none; min-height: 0; overflow: hidden; line-height: 1.4; display: block; }
.flow-table textarea::placeholder { color: var(--muted); opacity: .55; }
/* Zones du projet */
.zones-box { display: flex; flex-direction: column; gap: 5px; }
.zones-box .zl { font-size: 12px; font-weight: 600; color: var(--muted); }
.zone-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; min-height: 40px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.zchip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.zchip button { display: inline-flex; border: 0; background: none; color: inherit; cursor: pointer; padding: 1px; border-radius: 50%; opacity: .6; }
.zchip button:hover { opacity: 1; background: rgba(0,0,0,.08); }
.zchip i[data-icon] { width: 12px; height: 12px; }
.zone-acts { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.zone-acts .btn i[data-icon] { width: 14px; height: 14px; }
.zone-link { font-size: 12px; white-space: nowrap; }
.zones-page { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.zones-page .zone-chips { border: 0; padding: 0; min-height: 0; }
.zp-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.zone-add { border: 0 !important; box-shadow: none !important; padding: 4px 6px; flex: 1; min-width: 140px; background: transparent; font-size: 13px; }
.flow-table .num { color: var(--muted); font-weight: 700; font-size: 12px; text-align: center; width: 46px; white-space: nowrap; }
.flow-table .arrow { color: var(--muted); text-align: center; width: 20px; padding: 0; }
.flow-table .grp-src { border-left: 3px solid #0ea5e9; }
.flow-table .grp-dst { border-left: 3px solid #a855f7; }
.flow-table tr.grp-head th { text-align: center; font-size: 11px; padding: 6px; border-bottom: 0; }
.flow-table tr.grp-head th.grp-src { color: #0284c7; background: color-mix(in srgb, #0ea5e9 10%, var(--surface-2)); }
.flow-table tr.grp-head th.grp-dst { color: #9333ea; background: color-mix(in srgb, #a855f7 10%, var(--surface-2)); }
.flow-table tr.grp-head th.grp-svc { color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--surface-2)); }
.flow-table .grp-svc { border-left: 3px solid var(--primary); }
[data-theme="dark"] .flow-table tr.grp-head th.grp-src { color: #7dd3fc; } [data-theme="dark"] .flow-table tr.grp-head th.grp-dst { color: #d8b4fe; }
.flow-table thead tr:nth-child(2) th { top: 29px; }
/* Séparateurs de flux */
.flow-table tr.sec-row td { background: var(--primary-soft); border-top: 2px solid var(--primary); }
.flow-table tr.sec-row:hover td { background: var(--primary-soft); }
.sec-wrap { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.sec-wrap i[data-icon] { width: 18px; height: 18px; }
.flow-table input.sec-title { flex: 1; max-width: 520px; font-weight: 700; font-size: 14px; color: var(--primary); background: transparent; border-color: transparent; }
.flow-table input.sec-title:hover, .flow-table input.sec-title:focus { background: var(--surface); border-color: var(--border); }
.sec-count { font-size: 12px; font-weight: 600; white-space: nowrap; }
.flow-table .zone { border-radius: 6px; font-weight: 600; }
.flow-table select.act { font-weight: 700; border-radius: 6px; }
.flow-table select.act.allow { background: var(--ok-soft); color: var(--ok); }
.flow-table select.act.deny { background: var(--danger-soft); color: var(--danger); }
.flow-table .row-tools { display: grid; grid-template-columns: 26px 26px; gap: 0; width: 56px; }
.flow-table .row-tools .icon-btn { width: 26px; height: 26px; }
.flow-table .row-tools i[data-icon] { width: 14px; height: 14px; }
.w-xs { min-width: 64px; } .w-zone { min-width: 80px; } .w-sm { min-width: 88px; } .w-ip { min-width: 112px; } .w-md { min-width: 116px; } .w-lg { min-width: 120px; }
.flow-table select.act { min-width: 100px; }
.flow-table input::placeholder { color: var(--muted); opacity: .55; }
.add-row { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Autocomplete ---------- */
.ac { position: fixed; z-index: 1000; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 320px; overflow: auto; min-width: 320px; padding: 4px; }
.ac-item { display: grid; grid-template-columns: 74px 46px 1fr; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.ac-item.sel, .ac-item:hover { background: var(--primary-soft); }
.ac-item .p { font-family: var(--mono); font-weight: 700; }
.ac-item .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .s small { color: var(--muted); margin-left: 6px; }
.ac-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.role-ports { display: flex; flex-wrap: wrap; gap: 4px; }
.role-ports .badge .svc { font-weight: 500; opacity: .75; margin-left: 2px; }

/* ---------- Modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(19,34,38,.45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 900; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(460px, 100%); padding: 22px; display: flex; flex-direction: column; gap: 14px; animation: pop .18s; max-height: 90vh; overflow: auto; }
.modal h2 { font-size: 17px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .2s; max-width: 380px; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98) } }

/* ---------- Login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 22%, transparent), transparent), radial-gradient(900px 500px at 110% 110%, rgba(111,211,220,.16), transparent), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin-top: 4px; }
.login-card p { margin: -8px 0 6px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) { .notes { grid-template-columns: 220px 280px 1fr; } }
@media (max-width: 960px) {
  .notes { grid-template-columns: 1fr; }
  .notes .pane { display: none; border-right: 0; }
  .notes[data-pane="tree"] .tree, .notes[data-pane="list"] .list, .notes[data-pane="editor"] .editor { display: flex; }
  .mobile-only { display: inline-flex; }
  .editor-body .ql-editor { padding: 16px; }
  /* Matrice : lignes en cartes */
  .flow-table thead { display: none; }
  .flow-table, .flow-table tbody, .flow-table tr, .flow-table td { display: block; width: 100%; }
  .flow-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 12px; border-bottom: 1px solid var(--border); position: relative; }
  .flow-table td { border: 0 !important; padding: 0 !important; }
  .flow-table td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 2px 0; }
  .flow-table input, .flow-table select, .flow-table textarea { border-color: var(--border); }
  .flow-table .num { grid-column: 1 / -1; text-align: left; font-size: 14px; }
  .flow-table .arrow { display: none !important; }
  .flow-table td.full { grid-column: 1 / -1; }
  .flow-table .row-tools { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
  .flow-table tr.sec-row { grid-template-columns: 1fr; }
  .table-wrap.flows { overflow: visible; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { order: 2; flex-direction: row; border-right: 0; border-top: 1px solid var(--border); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .brand, .nav-spacer { display: none; }
  .nav-link { flex: 1; padding: 6px 2px; }
  .page { padding: 18px 14px 40px; }
  .page-head .actions .btn span.lbl { display: none; }
  .modal .row2 { grid-template-columns: 1fr; }
  #toasts { left: 12px; right: 12px; bottom: 76px; }
  .ac { min-width: 0; left: 8px !important; right: 8px; }
}
.modal textarea[name="ports"] { min-height: 190px; font-family: var(--mono); font-size: 13px; }
/* Lignes nouvellement créées (rôle, flux retour) */
@keyframes flash { from { background: color-mix(in srgb, var(--primary) 22%, transparent); } }
.flow-table tr.flash td { animation: flash 1.8s ease-out; }
/* Glisser-déposer des lignes de flux */
.flow-table .num-in { display: inline-flex; align-items: center; gap: 2px; }
.flow-table .grip { display: inline-flex; color: var(--muted); opacity: .45; cursor: grab; padding: 2px 0; border-radius: 4px; }
.flow-table .grip i[data-icon] { width: 14px; height: 16px; }
.flow-table tr:hover .grip { opacity: 1; }
.flow-table .grip:hover { color: var(--primary); background: var(--primary-soft); }
.flow-table .grip:active { cursor: grabbing; }
.flow-table .sec-wrap .grip { color: var(--primary); }
.flow-table tr.dragging { opacity: .4; }
.flow-table tr.drop-before td { box-shadow: inset 0 3px 0 var(--primary); }
.flow-table tr.drop-after td { box-shadow: inset 0 -3px 0 var(--primary); }
@media (hover: none) { .flow-table .grip { display: none; } }
/* Conflit d'enregistrement */
.save-state.conflict { color: var(--danger); font-weight: 600; }
/* Mon compte : sessions ouvertes */
.sess-box { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.sess-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.sess-list { list-style: none; margin: 0; padding: 0; max-height: 150px; overflow: auto; font-size: 12.5px; }
.sess-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 4px 6px; border-radius: 6px; }
.sess-list li.cur { background: var(--primary-soft); }
.sess-list em { color: var(--primary); font-style: normal; font-weight: 600; }
.sess-note { font-size: 12px; margin-top: 4px; }
