/* Professional polish: design tokens on the RJL navy and teal brand, the model canvas, the review board,
   the command palette, drag-and-drop import, tables, toasts, skeletons and empty states. Loaded last. */
:root{
 --rjl-navy:#0B1F33;--rjl-teal:#0F5B67;--rjl-teal-2:#167D8D;--rjl-teal-50:#EAF2F4;--rjl-teal-100:#D2E2E6;
 --rjl-ink:#182331;--rjl-muted:#56616F;--rjl-line:#D8DEE5;--rjl-surface:#fff;--rjl-canvas:#F5F7F8;
 --rjl-amber:#825212;--rjl-amber-50:#FFF0D8;--rjl-green:#245F3E;--rjl-green-50:#E4F2E9;--rjl-red:#9B2C2C;--rjl-red-50:#FBEAEA;
 --radius-sm:6px;--radius:10px;--radius-lg:14px;
 --shadow-1:0 1px 2px #0B1F330d,0 1px 3px #0B1F3308;--shadow-2:0 4px 14px #0B1F3312,0 1px 3px #0B1F330a;--shadow-3:0 18px 48px #0B1F3326,0 4px 12px #0B1F3314;
 --focus:0 0 0 3px #fff,0 0 0 5px var(--rjl-teal-2);
 --ease:cubic-bezier(.2,.7,.2,1);--dur:160ms
}
@media (prefers-reduced-motion:reduce){:root{--dur:0ms}*,*::before,*::after{animation-duration:0ms!important;transition-duration:0ms!important;scroll-behavior:auto!important}}
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}

/* ---- Global polish ---- */
:focus-visible{outline:2px solid var(--rjl-teal-2);outline-offset:2px}
.button{transition:background var(--dur) var(--ease),border-color var(--dur) var(--ease),box-shadow var(--dur) var(--ease);box-shadow:var(--shadow-1)}
.button.quiet{box-shadow:none}
.button:active:not(:disabled){transform:translateY(1px)}

