/* ==========================================================================
   PivotIQ -- design system v3
   Sora (display) / Inter (body) / JetBrains Mono (data), indigo + teal
   accents on a warm neutral base, dark stepper rail for visual hierarchy.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Color -- warm off-white base, Figma-blue primary accent */
  --bg: #f7f6f2;
  --bg-grad: #f7f6f2;
  --surface: #ffffff;
  --surface-sunken: #f6f6f4;
  --border: #e8e6df;
  --border-strong: #d8d6cd;

  --text-hi: #1c1d21;
  --text-mid: #63666f;
  --text-low: #94969e;

  --accent: #2f5eff;
  --accent-hover: #2148d6;
  --accent-soft: #eaf0ff;
  --accent-border: #c7d6ff;
  --accent-ink: #1d3fc7;

  --teal: #0b9c93;
  --teal-soft: #e4f8f5;
  --teal-border: #b9e9e2;

  --green: #12805a;
  --green-soft: #e7f8ef;
  --green-border: #bfe8d3;

  --red: #d1383a;
  --red-soft: #fdecec;
  --red-border: #f6c9ca;

  --blue: #2f5eff;
  --blue-soft: #eaf0ff;
  --blue-border: #c7d6ff;

  --amber: #b6790a;
  --amber-soft: #fdf3e0;
  --amber-border: #f3d99a;

  /* exact excel header blue, used for the in-app table viewer so it visually
     matches the downloaded workbook */
  --xl-header: #0070C0;
  --xl-header-ink: #ffffff;

  --rail-bg: #ffffff;
  --rail-border: var(--border);
  --rail-text: var(--text-mid);
  --rail-text-hi: var(--text-hi);

  --shadow-xs: 0 1px 2px rgba(28, 29, 33, 0.05);
  --shadow-sm: 0 2px 10px rgba(28, 29, 33, 0.06);
  --shadow-md: 0 10px 28px rgba(28, 29, 33, 0.08);
  --shadow-lg: 0 20px 50px rgba(28, 29, 33, 0.14);

  /* Type -- single grotesk family, like the source design */
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Inter', ui-monospace, 'SF Mono', monospace;

  /* Shape */
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;

  --actionbar-h: 76px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text-hi);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body { min-height: 100vh; }

h1, h2, h3 { font-family: var(--font-display); }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

a { color: var(--accent); }

button { font-family: inherit; }

img, svg { max-width: 100%; }

svg { display: block; }

/* --------------------------------------------------------------------
   App shell: fixed left sidebar + scrollable content column
   -------------------------------------------------------------------- */

.app-shell-outer {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.app-sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px 20px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

@media (max-width: 899px) { .app-sidebar { display: none; } }

.app-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
}

.app-sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.app-sidebar-user-text { display: flex; flex-direction: column; min-width: 0; }
.app-sidebar-user-name { font-weight: 600; font-size: 13px; color: var(--text-hi); }
.app-sidebar-user-email { font-size: 11px; color: var(--text-low); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-sidebar-nav { list-style: none; margin: 0 0 4px; padding: 0; }
.app-sidebar-nav-bottom { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }

.app-sidebar-nav li { margin-bottom: 2px; }

.app-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}

.app-sidebar-nav a svg { flex-shrink: 0; opacity: 0.75; }

.app-sidebar-nav a:hover { background: var(--surface-sunken); color: var(--text-hi); }

.app-sidebar-nav a.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.app-sidebar-nav a.is-active svg { opacity: 1; }

.app-content { flex: 1 1 auto; min-width: 0; }

/* --------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.brand-crumb {
  font-size: 12.5px;
  color: var(--text-low);
  font-weight: 500;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.015em;
  color: var(--text-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 13px;
  color: var(--text-low);
  display: none;
  white-space: nowrap;
}

@media (min-width: 760px) {
  .brand-sub { display: inline; }
}

.topbar-actions { display: flex; gap: 10px; flex-shrink: 0; align-items: center; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-mid);
  padding: 8px 14px;
  border-radius: var(--radius-s);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: border-color .15s ease, color .15s ease, background .15s ease, transform .1s ease;
}
.ghost-btn:hover { border-color: var(--accent-border); color: var(--accent-ink); background: var(--accent-soft); }
.ghost-btn:active { transform: translateY(1px); }

/* --------------------------------------------------------------------
   Mobile stepper (horizontal, shown < 900px)
   -------------------------------------------------------------------- */

.mobile-steps {
  display: none;
  gap: 6px;
  padding: 14px 20px 4px;
  max-width: 900px;
  margin: 0 auto;
}
@media (max-width: 899px) {
  .mobile-steps { display: flex; }
}
.mobile-steps .dot {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}
.mobile-steps .dot.is-done { background: var(--teal); }
.mobile-steps .dot.is-active { background: var(--accent); }
.mobile-step-label {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 10px;
  font-size: 12.5px;
  color: var(--text-mid);
  font-weight: 600;
}
.mobile-step-label span { color: var(--text-low); font-family: var(--font-mono); font-size: 11.5px; margin-right: 4px; font-weight: 600; }

/* --------------------------------------------------------------------
   Shell layout: stepper rail + main panel
   -------------------------------------------------------------------- */

.shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 22px 32px calc(var(--actionbar-h) + 40px);
}

@media (max-width: 899px) {
  .shell {
    padding: 8px 20px calc(var(--actionbar-h) + 32px);
  }
}

/* Horizontal stepper strip, sits under the header like a tab row */
.rail {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px 14px;
}
@media (max-width: 899px) { .rail { display: none; } }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: flex-start;
  gap: 0;
  max-width: 1160px;
  margin: 0 auto;
  overflow-x: auto;
}

.step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--rail-text);
  padding: 4px 20px 4px 0;
  flex-shrink: 0;
}
.step:not(:last-child)::after {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--border-strong);
  margin: 0 2px 0 4px;
  flex-shrink: 0;
}

.step-icon {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface-sunken);
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-low);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  transition: all .18s ease;
  z-index: 1;
}

.step-body { min-width: 0; padding-top: 0; display: flex; }

.step-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-mid);
  display: block;
  white-space: nowrap;
  font-family: var(--font-display);
  transition: color .18s ease;
}

.step-desc { display: none; }

.step.is-active .step-icon {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.step.is-active .step-title { color: var(--accent); }

.step.is-done .step-icon {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}
.step.is-done .step-title { color: var(--text-hi); }

/* --------------------------------------------------------------------
   Panels
   -------------------------------------------------------------------- */

.panel {
  display: none;
  min-width: 0;
}
.panel.is-visible { display: block; }
/* Only animate the first time a panel appears in a session step change — not on every action */
.panel.is-visible.panel-enter {
  animation: rise .28s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Soft loading on sheet view — avoid blanking the whole page */
.sheet-view-body.is-refreshing {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity .12s ease;
}

.panel-head { margin-bottom: 24px; }

.panel-eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
  font-weight: 700;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  margin: 0 0 9px;
  letter-spacing: -0.015em;
  color: var(--text-hi);
}

.panel-lede {
  color: var(--text-mid);
  font-size: 14.5px;
  line-height: 1.65;
  max-width: 66ch;
  margin: 0;
}

/* --------------------------------------------------------------------
   Cards / dropzones
   -------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 24px;
  box-shadow: var(--shadow-xs);
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 22px;
}
@media (max-width: 640px) { .upload-grid { grid-template-columns: 1fr; } }

.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-m);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
  background: var(--surface-sunken);
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.has-file {
  border-style: solid;
  border-color: var(--teal-border);
  background: var(--teal-soft);
}
.dropzone.has-error {
  border-style: solid;
  border-color: var(--red-border);
  background: var(--red-soft);
}

.dz-icon {
  width: 40px; height: 40px;
  margin: 0 auto 12px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}
.dropzone.has-file .dz-icon { color: var(--teal); border-color: var(--teal-border); }

.dz-label {
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 4px;
  font-family: var(--font-display);
}
.dz-hint {
  font-size: 12.5px;
  color: var(--text-low);
}
.dz-filename {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-hi);
  margin-top: 8px;
  word-break: break-all;
}
.dz-error-msg {
  font-size: 12px;
  color: var(--red);
  margin-top: 8px;
  font-weight: 500;
}
input[type=file] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0 !important;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.field-label {
  font-size: 13px;
  color: var(--text-mid);
  font-weight: 600;
}
.field-label small { display:block; color: var(--text-low); font-size: 11.5px; margin-top: 2px; font-weight: 400; }

select, .text-input {
  background: var(--surface);
  color: var(--text-hi);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  padding: 9px 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12.5px;
  min-width: 180px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select:focus, .text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* --------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------- */

.btn {
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-display);
  padding: 11px 22px;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease, opacity .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(47, 94, 255, 0.22);
}
.btn-primary:not(:disabled):hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(47, 94, 255, 0.3); }

