/* ========== Informelox · Design System ========== */
:root {
  --bg: #f5f7fb;
  --bg-elev: #ffffff;
  --bg-soft: #eef2f7;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --primary: #1f87c2;
  --primary-600: #1976a8;
  --primary-50: #e8f3fa;
  --accent: #00b8a9;
  --warn: #f59e0b;
  --danger: #ef4444;
  --success: #10b981;

  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 12px rgba(15, 23, 42, .07), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .10), 0 4px 12px rgba(15, 23, 42, .06);

  --sidebar-w: 248px;
  --topbar-h: 68px;
  --transition: 200ms cubic-bezier(.4,.0,.2,1);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-elev: #131b2c;
  --bg-soft: #1a2236;
  --border: #243049;
  --border-strong: #344166;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-soft: #64748b;
  --primary-50: #15324a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ========== Layout ========== */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
#sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; display: block; }
.brand-name { font-family: 'Sora', 'Inter', sans-serif; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--text-soft); letter-spacing: .04em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
}
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}
.sidebar-version { font-size: 11px; color: var(--text-soft); }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  transition: var(--transition);
}
.ghost-btn:hover { background: var(--bg-soft); color: var(--text); }
.ghost-btn svg { width: 16px; height: 16px; }

#main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}
#breadcrumb {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
#breadcrumb .crumb-sub { color: var(--text-soft); font-weight: 400; margin-left: 8px; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
#global-search {
  width: 280px;
  height: 38px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 14px;
  outline: none;
  transition: var(--transition);
}
#global-search:focus {
  background: var(--bg-elev);
  border-color: var(--primary);
}
.primary-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.primary-btn:hover { background: var(--primary-600); transform: translateY(-1px); box-shadow: var(--shadow); }
.primary-btn svg { width: 16px; height: 16px; }

.secondary-btn {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 500;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}
.secondary-btn:hover { background: var(--bg-elev); border-color: var(--border-strong); }
.secondary-btn svg { width: 16px; height: 16px; }

.danger-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 500;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}
.danger-btn:hover { background: rgba(239, 68, 68, .08); border-color: var(--danger); }

#view { padding: 28px; max-width: 100%; }

