/* =========================================================================
   OrgFlow Studio — estilos
   ========================================================================= */
:root {
  --bg: #f4f6fa;
  --canvas: #f7f9fc;
  --panel: #ffffff;
  --line: #e3e8ef;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --soft: #f1f5f9;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --accent-ink: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .18);
  --font: 'Segoe UI', 'Inter', Roboto, Helvetica, Arial, sans-serif;
  --top: 54px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ic { display: block; flex-shrink: 0; }
kbd { display: inline-block; padding: 0 6px; min-width: 20px; text-align: center; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: #fff; font-size: 11.5px; font-family: inherit; line-height: 18px; color: #334155; margin: 0 1px; }

/* ---------- Barra superior ---------- */
#topbar { height: var(--top); display: flex; align-items: center; gap: 10px; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; padding-right: 6px; }
.brand-name { font-size: 16px; letter-spacing: -.01em; }
.brand-name b { color: var(--accent); }
body[data-mode] .brand-name { display: none; }
.tb-doc { display: flex; align-items: center; gap: 6px; min-width: 0; }
.doc-title { border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 5px 8px; font-weight: 600; font-size: 15px; width: 260px; min-width: 120px; }
.doc-title:hover { border-color: var(--line); }
.doc-title:focus { outline: none; border-color: var(--accent); background: #fff; }
.save-state { font-size: 12px; color: var(--success); white-space: nowrap; }
.save-state.busy { color: var(--muted); }
.tb-tools { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 0 6px; border-left: 1px solid var(--line); }
.tb-right { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; flex-shrink: 0; }
.tb-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 0; background: transparent; border-radius: 7px; cursor: pointer; color: #334155; white-space: nowrap; font-size: 13px; }
.tb-btn.icon-only { padding: 0 8px; }
.tb-btn:hover:not(:disabled) { background: var(--soft); color: var(--text); }
.tb-btn.on { background: var(--accent-soft); color: var(--accent-ink); }
.tb-btn:disabled { opacity: .35; cursor: default; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 0; background: transparent; border-radius: 7px; cursor: pointer; color: #334155; flex-shrink: 0; }
.icon-btn:hover:not(:disabled) { background: var(--soft); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.sm { width: 26px; height: 26px; }
.zoom-label { border: 0; background: transparent; min-width: 52px; height: 30px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: #334155; font-variant-numeric: tabular-nums; }
.zoom-label:hover { background: var(--soft); }

/* ---------- Botões e campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { border-color: transparent; }
.btn.small { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.full { grid-column: 1 / -1; }
#btnExport { margin-left: 6px; height: 34px; }
input:not([type=checkbox]):not([type=color]):not([type=file]), select, textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 9px; background: #fff; font-size: 13.5px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
textarea { resize: vertical; min-height: 38px; }
textarea.mono { font-family: Consolas, 'Cascadia Mono', monospace; font-size: 12.5px; margin: 10px 0; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; gap: 12px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.mt { margin-top: 18px; }

/* ---------- Repositório (área de trabalho) ---------- */
#home { display: grid; grid-template-columns: 250px 1fr; height: calc(100vh - var(--top)); }
.ws-side { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; gap: 4px; }
.new-btn { width: 100%; height: 40px; margin-bottom: 10px; justify-content: flex-start; padding: 0 16px; font-size: 14.5px; border-radius: 10px; box-shadow: 0 2px 8px rgba(37, 99, 235, .25); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: #334155; font-size: 13.5px; user-select: none; min-height: 34px; }
.nav-item:hover { background: var(--soft); }
a.nav-item { text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item small { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.nav-item.drop { background: #dcfce7; outline: 2px dashed var(--success); }
.nav-item .icon-btn.xs { opacity: 0; }
.nav-item:hover .icon-btn.xs, .nav-item.active .icon-btn.xs { opacity: 1; }
.nav-ic { display: flex; color: inherit; flex-shrink: 0; }
.nav-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.icon-btn.xs { width: 24px; height: 24px; border-radius: 6px; }
.twisty { display: flex; width: 14px; justify-content: center; color: var(--muted); transition: transform .15s; margin-right: -4px; }
.twisty.open { transform: rotate(90deg); }
.twisty.none { visibility: hidden; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.empty-hint.small { font-size: 12px; padding: 4px 10px 8px; }
.side-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
.backup-chip { display: flex; align-items: center; gap: 8px; margin: 8px 4px 0; padding: 7px 10px; border-radius: 8px; font-size: 12px; cursor: pointer; background: var(--soft); color: #475569; }
.backup-chip .dot { width: 8px; height: 8px; }
.backup-chip.ok .dot { background: var(--success); }
.backup-chip.warn { background: #fffbeb; color: #92400e; }
.backup-chip.warn .dot { background: var(--warn); }
.backup-chip.err { background: #fef2f2; color: #991b1b; }
.backup-chip.err .dot { background: var(--danger); }
.ws-main { overflow-y: auto; padding: 22px 32px 48px; min-width: 0; }
.ws-main h2 { font-size: 15px; margin: 26px 0 12px; }
.ws-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.ws-head h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); cursor: pointer; font-size: 15px; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { color: var(--line-strong); }
.ws-tools { display: flex; align-items: center; gap: 10px; margin: 16px 0 18px; flex-wrap: wrap; }
.ws-tools .search-box { min-width: 260px; }
.seg.icons button { display: flex; align-items: center; justify-content: center; padding: 5px 9px; }
.sort-sel { width: auto !important; }
.result-count { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.link { color: var(--accent); cursor: pointer; font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 18px; }
.kpi { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; transition: border-color .15s; }
.kpi:hover { border-color: #93c5fd; }
.kpi b { font-size: 22px; display: block; line-height: 1.1; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.attention { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.att-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13.5px; }
.att-row:last-child { border-bottom: 0; }
.att-row:hover { background: var(--soft); }
.att-row small { color: var(--muted); }
.att-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.att-badge.vencida { background: #fee2e2; color: #b91c1c; }
.att-badge.proxima { background: #fef3c7; color: #b45309; }
.att-badge.revisao { background: #dbeafe; color: #1d4ed8; }
.sub-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 18px; }
.folder-card { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.folder-card:hover { border-color: #fcd34d; background: #fffbeb; }
.folder-card b { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-card small { color: var(--muted); }
.start-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.start-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: left; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
.start-card:hover { transform: translateY(-2px); border-color: #93c5fd; box-shadow: 0 8px 28px rgba(37, 99, 235, .16); }
.start-card b { font-size: 14px; margin-top: 8px; }
.start-card span { font-size: 12.5px; color: var(--muted); }
.sc-art { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: var(--soft); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sc-art svg { width: 88%; height: auto; }
.org-art { background: linear-gradient(160deg, #eff6ff, #dbeafe); }
.flow-art { background: linear-gradient(160deg, #f0fdf4, #fefce8); }
.pop-art { background: linear-gradient(160deg, #f5f3ff, #ede9fe); }
.import-art { background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 8px, #f1f5f9 8px, #f1f5f9 16px); color: var(--muted); }
.import-art .ic { width: 34px; height: 34px; }
.tpl-tag { position: absolute; top: 6px; left: 6px; font-size: 10.5px !important; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-ink) !important; background: #fff; border-radius: 4px; padding: 1px 6px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box .ic { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 34px !important; }
.search-box.small { width: 260px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.doc-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; overflow: hidden; transition: box-shadow .15s, border-color .15s; display: flex; flex-direction: column; }
.doc-card:hover { border-color: #93c5fd; box-shadow: var(--shadow); }
.doc-thumb { position: relative; height: 140px; background: var(--canvas); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; padding: 10px; }
.fav { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, .9); color: #94a3b8; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; }
.doc-card:hover .fav, .fav.on { opacity: 1; }
.fav.on, .fav-inline.on { color: #f59e0b; }
.fav.on svg, .fav-inline.on svg { fill: #fbbf24; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.status-badge { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; border: 1px solid; background: #fff; }
.snippet { font-size: 12px; color: #475569; background: #fefce8; border-radius: 4px; padding: 3px 6px; margin: 3px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 13.5px; }
.doc-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f8fafc; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.doc-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.doc-table tr:last-child td { border-bottom: 0; }
.doc-table tbody tr { cursor: pointer; }
.doc-table tbody tr:hover { background: #f8fafc; }
.cell-title { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.cell-title b { color: var(--text); }
.nowrap { white-space: nowrap; }
.fatal { max-width: 560px; margin: 80px auto; padding: 24px; background: #fff; border-radius: 12px; border: 1px solid #fecaca; }
.doc-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.thumb-ph { color: var(--line-strong); }
.doc-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.doc-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-info small { color: var(--muted); font-size: 12px; }
.doc-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.type-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 4px; }
.type-badge.org { background: #eff6ff; color: #1d4ed8; }
.type-badge.flow { background: #ecfdf5; color: #047857; }
.type-badge.pop { background: #f5f3ff; color: #6d28d9; }
.empty-docs { grid-column: 1 / -1; padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 12px; background: #fff; }
.footnote { color: var(--muted); font-size: 12.5px; margin-top: 18px; }

/* ---------- Editor ---------- */
#editor { --lw: 250px; --rw: 290px; display: grid; grid-template-columns: var(--lw) 1fr var(--rw); height: calc(100vh - var(--top)); transition: grid-template-columns .2s ease; }
#editor.left-collapsed { --lw: 0px; }
#editor.right-collapsed { --rw: 0px; }
#editor.left-collapsed .panel.left, #editor.right-collapsed .panel.right { visibility: hidden; border: 0; }
.panel { background: var(--panel); overflow-y: auto; min-height: 0; min-width: 0; }
.panel-toggle { position: absolute; top: 10px; z-index: 4; width: 26px; height: 30px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: #fff; color: #475569; cursor: pointer; box-shadow: var(--shadow); }
.panel-toggle:hover { color: var(--accent); border-color: #93c5fd; }
.panel-toggle.left { left: 0; border-left: 0; border-radius: 0 7px 7px 0; }
.panel-toggle.right { right: 0; border-right: 0; border-radius: 7px 0 0 7px; }
#editor.left-collapsed .panel-toggle.left .ic, #editor:not(.right-collapsed) .panel-toggle.right .ic { transform: rotate(180deg); }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); }
.panel-section { padding: 14px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.panel-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.panel-title.pad { padding: 12px 14px 6px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.field-label { font-size: 12px; font-weight: 600; color: #475569; }
.hint { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.meta { font-size: 12px; color: var(--muted); background: var(--soft); border-radius: 6px; padding: 6px 8px; }
.combo { position: relative; display: flex; }
.combo input { padding-right: 36px !important; }
.combo-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 30px; height: 28px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.combo-btn:hover { background: var(--soft); color: var(--text); }
.popup-ico .dot { width: 10px; height: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg { display: flex; background: var(--soft); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 6px; padding: 5px 6px; cursor: pointer; font-size: 12.5px; color: #475569; }
.seg button.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.sw { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(15, 23, 42, .15); cursor: pointer; padding: 0; }
.sw.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.sw.auto { background: repeating-linear-gradient(45deg, #fff, #fff 3px, #e2e8f0 3px, #e2e8f0 6px); font-size: 10px; font-weight: 700; color: #475569; }
.sw-custom { width: 26px; height: 24px; border: 0; padding: 0; background: none; cursor: pointer; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--soft); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.stat b { font-size: 20px; line-height: 1.1; }
.stat span { font-size: 11.5px; color: var(--muted); }
.dept-list { display: flex; flex-direction: column; gap: 6px; }
.dept-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 4px 8px; align-items: center; font-size: 13px; }
.dept-row .bar { grid-column: 2 / -1; height: 4px; border-radius: 2px; background: var(--accent); opacity: .25; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tips { margin: 0; padding-left: 18px; color: #475569; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.empty-hint { padding: 12px 14px; color: var(--muted); font-size: 13px; }
.lane-list { display: flex; flex-direction: column; gap: 6px; }
.lane-row { display: flex; gap: 4px; align-items: center; }
.lane-row input.num { width: 64px; flex-shrink: 0; }

/* Estrutura (outline) */
.outline { padding: 2px 6px 16px; }
.ol-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.ol-item:hover { background: var(--soft); }
.ol-item.active { background: var(--accent-soft); }
.ol-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ol-head { display: flex; align-items: center; gap: 2px; padding-right: 8px; }
.ol-item .twisty { margin-right: -2px; padding: 4px 0; border-radius: 4px; cursor: pointer; flex-shrink: 0; }
.ol-item .twisty:hover { color: var(--accent); background: #e2e8f0; }
.ol-count { font-size: 11px; font-weight: 600; color: #475569; background: #e2e8f0; border-radius: 999px; padding: 0 7px; flex-shrink: 0; }
.ol-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ol-item small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Paleta */
.palette { padding: 0 10px 20px; }
.pal-title { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 14px 4px 6px; }
.pal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.pal-grid.wide { grid-template-columns: 1fr; }
.pal-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 5px; border-radius: 8px; border: 1px solid transparent; cursor: grab; user-select: none; text-align: center; }
.pal-item:hover { background: var(--soft); border-color: var(--line); }
.pal-item:active { cursor: grabbing; }
.pal-item span { font-size: 10.5px; line-height: 1.2; color: #475569; }
.pal-svg { overflow: visible; }

/* Canvas */
#canvasWrap { position: relative; overflow: hidden; background: var(--canvas); min-width: 0; }
.canvas { display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.canvas.panning, .canvas.space { cursor: grab; }
.canvas.panning { cursor: grabbing; }
#statusbar { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, .88); border: 1px solid var(--line); padding: 4px 10px; border-radius: 6px; pointer-events: none; max-width: calc(100% - 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Organograma */
.org-node { cursor: pointer; }
.org-node:hover .card { stroke: #93c5fd; }
.org-node.selected .card { stroke: var(--accent); stroke-width: 2.5; }
.org-node.match .card { stroke: #f59e0b; stroke-width: 2.5; }
.org-node.dim { opacity: .3; }
.org-node.dragging { opacity: .85; pointer-events: none; }
.org-node.drop-target .card { stroke: var(--success); stroke-width: 3; fill: #f0fdf4; }
.org-toggle { cursor: pointer; }
.org-toggle:hover rect { filter: brightness(.95); }

/* Fluxograma */
.shape { cursor: move; }
.shape .port { fill: #fff; stroke: var(--accent); stroke-width: 1.5; opacity: 0; cursor: crosshair; transition: opacity .12s; }
.shape:hover .port { opacity: 1; }
.shape .port:hover { fill: var(--accent); }
.shape.k-pool { cursor: default; }
.shape.k-pool .ports { display: none; }
.pool-hdr, .lane-hdr { cursor: move; }
.lane-border { cursor: ns-resize; }
.text-box { stroke: transparent; }
.shape.k-text:hover .text-box { stroke: #cbd5e1; stroke-dasharray: 3 3; }
.canvas.readonly .ports { display: none; }
.canvas.readonly .shape { cursor: pointer; }
.edge { cursor: pointer; }
.edge-hit { pointer-events: stroke; }
.edge:hover .edge-main { stroke: var(--accent); }
.ui-layer * { pointer-events: none; }
.ui-layer [data-handle], .ui-layer [data-quick], .ui-layer [data-quick] * { pointer-events: all; }
.handle { cursor: nwse-resize; }
.h-n, .h-s { cursor: ns-resize; } .h-e, .h-w { cursor: ew-resize; } .h-ne, .h-sw { cursor: nesw-resize; }
.quick { cursor: pointer; }
.quick:hover rect { stroke: var(--accent); fill: var(--accent-soft); }
.inline-editor { position: absolute; z-index: 5; border: 2px solid var(--accent) !important; border-radius: 6px !important; background: rgba(255, 255, 255, .97) !important; padding: 4px 6px !important; resize: none; line-height: 1.28; text-align: center; box-shadow: var(--shadow) !important; min-height: 0 !important; overflow: hidden; }

/* ---------- Popups, modais, toasts ---------- */
.popup-menu { position: fixed; z-index: 100; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; min-width: 200px; animation: pop .12s ease-out; }
.popup-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 6px 10px 4px; }
.popup-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; cursor: pointer; text-align: left; font-size: 13px; }
.popup-item:hover { background: var(--soft); }
.popup-ico { width: 30px; display: flex; justify-content: center; color: #475569; }
.popup-ico svg.pal-svg { width: 30px; height: 22px; }
.popup-sep { height: 1px; background: var(--line); margin: 4px 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.modal-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .15s ease-out; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 20px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 6px 20px 12px; overflow-y: auto; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.issues { display: flex; flex-direction: column; gap: 6px; }
.issue { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: var(--soft); font-size: 13.5px; }
.issue.link { cursor: pointer; }
.issue.link:hover { background: #e2e8f0; }
.issue .badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; margin-top: 1px; }
.issue.error .badge { background: #fee2e2; color: #b91c1c; }
.issue.warn .badge { background: #fef3c7; color: #b45309; }
.issue.info .badge { background: #dbeafe; color: #1d4ed8; }
.success-box { display: flex; gap: 14px; align-items: center; padding: 18px; border-radius: 10px; background: #f0fdf4; color: #166534; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.help-cols h4 { margin: 4px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.keys { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 14px; }
.keys td { padding: 4px 0; border-bottom: 1px solid var(--soft); }
.keys td:first-child { white-space: nowrap; padding-right: 12px; width: 1%; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #0f172a; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13.5px; box-shadow: var(--shadow-lg); animation: pop .15s ease-out; transition: opacity .3s, transform .3s; max-width: 560px; }
.toast.success { background: #166534; }
.toast.error { background: #b91c1c; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- Barra superior: identificação do documento ---------- */
.doc-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.doc-id .doc-title { padding: 2px 8px; }
.folder-chip { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--muted); font-size: 11.5px; padding: 1px 8px; cursor: pointer; border-radius: 4px; align-self: flex-start; max-width: 260px; }
.folder-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-chip:hover { background: var(--soft); color: var(--text); }
.tb-seg { flex-shrink: 0; }
.tb-seg button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; }

/* ---------- Editor de POP ---------- */
.pop-scroll { position: absolute; inset: 0; overflow-y: auto; padding: 28px 24px 80px; background: #e8ecf2; }
.pop-scroll.viewing { padding: 0; overflow: hidden; }
.pop-scroll.viewing .paper { max-width: none; height: 100%; padding: 0; margin: 0; box-shadow: none; background: transparent; }
.pop-frame { width: 100%; height: 100%; border: 0; display: block; }
.paper { max-width: 820px; margin: 0 auto; background: #fff; padding: 34px 44px 44px; box-shadow: 0 2px 16px rgba(15, 23, 42, .12); border-radius: 4px; }
.pop-head { display: grid; grid-template-columns: 96px 1fr 150px; border: 1px solid #64748b; }
.pop-head > div { padding: 10px 12px; }
.ph-logo { display: flex; align-items: center; justify-content: center; border-right: 1px solid #64748b; }
.ph-logo img { max-width: 76px; max-height: 60px; }
.logo-ph { width: 52px; height: 52px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; font-size: 19px; display: flex; align-items: center; justify-content: center; }
.ph-company { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #475569; }
.ph-company a { color: var(--accent); text-transform: none; letter-spacing: 0; }
.ph-kind { font-size: 10.5px; color: var(--muted); }
.pop-title-in { border: 1px dashed transparent !important; padding: 2px 4px !important; margin-left: -5px; font-size: 19px !important; font-weight: 700; resize: none; overflow: hidden; line-height: 1.25; box-shadow: none !important; }
.pop-title-in:hover { border-color: var(--line-strong) !important; }
.pop-title-in:focus { border-color: var(--accent) !important; }
.ph-meta { border-left: 1px solid #64748b; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; font-size: 12.5px; }
.ph-meta b { font-size: 15px; }
.status-pill { color: #fff; font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; margin-top: 2px; }
.pop-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 12px; border: 1px solid #64748b; border-top: 0; font-size: 12px; color: #475569; margin-bottom: 22px; }
.pop-meta .vencida b { color: var(--danger); }
.pop-meta .proxima b { color: var(--warn); }
.pop-sec { margin-bottom: 22px; scroll-margin-top: 16px; }
.pop-sec h2 { font-size: 13.5px; text-transform: uppercase; letter-spacing: .03em; color: #1e3a8a; margin: 0 0 8px; padding-bottom: 4px; border-bottom: 1.5px solid #cbd5e1; }
.paper textarea, .paper input:not([type=checkbox]) { border-color: #e2e8f0; background: #fcfdfe; }
.paper textarea { resize: none; overflow: hidden; min-height: 40px; line-height: 1.5; }
.pop-text { min-height: 56px !important; }
.resp-row { display: grid; grid-template-columns: 220px 1fr 26px; gap: 8px; align-items: start; margin-bottom: 8px; }
.add-btn { color: var(--accent); margin-top: 2px; }
.step-card { display: grid; grid-template-columns: 34px 1fr 30px; gap: 10px; padding: 12px; border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 10px; background: #fff; }
.step-card:focus-within { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37, 99, 235, .08); }
.step-num { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.step-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.step-top { display: grid; grid-template-columns: 1fr 200px; gap: 6px; }
.step-title { font-weight: 600; }
.step-note { background: #fffbeb !important; border-color: #fde68a !important; font-size: 12.5px !important; min-height: 32px !important; }
.step-tools { display: flex; flex-direction: column; gap: 2px; opacity: .35; transition: opacity .15s; }
.step-card:hover .step-tools, .step-card:focus-within .step-tools { opacity: 1; }
.flow-link select { flex: 1; }
.flow-prev { margin-top: 10px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px; text-align: center; background: #fff; }
.flow-prev svg { max-width: 100%; height: auto; }
.rev-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rev-table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 4px; }
.rev-table td { padding: 3px 4px; }
.rev-table td:nth-child(1) { width: 64px; } .rev-table td:nth-child(2) { width: 150px; } .rev-table td:nth-child(4) { width: 170px; } .rev-table td:nth-child(5) { width: 30px; }
.cell { padding: 5px 7px !important; font-size: 13px !important; }
.ol-check { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-strong); font-size: 10.5px; display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; }
.ol-check.ok { background: var(--success); border-color: var(--success); color: #fff; }
.pop-outline .ol-item { padding: 7px 10px; }
.status-sel { font-weight: 600; }
.meta.vencida { background: #fef2f2; color: #b91c1c; }
.meta.proxima { background: #fffbeb; color: #92400e; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- Histórico, mover, configurações ---------- */
.hist-top { align-items: flex-start; margin-bottom: 10px; }
.hist-top p { margin: 0; font-size: 13px; }
.versions { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; }
.ver { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }
.ver.auto { background: #fafbfc; }
.ver small { display: block; color: var(--muted); font-size: 12px; }
.ver-ic { color: var(--accent); display: flex; }
.ver.auto .ver-ic { color: var(--muted); }
.move-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 4px; }
.move-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: #334155; }
.move-item span { display: flex; color: #f59e0b; }
.move-item:hover { background: var(--soft); }
.move-item.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.settings h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.settings h4:first-child { margin-top: 4px; }
.settings p { font-size: 13px; }
.settings .row.top { align-items: flex-start; }
.settings .col { display: flex; flex-direction: column; gap: 8px; }
.logo-box { width: 96px; height: 76px; border: 1px dashed var(--line-strong); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-box img { max-width: 84px; max-height: 64px; }
.settings .meta { margin-bottom: 8px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  #editor { --lw: 210px; --rw: 250px; }
  .tb-btn span { display: none; }
  .doc-title { width: 170px; }
}
@media (max-width: 800px) {
  #editor { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .panel-toggle { display: none; }
  .panel.left { display: none; }
  .panel.right { max-height: 34vh; border-left: 0; border-top: 1px solid var(--line); }
  #home { grid-template-columns: 1fr; }
  .ws-side { display: none; }
  .ws-main { padding: 16px; }
  .resp-row, .step-top { grid-template-columns: 1fr; }
  .paper { padding: 20px; }
  .save-state, .tb-right .tb-sep, #btnHelp { display: none; }
}
.popup-item:disabled { opacity: .45; cursor: not-allowed; background: transparent; }
.canvas:focus { outline: none; }
.canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* report indireto (linha pontilhada) */
.dotted-link { pointer-events: stroke; }
.org-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 2px 0; }
.org-legend span { display: inline-flex; align-items: center; gap: 6px; }
.org-legend i { display: inline-block; width: 26px; border-top: 2px solid #94a3b8; }
.org-legend i.lg-dotted { border-top: 2px dashed #2563eb; }
.dotted-chip { display: inline-flex; align-items: center; gap: 4px; border-style: dashed !important; }
.chip-x { border: 0; background: transparent; padding: 0; cursor: pointer; color: var(--muted); display: inline-flex; }
.chip-x:hover { color: #dc2626; }
.gap-sm { gap: 6px; }
/* atribuições do cartão */
.duty-btn { cursor: pointer; }
.duty-btn:hover circle { fill: var(--accent-soft); }
.duty-tip { position: fixed; z-index: 60; width: max-content; max-width: 360px; max-height: 60vh; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 12px 14px; font-size: 13px; line-height: 1.45; color: var(--text); pointer-events: none; }
.duty-tip.pinned { pointer-events: auto; border-color: #bfdbfe; }
.duty-head { display: flex; align-items: flex-start; gap: 8px; justify-content: space-between; }
.duty-head b { display: block; font-size: 13.5px; }
.duty-head small { color: var(--muted); font-size: 12px; }
.duty-title { margin: 10px 0 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.duty-list { margin: 4px 0 0; padding-left: 18px; }
.duty-list li { margin: 2px 0; }
.duty-text { margin: 4px 0 0; white-space: pre-wrap; }
.legend-row { display: flex; align-items: center; gap: 6px; }
.member-row { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