.btn-secondary { background: var(--surface); color: var(--text-hi); border-color: var(--border-strong); }
.btn-secondary:not(:disabled):hover { border-color: var(--accent-border); background: var(--accent-soft); color: var(--accent-ink); }

.btn-danger {
  background: var(--surface);
  color: #b91c1c;
  border-color: #fecaca;
}
.btn-danger:not(:disabled):hover {
  background: #fef2f2;
  border-color: #f87171;
  color: #991b1b;
}

.btn-ghost-small {
  background: var(--surface);
  color: var(--text-mid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  padding: 7px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s ease;
}
.btn-ghost-small:hover { border-color: var(--accent-border); color: var(--accent-ink); background: var(--accent-soft); }

.btn-teal-small {
  background: var(--teal-soft);
  color: var(--teal);
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-s);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12.5px;
  padding: 7px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s ease;
}
.btn-teal-small:hover { background: var(--teal); color: #fff; border-color: var(--teal); }

.spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: currentColor;
  animation: spin .7s linear infinite;
  display: none;
}
.btn-secondary .spinner { border-color: rgba(21,22,43,0.15); }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-text-idle { display: none; }
.spinner-dark { border-color: rgba(21,22,43,0.15); border-top-color: var(--accent); display: inline-block; margin-right: 8px; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------
   Fixed action bar -- always visible, never lost on scroll/zoom
   -------------------------------------------------------------------- */

.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 40;
  box-shadow: 0 -8px 26px rgba(21,22,43,0.07);
}
.action-bar-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--actionbar-h);
}
@media (max-width: 899px) {
  .action-bar-inner { padding: 12px 16px; }
}
.action-bar-spacer { flex: 1; }
.action-bar-hint {
  font-size: 12.5px;
  color: var(--text-low);
  margin-right: auto;
  display: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(360px, 40vw);
}
@media (min-width: 640px) {
  .action-bar-hint { display: block; }
}
.action-bar #bar-back { display: none; }
.action-bar.has-back #bar-back { display: inline-flex; }
.action-bar.hidden { display: none; }

/* Comparison footer download dropdown (fixed so it escapes footer overflow) */
.q-download-wrap { position: relative; display: inline-flex; }
.q-download-menu {
  display: none;
  position: fixed;
  z-index: 200;
  min-width: 220px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  padding: 6px;
  white-space: normal;
}
.q-download-menu.is-open { display: block; }
.q-download-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #0f172a;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
.q-download-menu button:hover {
  background: #f1f5f9;
}


/* --------------------------------------------------------------------
   Stat strip (record/column counts)
   -------------------------------------------------------------------- */

.stat-strip {
  display: flex;
  gap: 14px;
  margin: 18px 0 26px;
  flex-wrap: wrap;
}
.stat {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 12px 18px;
  box-shadow: var(--shadow-xs);
  flex: 1 1 160px;
}
.stat-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat .n {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
  color: var(--text-hi);
  display: block;
  line-height: 1.1;
}
.stat .l {
  font-size: 11px;
  color: var(--text-low);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  display: block;
}

/* --------------------------------------------------------------------
   Classification review: badges + column list
   -------------------------------------------------------------------- */

.review-section { margin-bottom: 18px; }

.review-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.badge-tag {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge-tag.keep { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.badge-tag.drop { color: var(--red); background: var(--red-soft); border-color: var(--red-border); }

.review-count { font-size: 12px; color: var(--text-low); font-family: var(--font-mono); font-weight: 500; }

.col-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--surface);
}
.col-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .12s ease;
}
.col-row:last-child { border-bottom: none; }
.col-row:hover { background: var(--surface-sunken); }

.col-main { min-width: 0; }
.col-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-hi);
  overflow-wrap: break-word;
}
.col-reason {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-low);
  margin-top: 2px;
}
.col-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-low);
  flex-shrink: 0;
  white-space: nowrap;
}
.empty-note {
  font-size: 12.5px;
  color: var(--text-low);
  padding: 14px;
  font-style: italic;
}

/* --------------------------------------------------------------------
   Configure step: base column choice
   -------------------------------------------------------------------- */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.switch {
  position: relative;
  width: 42px; height: 24px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s ease, border-color .15s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-low);
  transition: transform .15s ease, background .15s ease;
}
.switch.is-on { background: var(--accent); border-color: transparent; }
.switch.is-on::after { transform: translateX(18px); background: #fff; }

.base-select {
  min-width: 260px;
  max-width: 100%;
}
.base-select:invalid, .base-select option[value=""]:checked {
  color: var(--text-low);
}

.per-table-list { margin-top: 18px; }
.per-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.per-table-row:last-child { border-bottom: none; }
.per-table-name {
  font-size: 13.5px;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: break-word;
  flex: 1 1 200px;
}
.per-table-name .n { color: var(--accent); font-family: var(--font-mono); font-size: 11.5px; margin-right: 6px; font-weight: 700; }

/* --------------------------------------------------------------------
   Generate results
   -------------------------------------------------------------------- */

.result-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px;
  background: linear-gradient(135deg, var(--teal-soft) 0%, var(--accent-soft) 130%);
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-l);
  margin-bottom: 24px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-xs);
}
.result-hero-icon {
  width: 50px; height: 50px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--teal-border);
  color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}
.result-hero-title { font-family: var(--font-display); font-weight: 700; font-size: 17.5px; margin: 0 0 4px; overflow-wrap: break-word; }
.result-hero-sub { font-size: 13px; color: var(--text-mid); margin: 0; }

.view-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  margin-bottom: 16px;
}
.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-mid);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: calc(var(--radius-m) - 2px);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.view-toggle-btn:hover { color: var(--text-hi); }
.view-toggle-btn.is-active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--shadow-xs);
}

.sheet-view { margin-bottom: 8px; }
.sheet-view-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--text-mid);
  font-size: 13px;
}
.sheet-view-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.sheet-view-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 18px;
}
.sheet-view-section-body > .sheet-view-table:last-of-type {
  margin-bottom: 8px;
}
.sheet-view-table-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.sheet-view-table-title {
  font-size: 13.5px;
  font-weight: 700;
  margin: 0;
}
.sheet-view-table-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-low);
  white-space: nowrap;
}
.sheet-view-table .table-scroll {
  border: none;
  border-radius: 0;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 15px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.table-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.table-card-head { display: flex; align-items: flex-start; gap: 8px; }
.table-card-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 3px 6px;
  flex-shrink: 0;
  margin-top: 1px;
}
.table-card-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  line-height: 1.35;
  font-family: var(--font-body);
}
.table-card-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-low);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.table-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}
.table-card-actions .btn-teal-small,
.table-card-actions .btn-ghost-small { flex: 1; justify-content: center; }

.text-link-btn {
  background: none;
  border: none;
  color: var(--text-mid);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.text-link-btn:hover { color: var(--accent-ink); }


/* --------------------------------------------------------------------
   Keep / Drop shift buttons
   -------------------------------------------------------------------- */

.col-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* "Suggested keep / Suggested drop" AI-suggestion pill */
.col-suggest-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.col-suggest-badge.is-keep { background: var(--green-soft); color: var(--green); border-color: var(--green-border); }
.col-suggest-badge.is-drop { background: var(--red-soft); color: var(--red); border-color: var(--red-border); }

/* Keep / drop decision icon buttons ("your decision" column) */
.col-decision {
  display: flex;
  align-items: center;
  gap: 6px;
}

.decision-btn {
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-low);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .15s ease;
  padding: 0;
}
.decision-btn:hover { border-color: var(--border-strong); background: var(--surface-sunken); }

.decision-keep.is-chosen {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.decision-drop.is-chosen {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* --------------------------------------------------------------------
   Aggregate step
   -------------------------------------------------------------------- */

.agg-card { padding: 0; overflow: hidden; }

.agg-table-head {
  display: flex;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.agg-list { display: flex; flex-direction: column; }

.agg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.agg-row:last-child { border-bottom: none; }

.agg-row-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-hi);
}

.agg-btn-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  overflow: hidden;
  flex-shrink: 0;
}

.agg-btn {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border-strong);
  padding: 7px 14px;
  cursor: pointer;
  transition: all .15s ease;
}
.agg-btn:last-child { border-right: none; }
.agg-btn:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text-hi); }
.agg-btn:disabled { color: var(--text-low); opacity: 0.5; cursor: not-allowed; }

.agg-btn.is-active {
  background: var(--accent);
  color: #fff;
}