/* ========== Dashboard ========== */
.hero {
  background:
    radial-gradient(circle at 88% 18%, rgba(255,255,255,.22), transparent 50%),
    radial-gradient(circle at 12% 100%, rgba(0,184,169,.30), transparent 55%),
    linear-gradient(135deg, #0d2a4a 0%, #1f87c2 55%, #00b8a9 100%);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  color: white;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.04) 0, rgba(255,255,255,.04) 1px, transparent 1px, transparent 28px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0, rgba(255,255,255,.04) 1px, transparent 1px, transparent 28px);
  pointer-events: none;
  opacity: .5;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -40px; right: -40px;
  width: 280px; height: 280px;
  background-image: url('../assets/icon.svg');
  background-repeat: no-repeat;
  background-size: contain;
  opacity: .12;
  pointer-events: none;
  filter: brightness(0) invert(1);
}
.hero > * { position: relative; z-index: 2; }
.hero-title { font-family: 'Sora', 'Inter', sans-serif; font-size: 32px; font-weight: 800; margin-bottom: 8px; letter-spacing: -.02em; }
.hero-sub { opacity: .92; font-size: 15.5px; max-width: 540px; line-height: 1.55; }
.hero-ctas { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }
.hero .secondary-btn {
  background: rgba(255,255,255,.18);
  color: white;
  border-color: rgba(255,255,255,.25);
  backdrop-filter: blur(6px);
}
.hero .secondary-btn:hover { background: rgba(255,255,255,.28); }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--primary), var(--accent));
  opacity: 0; transition: var(--transition);
}
.kpi:hover::before { opacity: 1; }
.kpi-label { font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi-value { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; font-family: 'Sora', 'Inter', sans-serif; }
.kpi-trend { font-size: 12px; color: var(--success); margin-top: 4px; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 16px;
}
.section-title h2 { font-size: 19px; font-weight: 700; font-family: 'Sora', 'Inter', sans-serif; letter-spacing: -.01em; }
.section-title a { font-size: 13px; color: var(--primary); font-weight: 600; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-50);
  color: var(--primary);
  display: grid;
  place-items: center;
}
.card-icon svg { width: 20px; height: 20px; }
.card-title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.card-meta { font-size: 12px; color: var(--text-soft); display: flex; gap: 10px; flex-wrap: wrap; }
.card-tag {
  display: inline-block;
  background: var(--bg-soft);
  color: var(--text-muted);
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.card-tag.primary { background: var(--primary-50); color: var(--primary); }
.card-tag.warn { background: rgba(245,158,11,.12); color: var(--warn); }
.card-tag.success { background: rgba(16,185,129,.12); color: var(--success); }
.card-tag.info { background: rgba(31,135,194,.10); color: #2563eb; }
.card-tag.danger { background: rgba(239,68,68,.10); color: var(--danger); }

/* a11y: visible focus ring on every interactive element */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, a:focus-visible, .nav-item:focus-visible, .kpi:focus-visible {
  outline-offset: 3px;
}

/* Empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-muted);
}
.empty svg { width: 48px; height: 48px; margin-bottom: 14px; color: var(--text-soft); }
.empty h3 { font-size: 17px; color: var(--text); margin-bottom: 6px; }
.empty p { font-size: 14px; margin-bottom: 16px; max-width: 360px; }

/* Table */
.list-table {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
.list-table th, .list-table td {
  padding: 14px 18px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.list-table tr:last-child td { border-bottom: none; }
.list-table th {
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.list-table tbody tr { cursor: pointer; transition: var(--transition); }
.list-table tbody tr:hover { background: var(--bg-soft); }

/* ========== Editor ========== */
.editor-layout {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 18px;
  height: calc(100vh - var(--topbar-h) - 56px);
}
.editor-pane {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pane-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pane-header h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
.pane-body { flex: 1; overflow-y: auto; padding: 14px; }

.block-palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.block-pill {
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  cursor: grab;
  transition: var(--transition);
}
.block-pill:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary); }
.block-pill svg { width: 16px; height: 16px; color: var(--text-muted); }
.block-pill:hover svg { color: var(--primary); }
.block-pill:active { cursor: grabbing; }

.pal-cat { margin-bottom: 14px; }
.pal-cat-head { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-soft); font-weight: 700; margin: 0 0 6px 4px; }

/* drag indicators */
.report-block.is-dragging { opacity: .4; }
.report-block.drop-above { position: relative; }
.report-block.drop-below { position: relative; }
.report-block.drop-above::before { content: ''; position: absolute; left: 0; right: 0; top: -3px; height: 3px; background: var(--primary); border-radius: 2px; }
.report-block.drop-below::after { content: ''; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px; background: var(--primary); border-radius: 2px; }

/* slash menu */
.slash-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; background: transparent; border: 1px solid transparent;
  border-radius: 8px; cursor: pointer; transition: var(--transition);
}
.slash-item:hover, .slash-item.active { background: var(--primary-50); border-color: var(--primary); }
.slash-item svg { color: var(--text-muted); }
.slash-item:hover svg, .slash-item.active svg { color: var(--primary); }
.slash-item .sl-label { font-weight: 600; font-size: 14px; color: var(--text); }
.slash-item .sl-cat { font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }

/* ========== Rich text floating toolbar ========== */
.rt-toolbar {
  position: absolute;
  z-index: 250;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  font-size: 13px;
}
.rt-toolbar button {
  width: 30px; height: 30px;
  border: none; background: transparent; cursor: pointer; border-radius: 6px;
  color: var(--text); display: grid; place-items: center; font-size: 13px;
  transition: var(--transition);
}
.rt-toolbar button:hover { background: var(--bg-soft); }
.rt-toolbar button.active { background: var(--primary-50); color: var(--primary); }
.rt-toolbar select {
  height: 28px; padding: 0 6px; border-radius: 6px;
  background: var(--bg-soft); border: 1px solid transparent; font-size: 12px;
  cursor: pointer;
}
.rt-toolbar select:hover { background: var(--bg-elev); border-color: var(--border); }
.rt-toolbar .rt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.rt-toolbar .rt-color {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
  font-weight: 700; transition: var(--transition);
}
.rt-toolbar .rt-color:hover { background: var(--bg-soft); }
.rt-toolbar .rt-color input[type="color"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; border: none; padding: 0;
}

/* contenteditable host */
.rt-editable { outline: none; min-height: 1.4em; }
.rt-editable:focus { background: rgba(31,135,194,0.04); border-radius: 4px; }
.rt-editable [style*="background"] { padding: 0 2px; border-radius: 2px; }
.rt-editable a { color: var(--primary); text-decoration: underline; }
.rt-editable blockquote {
  margin: 8px 0; padding: 6px 14px; border-left: 3px solid var(--primary);
  background: #f8fafc; font-style: italic; color: #334155;
}
.rt-editable pre {
  background: #0f172a; color: #f1f5f9; padding: 10px 12px; border-radius: 6px;
  font-family: var(--font-mono); font-size: 12px; overflow-x: auto;
}
.rt-editable ul, .rt-editable ol { padding-left: 22px; margin: 4px 0; }
.rt-editable h1 { font-size: 22px; color: var(--primary); margin: 8px 0 4px; }
.rt-editable h2 { font-size: 17px; color: var(--primary); margin: 6px 0 3px; }
.rt-editable h3 { font-size: 14px; color: var(--primary); margin: 6px 0 3px; }

/* format toolbar */
.format-toolbar .fmt-btn {
  width: 30px; height: 30px; border: 1px solid var(--border); background: var(--bg-elev);
  border-radius: 6px; cursor: pointer; transition: var(--transition);
  display: grid; place-items: center; font-size: 13px;
}
.format-toolbar .fmt-btn:hover { background: var(--primary-50); border-color: var(--primary); color: var(--primary); }

#canvas-pane {
  background: var(--bg-soft);
  padding: 22px;
  overflow-y: auto;
  overflow-x: hidden;
  /* smooth, native-feeling scroll over the report */
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
#canvas-pane #canvas-host { padding-bottom: 32px; }
/* Slim, branded scrollbar on the canvas pane */
#canvas-pane::-webkit-scrollbar { width: 10px; }
#canvas-pane::-webkit-scrollbar-track { background: transparent; }
#canvas-pane::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 2px solid var(--bg-soft);
}
#canvas-pane::-webkit-scrollbar-thumb:hover { background: var(--primary); }
.page-canvas {
  background: white;
  width: 100%;
  max-width: 794px;
  margin: 0 auto;
  min-height: 1123px;
  box-shadow: var(--shadow-lg);
  border-radius: 6px;
  padding: 0;
  position: relative;
  font-family: var(--font-sans);
  color: #0f172a;
  overflow: hidden;
}
.page-header {
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-bottom: 2px solid var(--primary);
}
.page-header img { height: 38px; object-fit: contain; }
.page-header .header-cert { display: flex; gap: 10px; align-items: center; }
.page-header .header-cert img { height: 32px; }
.page-content { padding: 24px 32px 60px; }

.report-block {
  position: relative;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 6px;
  margin-bottom: 6px;
  transition: var(--transition);
}
.report-block:hover { border-color: var(--primary-50); }
.report-block.selected { border-color: var(--primary); }
.block-toolbar {
  position: absolute;
  top: -16px;
  right: 8px;
  display: none;
  gap: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.report-block.selected .block-toolbar { display: flex; }
.block-toolbar button {
  background: transparent;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  color: var(--text-muted);
  display: grid;
  place-items: center;
}
.block-toolbar button:hover { background: var(--bg-soft); color: var(--text); }
.block-toolbar button.danger:hover { background: rgba(239,68,68,.1); color: var(--danger); }
.block-toolbar svg { width: 14px; height: 14px; }

/* report styles inside canvas */
.rb-heading { font-weight: 700; color: var(--primary); border-bottom: 1px solid #cbd5e1; padding-bottom: 4px; margin: 12px 0 8px; }
.rb-heading[data-level="1"] { font-size: 22px; }
.rb-heading[data-level="2"] { font-size: 17px; }
.rb-heading[data-level="3"] { font-size: 14px; }
.rb-paragraph { font-size: 13px; line-height: 1.55; color: #1e293b; }
.rb-keyvalue { display: grid; grid-template-columns: 160px 1fr; row-gap: 4px; font-size: 13px; }
.rb-keyvalue dt { color: var(--text-muted); font-weight: 600; }
.rb-keyvalue dd { margin: 0; color: #0f172a; }
.rb-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 8px 0; }
.rb-table th, .rb-table td { border: 1px solid #cbd5e1; padding: 6px 9px; text-align: center; position: relative; }
.rb-table th { background: #e2e8f0; font-weight: 700; }
.rb-table tr.warn td { background: #fff4e6; }
.rb-table tr.warn td:last-child { color: var(--warn); font-weight: 600; }

/* Excel-grade editing */
.rb-table[data-editable-table] td,
.rb-table[data-editable-table] th { transition: background 120ms; }
.rb-table[data-editable-table] td:hover { background: #f1f5f9; cursor: text; }
.rb-table[data-editable-table] td:focus,
.rb-table[data-editable-table] th:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: white;
  box-shadow: 0 0 0 4px var(--primary-50);
  z-index: 2;
}
.rb-table[data-editable-table] td.cell-formula {
  background: rgba(31,135,194,.05);
  font-family: var(--font-mono);
}
.rb-table[data-editable-table] td.cell-formula::before {
  content: 'ƒ';
  position: absolute; top: 1px; left: 3px;
  font-size: 8px; color: var(--primary); font-family: var(--font-sans); font-weight: 700;
}
.rb-table[data-editable-table] td.cell-bad {
  background: #fee2e2 !important;
  color: var(--danger);
  font-weight: 700;
}
.rb-table[data-editable-table] tr.warn td:not(.cell-bad) { background: #fff7ed; }

/* +/× cell controls — visible on hover */
.cell-ctrl {
  position: absolute; opacity: 0; pointer-events: none;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--danger); font-size: 11px; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  transition: opacity 120ms; z-index: 3;
}
.rb-table[data-editable-table] th:hover .cell-ctrl,
.rb-table[data-editable-table] td:hover .cell-ctrl {
  opacity: 1; pointer-events: auto;
}
.cell-ctrl:hover { background: var(--danger); color: white; border-color: var(--danger); }
.cell-ctrl-col-del { top: -8px; right: 2px; }
.cell-ctrl-row-del { left: -8px; top: 50%; transform: translateY(-50%); }

/* + Row / + Col bar */
.tbl-add-bar {
  display: flex; gap: 6px; margin-top: 4px;
}
.tbl-add-bar button {
  background: var(--bg-soft);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  padding: 4px 12px;
  font-size: 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}
.tbl-add-bar button:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary); border-style: solid; }
.rb-cover {
  text-align: center;
  padding: 60px 30px 40px;
  background: linear-gradient(135deg, #e8f3fa 0%, #ffffff 70%);
  border-radius: 8px;
  margin: 8px 0;
  position: relative;
  overflow: hidden;
}
.rb-cover::before {
  content: '';
  position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: linear-gradient(90deg, #0d2a4a 0%, #1f87c2 50%, #00b8a9 100%);
}
.rb-cover .cover-photo { margin-bottom: 24px; }
.rb-cover .cover-photo img {
  max-width: 100%; max-height: 240px; border-radius: 8px; object-fit: cover;
  box-shadow: 0 8px 24px rgba(13,42,74,.15);
}
.rb-cover .cover-title {
  font-size: 30px; font-weight: 800; color: var(--primary);
  letter-spacing: -.02em; font-family: 'Sora','Inter',sans-serif;
  text-transform: uppercase; line-height: 1.1;
}
.rb-cover .cover-vessel {
  font-size: 26px; font-weight: 700; margin-top: 14px;
  font-family: 'Sora','Inter',sans-serif; color: #0d2a4a;
}
.rb-cover .cover-meta-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px;
  margin: 32px auto 0; max-width: 460px; text-align: left;
  font-size: 12px;
}
.rb-cover .cover-meta-grid > div {
  display: flex; flex-direction: column; gap: 1px;
  border-left: 2px solid var(--primary); padding-left: 10px;
}
.rb-cover .cover-k {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-soft); font-weight: 700;
}
.rb-cover .cover-v { font-weight: 600; color: #0d2a4a; font-size: 13px; }
.rb-image { text-align: center; margin: 10px 0; }
.rb-image img { max-width: 100%; max-height: 320px; border-radius: 6px; }
.rb-image figcaption { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-style: italic; }
.rb-signature { display: flex; gap: 18px; margin-top: 28px; }
.rb-signature .sig-box { flex: 1; padding-top: 30px; border-top: 1px solid #94a3b8; font-size: 12px; color: var(--text-muted); text-align: center; }
.rb-notes { background: #f8fafc; border-left: 3px solid var(--primary); padding: 10px 14px; font-size: 13px; border-radius: 0 6px 6px 0; }
.rb-pagebreak { border-top: 2px dashed var(--border-strong); margin: 18px 0; text-align: center; font-size: 11px; color: var(--text-soft); padding-top: 4px; }
.rb-chart { margin: 10px 0; height: 220px; }
.rb-callout { display:flex; gap: 12px; padding: 12px 14px; border-radius: 10px; margin: 10px 0; align-items: flex-start; font-size: 13px; line-height: 1.55; }
.rb-callout .cl-icon { width: 22px; height: 22px; flex-shrink: 0; }
.rb-callout-info { background: #e8f3fa; color: #0d4a6f; border-left: 3px solid #1f87c2; }
.rb-callout-warning { background: #fffaeb; color: #7a4f00; border-left: 3px solid #f59e0b; }
.rb-callout-success { background: #ecfdf5; color: #065f46; border-left: 3px solid #10b981; }
.rb-callout-danger { background: #fef2f2; color: #991b1b; border-left: 3px solid #ef4444; }
.rb-quote { margin: 14px 0; padding: 12px 18px; border-left: 3px solid #1f87c2; background: #f8fafc; font-style: italic; font-size: 14px; color: #334155; border-radius: 0 8px 8px 0; }
.rb-quote-author { margin-top: 6px; font-style: normal; font-size: 12px; color: #64748b; }
.rb-list { padding-left: 22px; font-size: 13px; line-height: 1.7; color: #1e293b; }
.rb-list li { margin-bottom: 4px; }
.rb-checklist { padding-left: 4px; list-style: none; font-size: 13px; line-height: 1.7; color: #1e293b; }
.rb-checklist li { margin-bottom: 4px; }
.rb-checklist .cl-item { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.rb-checklist .cl-item.done span { text-decoration: line-through; color: #94a3b8; }
.rb-checklist input[type="checkbox"] { width: 16px; height: 16px; accent-color: #1f87c2; }
.rb-code { background: #0f172a; color: #f1f5f9; padding: 12px 14px; border-radius: 8px; font-family: var(--font-mono); font-size: 12px; overflow-x: auto; margin: 10px 0; }
.rb-code code { background: transparent; padding: 0; color: inherit; }
.rb-columns { display: grid; gap: 14px; margin: 10px 0; }
.rb-col { background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 10px; min-height: 60px; }
.rb-col-empty { color: #94a3b8; font-size: 12px; text-align: center; padding: 16px; }
.rb-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 10px 0; }
.rb-gallery-item { margin: 0; }
.rb-gallery-item img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; }
.rb-gallery-item figcaption { font-size: 11px; color: #64748b; text-align: center; margin-top: 2px; }
.rb-gallery-empty { background: #f8fafc; border: 2px dashed #cbd5e1; padding: 20px; text-align: center; color: #64748b; font-size: 13px; border-radius: 8px; }
.rb-gallery-caption { font-size: 12px; color: #64748b; text-align: center; font-style: italic; margin-top: 4px; }
.rb-progress { margin: 10px 0; }
.rb-progress .pr-row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: #334155; }
.rb-progress .pr-bar { width: 100%; height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.rb-progress .pr-fill { height: 100%; background: linear-gradient(90deg, #1f87c2, #00b8a9); transition: width 200ms; }
.rb-qr { text-align: center; margin: 10px 0; }
.rb-qr img { display: inline-block; }
.rb-qr-text { font-size: 11px; color: #64748b; margin-top: 4px; font-family: var(--font-mono); word-break: break-all; }
.rb-divider { border: none; border-top: 1px solid #cbd5e1; margin: 18px 0; }
.rb-divider-dots { text-align: center; color: #94a3b8; letter-spacing: .3em; margin: 18px 0; font-size: 14px; }
.rb-divider-wave { margin: 14px 0; }
.rb-divider-wave svg { width: 100%; height: 14px; }
.rb-spacer { width: 100%; }

/* Annotated photo — clickable in editor to add annotations */
.rb-annotated[data-annotated-photo] .rb-ap-stage { cursor: crosshair; }
.rb-annotated .rb-ap-overlay { user-select: none; }
.rb-annotated:focus-within .rb-ap-overlay { outline: 1px dashed var(--primary); outline-offset: 2px; }

/* Diagram */
.rb-diagram svg { display: block; margin: 0 auto; }

/* KPI tiles */
.rb-kpi .kpi-tile {
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 16px 18px;
  text-align: left;
  position: relative;
}
.rb-kpi .kpi-tile[data-trend="warn"]  { border-left-color: var(--warn); }
.rb-kpi .kpi-tile[data-trend="bad"]   { border-left-color: var(--danger); }
.rb-kpi .kpi-tile[data-trend="ok"]    { border-left-color: var(--success); }
.rb-kpi .kpi-tile[data-trend="up"]    { border-left-color: var(--primary); }
.rb-kpi .kpi-tile[data-trend="down"]  { border-left-color: var(--accent); }
.rb-kpi .kpi-tile-value {
  font-family: 'Sora','Inter',sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: #0d2a4a;
  letter-spacing: -.02em;
  line-height: 1;
}
.rb-kpi .kpi-tile-unit {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}
.rb-kpi .kpi-tile-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 6px;
}
.rb-kpi .kpi-tile-trend { font-size: 11px; font-weight: 700; margin-top: 4px; }
.rb-kpi .kpi-ok   { color: var(--success); }
.rb-kpi .kpi-warn { color: var(--warn); }
.rb-kpi .kpi-bad  { color: var(--danger); }
.rb-kpi .kpi-up, .rb-kpi .kpi-down { color: var(--primary); }
.rb-kpi .kpi-flat { color: var(--text-muted); }

/* code inside paragraphs (inline formatting) */
.rb-paragraph code, .rb-notes code, .rb-callout code, .rb-quote code, .rb-list code {
  background: #f1f5f9; padding: 1px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 12px; color: #be185d;
}
.rb-paragraph a, .rb-notes a, .rb-callout a { color: var(--primary); text-decoration: underline; }

/* properties pane */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  transition: var(--transition);
}
.field input:focus, .field textarea:focus, .field select:focus {
  background: var(--bg-elev);
  border-color: var(--primary);
}
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tab-bar { display: flex; gap: 4px; padding: 2px; background: var(--bg-soft); border-radius: 8px; margin-bottom: 14px; }
.tab-bar button {
  flex: 1; padding: 7px 12px; border: none; background: transparent;
  border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text-muted);
}
.tab-bar button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 200;
  animation: fade-in .18s ease;
}
.modal {
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  width: 580px; max-width: 92vw; max-height: 88vh;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop-in .22s cubic-bezier(.34,1.56,.64,1);
}
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal .x { background: transparent; border: none; color: var(--text-muted); font-size: 22px; line-height: 1; cursor: pointer; }
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* Toast */
#toast-root {
  position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 300;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slide-in .22s ease;
  max-width: 360px;
}
.toast.success { border-left-color: var(--success); }
.toast.warn { border-left-color: var(--warn); }
.toast.danger { border-left-color: var(--danger); }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Settings */
.settings-grid { display: grid; grid-template-columns: 220px 1fr; gap: 28px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav a {
  padding: 10px 14px; border-radius: 8px; font-size: 14px; color: var(--text-muted); font-weight: 500;
}
.settings-nav a:hover, .settings-nav a.active { background: var(--bg-soft); color: var(--text); }
.settings-section { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 18px; }
.settings-section h3 { font-size: 16px; margin-bottom: 4px; }
.settings-section .section-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.logo-slot {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--bg-soft);
  position: relative;
}
.logo-slot img { max-width: 100%; max-height: 60px; object-fit: contain; }
.logo-slot label { font-size: 11px; color: var(--text-muted); }
.logo-slot button {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--danger); font-size: 14px; line-height: 1;
}

/* AI panel */
.ai-shell { display: grid; grid-template-columns: 1fr; gap: 16px; max-width: 920px; }
.ai-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.ai-status {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px; background: var(--bg-soft);
  font-size: 13px; margin-bottom: 14px;
}
.ai-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-soft); }
.ai-status.connected .dot { background: var(--success); box-shadow: 0 0 0 4px rgba(16,185,129,.15); }
.ai-prompts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.ai-prompts button {
  text-align: left; background: var(--bg-soft); border: 1px solid transparent;
  border-radius: 10px; padding: 14px; font-size: 13px;
  display: flex; flex-direction: column; gap: 4px; transition: var(--transition);
}
.ai-prompts button:hover { background: var(--primary-50); border-color: var(--primary); }
.ai-prompts strong { color: var(--text); font-weight: 600; }
.ai-prompts span { color: var(--text-muted); font-size: 12px; }
.ai-output {
  margin-top: 16px; padding: 16px; background: var(--bg-soft);
  border-radius: 10px; font-size: 13.5px; min-height: 80px;
  white-space: pre-wrap; line-height: 1.6;
}
.ai-spinner {
  width: 18px; height: 18px; border: 2px solid var(--border-strong);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block; vertical-align: middle; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Print / Export styles ========== */
.print-canvas {
  font-family: 'Calibri', 'Inter', sans-serif;
  width: 794px; /* A4 at 96 dpi */
  background: white;
  color: #0f172a;
}
@media print {
  #sidebar, #topbar, .editor-pane, .block-toolbar { display: none !important; }
  .page-canvas { box-shadow: none; }
}

/* ========== Auth screens ========== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.auth-aside {
  background: linear-gradient(160deg, var(--primary) 0%, #2196d3 50%, var(--accent) 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: white;
}
.auth-aside::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(255,255,255,.18), transparent 60%),
              radial-gradient(circle at 80% 20%, rgba(255,255,255,.10), transparent 50%);
}
.auth-brand {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 14px;
}
.auth-brand img { width: 52px; height: 52px; }
.auth-brand .name { font-family: 'Sora', sans-serif; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.auth-brand .sub { font-size: 12px; opacity: .85; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }

.auth-pitch {
  position: relative; z-index: 2;
  margin: auto 0;
  max-width: 460px;
}
.auth-pitch h1 { font-family: 'Sora', sans-serif; font-size: 44px; line-height: 1.05; letter-spacing: -.02em; margin-bottom: 18px; font-weight: 800; }
.auth-pitch p { font-size: 16px; opacity: .92; line-height: 1.6; max-width: 420px; }
.auth-features { margin-top: 28px; display: flex; flex-direction: column; gap: 10px; }
.auth-feature { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.auth-feature svg { width: 20px; height: 20px; flex-shrink: 0; opacity: .9; }

.auth-foot {
  position: relative; z-index: 2;
  font-size: 12px; opacity: .7;
}

.auth-main {
  display: flex; align-items: center; justify-content: center; padding: 40px 28px;
}
.auth-card {
  width: 100%; max-width: 380px;
}
.auth-card h2 { font-family: 'Sora', sans-serif; font-size: 28px; margin-bottom: 8px; letter-spacing: -.01em; }
.auth-card .lede { color: var(--text-muted); margin-bottom: 26px; font-size: 15px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card input {
  height: 44px; font-size: 15px; padding: 0 14px;
  border-radius: 10px; background: var(--bg-soft); border: 1px solid transparent;
  width: 100%; outline: none; transition: var(--transition);
}
.auth-card input:focus { background: var(--bg-elev); border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.auth-card .primary-btn { width: 100%; justify-content: center; height: 44px; font-size: 15px; margin-top: 6px; }
.auth-card .switcher { margin-top: 18px; font-size: 14px; color: var(--text-muted); text-align: center; }
.auth-card .switcher a { color: var(--primary); font-weight: 600; cursor: pointer; }
.auth-error {
  background: rgba(239,68,68,.08); color: var(--danger); padding: 10px 14px;
  border-radius: 10px; font-size: 13px; margin-bottom: 14px; border: 1px solid rgba(239,68,68,.18);
}

/* User pill in sidebar */
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  background: var(--bg-soft); border-radius: 10px;
  margin-top: 8px;
  font-size: 13px;
  cursor: pointer; transition: var(--transition);
}
.user-pill:hover { background: var(--primary-50); }
.user-pill .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; font-weight: 700; font-size: 13px;
  display: grid; place-items: center; flex-shrink: 0;
}
.user-pill .info { flex: 1; min-width: 0; }
.user-pill .info .name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pill .info .email { font-size: 11px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pill .logout-btn { background: transparent; border: none; color: var(--text-muted); padding: 4px; cursor: pointer; border-radius: 6px; }
.user-pill .logout-btn:hover { background: rgba(239,68,68,.1); color: var(--danger); }
.user-pill .logout-btn svg { width: 16px; height: 16px; }

/* responsive */
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-main { padding: 60px 24px; }
}
@media (max-width: 1100px) {
  .editor-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - var(--topbar-h) - 56px);
  }
  .editor-pane { max-height: none; }
  #canvas-pane { overflow-y: visible; max-height: none; }
}
@media (max-width: 720px) {
  #sidebar { display: none; }
  #app { grid-template-columns: 1fr; }
  #topbar { padding: 0 16px; }
  #global-search { width: 140px; }
  #view { padding: 16px; }
}
