/* Vigia Studio : interface d'édition (le tableau lui-même utilise vigia.css). */
:root { --ink: #0f172a; --muted: #5b6b7d; --line: #dbe4ee; --bg: #f3f6fa; --brand: #0891b2; --brand-d: #0e7490; --hot: #c2410c; --danger: #b91c1c; --card: #fff; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: "Vigia Grotesk", system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-d); }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .err { color: var(--danger); } .hidden { display: none !important; }
.mark { width: 30px; height: 30px; border-radius: 8px; background: #0b1628 url("/site/assets/vigia/icon.svg") center / cover; display: inline-block; flex: none; }

/* Barre du haut */
.top { position: sticky; top: 0; z-index: 30; height: 58px; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: #fff; border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: .02em; }
.logo small { font-weight: 500; color: var(--muted); font-size: 14px; }
.crumb { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumb b { color: var(--ink); }
.sp { flex: 1; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* Boutons et champs */
.btn { font: inherit; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #b7c9d8; }
.btn:focus-visible, .in:focus-visible, .pal-it:focus-visible, .tpl:focus-visible, .theme-sw:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-d); }
.btn.danger { background: #fff; border-color: #f3c4c4; color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; } .btn.ghost:hover { background: #eef3f8; }
.btn.danger-t { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 11px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; font-size: 17px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.file { position: relative; }
.in { font: inherit; font-size: 14px; width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #c9d6e3; border-radius: 8px; background: #fff; color: var(--ink); }
.in.small { min-height: 36px; font-size: 13px; }
textarea.in { resize: vertical; min-height: 80px; }
.fld { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; border: 0; padding: 0; min-width: 0; }
.fld > span, .fld > legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin: 0 0 9px; min-height: 28px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--brand); }
.pair { display: flex; gap: 6px; align-items: center; }
.pair input[type="color"] { width: 46px; height: 36px; border: 1px solid #c9d6e3; border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.seg { display: flex; gap: 4px; background: #eef3f8; padding: 4px; border-radius: 10px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; flex: 1 1 auto; border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); min-height: 36px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.note { background: #eef7fa; border: 1px solid #cfe6ee; border-radius: 9px; padding: 11px 13px; font-size: 13px; line-height: 1.5; margin: 10px 0; }
.note.ok { background: #effaf2; border-color: #c8ecd3; } .note.err { background: #fdf0f0; border-color: #f4cccc; color: var(--danger); }
.thumb { max-width: 100%; max-height: 70px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px; margin-bottom: 6px; align-self: flex-start; }

/* Connexion */
.auth { min-height: calc(100vh - 58px); display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px rgba(15, 23, 42, .08); }
.auth-brand { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.auth-brand .mark { width: 46px; height: 46px; border-radius: 12px; }
.auth-brand h1 { margin: 0 0 4px; font-size: 24px; }
.auth-brand p { margin: 0; line-height: 1.45; }

/* Accueil */
.home { max-width: 1360px; margin: 0 auto; padding: 26px 24px 60px; display: flex; flex-direction: column; gap: 34px; }
.sec-h { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.sec-h h1, .sec-h h2 { margin: 0; font-size: 22px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.dash-open { display: block; }
.dash-b { padding: 12px 14px; }
.dash-b h2 { margin: 0 0 3px; font-size: 16px; } .dash-b h2 a { color: var(--ink); text-decoration: none; }
.mini { aspect-ratio: 16 / 9; background: var(--bg); padding: 10px; border-bottom: 1px solid var(--line); }
.mini-g { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; height: 100%; }
.mini-g i { background: var(--panel); border: 1px solid var(--border); border-radius: 3px; }
.mini.theme-night { --bg: #060c18; --panel: #10203a; --border: rgba(34, 211, 238, .4); }
.mini.theme-day { --bg: #eef3f8; --panel: #fff; --border: #c9d6e3; }
.mini.theme-paper { --bg: #f5efe3; --panel: #efe6d4; --border: #1c1917; }
.mini.theme-pop { --bg: #f4f2fb; --panel: #fff; --border: #e0dbf5; }
.mini.theme-control { --bg: #2a2e35; --panel: #343a43; --border: #555e6b; }
.mini-g i:first-child { background: var(--accent); }
.new-card { font: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 220px; border-style: dashed; cursor: pointer; color: var(--ink); text-align: center; padding: 16px; }
.new-card .plus { width: 46px; height: 46px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 26px; }
.tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tpl { font: inherit; text-align: left; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; cursor: pointer; color: var(--ink); transition: transform .15s, box-shadow .15s; }
.tpl:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(15, 23, 42, .1); }
.tpl-shot { position: relative; aspect-ratio: 16 / 10; overflow: hidden; border-bottom: 1px solid var(--line); background: #eef3f8; }
.tpl-frame { position: absolute; top: 0; left: 0; width: 1440px; transform: scale(var(--k, .22)); transform-origin: 0 0; pointer-events: none; }
.tpl-b { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; }
.tpl-b b { font-size: 15px; }

/* Éditeur */
.ed { display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; height: calc(100vh - 58px); }
.pal { border-right: 1px solid var(--line); background: #fff; overflow: auto; padding: 14px; }
.pal-h { display: flex; flex-direction: column; gap: 8px; }
.pal-h h2 { margin: 0; font-size: 16px; }
.pal h3 { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.pal-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.pal-it { font: inherit; font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 6px; min-height: 64px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; color: var(--ink); cursor: grab; text-align: center; touch-action: none; }
.pal-it:hover { border-color: var(--brand); color: var(--brand-d); }
.pal-it svg { color: var(--brand); }
.cv { overflow: auto; background: #dfe6ee; padding: 18px; }
#cvBox { position: relative; margin: 0 auto; }
#cv { position: absolute; top: 0; left: 0; transform-origin: 0 0; border-radius: 10px; box-shadow: 0 6px 24px rgba(15, 23, 42, .12); overflow: hidden; }
#cv .vg-b { touch-action: none; user-select: none; }
.side { border-left: 1px solid var(--line); background: #fff; overflow: auto; display: flex; flex-direction: column; }
.tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.tabs button { font: inherit; font-weight: 600; flex: 1; border: 0; background: transparent; padding: 14px 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; min-height: 48px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--brand); }
.tabs button:disabled { opacity: .4; cursor: default; }
.side-b { padding: 16px; }
.side-b h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 18px 0 10px; }
.bp-h { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; color: var(--brand); }
.bp-h div { display: flex; flex-direction: column; color: var(--ink); }
.themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.theme-sw { font: inherit; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 5px; padding: 8px; min-height: 40px; border-radius: 9px; border: 1px solid var(--line); cursor: pointer; text-align: left; }
.theme-sw i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.theme-sw span { margin-left: 4px; }
.theme-sw.on { outline: 2px solid var(--brand); outline-offset: 1px; }
.sw-night { background: #0b1628; color: #d6ecff; } .sw-day { background: #eef3f8; color: #0f172a; } .sw-paper { background: #f5efe3; color: #1c1917; font-family: Georgia, serif; }
.sw-pop { background: #f4f2fb; color: #1e1b4b; } .sw-control { background: #343a43; color: #e7e9ec; }
.sw-aurora { background: linear-gradient(135deg, #2a1660, #0b0b1e 60%, #0e3a4a); color: #eef0ff; } .sw-swiss { background: #fff; color: #111; }
.sw-corporate { background: #f5f6f8; color: #101828; } .sw-terminal { background: #040904; color: #b8ffc8; font-family: ui-monospace, monospace; }
.sw-bento { background: #efe9df; color: #2b2620; } .sw-neon { background: #0a0014; color: #f7ecff; box-shadow: inset 0 0 0 1px rgba(255, 43, 214, .5); }
.sw-brutal { background: #fff; color: #111; border: 2px solid #111 !important; box-shadow: 2px 2px 0 #111; } .sw-luxe { background: #0d0c0a; color: #e8d9b0; font-family: Georgia, serif; }
.sw-holo { background: linear-gradient(150deg, #23373f, #16242c); color: #e2f6f7; box-shadow: inset 0 0 0 1px rgba(46, 230, 214, .35); } .sw-holoblue { background: #03163a; color: #d3ecff; box-shadow: inset 0 0 0 1px rgba(56, 170, 255, .6); }
.link-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 36px; gap: 5px; margin-bottom: 6px; }
.adv summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
.drag-chip { position: fixed; z-index: 100; pointer-events: none; background: var(--brand); color: #fff; font-weight: 600; font-size: 13px; padding: 7px 11px; border-radius: 8px; box-shadow: 0 8px 20px rgba(0, 0, 0, .2); }

/* Fenêtres */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(15, 23, 42, .3); color: var(--ink); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dh { padding: 18px 20px 4px; } .dh h2 { margin: 0; font-size: 19px; }
.db { padding: 10px 20px; } .db p { margin: 0 0 12px; line-height: 1.5; }
.df { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-weight: 600; z-index: 200; max-width: calc(100vw - 32px); }
.toast.err { background: var(--danger); }

@media (max-width: 1100px) {
  .ed { grid-template-columns: 210px minmax(0, 1fr) 280px; }
}
@media (max-width: 860px) {
  .ed { grid-template-columns: 1fr; height: auto; }
  .pal, .side { border: 0; max-height: none; }
  .pal-items { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .top { gap: 8px; padding: 0 10px; overflow-x: auto; }
  .crumb { display: none; }
}