/* --------------------------------------------------------------------
   In-app table viewer modal
   -------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 32, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }

.modal-panel {
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 880px;
  max-height: min(720px, 88vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(14px) scale(.98);
  transition: transform .2s cubic-bezier(.2,.8,.2,1);
}
.modal-overlay.is-open .modal-panel { transform: translateY(0) scale(1); }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--teal-soft) 160%);
  flex-shrink: 0;
}
.modal-head-text { min-width: 0; }
.modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text-hi);
  overflow-wrap: break-word;
}
.modal-sub {
  font-size: 12.5px;
  color: var(--text-mid);
  margin: 0;
  font-family: var(--font-mono);
}
.modal-head-actions { display: flex; gap: 8px; flex-shrink: 0; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-mid);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .15s ease;
}
.icon-btn:hover { border-color: var(--accent-border); color: var(--accent-ink); background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn.modal-close:hover { border-color: var(--red-border); color: var(--red); background: var(--red-soft); }

.modal-body {
  padding: 20px 22px 24px;
  overflow: auto;
  flex: 1;
}
.modal-loading {
  display: flex;
  align-items: center;
  color: var(--text-mid);
  font-size: 13.5px;
  padding: 30px 4px;
}

.table-scroll { overflow: auto; border-radius: var(--radius-m); border: 1px solid var(--border); }

.xl-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  font-family: var(--font-body);
}
.xl-table th, .xl-table td {
  border: 1px solid var(--border);
  padding: 9px 13px;
  white-space: nowrap;
}
.xl-table thead th {
  background: var(--xl-header);
  color: var(--xl-header-ink);
  font-weight: 700;
  font-family: var(--font-display);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
}
.xl-table thead th:first-child {
  text-align: left;
  z-index: 3;
}
.xl-table tbody td { text-align: center; color: var(--text-hi); }
.xl-table tbody td:first-child {
  text-align: left;
  font-weight: 600;
  background: var(--surface-sunken);
  position: sticky;
  left: 0;
}
.xl-table tbody tr:nth-child(even) td { background: #fafafe; }
.xl-table tbody tr:nth-child(even) td:first-child { background: #f2f2fb; }
.xl-table tbody tr.xl-overall-row td {
  background: var(--xl-header);
  color: var(--xl-header-ink);
  font-weight: 700;
}
.xl-table tbody tr.xl-overall-row td:first-child { background: var(--xl-header); }

/* --------------------------------------------------------------------
   Toast / errors
   -------------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: calc(var(--actionbar-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text-hi);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-m);
  font-size: 13px;
  font-weight: 500;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 150;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

.hint-inline {
  font-size: 12px;
  color: var(--text-low);
  margin-top: 12px;
  display: flex;
  align-items: center;
}
.hint-inline strong { color: var(--text-mid); }

/* --------------------------------------------------------------------
   Small screens polish
   -------------------------------------------------------------------- */

@media (max-width: 480px) {
  .panel-title { font-size: 21px; }
  .card { padding: 16px; }
  .result-hero { padding: 18px; }
  .stat-strip { gap: 10px; }
  .stat { padding: 10px 14px; }
  .modal-overlay { padding: 10px; }
  .modal-head { padding: 16px; }
  .modal-body { padding: 14px; }
}

.brand-version {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 2px 7px;
  margin-left: 6px;
  letter-spacing: 0.04em;
}

.xl-table td.xl-editable {
  cursor: text; outline: none;
  transition: background .12s ease, box-shadow .12s ease;
}
.xl-table td.xl-editable:hover {
  background: #fdf3e0 !important;
  box-shadow: inset 0 0 0 1.5px #f3d99a;
}
.xl-table td.xl-editable:focus {
  background: #fffbea !important;
  box-shadow: inset 0 0 0 2px #b6790a;
}
.xl-table td.xl-editable.is-saving { opacity: 0.55; }
.sheet-view-section { margin-bottom: 28px; }
.sheet-view-section-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #e6e6f2;
}
.sheet-view-section-badge {
  font-family: var(--font-body); font-weight: 700; font-size: 12px;
  background: var(--accent); color: #fff; border-radius: 8px; padding: 4px 10px;
}
.sheet-view-section-title { font-size: 16px; font-weight: 700; margin: 0; flex: 1; }
.sheet-view-section-count { font-size: 11.5px; color: var(--text-low); }

/* Pivot cell → dataset drill-down */
.xl-table td.xl-drill {
  cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease;
}
.xl-table td.xl-drill:hover {
  background: #e9f3fc !important;
  box-shadow: inset 0 0 0 1.5px #bfdcf5;
  text-decoration: underline;
}

.modal-panel-wide { max-width: 980px; }

.drill-table td.drill-cell {
  cursor: text;
  min-width: 72px;
}
.drill-table td.drill-cell:focus {
  background: #fffbea !important;
  box-shadow: inset 0 0 0 2px #b6790a;
  outline: none;
}
.drill-idx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-low);
  background: var(--surface-sunken);
}
.drill-hint {
  font-size: 12.5px;
  color: var(--text-mid);
  margin: 14px 0 0;
}