.panel{transition:box-shadow var(--dur) var(--ease)}
@media(min-width:901px){.topbar{position:sticky;top:44px;z-index:20;background:#ffffffeb;backdrop-filter:saturate(1.4) blur(8px)}}
.rail nav a{position:relative;transition:background var(--dur) var(--ease),color var(--dur) var(--ease)}
.rail nav a.active::before{content:"";position:absolute;left:-16px;top:8px;bottom:8px;width:3px;border-radius:0 3px 3px 0;background:var(--rjl-teal-2)}
kbd{font:600 11px 'DM Sans',system-ui,sans-serif;border:1px solid var(--rjl-line);border-bottom-width:2px;border-radius:5px;padding:1px 6px;background:#fff;color:var(--rjl-muted);white-space:nowrap}
.button.primary kbd{background:transparent;color:#fff;border-color:#ffffff66}
.palette-trigger{display:inline-flex;align-items:center;gap:8px;min-height:34px;padding:6px 8px 6px 12px;border:1px solid var(--rjl-line);border-radius:8px;background:var(--rjl-canvas);color:var(--rjl-muted);font-size:13px;cursor:pointer;transition:border-color var(--dur) var(--ease),background var(--dur)}
.palette-trigger:hover{border-color:var(--rjl-teal-2);background:#fff}
.palette-trigger span{font-size:16px;line-height:1}

/* ---- Toasts ---- */
#toast{left:auto;right:24px;bottom:24px;transform:translateY(12px);max-width:min(440px,calc(100vw - 32px));padding:14px 18px 14px 46px;border-radius:var(--radius);background:var(--rjl-navy);box-shadow:var(--shadow-3);line-height:1.5;transition:opacity var(--dur) var(--ease),transform var(--dur) var(--ease)}
#toast::before{content:"✓";position:absolute;left:16px;top:13px;width:20px;height:20px;border-radius:50%;background:var(--rjl-teal-2);color:#fff;display:grid;place-items:center;font-size:12px;font-weight:700}
#toast.visible{transform:none}
@media(max-width:650px){#toast{left:16px;right:16px;bottom:16px;max-width:none}}

/* ---- Skeleton and empty states ---- */
.pro-skeleton{display:grid;gap:14px;padding:6px 0}
.sk{border-radius:8px;background:linear-gradient(90deg,#E9EEF1 0%,#F4F7F8 50%,#E9EEF1 100%);background-size:200% 100%;animation:sk 1.3s ease-in-out infinite}
.sk-eyebrow{width:120px;height:12px}.sk-title{width:min(420px,80%);height:34px}.sk-line{width:min(620px,95%);height:14px}
.sk-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;margin-top:12px}.sk-card{height:140px;border-radius:var(--radius-lg)}
@keyframes sk{from{background-position:200% 0}to{background-position:-200% 0}}
.pro-empty{text-align:center;padding:44px 24px;display:grid;justify-items:center;gap:6px}
.pro-empty p{max-width:520px;color:var(--rjl-muted)}
.pro-empty .actions{justify-content:center;display:flex;gap:10px;flex-wrap:wrap}
.pro-empty-art{position:relative;width:132px;height:74px;margin-bottom:10px}
.pro-empty-art span{position:absolute;width:54px;height:30px;border-radius:8px;border:2px solid var(--rjl-teal-100);background:var(--rjl-teal-50)}
.pro-empty-art span:nth-child(1){left:0;top:0}.pro-empty-art span:nth-child(2){right:0;top:8px}.pro-empty-art span:nth-child(3){left:38px;bottom:0;border-color:var(--rjl-teal-2)}

/* ---- Tables ---- */
.pro-tall{max-height:min(72vh,760px);overflow:auto;border-radius:var(--radius)}
#main table thead th{position:sticky;top:0;z-index:2;background:#F8FAFB;box-shadow:inset 0 -1px 0 var(--rjl-line)}
#main table tbody tr{transition:background var(--dur)}
#main table tbody tr:hover{background:#F8FBFC}
.th-sort{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;font:inherit;font-weight:inherit;color:inherit;border-radius:4px}
.th-sort:focus-visible{outline:2px solid var(--rjl-teal-2);outline-offset:2px}
.th-arrow{width:0;height:0;border:4px solid transparent;border-top-color:#A7B3BD;margin-top:4px;opacity:.7}
th[aria-sort=ascending] .th-arrow{border-top-color:transparent;border-bottom-color:var(--rjl-teal);margin-top:-4px;opacity:1}
th[aria-sort=descending] .th-arrow{border-top-color:var(--rjl-teal);opacity:1}
.pro-filter-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:12px 16px;border-bottom:1px solid var(--rjl-line)}
.pro-filter input{min-height:36px;width:min(320px,100%);padding:8px 12px 8px 32px;border:1px solid var(--rjl-line);border-radius:8px;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2356616F' stroke-width='2'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='M9.5 9.5 13 13'/%3E%3C/svg%3E") no-repeat 11px center;font-size:13px;color:var(--rjl-ink)}
.pro-filter input:focus{border-color:var(--rjl-teal-2);outline:none;box-shadow:0 0 0 3px #167D8D33}
.pro-filter{display:block;max-width:100%}

/* ---- Command palette ---- */
.palette{padding:0;border:0;background:transparent;width:min(640px,calc(100vw - 32px));margin:12vh auto auto;max-height:none;overflow:visible}
.palette::backdrop{background:#0B1F3359;backdrop-filter:blur(2px)}
.palette-box{background:#fff;border:1px solid var(--rjl-line);border-radius:var(--radius-lg);box-shadow:var(--shadow-3);overflow:hidden;animation:pop var(--dur) var(--ease)}
@keyframes pop{from{opacity:0;transform:translateY(-6px) scale(.985)}to{opacity:1;transform:none}}
#palette-input{width:100%;border:0;border-bottom:1px solid var(--rjl-line);padding:18px 20px;font-size:16px;color:var(--rjl-ink);outline:none}
#palette-list{list-style:none;margin:0;padding:6px;max-height:min(52vh,420px);overflow:auto}
.palette-group{padding:10px 12px 4px;font-size:11px;letter-spacing:1.2px;text-transform:uppercase;color:var(--rjl-muted);font-weight:700}
.palette-item{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 12px;border-radius:8px;cursor:pointer;font-size:14px;color:var(--rjl-ink)}
.palette-item small{color:var(--rjl-muted);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:45%}
.palette-item.active,.palette-item:hover{background:var(--rjl-teal-50);color:var(--rjl-teal)}
.palette-item.active{box-shadow:inset 3px 0 0 var(--rjl-teal-2)}
.palette-none{padding:18px;color:var(--rjl-muted);text-align:center}
.palette-foot{display:flex;gap:16px;margin:0;padding:10px 16px;border-top:1px solid var(--rjl-line);background:var(--rjl-canvas);font-size:12px;color:var(--rjl-muted);flex-wrap:wrap}
.palette-foot kbd{margin-right:3px}

/* ---- Drop overlay ---- */
.drop-overlay{position:fixed;inset:0;z-index:90;display:grid;place-items:center;padding:16px;background:#0B1F33b3;backdrop-filter:blur(3px)}
.drop-overlay[hidden]{display:none}
.drop-card{width:min(520px,100%);background:#fff;border:2px dashed var(--rjl-teal-2);border-radius:18px;padding:30px;text-align:center;box-shadow:var(--shadow-3);pointer-events:none}
.drop-card ul{text-align:left;margin:14px auto;padding-left:20px;line-height:1.9;font-size:14px}
.drop-icon{width:56px;height:56px;margin:0 auto 10px;border-radius:50%;display:grid;place-items:center;background:var(--rjl-teal-50);color:var(--rjl-teal);font-size:28px}
.drop-note{font-size:12px;color:var(--rjl-muted);margin:0}

/* ---- Model canvas ---- */
.cv-shell{display:grid;gap:12px}
.cv-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:10px 18px;padding:10px 12px;background:#fff;border:1px solid var(--rjl-line);border-radius:var(--radius);box-shadow:var(--shadow-1)}
.cv-tool-group{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.cv-icon{min-width:34px;font-size:16px;padding:4px 8px}
.cv-zoom{min-width:48px;text-align:center;font-size:12px;color:var(--rjl-muted);font-variant-numeric:tabular-nums}
.cv-legend{margin-left:auto;display:flex;gap:14px;font-size:12px;color:var(--rjl-muted)}
.cv-leg::before{content:"";display:inline-block;width:22px;height:0;border-top:2px solid #6F8792;vertical-align:middle;margin-right:6px}
.cv-leg.proposed::before{border-top-style:dashed;border-color:#B47A2A}
.cv-body{display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:12px}
.cv-stage{position:relative;height:min(68vh,640px);min-height:380px;border:1px solid var(--rjl-line);border-radius:var(--radius-lg);overflow:hidden;background:#FBFCFD;box-shadow:var(--shadow-1)}
.cv-svg{display:block;width:100%;height:100%;touch-action:none;cursor:grab;user-select:none;-webkit-user-select:none}
.cv-svg.panning{cursor:grabbing}
.cv-dot{fill:#D5DEE3}
.cv-card{cursor:pointer;outline:none}
.cv-card-bg{fill:#fff;stroke:#C9D5DA;stroke-width:1.2;filter:drop-shadow(0 1px 2px #0B1F331a);transition:stroke var(--dur)}
.cv-card:hover .cv-card-bg{stroke:var(--rjl-teal-2)}
.cv-card:focus-visible .cv-card-bg{stroke:var(--rjl-teal-2);stroke-width:3}
.cv-card.selected .cv-card-bg{stroke:var(--rjl-teal);stroke-width:2.6;fill:#F2F8F9}
.cv-card.dragging{cursor:grabbing}.cv-card.dragging .cv-card-bg{filter:drop-shadow(0 10px 18px #0B1F3333)}
.cv-card.drop-target .cv-card-bg{stroke:var(--rjl-teal-2);stroke-width:3;stroke-dasharray:6 4;fill:var(--rjl-teal-50)}
.cv-card-title{font:600 13px 'DM Sans',system-ui,sans-serif;fill:var(--rjl-navy)}
.cv-card-meta{font:500 11px 'DM Sans',system-ui,sans-serif;fill:var(--rjl-muted)}
.cv-status{fill:#E2A33B}.cv-card.approved .cv-status{fill:#2F8A57}
.cv-handle{cursor:crosshair;opacity:0;transition:opacity var(--dur)}
.cv-handle circle{fill:var(--rjl-teal-2);stroke:#fff;stroke-width:2}.cv-handle path{stroke:#fff;stroke-width:2}
.cv-card:hover .cv-handle,.cv-card:focus-visible .cv-handle,.cv-card.selected .cv-handle{opacity:1}
@media (hover:none){.cv-handle{opacity:1}}
.cv-edge{cursor:pointer;outline:none}
.cv-hit{stroke:transparent;stroke-width:14}
.cv-line{stroke:#6F8792;stroke-width:1.8;fill:none}
.cv-edge.proposed .cv-line{stroke:#B47A2A;stroke-dasharray:6 5}
.cv-arrowhead{fill:#6F8792}
.cv-edge:hover .cv-line,.cv-edge:focus-visible .cv-line,.cv-edge.selected .cv-line{stroke:var(--rjl-teal);stroke-width:2.6}
.cv-edge-label-bg{fill:#fff;stroke:#DCE4E8}
.cv-edge.selected .cv-edge-label-bg,.cv-edge:focus-visible .cv-edge-label-bg{stroke:var(--rjl-teal-2);stroke-width:2}
.cv-edge-label{font:500 11px 'DM Sans',system-ui,sans-serif;fill:#3A4554}
.cv-ghost{stroke:var(--rjl-teal-2);stroke-width:2;stroke-dasharray:5 4;pointer-events:none}
.cv-minimap{position:absolute;right:12px;bottom:12px;width:180px;height:112px;background:#ffffffee;border:1px solid var(--rjl-line);border-radius:8px;box-shadow:var(--shadow-2);cursor:pointer}
.cv-minimap rect{fill:#B9CCD2}.cv-minimap rect.sel{fill:var(--rjl-teal)}
.cv-mini-view{fill:#167D8D14!important;stroke:var(--rjl-teal-2);stroke-width:1.5}
.cv-popover{position:absolute;z-index:5;width:300px;max-width:calc(100% - 16px);background:#fff;border:1px solid var(--rjl-line);border-radius:var(--radius);box-shadow:var(--shadow-3);padding:16px;animation:pop var(--dur) var(--ease)}
.cv-popover h3{margin:0 0 6px}.cv-popover .field{margin-bottom:10px}.cv-popover .muted{font-size:12px;margin:4px 0 8px}
.cv-popover .dialog-actions{display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap;margin-top:6px}
.cv-relate-ends{font-size:13px;margin-bottom:10px}
.cv-inspector{padding:18px;align-self:start;max-height:min(68vh,640px);overflow:auto}
.cv-inspector h2{font-size:17px}.cv-inspector p{font-size:13px}.cv-inspector .actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:12px}
.cv-rel-list{list-style:none;padding:0;margin:6px 0;display:grid;gap:6px;font-size:13px}
.cv-help{font-size:12px;margin:0}
@media(max-width:1000px){.cv-body{grid-template-columns:1fr}.cv-inspector{max-height:none}}
@media(max-width:650px){.cv-stage{height:62vh;min-height:320px}.cv-minimap{width:120px;height:75px}.cv-legend{margin-left:0}.cv-toolbar{gap:8px}}

/* ---- Review board ---- */
.board-tools{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin-bottom:14px}
.board-tools .muted{font-size:12px}
.board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;align-items:start}
.board-col{background:#F1F4F6;border:1px solid var(--rjl-line);border-radius:var(--radius-lg);padding:12px;min-height:220px;transition:background var(--dur),border-color var(--dur),box-shadow var(--dur)}
.board-col header{padding:4px 4px 10px;border-top:3px solid #9AA8B3;margin:-12px -12px 8px;padding:12px 16px 10px;border-radius:var(--radius-lg) var(--radius-lg) 0 0}
.board-review header{border-top-color:var(--rjl-teal-2)}.board-disputed header{border-top-color:#B54848}.board-approved header{border-top-color:#2F8A57}.board-draft header{border-top-color:#C08A3A}
.board-col h2{display:flex;align-items:center;justify-content:space-between;font-size:15px;margin:0 0 4px}
.board-col header p{font-size:12px;color:var(--rjl-muted);margin:0;line-height:1.45}
.board-count{font-size:12px;font-weight:700;background:#fff;border:1px solid var(--rjl-line);border-radius:999px;padding:1px 9px;color:var(--rjl-ink)}
.board-list{list-style:none;margin:0;padding:0;display:grid;gap:10px;min-height:60px}
.board-card{background:#fff;border:1px solid var(--rjl-line);border-radius:var(--radius);padding:12px 12px 10px;box-shadow:var(--shadow-1);cursor:grab;transition:box-shadow var(--dur),transform var(--dur),opacity var(--dur)}
.board-card:hover{box-shadow:var(--shadow-2)}
.board-card.dragging{opacity:.45;transform:rotate(1deg)}
.board-card.just-moved{animation:flash 1s var(--ease)}
@keyframes flash{0%{box-shadow:0 0 0 3px var(--rjl-teal-2)}100%{box-shadow:var(--shadow-1)}}
.board-card-top{display:flex;justify-content:space-between;gap:8px;align-items:flex-start}
.board-card-top strong{font-size:14px;color:var(--rjl-navy);overflow-wrap:anywhere}
.board-card p{font-size:13px;margin:6px 0;line-height:1.5;color:#3A4554}
.board-src,.board-meta{display:block;font-size:12px;color:var(--rjl-muted);margin-top:2px}
.board-meta{color:var(--rjl-teal)}.board-disputed .board-meta{color:var(--rjl-red)}
.board-note{margin:8px 0 0;padding:8px 10px;border-left:3px solid #B54848;background:var(--rjl-red-50);font-size:12px;border-radius:0 6px 6px 0;color:#5A1F1F}
.board-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
.board-actions .button{min-height:30px;font-size:12px;padding:5px 10px}
.board-empty{border:2px dashed #CBD5DB;border-radius:var(--radius);padding:18px;text-align:center;font-size:12px;color:var(--rjl-muted)}
.board.is-dragging .board-col{border-style:dashed}
.board-col.drop-ok{background:var(--rjl-teal-50);border-color:var(--rjl-teal-2);box-shadow:0 0 0 3px #167D8D26}
.board-col.drop-no{background:var(--rjl-red-50);border-color:#B54848}

@media(max-width:1150px){.board{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:650px){.board{grid-template-columns:1fr}.board-col{min-height:0}.palette-trigger{display:none}}
.cv-popover .field-help{display:none}
.cv-popover{max-height:calc(100% - 16px);overflow:auto}
@media(min-width:1151px){.board-list{max-height:min(70vh,820px);overflow:auto;padding:2px;margin:-2px}}
.board-actions .button.quiet{border-color:var(--rjl-line)}
.cv-popover .error:empty{display:none}
/* Existing connection table hid its From heading while showing the From cells; realign on wide screens. */
@media(min-width:701px){.rel-table thead th:first-child{display:table-cell}}
/* ---- Touch and pen dragging on the review board (pointer-drag.js) ---- */
.board-card{-webkit-touch-callout:none}
@media (pointer:coarse){.board-card{-webkit-user-select:none;user-select:none}}
.board.touch-dragging .board-card{-webkit-user-select:none;user-select:none}
.board.touch-dragging{touch-action:none}
.board-card[data-lifted]{outline:2px dashed var(--rjl-teal-2);outline-offset:2px;opacity:.55}
.pdrag-ghost{position:fixed;left:0;top:0;z-index:90;pointer-events:none}
.pdrag-ghost span{display:block;max-width:min(320px,80vw);margin:-64px 0 0 -40px;padding:12px 16px;border:1px solid var(--rjl-teal-2);border-radius:var(--radius);background:var(--rjl-surface);color:var(--rjl-ink);font-weight:700;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;box-shadow:var(--shadow-3);transform:rotate(-1.5deg) scale(1.03);animation:pdrag-lift var(--dur) var(--ease)}
@keyframes pdrag-lift{from{transform:none;box-shadow:var(--shadow-1)}}
@media (prefers-reduced-motion:reduce){.pdrag-ghost span{animation:none;transform:none}}
.pro-theme-toggle[aria-pressed="true"]{border-color:var(--rjl-teal-2)}
.board-tools .pro-theme-toggle{margin-left:auto}
.pro-theme-toggle svg{vertical-align:-2px;margin-right:2px}
