#fc-root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}
#fc-root * { box-sizing: border-box; }
#fc-root, #fc-root { margin: 0; height: 100%; }
#fc-root { display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
#fc-root [hidden] { display: none !important; }
#fc-root button, #fc-root .btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}
#fc-root button:hover:not(:disabled), #fc-root .btn:hover { background: #f1f5f9; }
#fc-root button:disabled { opacity: 0.4; cursor: default; }
#fc-root button.primary, #fc-root .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
#fc-root button.primary:hover, #fc-root .btn.primary:hover { background: #1d4ed8; }
#fc-root button.danger { color: var(--danger); }
#fc-root button.danger:hover { background: #fef2f2; }
#fc-root input[type='text'], #fc-root input[type='number'], #fc-root input[type='search'], #fc-root select, #fc-root textarea {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}
#fc-root input:focus, #fc-root select:focus, #fc-root textarea:focus { outline: 2px solid #93c5fd; outline-offset: 0; border-color: var(--accent); }
#fc-root .muted { color: var(--muted); }
#fc-root .spacer { flex: 1; }
#fc-root .app-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px;
  height: 48px;
  background: #0f172a;
  color: #fff;
  flex-shrink: 0;
}
#fc-root .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
#fc-root .tabs { display: flex; gap: 4px; height: 100%; }
#fc-root .tabs button {
  background: none;
  border: none;
  border-radius: 0;
  color: #94a3b8;
  border-bottom: 3px solid transparent;
  padding: 0 14px;
  height: 100%;
  font-weight: 600;
}
#fc-root .tabs button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
#fc-root .tabs button.active { color: #fff; border-bottom-color: #60a5fa; }
#fc-root .view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#fc-root .topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#fc-root #doc-name { width: 240px; font-weight: 600; border-color: transparent; background: transparent; }
#fc-root #doc-name:hover { border-color: var(--border-strong); }
#fc-root #save-status { color: var(--muted); font-size: 12px; min-width: 100px; }
#fc-root #save-status.dirty { color: #b45309; }
#fc-root .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
#fc-root .workspace { flex: 1; display: flex; min-height: 0; }
#fc-root .palette {
  width: 196px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px;
}
#fc-root .palette h4 { margin: 14px 2px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
#fc-root .tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#fc-root .tools button { flex-direction: column; gap: 3px; padding: 8px 4px; font-size: 12px; }
#fc-root .tools button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
#fc-root .shape-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#fc-root .shape-tile {
  flex-direction: column;
  gap: 2px;
  padding: 6px 2px;
  font-size: 11px;
  color: #334155;
  cursor: grab;
  border-color: var(--border);
}
#fc-root .shape-tile span { white-space: normal; text-align: center; }
#fc-root .shape-tile:hover { border-color: var(--accent); background: var(--accent-soft); }
#fc-root .canvas-wrap { flex: 1; position: relative; overflow: hidden; background: #f8fafc; }
#fc-root #canvas { width: 100%; height: 100%; display: block; outline: none; touch-action: none; user-select: none; cursor: default; }
#fc-root #canvas[data-tool='pan'], #fc-root #canvas.grab { cursor: grab; }
#fc-root #canvas.grabbing { cursor: grabbing; }
#fc-root #canvas[data-tool='arrow'], #fc-root #canvas[data-tool='place'] { cursor: crosshair; }
#fc-root #canvas[data-tool='text'] { cursor: text; }
#fc-root #canvas .node { cursor: move; }
#fc-root #canvas .edge { cursor: pointer; }
#fc-root #canvas .port { cursor: crosshair; }
#fc-root #canvas .edge-end { cursor: grab; }
#fc-root #canvas .handle-nw, #fc-root #canvas .handle-se { cursor: nwse-resize; }
#fc-root #canvas .handle-ne, #fc-root #canvas .handle-sw { cursor: nesw-resize; }
#fc-root #canvas .handle-n, #fc-root #canvas .handle-s { cursor: ns-resize; }
#fc-root #canvas .handle-e, #fc-root #canvas .handle-w { cursor: ew-resize; }
#fc-root #canvas[data-tool='arrow'] .node { cursor: crosshair; }
#fc-root #text-editor {
  position: absolute;
  z-index: 5;
  resize: none;
  overflow: hidden;
  padding: 2px 4px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.95);
  font-family: Helvetica, Arial, sans-serif;
  box-shadow: var(--shadow);
  min-height: 24px;
}
#fc-root .zoombar {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  box-shadow: var(--shadow);
}
#fc-root .zoombar button { border: none; padding: 4px 10px; }
#fc-root #zoom-label { min-width: 56px; justify-content: center; font-variant-numeric: tabular-nums; }
#fc-root .panel {
  width: 272px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