/* Section navigation + accordion */
.section-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 18px; padding: 12px 14px;
  background: var(--surface-sunken, #f4f5fb);
  border: 1px solid var(--border, #e6e6f2);
  border-radius: 12px;
}
.section-nav-label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-low, #9193a8); margin-right: 4px;
}
.section-nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 6px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border, #d8d9e6); background: #fff;
  color: var(--text-mid, #4a4c63); transition: all .15s ease;
}
.section-nav-btn:hover { border-color: var(--accent, #5b3df0); color: var(--accent, #5b3df0); }
.section-nav-badge {
  font-family: var(--font-mono, monospace); font-size: 11px; font-weight: 700;
  background: var(--accent, #5b3df0); color: #fff; border-radius: 6px; padding: 2px 7px;
}
.section-nav-count {
  font-family: var(--font-mono, monospace); font-size: 11px; color: var(--text-low, #9193a8);
}
.section-nav-all { background: transparent; }
.empty-sections-nav-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sheet-view-section { margin-bottom: 12px; border: 1px solid var(--border, #e6e6f2); border-radius: 12px; overflow: hidden; }
.sheet-view-section-head.section-toggle {
  width: 100%; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0; padding: 12px 14px; border: none; background: #fafbff;
  cursor: pointer; text-align: left; font: inherit;
}
.sheet-view-section-head.section-toggle:hover { background: #f0f2fb; }
.section-chevron {
  width: 10px; height: 10px; border-right: 2px solid #6b6d82; border-bottom: 2px solid #6b6d82;
  transform: rotate(-45deg); transition: transform .2s ease; flex-shrink: 0;
}
.sheet-view-section.is-open .section-chevron { transform: rotate(45deg); }
.sheet-view-section-body {
  display: none; padding: 4px 14px 16px;
}
.sheet-view-section.is-open .sheet-view-section-body { display: block; }

/* Dictionary dropdowns in drill-down editor */
.drill-select {
  width: 100%; min-width: 120px; max-width: 260px;
  font-family: inherit; font-size: 12.5px;
  padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--border, #d8d9e6); background: #fff;
  cursor: pointer;
}
.drill-select:focus {
  outline: none; border-color: var(--accent, #5b3df0);
  box-shadow: 0 0 0 3px rgba(47, 94, 255, 0.15);
}
.th-choice-hint { font-size: 10px; opacity: 0.7; }
.drill-cell-wrap { padding: 4px 6px !important; }

/* Inline rename (title / headers / rows / sections) */
.xl-rename, .xl-rename-section {
  cursor: text;
  outline: none;
  border-radius: 4px;
  transition: background .12s ease, box-shadow .12s ease;
}
.xl-rename:hover, .xl-rename-section:hover {
  background: #fdf3e0;
  box-shadow: inset 0 0 0 1px #f3d99a;
}
.xl-rename:focus, .xl-rename-section:focus {
  background: #fffbea;
  box-shadow: inset 0 0 0 2px #b6790a;
}
.xl-rename.is-saving { opacity: 0.55; }
th.xl-rename { font-weight: 700; }
.sheet-view-table-title.xl-rename { display: inline-block; min-width: 120px; padding: 2px 6px; }
#modalTitle.xl-rename { cursor: text; }

/* Aggregation dropdown on Keep list */
.agg-select {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border, #d8d9e6);
  background: #fff;
  color: var(--text-mid, #4a4c63);
  cursor: pointer;
  max-width: 110px;
}
.agg-select:hover, .agg-select:focus {
  border-color: var(--accent, #5b3df0);
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 94, 255, 0.12);
}

/* API data source panel */
#api-source-panel {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 16px;
  border: 1px dashed var(--border, #d8d9e6);
  border-radius: 14px;
  background: var(--surface-sunken, #f7f8fc);
}
.api-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0;
}
.api-textarea {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  min-height: 52px;
  resize: vertical;
}
.api-status {
  font-size: 12.5px;
  color: var(--text-mid, #4a4c63);
  margin: 8px 0 0;
}
.agg-select-result { max-width: 120px; }
#modal-agg-select { margin-left: 8px; vertical-align: middle; }

.sheet-view-table-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sheet-view-table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.agg-inline-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-low, #9193a8);
}
.agg-select-sheet { max-width: 120px; }

.sheet-view-section-initials {
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  font-size: 12px;
  color: var(--accent, #5b3df0);
  margin-right: 4px;
}
.btn-move-section {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #d8d9e6);
  background: #fff;
  color: var(--text-mid, #4a4c63);
  cursor: pointer;
}
.btn-move-section:hover {
  border-color: var(--accent, #5b3df0);
  color: var(--accent, #5b3df0);
}
.move-section-menu {
  position: fixed;
  z-index: 10050;
  min-width: 160px;
  max-width: 220px;
  max-height: min(360px, 70vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border, #e6e6f2);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(20, 20, 40, 0.18);
  padding: 6px 0;
}
.move-section-menu-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-low, #9193a8);
  margin: 6px 14px 8px;
  flex: 0 0 auto;
}
.move-section-menu-list {
  overflow: auto;
  max-height: min(300px, 60vh);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.move-section-item {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text, #1e1f36);
  white-space: nowrap;
}
.move-section-item:hover {
  background: #f1f5f9;
  color: var(--accent, #5b3df0);
}
.section-nav-text {
  font-size: 12px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Number / Percent / Both segmented control */
.value-mode-toggle {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  background: #eef0f6;
  padding: 3px;
  gap: 2px;
  border: 1px solid #e2e5ef;
}
.vmode-btn {
  min-width: 36px;
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #6b6f85;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.vmode-btn:hover {
  color: #3d4160;
}
.vmode-btn.is-active {
  background: #3b6ef5;
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 110, 245, 0.35);
}

.section-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: default;
}
.section-nav-badge.section-nav-jump,
.section-nav-count.section-nav-jump {
  cursor: pointer;
}
.section-nav-initials {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent, #5b3df0);
}
.section-nav-text.xl-rename-section {
  cursor: text;
  outline: none;
  border-radius: 4px;
  padding: 1px 4px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.section-nav-text.xl-rename-section:hover,
.section-nav-text.xl-rename-section:focus {
  background: rgba(47, 94, 255, 0.08);
  overflow: visible;
  white-space: normal;
  max-width: 240px;
}

.btn-remove-table,
.btn-remove-section {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid #f0c4c4;
  background: #fff5f5;
  color: #c0392b;
  cursor: pointer;
}
.btn-remove-table:hover,
.btn-remove-section:hover {
  background: #c0392b;
  color: #fff;
  border-color: #c0392b;
}
.btn-remove-section {
  margin-left: 8px;
  flex-shrink: 0;
}
.sheet-view-section-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.quarter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.quarter-card {
  border: 1px solid var(--border, #e6e6f2);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.quarter-card-title {
  font-weight: 700;
  margin: 0 0 10px;
}
.quarter-file-name {
  font-size: 12.5px;
  color: var(--text-mid, #4a4c63);
  margin: 8px 0 0;
  word-break: break-all;
}

/* --------------------------------------------------------------------
   Quarter compare / Roster combine: dropzone + file-card list layout
   -------------------------------------------------------------------- */

.panel-head--with-badge {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.panel-head--with-badge .panel-head-main { flex: 1 1 380px; min-width: 0; }

.count-badge {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1px solid var(--accent-border);
  white-space: nowrap;
  margin-top: 2px;
}

.uploader-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: stretch;
  margin-top: 18px;
}
@media (max-width: 760px) {
  .uploader-shell { grid-template-columns: 1fr; }
}

.uploader-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 168px;
  padding: 22px 16px;
}
.uploader-dropzone .dz-icon { margin-bottom: 10px; }
.uploader-dropzone .dz-label { margin-bottom: 2px; }

.file-card-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-content: start;
}
@media (max-width: 560px) {
  .file-card-list { grid-template-columns: 1fr; }
}
.file-card-list--roster { grid-template-columns: 1fr; }

.file-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border, #e6e6f2);
  border-radius: 12px;
  padding: 12px 40px 12px 12px;
  background: var(--surface-sunken, #f6f6f4);
  transition: border-color .15s ease, background .15s ease;
  min-height: 66px;
}
.file-card.is-filled {
  border-color: var(--accent-border);
  background: var(--surface, #fff);
  box-shadow: var(--shadow-xs);
}

.file-card-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 800;
  color: #fff;
  background: var(--text-low, #94969e);
}
.file-card-icon--q1 { background: var(--accent); }
.file-card-icon--q2 { background: var(--text-hi, #1c1d21); }
.file-card-icon--q3 { background: var(--green); }
.file-card-icon--q4 { background: #7c3aed; }
.file-card-icon--q5 { background: #e11d48; }
.file-card-icon--q6 { background: #0891b2; }
.file-card-icon--q7 { background: #ca8a04; }
.file-card-icon--q8 { background: #4338ca; }
.file-card-icon--q9 { background: #16a34a; }
.file-card-icon--q10 { background: #db2777; }
.file-card-icon--roster { background: var(--teal); }
.q-card-hidden { display: none !important; }

.file-card-body { min-width: 0; flex: 1; }

.file-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-hi);
  margin: 0;
  word-break: break-word;
  line-height: 1.35;
}
.file-card.is-filled .file-card-name { font-family: var(--font-mono); font-size: 12.5px; }

.file-card-sub {
  font-size: 11.5px;
  color: var(--text-low);
  margin: 3px 0 0;
}

.file-card-meta {
  font-size: 11px;
  color: var(--text-low);
  margin: 3px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card-sheet.file-card-sheet { margin-top: 8px; font-size: 12px; }

.file-card-choose {
  display: none;
  margin-top: 8px;
}
.file-card:not(.is-filled) .file-card-choose {
  display: inline-flex;
  font-size: 11.5px;
  padding: 5px 10px;
}

.file-card-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface, #fff);
  color: var(--text-low);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.file-card-remove:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.file-card-order {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.file-card-order .order-index {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-low);
  font-weight: 600;
}
.order-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface, #fff);
  color: var(--text-mid);
  cursor: pointer;
}
.order-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.order-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Roster header pills (base column / youth age band) */
.roster-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}
.roster-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: var(--shadow-xs);
}
.roster-pill-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-low);
  font-weight: 700;
}
.roster-pill-select {
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-hi);
  padding: 0;
  min-width: 130px;
}
.roster-pill-select:focus { outline: none; }
.roster-pill-range {
  display: flex;
  align-items: center;
  gap: 6px;
}
.roster-pill-num {
  width: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 4px;
  font-size: 12.5px;
  text-align: center;
}
.roster-pill-sep { color: var(--text-low); font-size: 12px; }

#q-sheetViewBody {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}
#q-sheetViewBody .sheet-view-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
#q-sheetViewBody .sheet-view-section {
  width: 100%;
  max-width: 100%;
}
#q-sheetViewBody .sheet-view-section-body {
  display: none;
  flex-direction: column;
  gap: 20px;
  padding: 12px 0 8px;
}
#q-sheetViewBody .sheet-view-section.is-open .sheet-view-section-body {
  display: flex;
}
#q-sheetViewBody .q-sheet-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border, #e6e6f2);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}
#q-sheetViewBody .sheet-view-table-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin-bottom: 8px;
}
/* Quarter sheet view shows Move / Remove / value-mode like main sheet view */
#q-sheetViewBody .sheet-view-table-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}


/* Deleted items panel: anchored in document flow directly below the trigger.
   It stays put while the page scrolls; only the item list scrolls internally. */
.trash-popover {
  position: absolute;
  z-index: 9000;
  display: none;
  flex-direction: column;
  width: min(880px, calc(100vw - 32px));
  max-width: 880px;
  max-height: 560px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #dbe3ee;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  padding: 16px;
  overflow: hidden;
}
.trash-popover .trash-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}
.trash-popover .trash-toolbar .btn {
  font-size: 12px;
  padding: 7px 10px;
}
.trash-popover .trash-count {
  margin-left: auto;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}
.section-nav-trash-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #334155;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.section-nav-trash-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.table-download-menu { flex: 0 0 auto; }
.table-download-trigger {
  width: 34px;
  height: 32px;
  padding: 0;
}
.table-download-popover {
  min-width: 120px;
}

.trash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 12px;
  flex-shrink: 0;
}
.trash-panel-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.trash-drawer-hint {
  margin: 0 0 8px;
  flex-shrink: 0;
}
.trash-list {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 4px;
  -webkit-overflow-scrolling: touch;
}
.trash-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.trash-item:last-child {
  border-bottom: none;
}
.trash-item > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}
.trash-item-meta {
  display: block;
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 3px;
}
.trash-item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.trash-item-actions .btn {
  white-space: nowrap;
  font-size: 0.8rem;
  padding: 6px 10px;
}
.section-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-sec-prev:disabled,
.btn-sec-next:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}


/* Sheet view: one section at a time (focus mode) */
.sheet-view-section.is-hidden-section {
  display: none !important;
}
.sheet-expand-all .sheet-view-section.is-hidden-section {
  display: block !important;
}
.section-focus-nav {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 16px 12px 8px;
  margin-top: 8px;
  border-top: 1px solid #e2e8f0;
}
.section-focus-nav-top {
  display: flex;
  gap: 8px;
  margin-left: 8px;
}
.sheet-expand-all .section-focus-nav {
  /* still useful when all expanded */
}

/* ==========================================================================
   Profiles landing page + profile history screen
   ========================================================================== */

.screen {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.crumb-link {
  color: var(--text-mid);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.crumb-link:hover { color: var(--accent-ink); }

.profile-create-btn { margin-top: 22px; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color .15s ease, transform .1s ease, box-shadow .15s ease;
  text-align: left;
}
.profile-card:hover {
  border-color: var(--accent-border);
  box-shadow: 0 4px 14px rgba(47, 94, 255, 0.12);
  transform: translateY(-1px);
}
.profile-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15.5px;
  color: var(--text-hi);
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}
.profile-card-meta {
  color: var(--text-mid);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0 0 10px;
}
.profile-card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.profile-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1px solid var(--accent-border);
}
.profile-badge.teal {
  background: var(--teal-soft);
  color: var(--teal);
  border-color: var(--teal-border);
}

.profile-empty {
  margin-top: 30px;
  padding: 30px;
  text-align: center;
  color: var(--text-mid);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-l);
  background: var(--surface-sunken);
}

.table-search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-l, 12px);
}
.table-search-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-hi, #0f172a);
}
.table-search-input {
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 480px;
}
.table-search-hint {
  font-size: 12px;
  flex: 1 1 100%;
}
.table-search-status {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-ink, #4338ca);
}
.sheet-view-section.search-empty {
  display: none !important;
}
.run-card-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.run-card-name-editable {
  cursor: text;
  border-radius: 6px;
  outline: none;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.run-card-name-editable:hover {
  box-shadow: inset 0 0 0 1px var(--border, #e2e8f0);
}
.run-card-name-editable:focus {
  box-shadow: inset 0 0 0 2px var(--accent, #4f46e5);
  background: #fff;
}
.run-rename-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-mid, #64748b);
  cursor: pointer;
}
.run-rename-icon:hover {
  background: rgba(79, 70, 229, 0.1);
  color: var(--accent-ink, #4338ca);
}

.run-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}
.run-list-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.run-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.run-card-info { min-width: 0; }
.run-card-date {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text-mid);
  margin: 2px 0 6px;
}
.run-card-meta {
  color: var(--text-mid);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0;
}
.run-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
  align-items: center;
}
.run-card-info { flex: 1 1 auto; min-width: 0; }


#backToProfilesBtn { margin-right: 6px; }

/* ---- Selective export panel ---- */
.export-panel {
  margin: 16px 0 20px;
  padding: 18px 20px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.export-panel-head { margin-bottom: 14px; }
.export-panel-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-display);
}
.export-panel-lede {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-mid, #64748b);
}
.export-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 320px;
  margin-bottom: 12px;
}
.export-picker {
  margin: 8px 0 14px;
  padding: 12px 14px;
  background: var(--bg-soft, #f8fafc);
  border-radius: 12px;
  border: 1px solid var(--border, #e2e8f0);
}
.export-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.export-picker-actions { display: flex; gap: 12px; }
.export-check-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 12px;
  max-height: 220px;
  overflow-y: auto;
}
.export-check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.86rem;
  line-height: 1.35;
  padding: 4px 2px;
  cursor: pointer;
}
.export-check-item input { margin-top: 2px; flex-shrink: 0; }
.export-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}
#btnHistoryNav { margin-right: 4px; }

/* Column id reference shown in view only (never exported) */
.table-id-ref {
  color: var(--text-mid, #64748b);
  font-weight: 500;
  font-size: 0.92em;
  white-space: nowrap;
}
.sheet-view-table-title .xl-rename {
  display: inline;
  outline: none;
}
.run-card-workbook {
  margin: 2px 0 4px;
  font-size: 0.88rem;
  color: var(--text-mid, #64748b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}

/* Profile rename */
.profile-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.profile-card-name {
  flex: 1;
  min-width: 0;
}
.profile-card-name.is-editing {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: 2px;
  border-radius: 6px;
  padding: 2px 4px;
  background: #fff;
}
.profile-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.profile-rename-btn,
.profile-delete-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-mid, #64748b);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.profile-card:hover .profile-rename-btn,
.profile-card:hover .profile-delete-btn,
.profile-rename-btn:focus-visible,
.profile-delete-btn:focus-visible {
  opacity: 1;
}
.profile-rename-btn:hover {
  background: rgba(79, 70, 229, 0.1);
  color: var(--accent-ink, #4338ca);
}
.profile-delete-btn:hover {
  background: #fef2f2;
  color: #b91c1c;
}
.profile-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 18px;
}
.profile-detail-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  box-sizing: border-box;
  line-height: 1.2;
  vertical-align: middle;
}
.profile-detail-actions .btn-danger {
  background: #fff;
  border: 1.5px solid #fecaca;
  color: #b91c1c;
  box-shadow: none;
}
.profile-detail-actions .btn-danger:hover {
  background: #fef2f2;
  border-color: #f87171;
  color: #991b1b;
}
.profile-name-editable {
  cursor: text;
  border-radius: 8px;
  outline: none;
}
.profile-name-editable:hover {
  box-shadow: inset 0 0 0 1px var(--border, #e2e8f0);
}
.profile-name-editable:focus {
  box-shadow: inset 0 0 0 2px var(--accent, #4f46e5);
  background: #fff;
}


/* Profile export / import */
.profile-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}
.profile-backup-hint {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-mid, #64748b);
  max-width: 40rem;
  line-height: 1.45;
}

.run-card-profile-name {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text, #0f172a);
  line-height: 1.3;
}
.run-card-workbook {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-mid, #64748b);
}

/* ==========================================================================
   Dashboard screen -- PivotIQ's own usage (profiles/runs/tables/columns).
   Scoped entirely under .dash-screen with its own green palette so it never
   collides with the app's indigo accent theme used everywhere else.
   ========================================================================== */
.dash-screen {
  --dash-green: #1a9e5c;
  --dash-green-dark: #0f7a45;
  --dash-green-soft: #e7f8ef;
  --dash-green-border: #bfe8d3;
  --dash-blue: #2f5eff;
  --dash-amber: #b6790a;
  --dash-red: #d1383a;
  --dash-teal: #0b9c93;
  --dash-ink: #12351f;
  max-width: 1180px;
}

.dash-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(120deg, var(--dash-green) 0%, var(--dash-green-dark) 100%);
  border-radius: 16px;
  padding: 22px 26px;
  margin-bottom: 22px;
  box-shadow: 0 8px 24px rgba(15, 122, 69, 0.18);
}
.dash-bar-eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.75);
}
.dash-bar-title h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  color: #ffffff;
}
.dash-bar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-select {
  appearance: none;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.4);
  color: #ffffff;
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 34px 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
}
.dash-select option { color: #12351f; }
.dash-reset-btn {
  background: #ffffff;
  color: var(--dash-green-dark);
  border: none;
  font-weight: 700;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.dash-reset-btn:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.18); transform: translateY(-1px); }

.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.dash-kpi-row--compact { margin-bottom: 16px; }
@media (max-width: 900px) {
  .dash-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.dash-kpi-card {
  background: #ffffff;
  border: 1px solid var(--border, #e8e6df);
  border-left: 4px solid var(--dash-green);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.05);
}
.dash-kpi-card.is-blue { border-left-color: var(--dash-blue); }
.dash-kpi-card.is-amber { border-left-color: var(--dash-amber); }
.dash-kpi-card.is-teal { border-left-color: var(--dash-teal); }
.dash-kpi-card.is-red { border-left-color: var(--dash-red); }
.dash-kpi-label {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-mid, #64748b);
}
.dash-kpi-value {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  color: var(--dash-ink);
  line-height: 1.15;
}
.dash-kpi-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-mid, #64748b);
}

.dash-empty, .dash-empty-inline {
  background: var(--dash-green-soft);
  border: 1px dashed var(--dash-green-border);
  border-radius: 12px;
  padding: 18px;
  color: var(--dash-green-dark);
  font-size: 13.5px;
  margin-bottom: 20px;
  text-align: center;
}
.dash-empty-inline { margin: 0; border: none; background: none; padding: 14px 0; color: var(--text-mid); }

.dash-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 860px) {
  .dash-panels { grid-template-columns: 1fr; }
}

