:root {
  --aau-blue: #211a52;
  --bg: #202842;
  --bg-soft: #252f4b;
  --sidebar: #1b2338;
  --panel: #26314f;
  --panel-solid: #26314f;
  --panel-raised: #2c3758;
  --panel-muted: #222b46;
  --line: rgba(142, 151, 180, .16);
  --line-strong: rgba(142, 151, 180, .28);
  --text: #e9edf8;
  --muted: #8f97ae;
  --muted-strong: #bdc4d8;
  --blue: #4b6fe5;
  --blue-hover: #587bf0;
  --blue-soft: rgba(75, 111, 229, .14);
  --teal: #2e7d92;
  --danger: #ff6a6a;
  --danger-soft: rgba(255, 106, 106, .12);
  --green: #63d398;
  --green-soft: rgba(99, 211, 152, .12);
  --purple: #aaa4d6;
  --purple-soft: rgba(170, 164, 214, .12);
  --shadow: none;
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

html { font-size: 14px; }

body {
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

body:not(.login-page) { padding-left: 68px; }

a { color: var(--blue); text-decoration: none; }
a:hover { color: #7f96ec; }
.text-muted { color: var(--muted) !important; }
.lucide { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1060;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 68px;
  padding: 20px 0;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.sidebar-brand,
.sidebar-link,
.sidebar-button,
.btn,
.icon-button,
.card-heading,
.preview-heading,
.preview-badge,
.app-alert {
  display: flex;
  align-items: center;
}

.sidebar-brand {
  justify-content: center;
  width: 38px;
  height: 38px;
  color: var(--text);
}
.sidebar-brand:hover { color: var(--text); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--teal);
  border: 1px solid rgba(46, 125, 146, .72);
  border-radius: 50%;
  box-shadow: none;
}
.brand-mark .lucide { width: 20px; height: 20px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 64px;
}
.sidebar-link,
.sidebar-button {
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
}
.sidebar-link {
  color: var(--text);
  background: var(--panel-muted);
}
.sidebar-link:hover,
.sidebar-button:hover,
.sidebar-button.active {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--panel-muted);
}
.sidebar-button { cursor: pointer; }
.sidebar-logout-form { width: 100%; margin: 0; }
.sidebar-logout-form { display: flex; justify-content: center; }
.sidebar-spacer { flex: 1 1 auto; min-height: 28px; }

.app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 36px 44px 48px;
}

.page-heading { margin-bottom: 26px; }
.page-heading h1 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: clamp(2rem, 3vw, 2.65rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -.035em;
}
.page-heading p:not(.eyebrow) { margin: 0; color: var(--muted-strong); font-size: 1.18rem; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.draft-panel,
.content-card,
.preview-pane {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: none;
}

.draft-panel { overflow: hidden; padding: 0; }
.draft-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.draft-toolbar h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.draft-toolbar p {
  margin: 3px 0 0;
  color: var(--muted);
}
.draft-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}
.draft-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(320px, 38vw);
  min-height: 40px;
  padding: 0 12px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-muted);
}
.draft-search input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  border: 0;
  outline: 0;
  background: transparent;
}
.draft-search input::placeholder { color: var(--muted); }
.draft-upload-form { margin: 0; }
.draft-new-report { min-height: 40px; padding-inline: 14px; }
.draft-table-wrap { overflow-x: auto; }
.draft-table { width: 100%; min-width: 1060px; border-collapse: collapse; color: var(--text); }
.draft-table th {
  padding: 20px 24px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 650;
  letter-spacing: .035em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.draft-table th span { display: inline-flex; align-items: center; gap: 10px; }
.draft-table td { padding: 18px 24px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.draft-table tr:last-child td { border-bottom: 0; }
.draft-row { transition: background .16s ease, transform .16s ease; }
.draft-row:hover { background: var(--panel-raised); }
.report-name-cell { display: grid; grid-template-columns: 36px 1fr; gap: 16px; align-items: center; min-width: 300px; }
.row-icon,
.card-icon,
.empty-icon {
  display: grid;
  place-items: center;
  color: var(--muted-strong);
  border: 1px solid var(--line-strong);
  background: var(--panel-muted);
}
.row-icon { width: 34px; height: 34px; border-radius: 8px; }
.report-name-cell strong { display: block; color: var(--text); font-size: 1.05rem; letter-spacing: -.02em; }
.report-name-cell small,
.source-cell small,
.muted-cell span { display: block; color: var(--muted); }
.muted-cell { color: var(--muted-strong); }
.muted-cell strong { color: var(--text); }
.report-count-cell { min-width: 118px; color: var(--muted); }
.report-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 36px;
  margin-bottom: 4px;
  color: var(--text);
  border: 1px solid rgba(75, 111, 229, .42);
  border-radius: 10px;
  background: var(--blue-soft);
  font-size: 1.05rem;
  font-weight: 800;
}
.report-count-cell small { display: block; color: var(--muted); font-weight: 750; }
.source-cell { display: grid; grid-template-columns: auto minmax(140px, 1fr); gap: 3px 12px; align-items: center; color: var(--muted-strong); }
.source-cell small { grid-column: 2; }
.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 26px;
  color: #9fdab1;
  border: 1px solid rgba(99, 211, 152, .24);
  border-radius: 7px;
  background: var(--green-soft);
  font-size: .72rem;
  font-weight: 750;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 750;
}
.status-pill.ready { color: #88f3b2; background: var(--green-soft); }
.status-pill.draft { color: var(--text); background: rgba(142, 151, 180, .12); }
.status-pill.review { color: #d7bbff; background: var(--purple-soft); }
.actions-cell { min-width: 260px; white-space: nowrap; }
.actions-cell .btn,
.actions-cell .icon-button { margin-left: 10px; }
.actions-cell .btn,
.actions-cell .icon-button,
.actions-cell form { display: inline-flex !important; vertical-align: middle; }

.empty-drafts { display: grid; place-items: center; min-height: 360px; text-align: center; color: var(--muted-strong); }
.empty-drafts h2 { margin: 18px 0 6px; color: var(--text); font-size: 1.7rem; }
.empty-drafts p { margin: 0; color: var(--muted); }
.empty-icon { width: 64px; height: 64px; color: var(--teal); border-radius: 18px; }
.empty-icon .lucide { width: 30px; height: 30px; }

.btn {
  justify-content: center;
  gap: 9px;
  border-radius: 8px;
  font-weight: 700;
  box-shadow: none !important;
}
.btn-primary {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
  box-shadow: none !important;
}
.btn-primary:hover,
.btn-primary:focus { color: #fff; border-color: var(--blue-hover); background: var(--blue-hover); }
.btn-outline-primary,
.btn-outline-secondary {
  color: var(--muted-strong);
  border-color: var(--line-strong);
  background: transparent;
}
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-primary:focus,
.btn-outline-secondary:focus { color: var(--text); border-color: rgba(75, 111, 229, .6); background: var(--blue-soft); }
.btn-outline-danger { color: #ff7777; border-color: rgba(255, 77, 77, .42); background: var(--danger-soft); }
.btn-outline-danger:hover { color: #fff; border-color: var(--danger); background: rgba(255, 106, 106, .18); }
.btn-sm { min-height: 34px; padding-inline: 12px; }
.action-open { min-width: 132px; }
.icon-button {
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  color: var(--muted-strong);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
}
.icon-button:hover { color: var(--text); border-color: rgba(75, 111, 229, .58); background: var(--blue-soft); }
.icon-button.danger { color: var(--danger); border-color: rgba(255, 77, 77, .52); background: var(--danger-soft); }
.icon-button.danger:hover { color: #fff; border-color: var(--danger); background: rgba(255, 106, 106, .2); }

.app-alert {
  gap: 10px;
  margin-bottom: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel-raised);
}
.app-alert-success { border-color: rgba(65, 211, 124, .24); background: var(--green-soft); }
.app-alert-danger { border-color: rgba(255, 77, 77, .32); background: var(--danger-soft); }

.login-page { min-height: 100vh; background: var(--bg); }
.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
}
.login-card {
  width: min(100%, 420px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: none;
}
.login-brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 24px;
  color: #fff;
  border: 1px solid var(--blue);
  border-radius: 12px;
  background: var(--blue);
  box-shadow: none;
  font-weight: 850;
  letter-spacing: -.04em;
}
.login-card h1 { margin: 0 0 22px; color: var(--text); font-size: 2rem; font-weight: 750; letter-spacing: -.04em; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-error { margin: 0; }

.content-card { padding: 22px; }
.content-card h1,
.content-card h2,
.content-card h3 { margin: 0; color: var(--text); font-weight: 700; line-height: 1.12; letter-spacing: -.025em; }
.content-card h1 { font-size: 1.9rem; }
.content-card h2 { font-size: 1.24rem; }
.content-card h3 { font-size: 1rem; }
.card-heading { gap: 14px; margin-bottom: 18px; }
.card-heading.compact { margin-bottom: 14px; }
.card-heading.mb-0 { margin-bottom: 0 !important; }
.card-icon { width: 38px; height: 38px; color: var(--teal); border-radius: 10px; }

.form-label,
.editor-field,
.editor-check { color: var(--text); font-weight: 800; }
.form-control,
.form-select {
  min-width: 0;
  max-width: 100%;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background-color: var(--panel-muted);
}
.form-control:focus,
.form-select:focus {
  color: var(--text);
  border-color: rgba(75, 111, 229, .86);
  background-color: #242d49;
  box-shadow: 0 0 0 .2rem rgba(75, 111, 229, .14);
}
.form-control::placeholder { color: rgba(194, 202, 215, .55); }
.form-control:disabled,
.form-select:disabled { color: var(--muted); background-color: rgba(142, 151, 180, .08); }
.form-text,
.empty-state,
.small-list,
.editor-field small,
.column-row small,
.column-picker-count,
.column-picker-option small,
.custom-sort-empty,
.filter-no-value,
.graph-analysis,
.pagebreak-editor,
.preview-status { color: var(--muted); }
.form-check-input {
  border-color: var(--line-strong);
  background-color: rgba(5, 12, 21, .9);
}
.form-check-input:checked { border-color: var(--blue); background-color: var(--blue); }

.summary-grid { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; }
.summary-grid dt { color: var(--muted); font-weight: 800; }
.summary-grid dd { margin: 0; color: var(--text); }
.warning-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.warning-list span,
.neutral-warning:not(:empty) {
  padding: 7px 11px;
  color: #ffd099;
  border: 1px solid rgba(251, 191, 36, .28);
  border-radius: 999px;
  background: rgba(251, 191, 36, .12);
}

.editor-shell {
  --editor-pane-width: 48%;
  display: grid;
  grid-template-columns: minmax(420px, var(--editor-pane-width)) 14px minmax(420px, 1fr);
  gap: 10px;
  height: calc(100vh - 174px);
  margin-bottom: 92px;
}
.editor-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.editor-page .app-shell {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 56px;
  overflow: hidden;
}
.editor-page .app-shell main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}
.editor-page .editor-shell {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  margin-bottom: 0;
}
.editor-pane { min-height: 0; contain: layout paint; overflow: auto; scrollbar-color: rgba(148, 163, 184, .4) transparent; }
.config-pane { padding-right: 4px; }
.editor-resize-handle {
  position: relative;
  min-height: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}
.editor-resize-handle::before {
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 50%;
  width: 2px;
  content: "";
  border-radius: 999px;
  background: var(--line-strong);
  transform: translateX(-50%);
  transition: background-color .16s ease, width .16s ease;
}
.editor-resize-handle::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 44px;
  content: "";
  border-radius: 999px;
  background: var(--line-strong);
  transform: translate(-50%, -50%);
}
.editor-resize-handle:hover::before,
.editor-resize-handle:focus-visible::before,
.editor-resize-handle.dragging::before { width: 4px; background: var(--teal); }
.editor-resize-handle:focus-visible { outline: 2px solid rgba(46, 125, 146, .7); outline-offset: 4px; }
body.editor-pane-resizing { cursor: col-resize; user-select: none; }
body.editor-pane-resizing iframe,
body.editor-pane-resizing canvas { pointer-events: none; }
.preview-pane {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  padding: 16px;
}
.editor-page .preview-pane { position: relative; top: auto; }
.preview-heading { justify-content: space-between; gap: 12px; }
.preview-heading h2 { margin: 0; color: var(--text); font-size: 1.3rem; font-weight: 750; }
.preview-badge { gap: 8px; color: #a9d5e0; font-weight: 700; }
.editor-toolbar,
.preview-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.preview-toolbar { margin-bottom: 0; }
.preview-toolbar .form-select { flex: 1; min-width: 180px; }
.preview-status { min-height: 28px; }
.pdf-viewer-shell {
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  contain: layout paint;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 16px;
  background: #eef2f7;
  box-shadow: none;
}
.pdf-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-height: 100%;
  padding: 20px;
}
.pdf-loading,
.pdf-error {
  width: 100%;
  padding: 28px;
  color: #475467;
  text-align: center;
}
.pdf-error { color: #9f1239; }
.pdf-page {
  position: relative;
  contain: layout paint;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
}
.pdf-page canvas { display: block; }
.pdf-annotation-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.pdf-link-annotation {
  position: absolute;
  display: block;
  border-radius: 2px;
  cursor: pointer;
  pointer-events: auto;
}
.pdf-link-annotation:focus-visible {
  outline: 2px solid rgba(75, 111, 229, .8);
  outline-offset: 1px;
}
.pdf-sync-marker {
  position: absolute;
  left: 5px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0;
  color: var(--blue);
  pointer-events: none;
  transform: translateY(-50%);
}
.pdf-sync-marker[hidden] { display: none; }
.pdf-sync-marker .lucide {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .28));
}
.pdf-sync-marker-line {
  width: 26px;
  height: 2px;
  margin-left: -4px;
  border-radius: 999px;
  background: currentColor;
  opacity: .92;
}

.editor-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 68px;
  z-index: 1030;
  border-top: 1px solid var(--line);
  background: var(--bg);
  box-shadow: none;
}
.editor-footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  max-width: none;
  margin: 0;
  padding: 0 0 0 44px;
}
.editor-footer-status { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); }
.dirty-indicator { border-radius: 999px; padding: 5px 11px; font-weight: 750; }
.dirty-indicator.clean { color: #8ff0b4; background: var(--green-soft); }
.dirty-indicator.dirty { color: #ffd099; background: rgba(251, 191, 36, .14); }
.editor-footer .btn-primary {
  align-self: stretch;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 0;
}

.inline-form { display: flex; gap: 10px; align-items: center; }
.inline-form .btn { min-height: 38px; white-space: nowrap; }
.block-section,
.column-picker,
.custom-sort-list,
.series-grid section,
.filter-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-muted);
}
.variable-field-shell { position: relative; display: flex; align-items: stretch; min-width: 0; }
.variable-field-shell > .form-control { padding-right: 36px; }
.variable-field-shell > textarea.form-control { min-height: 42px; }
.variable-field-button {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(142, 151, 180, .24);
  border-radius: 8px;
  color: #b9c8ff;
  background: rgba(75, 111, 229, .12);
}
.variable-field-button:hover,
.variable-field-button:focus-visible { color: #fff; border-color: rgba(125, 151, 255, .58); background: rgba(75, 111, 229, .28); }
.variable-field-shell:has(textarea) .variable-field-button { top: 6px; transform: none; }
.variable-field-button .lucide { width: 14px; height: 14px; }
body.variable-modal-open { overflow: hidden; }
body.zip-download-open { overflow: hidden; }
.zip-download-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 12, 25, .78);
  backdrop-filter: blur(6px);
}
.zip-download-backdrop[hidden] { display: none; }
.zip-download-modal {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(142, 151, 180, .22);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  box-shadow: 0 28px 80px rgba(0, 0, 0, .42);
  text-align: center;
}
.zip-download-modal h2 { margin: 4px 0 10px; color: var(--text); font-size: 1.45rem; }
.zip-download-modal p:last-of-type { margin-bottom: 0; color: var(--muted-strong); }
.zip-download-modal .btn { margin-top: 22px; min-width: 120px; }
.zip-download-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  border: 4px solid rgba(73, 194, 223, .18);
  border-top-color: #49c2df;
  border-radius: 50%;
  animation: zip-download-spin .8s linear infinite;
}
@keyframes zip-download-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .zip-download-spinner { animation-duration: 1.8s; }
}
.variable-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1090;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 13, 28, .72);
  backdrop-filter: blur(8px);
}
.variable-modal-backdrop[hidden] { display: none; }
.variable-modal {
  width: min(1080px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid rgba(142, 151, 180, .28);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(36, 46, 75, .98), rgba(24, 31, 52, .98));
  box-shadow: 0 24px 80px rgba(0, 0, 0, .42);
}
.variable-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
}
.variable-modal-header h2 { margin: 0; color: var(--text); font-size: clamp(1.35rem, 2vw, 1.8rem); }
.variable-modal-header small { color: var(--muted); }
.variable-modal-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .75fr); gap: 16px; padding: 18px 24px 24px; }
.variable-builder-card,
.variable-preview-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(30, 38, 61, .78);
  padding: 16px;
}
.variable-builder-stack { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.variable-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.summary-mode-note { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.35; }
.summary-answer-builder { display: flex; flex-direction: column; gap: 10px; }
.summary-answer-note,
.summary-answer-list {
  border: 1px solid rgba(142, 151, 180, .18);
  border-radius: 14px;
  background: rgba(20, 27, 45, .58);
  padding: 12px;
}
.summary-answer-note { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.summary-answer-note span,
.summary-answer-list small { color: var(--muted); }
.summary-answer-list-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.summary-answer-option { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-top: 1px solid rgba(142, 151, 180, .10); }
.summary-answer-option:first-of-type { border-top: 0; }
.summary-answer-option span { min-width: 0; overflow-wrap: anywhere; }
.summary-answer-option small { margin-left: 6px; }
.variable-preview-card { display: flex; flex-direction: column; gap: 16px; }
.variable-preview-card code {
  display: block;
  margin-top: 7px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #dbe5ff;
  background: rgba(11, 18, 32, .76);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.variable-preview-card output {
  display: block;
  min-height: 46px;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid rgba(0, 127, 163, .28);
  border-radius: 12px;
  color: #dff8ff;
  background: rgba(0, 127, 163, .10);
}
.variable-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: auto; }
.custom-variable-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.custom-variable-row { display: grid; grid-template-columns: minmax(120px, .75fr) minmax(180px, 1fr) auto auto; gap: 10px; align-items: center; }
.custom-variable-row code { color: #9db0f2; white-space: nowrap; }
.asset-list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.asset-list-row:last-child { border-bottom: 0; }
.asset-list-row span { min-width: 0; overflow-wrap: anywhere; }
.designed-item-list { display: flex; flex-direction: column; gap: 14px; }
.designed-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(38, 49, 79, .92), rgba(31, 39, 62, .92));
  padding: 12px;
}
.designed-item .designed-item {
  border-color: rgba(142, 151, 180, .13);
  background: rgba(30, 38, 61, .72);
}
.designed-item-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: -2px -2px 12px;
  padding: 10px;
  border: 1px solid rgba(142, 151, 180, .12);
  border-radius: 12px;
  background: rgba(34, 43, 70, .76);
}
.designed-item-header strong { flex: 1 1 170px; min-width: 0; color: var(--text); font-weight: 800; letter-spacing: -.01em; }
.designed-item-actions {
  display: flex;
  flex: 999 1 430px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.designed-item-add { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 8px; align-items: center; }
.designed-item-actions .form-select,
.designed-item-add .form-select { max-width: none; min-width: 0; }
.designed-item-actions .form-select { flex: 1 1 220px; }
.designed-item-actions input[type="number"] { flex: 0 0 96px; max-width: none; text-align: center; }
.designed-item-button-group { display: flex; flex: 1 1 250px; flex-wrap: wrap; justify-content: flex-end; gap: 6px; min-width: 0; }
.designed-item-button-group .btn { flex: 1 1 72px; min-height: 36px; padding: 6px 10px; border-radius: 10px; font-weight: 800; }
.designed-item-button-group .btn .lucide { width: 17px; height: 17px; }
.designed-item-body { display: flex; flex-direction: column; gap: 14px; }
.column-component-settings { margin-bottom: 16px; }
.block-section-body > .form-grid + .designed-item-list,
.designed-item-body > .form-grid + .designed-item-list,
.block-section-body > .form-grid + .nested-block-list { margin-top: 2px; }
.designed-item-add {
  padding: 9px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(34, 43, 70, .48);
}
.designed-item .mini-editor-card,
.designed-item .series-grid section,
.designed-item .filter-editor,
.designed-item .column-picker {
  border-color: rgba(142, 151, 180, .14);
  background: rgba(34, 43, 70, .62);
}

.column-dictionary {
  min-width: 0;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-top: 10px;
  background: var(--panel-muted);
}
.column-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; padding: 11px; border-bottom: 1px solid var(--line); }
.column-row > *,
.column-row strong,
.column-row small { min-width: 0; overflow-wrap: anywhere; }
.column-row:last-child { border-bottom: 0; }
.column-picker-empty { margin: 0; padding: 10px 12px; color: var(--muted); }
.small-list code { color: #9db0f2; }
.split-value-aliases { display: flex; flex-direction: column; gap: 10px; }
.split-value-alias-intro { display: flex; flex-direction: column; gap: 3px; }
.split-value-alias-intro strong { color: var(--text); }
.split-value-alias-intro small { color: var(--muted); }
.split-value-alias-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-muted);
  overflow: hidden;
}
.split-value-alias-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.split-value-alias-header strong { color: var(--text); }
.split-value-alias-header small,
.split-value-row small { color: var(--muted); }
.split-value-list { max-height: 280px; overflow: auto; }
.split-value-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
  gap: 12px;
  align-items: center;
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.split-value-row:last-child { border-bottom: 0; }
.split-value-row span { min-width: 0; }
.split-value-row strong,
.split-value-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.block-list-root { margin-top: 22px; }
.block-list-root .card-heading { margin-bottom: 8px; }
.block-list-root > .form-text { margin-bottom: 14px; }
.block-list { display: flex; flex-direction: column; gap: 10px; margin-top: 0; }
.block-insert-scroll-spacer { flex: 0 0 auto; width: 1px; pointer-events: none; }
.insert-block-line { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.insert-block-rule { flex: 1 1 0; height: 1px; min-width: 24px; background: var(--line); }
.insert-block-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted-strong);
  font-weight: 750;
  padding: 7px 14px;
  white-space: nowrap;
}
.insert-block-toggle:hover { border-color: var(--blue); color: var(--text); background: var(--blue-soft); }
.insert-block-select { flex: 0 1 260px; max-width: 260px; }
.block-card,
.nested-block-card {
  contain: layout paint;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 15px;
  background: var(--panel-raised);
}
.nested-block-list { display: flex; flex-direction: column; gap: 12px; }
.nested-block-card {
  background: linear-gradient(180deg, rgba(38, 49, 79, .9), rgba(31, 39, 62, .9));
}
.nested-block-card .block-target-row { margin-bottom: 12px; }
.nested-block-card .block-actions { flex-wrap: wrap; justify-content: flex-end; }
.nested-insert-block-line { margin: 0; }
.process-flow-editor,
.process-flow-step-list { display: flex; flex-direction: column; gap: 12px; }
.process-flow-step-editor {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .025);
}
.process-flow-step-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.process-flow-step-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.process-flow-step-fields > * { min-width: 0; }
.reference-box-editor,
.reference-box-list,
.reference-connection-editor,
.reference-connection-list { display: flex; flex-direction: column; gap: 12px; }
.reference-box-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .025);
}
.reference-box-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.reference-box-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.reference-box-geometry { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.reference-connection-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.reference-connection-item .btn { min-height: 38px; }
.reference-diagram-preview {
  position: relative;
  width: 100%;
  min-height: 180px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
}
.reference-diagram-preview svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.reference-diagram-preview line { stroke: #0b2a66; stroke-width: 4; stroke-linecap: round; }
.reference-diagram-preview polygon { fill: #0b2a66; }
.reference-preview-box {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 5px;
  border: 2px solid #211a52;
  border-radius: 7px;
  background: #fff;
  color: #211a52;
  text-align: center;
  line-height: 1.12;
}
.reference-preview-box strong { max-width: 100%; overflow: hidden; font-size: clamp(.52rem, .9vw, .75rem); }
.reference-preview-box span { display: -webkit-box; max-width: 100%; overflow: hidden; margin-top: 3px; font-size: clamp(.45rem, .75vw, .65rem); -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.reference-preview-box-soft { background: #f3f8fa; }
.reference-preview-box-accent { background: #dceff7; }
.reference-preview-box-dark { background: #211a52; color: #fff; }
.reference-preview-box-note { align-items: flex-start; border-color: #3fa6d8; text-align: left; }
.block-card.sync-active {
  border-color: rgba(75, 111, 229, .86);
  box-shadow: inset 3px 0 0 var(--blue);
}
.block-card.block-newly-inserted {
  border-color: rgba(73, 194, 223, .95);
  box-shadow: inset 4px 0 0 #49c2df, 0 0 0 3px rgba(73, 194, 223, .12);
}
.block-new-indicator {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 3px 8px;
  border: 1px solid rgba(73, 194, 223, .48);
  border-radius: 999px;
  background: rgba(73, 194, 223, .14);
  color: #a9e8f4;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: middle;
}
.block-header { display: grid; grid-template-columns: auto auto 1fr auto; gap: 10px; align-items: center; margin-bottom: 12px; }
.drag-handle { cursor: grab; color: var(--muted); }
.block-summary { min-width: 0; color: var(--muted); overflow: hidden; overflow-wrap: anywhere; text-overflow: ellipsis; white-space: nowrap; }
.block-actions { display: flex; gap: 5px; }
.block-error { color: #ff8b8b; font-weight: 700; min-height: 20px; margin-top: 4px; }
.block-target-row { margin: 0 0 12px; }
.block-target-row .editor-field { max-width: 520px; }
.block-form { display: flex; flex-direction: column; gap: 12px; }
.block-section { overflow: hidden; }
.block-section-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.block-section-summary::-webkit-details-marker { display: none; }
.block-section[open] .block-section-summary { border-bottom: 1px solid var(--line); }
.block-section-title { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 750; }
.block-section-title .lucide { transition: transform .16s ease; }
.block-section:not([open]) .block-section-title .lucide { transform: rotate(-90deg); }
.block-section-summary small { color: var(--muted); font-weight: 650; line-height: 1.35; }
.block-section-body { padding: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.editor-field { display: flex; flex-direction: column; gap: 6px; }
.editor-check { display: flex; gap: 8px; align-items: center; margin: 0; padding-top: 30px; }
.toggles-grid .editor-check { padding-top: 0; }
.compact-select { max-width: 320px; }

.column-picker { padding: 11px; }
.column-picker-toolbar { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-bottom: 10px; }
.column-picker-options { display: flex; flex-direction: column; gap: 7px; max-height: 320px; overflow: auto; padding-right: 4px; }
.column-picker-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-weight: 500;
}
.column-picker-option:hover { border-color: var(--line-strong); background: rgba(142, 151, 180, .07); }
.column-picker-option strong { display: block; overflow-wrap: anywhere; line-height: 1.25; color: var(--text); }
.custom-sort-list { display: flex; flex-direction: column; gap: 7px; padding: 10px; }
.custom-sort-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  cursor: grab;
  font-weight: 700;
}
.custom-sort-item:hover { border-color: var(--line-strong); background: rgba(142, 151, 180, .07); }
.custom-sort-item:active { cursor: grabbing; }
.custom-sort-actions { display: flex; gap: 5px; }
.custom-sort-empty { padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); background: rgba(255, 255, 255, .025); }
.series-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.outcome-card-editor-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.series-grid section { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 13px; }
.series-grid h3 { margin-bottom: 0; color: var(--text); }
.sub-editor-heading { margin: 4px 0 -2px; color: var(--text); font-size: .95rem; font-weight: 750; }
.metric-card-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric-card-editor-grid.single,
.component-editor-grid { grid-template-columns: minmax(0, 1fr); }
.metric-card-editor-grid.single .mini-editor-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.mini-editor-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: transparent;
}
.block-section-body > .form-grid + .metric-card-editor-grid,
.block-section-body > .form-grid + .outcome-card-editor-grid { margin-top: 14px; }
.filter-editor { padding: 13px; container-type: inline-size; }
.filter-editor-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.filter-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.filter-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(130px, .8fr) minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.filter-row > * { min-width: 0; }
.filter-row .btn { justify-content: center; white-space: nowrap; }
.filter-no-value { padding: 7px 0; }
.between-values { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.graph-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.graph-analysis { display: flex; gap: 12px; }
.pie-chart-options {
  min-width: 0;
  margin: 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .025);
}
.pie-chart-options legend {
  float: none;
  width: auto;
  margin: 0 0 10px;
  padding: 0;
  color: var(--text);
  font-size: .9rem;
  font-weight: 800;
}
.pie-chart-options .editor-check { padding-top: 0; }
.pagebreak-editor { border: 1px dashed var(--line-strong); border-radius: var(--radius-md); padding: 12px; text-align: center; }

@container (max-width: 640px) {
  .filter-row { grid-template-columns: minmax(0, 1fr) auto; }
}

@container (max-width: 520px) {
  .filter-row { grid-template-columns: 1fr; }
  .filter-row .btn { width: 100%; }
}

@media (max-width: 1280px) {
  .draft-toolbar { align-items: flex-start; flex-direction: column; }
  .draft-toolbar-actions { justify-content: flex-start; width: 100%; }
  .draft-search { width: min(420px, 100%); }
}

@media (max-width: 1100px) {
  .app-shell { padding: 28px 22px 42px; }
  .editor-shell { grid-template-columns: 1fr; height: auto; }
  .editor-resize-handle { display: none; }
  .preview-pane { position: static; overflow: auto; }
  .pdf-sync-marker { display: none; }
  .pdf-viewer-shell { flex-basis: auto; min-height: 540px; }
}

@media (max-width: 760px) {
  body:not(.login-page) { padding-left: 0; }
  .app-sidebar {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    width: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-nav { flex-direction: row; gap: 10px; margin-top: 0; }
  .sidebar-spacer { display: none; }
  .sidebar-logout-form { width: auto; margin-left: auto; }
  .draft-toolbar-actions,
  .preview-toolbar,
  .inline-form,
  .designed-item-header,
  .designed-item-actions,
  .designed-item-add { align-items: stretch; flex-direction: column; }
  .designed-item-header,
  .designed-item-actions,
  .designed-item-add { grid-template-columns: 1fr; }
  .designed-item-button-group { justify-content: stretch; }
  .designed-item-button-group .btn { flex: 1 1 0; }
  .editor-footer { left: 0; }
  .editor-footer-inner { align-items: stretch; flex-direction: column; gap: 8px; padding: 8px 16px; }
  .editor-footer .btn-primary { min-height: 44px; border-radius: 8px; }
  .variable-modal-backdrop { align-items: stretch; padding: 10px; }
  .variable-modal { max-height: calc(100vh - 20px); border-radius: 18px; }
  .variable-modal-header { padding: 18px; }
  .variable-modal-grid,
  .variable-summary-grid { grid-template-columns: 1fr; }
  .variable-modal-grid { padding: 14px 18px 18px; }
  .variable-modal-actions { flex-direction: column-reverse; }
  .variable-modal-actions .btn { width: 100%; }
  .column-row,
  .split-value-row,
  .custom-variable-row,
  .block-header,
  .block-target-row,
  .form-grid,
  .series-grid,
  .metric-card-editor-grid,
  .metric-card-editor-grid.single .mini-editor-card,
  .filter-row { grid-template-columns: 1fr; }
  .block-summary { overflow: visible; text-overflow: clip; white-space: normal; }
  .block-target-row { margin-left: 0; max-width: none; }
  .block-actions { flex-wrap: wrap; }
  .process-flow-step-header,
  .process-flow-step-actions,
  .reference-box-header,
  .reference-box-actions { align-items: stretch; flex-direction: column; }
  .process-flow-step-actions .btn,
  .reference-box-actions .btn { width: 100%; }
  .reference-box-geometry,
  .reference-connection-item { grid-template-columns: 1fr; }
  .reference-connection-item .btn { width: 100%; }
  .insert-block-line { gap: 8px; }
  .insert-block-rule { min-width: 12px; }
  .insert-block-select { max-width: min(260px, 60vw); }
}