#fc-root .panel section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
#fc-root .panel h3 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
#fc-root .panel .row { display: flex; align-items: center; gap: 8px; margin: 7px 0; min-height: 28px; }
#fc-root .panel .row > span:first-child { flex: 1; color: #334155; }
#fc-root .panel .col { display: flex; flex-direction: column; gap: 4px; margin: 7px 0; }
#fc-root .panel .col span { color: #334155; }
#fc-root .panel textarea { resize: vertical; font-family: inherit; }
#fc-root .panel select { max-width: 150px; }
#fc-root .panel input[type='number'] { width: 70px; }
#fc-root .panel input[type='range'] { width: 100px; }
#fc-root .panel output { width: 26px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
#fc-root .panel input[type='color'] { width: 38px; height: 28px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 6px; background: #fff; }
#fc-root .panel input[type='color']:disabled { opacity: 0.3; }
#fc-root .check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
#fc-root .btns { display: flex; gap: 4px; }
#fc-root .btns.wrap { flex-wrap: wrap; }
#fc-root .btns button { padding: 5px 9px; }
#fc-root .btns button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
#fc-root .swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0; }
#fc-root .swatch { height: 24px; padding: 0; border-width: 2px; border-radius: 6px; }
#fc-root .swatch:hover { transform: scale(1.1); }
#fc-root .grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#fc-root .grid4 label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
#fc-root .grid4 input { width: 100%; }
#fc-root .help ul { margin: 0; padding-left: 16px; color: #475569; font-size: 12.5px; line-height: 1.5; }
#fc-root .help li { margin-bottom: 4px; }
#fc-root .library { overflow-y: auto; padding: 24px 32px; }
#fc-root .lib-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
#fc-root .lib-head h2 { margin: 0 0 4px; }
#fc-root .lib-head p { margin: 0; }
#fc-root #lib-search { width: 240px; }
#fc-root .dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  margin-bottom: 20px;
  transition: all 0.15s;
}
#fc-root .dropzone:hover, #fc-root .library.dropping .dropzone { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
#fc-root .library.dropping .dropzone { padding: 48px; }
#fc-root .lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
#fc-root .lib-empty { text-align: center; padding: 40px; }
#fc-root .card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
#fc-root .thumb { height: 180px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; border-bottom: 1px solid var(--border); }
#fc-root .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
#fc-root .thumb-err { color: var(--muted); font-size: 12px; }
#fc-root .meta { padding: 10px 12px 4px; }
#fc-root .meta .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#fc-root .meta .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
#fc-root .badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; min-height: 20px; }
#fc-root .badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: #f1f5f9; color: #475569; }
#fc-root .badge.ok { background: #dcfce7; color: #166534; }
#fc-root .card-actions { display: flex; gap: 4px; padding: 8px 12px 12px; margin-top: auto; }
#fc-root .card-actions button { padding: 5px 8px; font-size: 12px; }
#fc-root .card-actions .primary { flex: 1; justify-content: center; }
#fc-root .spinner { width: 22px; height: 22px; border: 3px solid #cbd5e1; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#fc-root .folders { overflow: hidden; padding: 24px 32px 0; }
#fc-root .crumbs { margin: 0; }
#fc-root .crumbs a { color: var(--accent); text-decoration: none; }
#fc-root .crumbs a:hover { text-decoration: underline; }
#fc-root .folder-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
#fc-root .folder-chips button { border-radius: 99px; padding: 5px 12px; font-size: 13px; }
#fc-root .folder-chips button span { color: var(--muted); font-size: 12px; }
#fc-root .folder-chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#fc-root .folder-chips button.on span { color: #dbeafe; }
#fc-root .folder-board {
  flex: 1;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 20px 20px;
  display: flex;
}
#fc-root .folder-svg { margin: auto; flex-shrink: 0; max-width: 100%; height: auto; }
#fc-root .map-node { cursor: pointer; }
#fc-root .map-node:hover path:first-of-type { filter: drop-shadow(0 3px 8px rgba(37, 99, 235, 0.35)); }
#fc-root .folder-group { border: 1px solid var(--border); border-radius: 8px; }
#fc-root .folder-group summary { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-weight: 600; user-select: none; }
#fc-root .folder-group summary .count { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); background: #f1f5f9; border-radius: 99px; padding: 1px 8px; }
#fc-root .folder-group[open] summary { border-bottom: 1px solid var(--border); }
#fc-root .folder-items { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
#fc-root .open-item.current { border-color: var(--accent); background: var(--accent-soft); }
#fc-root .modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
#fc-root .modal { background: var(--surface); border-radius: 12px; width: 440px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
#fc-root .modal.wide { width: 620px; }
#fc-root .modal-head { display: flex; align-items: center; padding: 14px 18px 6px; }
#fc-root .modal-head h3 { margin: 0; flex: 1; font-size: 16px; }
#fc-root .modal-close { border: none; padding: 4px 8px; color: var(--muted); }
#fc-root .modal-body { padding: 6px 18px 12px; overflow-y: auto; }
#fc-root .modal-body p { line-height: 1.5; margin: 6px 0 10px; }
#fc-root .modal-body .row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
#fc-root .modal-body .row > span:first-child { flex: 1; }
#fc-root .modal-body .col { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
#fc-root .modal-body .col input { width: 100%; }
#fc-root .modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
#fc-root .open-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
#fc-root .open-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
#fc-root .open-item > div:first-child { flex: 1; min-width: 0; }
#fc-root .open-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#fc-root .open-item .sub { font-size: 12px; color: var(--muted); }
#fc-root .open-pdf { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
#fc-root .toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
#fc-root .toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); transition: opacity 0.3s, transform 0.3s; max-width: 520px; }
#fc-root .toast.success { background: #166534; }
#fc-root .toast.error { background: #b91c1c; }
#fc-root .toast.out { opacity: 0; transform: translateY(8px); }

/* fill the CRM section height; the app's internal panels scroll */
#fc-root { height: calc(100vh - 54px); display: flex; flex-direction: column; overflow: hidden; }