.dash-panel {
  background: #ffffff;
  border: 1px solid var(--border, #e8e6df);
  border-radius: 14px;
  padding: 18px 20px 20px;
  margin-bottom: 20px;
}
.dash-panels .dash-panel { margin-bottom: 0; }
.dash-panel-title {
  margin: 0 0 14px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--dash-ink);
}
.dash-panel-sub {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-mid, #64748b);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
}
.dash-session-panel { border-color: var(--dash-green-border); background: linear-gradient(180deg, var(--dash-green-soft) 0%, #ffffff 40px); }

.dash-subpanel-title {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-mid, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Donut chart + legend */
.dash-donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.dash-donut-svg { flex: 0 0 auto; }
.dash-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1 1 160px; min-width: 140px; }
.dash-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dash-ink); }
.dash-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.dash-legend .legend-count { margin-left: auto; font-weight: 700; color: var(--text-mid); font-family: var(--font-mono); }

/* Horizontal bar chart: label -- track -- value */
.dash-bar-row { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 10px; margin-bottom: 12px; }
.dash-bar-row:last-child { margin-bottom: 0; }
.dash-bar-label { font-size: 13px; font-weight: 600; color: var(--dash-ink); }
.dash-bar-track { background: var(--surface-sunken, #f6f6f4); border-radius: 999px; height: 12px; overflow: hidden; }
.dash-bar-fill { height: 100%; border-radius: 999px; background: var(--dash-green); }
.dash-bar-value { font-size: 12.5px; font-weight: 700; color: var(--text-mid); text-align: right; font-family: var(--font-mono); }

/* Session mini-lists (section/aggregation breakdown) reuse the bar-row look */
.dash-mini-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border, #e8e6df); font-size: 13px; }
.dash-mini-row:last-child { border-bottom: none; }
.dash-mini-count { font-weight: 700; color: var(--dash-green-dark); font-family: var(--font-mono); }

/* Recent runs table */
.dash-table-wrap { overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mid, #64748b);
  padding: 8px 10px;
  border-bottom: 2px solid var(--border, #e8e6df);
  white-space: nowrap;
}
.dash-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border, #e8e6df);
  color: var(--dash-ink);
  vertical-align: middle;
}
.dash-table tr:last-child td { border-bottom: none; }
.dash-table td.dash-td-muted { color: var(--text-mid, #64748b); }
.dash-run-view-link {
  color: var(--dash-green-dark);
  font-weight: 700;
  text-decoration: none;
  font-size: 12.5px;
  white-space: nowrap;
}
.dash-run-view-link:hover { text-decoration: underline; }
.dash-section-chip {
  display: inline-block;
  background: var(--dash-green-soft);
  color: var(--dash-green-dark);
  border: 1px solid var(--dash-green-border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  margin: 0 4px 4px 0;
}

/* Projects + modals (additive only) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 9000; padding: 16px;
}
.modal-card {
  background: #fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(15,23,42,.18);
  max-width: 420px; width: 100%; padding: 24px 24px 20px;
}
.modal-title { margin: 0 0 6px; font-size: 1.25rem; font-weight: 700; color: #0f172a; }
.modal-lede { margin: 0 0 16px; font-size: .9rem; color: #64748b; line-height: 1.45; }
.field-label { display: block; font-size: .8rem; font-weight: 600; color: #334155; margin: 12px 0 6px; }
.field-label .req { color: #dc2626; }
.field-input {
  width: 100%; box-sizing: border-box; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 10px 12px; font-size: .95rem; color: #0f172a; background: #f8fafc;
}
.field-input:focus { outline: none; border-color: #3b82f6; background: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.project-group { margin-bottom: 28px; }
.project-group-header {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px;
  padding-bottom: 6px; border-bottom: 1px solid #e8e6df;
}
.project-group-title { margin: 0; font-size: 1rem; font-weight: 700; color: #0f172a; }
.project-group-meta { font-size: .8rem; color: #64748b; }
.profile-card-project { font-size: .75rem; font-weight: 600; color: #3b82f6; margin: 0 0 4px; }
.run-card-profile-name { margin: 0 0 2px; font-size: .98rem; font-weight: 700; color: #0f172a; }
.import-choice-list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.import-choice {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px;
  border: 1px solid #e2e8f0; border-radius: 12px; cursor: pointer; background: #f8fafc;
}
.import-choice:has(input:checked) { border-color: #3b82f6; background: #eff6ff; }
.import-choice strong { display: block; font-size: .95rem; color: #0f172a; }
.import-choice-sub { display: block; font-size: .8rem; color: #64748b; margin-top: 2px; }

/* ---- Projects hierarchy (tabs + detail) ---- */
.project-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e8e6df;
}
.project-tab {
  appearance: none;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.project-tab:hover {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #f0f7ff;
}
.project-tab.is-active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.project-card {
  border-left: 3px solid #3b82f6;
}
.project-detail-header {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  border: 1px solid #e0e7ff;
  border-radius: 14px;
}
.project-detail-title {
  margin: 4px 0 2px;
  font-size: 1.25rem;
  font-weight: 750;
  color: #0f172a;
}
.project-detail-meta {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
}
.project-back-all {
  display: inline-block;
  margin-bottom: 2px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #3b82f6;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.project-back-all:hover { text-decoration: underline; color: #1d4ed8; }
.project-detail-actions { display: flex; gap: 8px; align-items: center; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.crumb-sep { margin: 0 6px; color: #94a3b8; font-weight: 400; }
.profile-card {
  transition: transform .15s ease, box-shadow .15s ease;
}
.profile-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
.profile-card:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ---- Dashboard v2 (clearer KPIs, week chart, rankings) ---- */
.dash-bar-lede {
  margin: 6px 0 0;
  max-width: 52rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(255,255,255,0.82);
  font-weight: 450;
}
.dash-filter-label {
  font-size: 0.78rem;
  font-weight: 650;
  color: rgba(255,255,255,0.85);
  margin-right: 2px;
}
.dash-kpi-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.dash-kpi-icon {
  font-size: 1.05rem;
  line-height: 1;
}
.dash-kpi-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
@media (max-width: 1100px) {
  .dash-kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .dash-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.dash-kpi-card {
  transition: transform .15s ease, box-shadow .15s ease;
}
.dash-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(18, 53, 31, 0.08);
}
.dash-panel-hint {
  margin: -4px 0 14px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #64748b;
}
.dash-panels-3 {
  grid-template-columns: 1.4fr 1fr;
}
.dash-panel-span-2 { grid-column: span 1; }
@media (max-width: 900px) {
  .dash-panels-3 { grid-template-columns: 1fr; }
}
.dash-panels-inner {
  grid-template-columns: 1fr 1fr;
  margin-top: 8px;
}
.dash-week-chart { min-height: 160px; }
.dash-week-bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 160px;
  padding: 8px 4px 0;
}
.dash-week-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.dash-week-bar {
  width: 100%;
  max-width: 42px;
  border-radius: 8px 8px 4px 4px;
  background: #e2e8f0;
  min-height: 4px;
  transition: height .25s ease, background .15s ease;
}
.dash-week-bar.is-active {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.dash-week-label {
  font-size: 0.72rem;
  font-weight: 650;
  color: #64748b;
}
.dash-week-val {
  font-size: 0.72rem;
  font-weight: 700;
  color: #0f172a;
  min-height: 1em;
}
.dash-rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s ease;
}
.dash-rank-row:hover { background: #f1f5f9; }
.dash-rank-main { flex: 1; min-width: 0; }
.dash-rank-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
}
.dash-rank-sub {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  margin: 2px 0 6px;
}
.dash-rank-track {
  display: block;
  height: 6px;
  border-radius: 99px;
  background: #e2e8f0;
  overflow: hidden;
}
.dash-rank-fill {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #22c55e, #16a34a);
}
.dash-rank-fill.is-teal {
  background: linear-gradient(90deg, #14b8a6, #0d9488);
}
.dash-rank-value {
  flex: 0 0 auto;
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  text-align: right;
}
.dash-rank-value small {
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
}
.dash-kind-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 4px;
}
.dash-kind-badge.is-main {
  background: #dcfce7;
  color: #166534;
}
.dash-kind-badge.is-quarter {
  background: #e0e7ff;
  color: #3730a3;
}
.dash-panel-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}
.dash-footnote {
  margin: 18px 0 8px;
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.45;
}
.dash-run-view-link {
  font-weight: 650;
  color: var(--dash-green-dark, #0f7a45);
  text-decoration: none;
  white-space: nowrap;
}
.dash-run-view-link:hover { text-decoration: underline; }

/* Roster cards: number badge + drag reorder */
.file-card-icon--num {
  background: #1e293b !important;
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
}
.roster-order-num {
  line-height: 1;
}
.roster-card-draggable {
  cursor: grab;
}
.roster-card-draggable.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}
.roster-card-draggable.drag-over {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: 2px;
}
.profile-card-draggable {
  cursor: grab;
}
.profile-card-draggable.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}
.profile-card-draggable.drag-over {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: 2px;
}
.file-card-drag-hint {
  font-size: 0.75rem;
  margin: 4px 0 0;
}


/* App confirm dialog */
.app-confirm-card {
  max-width: 420px;
  width: 100%;
}
#appConfirmModal.modal-backdrop {
  z-index: 9500;
}


/* centered pivot headers (Yes / No / Q1 / Q2 / choice labels) */
.xl-table thead th,
.xl-table th,
.sheet-view-table thead th,
.sheet-view-table th,
.table-scroll table thead th,
.table-scroll table th {
  text-align: center !important;
  vertical-align: middle !important;
}
/* Only the base/corner label (District) is left-aligned — never choice headers like Yes/No */
.xl-table thead tr:first-child th[rowspan],
.xl-table thead tr:first-child th:first-child:not([colspan]),
.sheet-view-table thead tr:first-child th[rowspan],
.sheet-view-table thead tr:first-child th:first-child:not([colspan]),
.table-scroll table thead tr:first-child th[rowspan],
.table-scroll table thead tr:first-child th:first-child:not([colspan]) {
  text-align: left !important;
}
/* Body first column (row labels) left */
.xl-table tbody td:first-child,
.sheet-view-table tbody td:first-child,
.table-scroll table tbody td:first-child {
  text-align: left !important;
}

.history-jump-highlight {
  outline: 2px solid var(--accent, #3b82f6) !important;
  box-shadow: 0 0 0 4px rgba(59,130,246,.25);
  transition: outline .2s, box-shadow .2s;
}

.xl-table thead th.xl-base-corner {
  text-align: left !important;
}
.xl-table thead tr:nth-child(2) th {
  text-align: center !important;
}

.btn-duplicate-table {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  cursor: pointer;
}
.btn-duplicate-table:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.rail.is-hidden-for-profile-tool,
.stepper.is-hidden-for-profile-tool,
#wizardSteps.is-hidden-for-profile-tool {
  display: none !important;
}

/* Auto compare: hide ALL manual upload chrome — only comparison tables */
#panel-quarters.is-auto-compare-view #manualQuarterUploadBlock {
  display: none !important;
}
#panel-quarters.is-auto-compare-view #autoQuarterResultsHead {
  display: block !important;
  margin-bottom: 16px;
}
#panel-quarters.is-auto-compare-view #quarterResults {
  display: block !important;
  margin-top: 0 !important;
}
#panel-quarters:not(.is-auto-compare-view) #autoQuarterResultsHead {
  display: none !important;
}

/* Top prev/next only on focused section (when not expand-all) */
.sheet-view-section:not(.is-focused) .section-focus-nav-top {
  display: none !important;
}
.sheet-expand-all .section-focus-nav-top {
  display: flex !important;
}
<<<<<<< Updated upstream
/* Bottom prev/next always visible whenever the section body is open */
.sheet-view-section .section-focus-nav-bottom {
  display: flex !important;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 0 4px;
  margin-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.sheet-view-section .section-focus-nav {
  display: none !important; /* legacy class unused */
}
/* Per-section collapse/expand button */
.btn-sec-collapse {
  font-size: 12px;
  padding: 4px 10px;
  margin-left: 4px;
  white-space: nowrap;
}
/* Saved dictionaries picker */
.saved-dict-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0 4px;
}
.saved-dict-list {
  display: none;
  margin-top: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  max-height: 220px;
  overflow: auto;
  box-shadow: 0 8px 24px rgba(15,23,42,.1);
}
.saved-dict-list.is-open { display: block; }
.saved-dict-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  font-size: 13px;
}
.saved-dict-item:last-child { border-bottom: none; }
.saved-dict-item:hover { background: #f8fafc; }
.saved-dict-item-name { font-weight: 600; color: #0f172a; }
.saved-dict-item-meta { font-size: 11.5px; color: #64748b; }
.saved-dict-item-del {
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
}
.saved-dict-item-del:hover { background: #fee2e2; color: #b91c1c; }



/* Duplicate-check multi-select dropdown */
.dup-dd { position: relative; overflow: visible !important; }
.dup-dd-panel {
  position: absolute;
  z-index: 200 !important;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15,23,42,.14);
}
.card:has(.dup-dd) { overflow: visible !important; }

/* V4: a consistent responsive dialog system for every popup. */
.modal-backdrop {
  padding: clamp(8px, 2.2vmin, 22px);
  overflow: auto;
  overscroll-behavior: contain;
}
.modal-backdrop > .modal-card {
  box-sizing: border-box;
  width: min(100%, 440px);
  max-width: min(100%, calc(100vw - 16px));
  max-height: min(92dvh, 860px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: clamp(14px, 2.5vmin, 24px);
}
.modal-backdrop > .modal-card--wide { width: min(100%, 940px); max-width: min(100%, 940px); }
.modal-backdrop > .modal-card--medium { width: min(100%, 560px); max-width: min(100%, 560px); }
.modal-card .field-input, .modal-card .text-input, .modal-card select,
.modal-card input, .modal-card textarea { max-width: 100%; min-width: 0; }
.modal-card table { max-width: 100%; }
.modal-card .modal-actions { flex-wrap: wrap; }
@media (max-width: 650px), (max-height: 650px) {
 .modal-backdrop { align-items: flex-start; }
 .modal-backdrop > .modal-card { max-height: calc(100dvh - 16px); }
 .modal-card .modal-actions > button { flex: 1 1 auto; }
}

/* V4: the drill-down and table-view popups have a separate responsive shell. */
.modal-overlay { padding: clamp(8px, 2vmin, 24px); box-sizing: border-box; }
.modal-overlay .modal-panel { width: min(100%, 980px); max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px); min-height: 0; }
.modal-overlay .modal-body { min-height: 0; overflow: auto; }
.modal-overlay .modal-head { flex-wrap: wrap; padding: clamp(10px, 2vmin, 20px); }
.modal-overlay .modal-head-actions { flex-wrap: wrap; }
@media (max-width: 650px) {
  .modal-overlay .modal-panel { max-height: calc(100dvh - 12px); }
  .modal-overlay .modal-head, .modal-overlay .modal-body { padding: 12px; }
}

/* ==========================================================================
   2026-09-28 UX hardening: persistent modal chrome + request feedback
   ========================================================================== */

/* Modal cards enhanced by app.js use a real fixed header/footer and only the
   middle content scrolls. This keeps Save / Cancel / Generate controls visible
   even in tall dialogs and at browser zoom levels above 100%. */
.modal-backdrop > .modal-card.modal-shell-ready {
  padding: 0 !important;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.modal-shell-header {
  flex: 0 0 auto;
  padding: 18px clamp(14px, 2.5vmin, 24px) 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-soft) 180%);
  position: relative;
  z-index: 3;
}
.modal-shell-header > .modal-title:last-child,
.modal-shell-header > .modal-lede:last-child { margin-bottom: 0; }
.modal-shell-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px clamp(14px, 2.5vmin, 24px);
  scrollbar-gutter: stable;
}
.modal-shell-footer {
  flex: 0 0 auto;
  padding: 12px clamp(14px, 2.5vmin, 24px) 16px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,.98);
  box-shadow: 0 -8px 24px rgba(28,29,33,.06);
  position: relative;
  z-index: 4;
}
.modal-shell-footer .modal-actions {
  margin: 0 !important;
  padding: 0 !important;
}

/* Complex dialogs that cannot be mechanically split still keep their title /
   top close controls visible while the card scrolls. */
.modal-backdrop > .modal-card:not(.modal-shell-ready) > .modal-title:first-child,
.modal-backdrop > .modal-card:not(.modal-shell-ready) > div:first-child:has(> .modal-title) {
  position: sticky;
  top: -1px;
  z-index: 5;
  background: rgba(255,255,255,.98);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding-top: 4px;
  padding-bottom: 10px;
}

/* Table/drill viewers already have a fixed header. Give their explicit footer
   a solid sticky treatment so actions are visually separated from data. */
.modal-overlay .modal-foot {
  background: rgba(255,255,255,.98);
  border-top: 1px solid var(--border);
  padding-top: 12px;
  box-shadow: 0 -6px 18px rgba(28,29,33,.05);
}

/* Styled success/error request dialog. */
.app-notice-card { max-width: 500px !important; }
.app-notice-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.app-notice-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex: 0 0 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  background: var(--green-soft);
  border: 1px solid var(--green-border);
  color: var(--green);
}
.app-notice-card[data-tone="error"] .app-notice-icon {
  background: var(--red-soft);
  border-color: var(--red-border);
  color: var(--red);
}
.app-notice-card[data-tone="warning"] .app-notice-icon {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  color: var(--amber);
}

/* Keep all result actions in the already-fixed app footer. */
.action-bar-inner { flex-wrap: wrap; }
.action-bar .btn { white-space: nowrap; }

/* Profile-level controls stay reachable under the sticky app header while the
   run list scrolls. This is especially useful on long profile histories. */
#screen-profile-detail .profile-detail-actions {
  position: sticky;
  top: 94px;
  z-index: 18;
  background: rgba(247,246,242,.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 899px) {
  :root { --actionbar-h: 118px; }
  .action-bar-inner {
    padding: 10px 12px;
    gap: 8px;
    align-content: center;
  }
  .action-bar-spacer { display: none; }
  .action-bar-hint { flex: 1 1 100%; order: 10; margin: 0; }
  .action-bar .btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
  #screen-profile-detail .profile-detail-actions { top: 78px; }
}

@media (max-width: 520px) {
  :root { --actionbar-h: 150px; }
  .topbar { padding: 14px 16px 12px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .ghost-btn { padding-left: 9px; padding-right: 9px; }
  .modal-shell-header { padding-top: 14px; }
  .modal-shell-footer { padding-bottom: 12px; }
}

/* Empty modal middles (confirm / notice) should not create dead vertical space. */
.modal-shell-body:empty { display: none; }

/* Drill-down tables can be very tall. Keep the title and action footer fixed
   and make only the table region scroll so Restore/Close-style actions never
   disappear below the viewport. */
#drillModal .modal-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#drillModal #drillBody {
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}
#drillModal #drillBody .table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#drillModal #drillBody .modal-foot {
  flex: 0 0 auto;
  margin-top: 10px;
}

/* The selective-export dialog has purpose-built nested actions rather than a
   direct .modal-actions footer, so keep that action row pinned separately. */
#customExportModal .export-actions {
  position: sticky;
  bottom: -1px;
  z-index: 5;
  margin-left: -4px;
  margin-right: -4px;
  padding: 12px 4px 4px;
  background: rgba(255,255,255,.98);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 18px rgba(28,29,33,.05);
}

/* V6: On desktop keep every footer action in one visible row.  The previous
   flex-wrap rule could push the primary Download workbook button onto a second
   line even on a wide screen (the screenshot showed exactly this).  Let the
   hint text yield space first; mobile still wraps into touch-friendly rows. */
@media (min-width: 900px) {
  .action-bar-inner { flex-wrap: nowrap; }
  .action-bar-hint {
    min-width: 0;
    margin-right: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
  }
  .action-bar-spacer { flex: 0 1 0; min-width: 0; }
  .action-bar .btn { flex: 0 0 auto; }
}


/* Calc switch: keep the control responsive while the one-table rebuild runs. */
.agg-select.is-updating { opacity: .65; cursor: progress; }

/* Per-table download control */
.table-download-menu{position:relative;display:inline-flex;align-items:center;}
.table-download-trigger{display:inline-flex;align-items:center;justify-content:center;width:32px;height:30px;padding:0;cursor:pointer;}
.table-download-popover{display:none;position:absolute;right:0;top:calc(100% + 6px);z-index:1200;min-width:105px;padding:5px;background:#fff;border:1px solid #dbe2ea;border-radius:9px;box-shadow:0 8px 24px rgba(15,23,42,.14);}
.table-download-popover.is-open{display:flex;flex-direction:column;}
.table-download-popover button{border:0;background:transparent;text-align:left;padding:7px 9px;border-radius:6px;cursor:pointer;font:inherit;color:#1f2937;}
.table-download-popover button:hover{background:#f1f5f9;}

/* Zero-value table warning: intentionally high-visibility but non-blocking. */
.zero-value-alert {
  margin: 10px 0 14px;
  padding: 11px 14px;
  border: 1px solid #f59e0b;
  border-left: 5px solid #dc2626;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 2px 8px rgba(127, 29, 29, .08);
}
.zero-value-alert[hidden] { display: none !important; }
.zero-value-alert-refs { font-family: var(--font-mono); font-weight: 700; }
.sheet-view-table.is-zero-value-table {
  border: 2px solid #ef4444;
  background: #fff7f7;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, .08);
}
.sheet-view-table.is-zero-value-table .sheet-view-table-head {
  background: #fff1f2;
}
.table-card.is-zero-value-table {
  border: 2px solid #ef4444;
  background: #fff7f7;
}
.zero-value-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  font: 700 10px/1.2 var(--font-mono);
  letter-spacing: .04em;
  vertical-align: middle;
}

/* The trigger owns the absolute Deleted panel. */
.section-nav-trash-btn-wrap { position: relative; display: inline-flex; align-items: flex-start; }
.trash-popover-anchor { position: relative; display: inline-flex; }
.trash-select-row { display:flex; align-items:flex-start; gap:8px; cursor:pointer; }
.trash-select-row input { margin-top:3px; }
.trash-popover .trash-list { overflow-y:auto; overflow-x:hidden; flex:1 1 auto; min-height:140px; }


/* ---- Results page: big "workbook ready" card is replaced by a compact bar
   placed directly under the section chips. The original element stays in the
   DOM (hidden) because other code writes the filename / summary into it. */
#panel-result > .result-hero { display: none; }
.result-hero.result-hero--compact {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 7px 12px;
  margin: 10px 0 14px;
  border-radius: 10px;
  min-height: 0;
  width: 100%;
}
.result-hero--compact .result-hero-icon {
  width: 24px; height: 24px; border-radius: 7px;
}
.result-hero--compact .result-hero-title {
  font-size: 13.5px; margin: 0; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-hero--compact .result-hero-sub { font-size: 12.5px; margin: 0; white-space: nowrap; }
/* Deleted button sits in the section header, between Collapse and Remove section */
.sheet-view-section-head .trash-popover-anchor { margin-left: 4px; }
=======
/* Tool chooser shown before entering a specific workflow. */
.tool-picker-screen {
  max-width: 920px;
  margin: 0 auto;
  padding: 70px 28px 80px;
}

.tool-picker-head {
  text-align: center;
  margin-bottom: 54px;
}

.tool-picker-title {
  margin: 0;
  color: #0b1b33;
  font-size: clamp(34px, 4vw, 46px);
  letter-spacing: -1.5px;
}

.tool-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.tool-card {
  position: relative;
  min-height: 218px;
  padding: 28px 30px;
  border: 1px solid #dfe4ea;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.tool-card:nth-child(3) {
  grid-column: 1;
}

.tool-card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  border: 1px solid #e1e6eb;
  border-radius: 11px;
  color: #5b6068;
  background: #f5f6f8;
  font-size: 25px;
  line-height: 1;
}

.tool-card-icon-primary {
  border-color: #2f67e8;
  color: #fff;
  background: #2f67e8;
}

.tool-card h2 {
  margin: 0 0 10px;
  color: #0b1b33;
  font-size: 18px;
}

.tool-card p {
  max-width: 390px;
  min-height: 48px;
  margin: 0 0 20px;
  color: #68778b;
  font-size: 15px;
  line-height: 1.45;
}

.tool-card-action {
  display: inline-flex;
  gap: 9px;
  align-items: center;
}

.tool-card-version {
  position: absolute;
  top: 28px;
  right: 28px;
  padding: 3px 9px;
  border: 1px solid #e2e6eb;
  border-radius: 999px;
  color: #8994a4;
  background: #f8f9fa;
  font-size: 12px;
}

@media (max-width: 700px) {
  .tool-picker-screen {
    padding: 42px 18px 60px;
  }

  .tool-picker-grid {
    grid-template-columns: 1fr;
  }

  .tool-card:nth-child(3) {
    grid-column: auto;
  }
}
>>>>>>> Stashed changes
