/* AskBI — v1 styles. Plain CSS, no framework. */

:root {
    --bg: #f7f8fb;
    --panel: #ffffff;
    --border: #e3e6ee;
    --text: #1f2330;
    --muted: #6b7185;
    --accent: #4f46e5;        /* indigo-600 */
    --accent-soft: #eef2ff;   /* indigo-50  */
    --accent-strong: #4338ca; /* indigo-700 (hover/active) */
    --accent-2: #f59e0b;      /* amber-500 — secondary / highlight */
    --accent-2-soft: #fffbeb; /* amber-50  */
    --accent-2-strong: #d97706; /* amber-600 (hover) */
    --error: #b3261e;
    --status-completed: #1f8a3e;
    --status-inprogress: #b07700;
    --status-failed: #b3261e;
    --status-disabled: #6b7185;
    --status-unknown: #6b7185;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

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

/* App shell */
.app-shell {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100vh;
}
.app-shell.demo { grid-template-rows: auto auto 1fr; }

/* Demo Mode banner — sits above the header so it's the first thing seen. */
.demo-banner {
    background: linear-gradient(90deg, #6d28d9, #4f46e5);
    color: white;
    text-align: center;
    padding: 6px 16px;
    font-size: 13px;
    letter-spacing: 0.01em;
}
.demo-banner strong { font-weight: 700; }

.app-header {
    background: linear-gradient(90deg, var(--accent-strong), var(--accent));
    color: #fff;
    border-bottom: 3px solid var(--accent-2);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.app-header a, .app-header h1, .app-header .app-subtitle { color: #fff; }
.app-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
/* Logo lockup — square brand mark + wordmark/subtitle stack. */
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent-2);
    color: #3a2a00;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.02em;
    box-shadow: 0 2px 6px rgba(36, 81, 214, 0.25);
}
.brand-text { line-height: 1.15; }
.brand-text h1 { margin: 0; }
.app-header-right { display: flex; align-items: center; gap: 12px; }

/* Equal-width side columns so the product nav sits dead-centre in the header,
   regardless of how wide the brand (left) or spend+user (right) blocks are. */
.app-header-side-left { flex: 1 1 0; min-width: 0; display: flex; align-items: center; }
.app-header-right     { flex: 1 1 0; min-width: 0; justify-content: flex-end; }

/* Logo / title area is a link back to chat — works as the universal "home" button */
.app-home-link {
    text-decoration: none;
    color: inherit;
    display: inline-block;
    border-radius: 4px;
    padding: 4px 8px;
    margin: -4px -8px;
    transition: background-color 0.12s ease;
}
.app-home-link:hover { background: rgba(255, 255, 255, 0.15); }
.app-home-link:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.header-link {
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
}
.header-link:hover { color: #3a2a00; background: var(--accent-2); border-color: var(--accent-2); }
.header-link.compact { padding: 6px 9px; line-height: 1; }

/* Product-switcher nav — jump between the five products. Sits in the header
   between the logo and the right-hand utilities. Each item carries its product
   accent as a dot; the active item flips to a solid white pill in that color. */
.product-nav { display: flex; align-items: center; justify-content: center; flex: 0 1 auto; gap: 3px; flex-wrap: wrap; }
.product-nav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: 8px;
    opacity: 0.85;
    transition: background-color 0.12s ease, opacity 0.12s ease;
}
.product-nav a:hover { background: rgba(255, 255, 255, 0.16); opacity: 1; }
.product-nav a.active { background: #fff; opacity: 1; }
.product-nav a .pdot { width: 9px; height: 9px; border-radius: 3px; flex: none; background: currentColor; }
/* Per-product accent — dot always tinted; active item also tints its text. */
.product-nav a.p-home .pdot      { background: #cbd5e1; }
.product-nav a.p-ask .pdot       { background: #818cf8; }
.product-nav a.p-model .pdot     { background: #a78bfa; }
.product-nav a.p-report .pdot    { background: #22d3ee; }
.product-nav a.p-deliver .pdot   { background: #fbbf24; }
.product-nav a.p-scheduler .pdot { background: #f472b6; }
.product-nav a.p-portal .pdot    { background: #34d399; }
.product-nav a.p-studio .pdot    { background: #a78bfa; }
.product-nav a.p-prove .pdot     { background: #14b8a6; }
.product-nav a.active.p-home    { color: #475569; }
.product-nav a.active.p-home .pdot    { background: #475569; }
.product-nav a.active.p-ask     { color: #4f46e5; }
.product-nav a.active.p-ask .pdot     { background: #4f46e5; }
.product-nav a.active.p-model   { color: #7c3aed; }
.product-nav a.active.p-model .pdot   { background: #7c3aed; }
.product-nav a.active.p-report  { color: #0891b2; }
.product-nav a.active.p-report .pdot  { background: #0891b2; }
.product-nav a.active.p-deliver { color: #d97706; }
.product-nav a.active.p-deliver .pdot { background: #d97706; }
.product-nav a.active.p-scheduler { color: #db2777; }
.product-nav a.active.p-scheduler .pdot { background: #db2777; }
.product-nav a.active.p-portal  { color: #059669; }
.product-nav a.active.p-portal .pdot  { background: #059669; }
.product-nav a.active.p-studio  { color: #7c3aed; }
.product-nav a.active.p-studio .pdot  { background: #7c3aed; }
.product-nav a.active.p-prove   { color: #0d9488; }
.product-nav a.active.p-prove .pdot   { background: #0d9488; }

/* Session spend meter — amber chip in the header. */
.session-spend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-2-strong);
    background: var(--accent-2-soft);
    border: 1px solid #fde6b0;
    border-radius: 999px;
    padding: 4px 10px;
    white-space: nowrap;
    cursor: default;
}
.session-spend-dot { color: var(--accent-2); font-size: 8px; line-height: 1; }
.app-header h1 { margin: 0; font-size: 18px; font-weight: 600; }
.app-subtitle { color: var(--muted); font-size: 13px; }

/* User badge */
.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
}
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-meta { line-height: 1.1; text-align: center; }
.user-name { font-size: 13px; font-weight: 500; }
.user-email { font-size: 11px; }
.signout-btn {
    margin-left: 6px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
}
.signout-btn:hover { background: var(--accent-soft); color: var(--accent); }
.signin-link {
    padding: 6px 12px;
    background: var(--accent);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
}

/* The 1fr grid row. A non-visible overflow makes it a scroll container that
   stays at the available height (auto min-size resolves to 0), so:
   • pages that own their scroll (.chat, .page, .report-editor-page, .dp) fit
     it exactly and scroll internally, AND
   • pages that DON'T own a scroll (model wizard/viewer/studio, knowledge,
     integration) scroll here instead of being clipped at the bottom.
   The header + product-nav live in a separate grid row, so they stay pinned. */
.app-main { overflow-y: auto; overflow-x: hidden; }

/* Two-pane home with sidebar | (tab-bar + main view) */
.home-grid {
    display: grid;
    grid-template-columns: 64px var(--model-w, 300px) 6px 1fr;
    height: 100%;
}

/* Draggable splitter between the Models pane and the main pane. The model
   column width is driven by --model-w (set/persisted by askbiInitModelResizer). */
.col-resizer {
    cursor: col-resize;
    background: transparent;
    transition: background-color 0.12s ease;
}
.col-resizer:hover,
body.col-resizing .col-resizer { background: var(--accent-soft); }
body.col-resizing { cursor: col-resize; user-select: none; }

.main-pane {
    display: grid;
    grid-template-rows: 1fr;
    overflow: hidden;
    background: var(--bg);
}

/* Left icon nav rail — replaces the old emoji tab bar. */
.rail {
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 4px;
}
.rail-item {
    position: relative;
    width: 50px;
    padding: 9px 0 7px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.rail-item:hover { color: var(--accent); background: var(--accent-soft); }
.rail-item.active { color: var(--accent); background: var(--accent-soft); }
.rail-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.rail-count {
    position: absolute;
    top: 4px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--accent);
    color: white;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

/* Tab bar across the top of the main pane */
.tab-bar {
    display: flex;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
}
.tab {
    background: transparent;
    border: none;
    padding: 12px 18px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}
.tab-count {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
}
.tab.active .tab-count { background: var(--accent); color: white; }

/* Sidebar */
.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.refresh-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    color: var(--muted);
}
.refresh-btn:hover { background: var(--accent-soft); color: var(--accent); }

.model-list { list-style: none; margin: 0; padding: 6px 0; }
.model-row {
    padding: 10px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
}
.model-row:hover { background: var(--accent-soft); }
.model-row.selected {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}
.model-name { font-weight: 500; }
.model-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
    font-size: 12px;
}

.status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(0,0,0,0.04);
}
.status-completed   { color: var(--status-completed); }
.status-inprogress  { color: var(--status-inprogress); }
.status-failed      { color: var(--status-failed); }
.status-disabled    { color: var(--status-disabled); }
.status-unknown     { color: var(--status-unknown); }

/* ---- Workspace drill-down (sidebar groups semantic models by workspace) ---- */
.ws-tree { padding: 4px 0; }
.ws-group { border-bottom: 1px solid var(--border); }
.ws-group:last-child { border-bottom: 0; }
.ws-head {
    display: flex; align-items: center; gap: 8px; width: 100%;
    text-align: left; background: transparent; border: 0; cursor: pointer;
    padding: 11px 14px; font: inherit; color: var(--text);
}
.ws-head:hover { background: var(--accent-soft); }
.ws-chev {
    color: var(--muted); transition: transform .15s ease;
    flex: 0 0 auto; font-size: 11px; width: 12px;
}
.ws-group.open .ws-chev { transform: rotate(90deg); }
.ws-icon { flex: 0 0 auto; color: var(--accent); }
.ws-name {
    font-weight: 600; flex: 1 1 auto;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-count {
    flex: 0 0 auto; font-size: 11px; font-weight: 600; color: var(--accent-strong);
    background: var(--accent-soft); border-radius: 10px; padding: 1px 8px;
}
.ws-dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--status-unknown); }
.ws-dot.dot-completed  { background: var(--status-completed); }
.ws-dot.dot-inprogress { background: var(--status-inprogress); }
.ws-dot.dot-failed     { background: var(--status-failed); }
.ws-dot.dot-disabled   { background: var(--status-disabled); }
.ws-dot.dot-unknown    { background: var(--status-unknown); }
/* Models nested under a workspace are indented past the chevron. */
.ws-body { padding: 2px 0 6px; }
.ws-body .model-row { padding-left: 38px; }

/* Chat */
.chat {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100%;
    background: var(--bg);
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted);
}
.chat-empty h2 { margin: 0 0 4px 0; font-size: 16px; color: var(--text); }

/* Inline SVG icons — inherit text color, sit on the text baseline. */
.icon { display: inline-block; vertical-align: -2px; flex: none; }

/* Empty-state welcome with clickable example questions. */
.chat-welcome {
    margin: auto;
    max-width: 560px;
    text-align: center;
    padding: 32px 0;
}
.chat-welcome-spark {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-welcome h3 { margin: 0 0 4px; font-size: 18px; color: var(--text); }
.chat-welcome p { margin: 0 0 18px; }
.chat-examples { display: grid; gap: 10px; text-align: left; }
.chat-example {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13.5px;
    text-align: left;
    transition: border-color .12s ease, transform .12s ease;
}
.chat-example:hover { border-color: var(--accent); transform: translateY(-1px); }
.chat-example:disabled { opacity: .6; cursor: not-allowed; }
.chat-example-q { flex: 1; font-weight: 500; }
.chat-example-arrow { color: var(--accent); display: inline-flex; }

.chat-header {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.chat-header h2 { margin: 0; font-size: 16px; }
.chat-header p { margin: 2px 0 0 0; }
.chat-build-report { flex: 0 0 auto; white-space: nowrap; }

.chat-messages {
    overflow-y: auto;
    /* The 1fr grid row must be allowed to shrink below its content height,
       or a tall message (e.g. expanded "Show DAX") grows the row past the
       viewport and .app-main (overflow:hidden, 100vh) clips the bottom. */
    min-height: 0;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg {
    max-width: 720px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel);
}
.msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.msg-assistant { align-self: flex-start; }
.msg-content { white-space: pre-wrap; }

/* Idea #2 — citation chips below an assistant answer. Different colors for
   measures (fx) vs columns (⊞) so the user can tell at a glance whether the
   model leaned on a curated measure or computed something ad-hoc from raw
   columns. */
.msg-citations {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.msg-citations-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 4px;
}
.cite-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    border: 1px solid;
}
.cite-chip.cite-measure { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.cite-chip.cite-column  { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

/* Idea #6 — templates picker just above the chat input. Grouped <details>
   blocks per category; chip-btns for each prompt. */
.chat-templates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 6px 12px;
    border-top: 1px solid var(--border);
    background: #fafbfd;
}
.chat-templates-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.chat-templates-group summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    user-select: none;
}
.chat-templates-group summary:hover { background: var(--accent-soft); color: var(--accent); }
.chat-templates-group[open] summary { color: var(--accent); }
.chat-templates-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0 2px;
}

/* Idea #3 — inline chart beneath an answer when the result shape fits. */
.answer-chart {
    margin-top: 10px;
    padding: 8px 10px;
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow-x: auto;
}
.answer-chart-head {
    font-size: 11px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.msg-dax {
    margin-top: 8px;
    border-top: 1px dashed var(--border);
    padding-top: 8px;
}
.msg-dax summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
}
.msg-dax pre {
    margin: 8px 0 0 0;
    padding: 10px;
    background: #0f1220;
    color: #d5dbf2;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
}

.thinking .msg-content { color: var(--muted); }

/* Per-message action row (Generate report, Send to Outlook) */
.msg-actions {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.action-group { display: flex; align-items: center; gap: 4px; }
.chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
}
.chip-btn .icon { vertical-align: 0; }
.chip-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.chip-btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.chip-btn.primary:hover { background: #1f47b8; color: white; }
.small { font-size: 11px; }

/* Artifact chip — file attached to a message */
.msg-attachment { margin-top: 10px; }

/* Star-to-save button on user messages */
.msg-star {
    margin-top: 8px;
    padding: 2px 10px;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 999px;
    color: white;
    font-size: 11px;
    cursor: pointer;
    font-weight: 500;
}
.msg-star:hover { background: rgba(255,255,255,0.28); }
.msg-star.saved { background: #fbbf24; border-color: #fbbf24; color: #422006; }
.msg-star.saved:hover { background: #f59e0b; }

/* "Next run" preview on scheduled saved prompts */
.next-run-pill {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-size: 11px;
    font-weight: 500;
}
.paused-pill {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    background: #FFF8E8;
    border: 1px solid #F0C36D;
    border-radius: 999px;
    color: #5A4A1A;
    font-size: 11px;
    font-weight: 600;
}
/* Last-delivery outcome badge on saved prompts */
.run-status-pill {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.run-status-pill.run-delivered { background: #E9F7EF; border-color: #9AD9B5; color: #1B5E33; }
.run-status-pill.run-failed    { background: #FDECEC; border-color: #F0A6A6; color: #8A1F1F; }
.run-status-pill.run-running   { background: var(--bg); border-color: var(--border); color: var(--text); }
.run-error {
    margin-top: 4px;
    color: #8A1F1F;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60ch;
}
.artifact-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-width: 100%;
}
.msg-user .artifact-chip {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.25);
    color: white;
}
.chip-icon { font-size: 20px; }
.chip-meta { line-height: 1.2; }
.chip-name { font-size: 13px; font-weight: 500; }
.chip-size { font-size: 11px; }

/* Modal overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 32, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal {
    background: var(--panel);
    border-radius: 8px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; display: grid; gap: 14px; }
.modal-body textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}
.modal-foot {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.success-state {
    text-align: center;
    padding: 20px 0;
}
.success-state .ok { font-size: 14px; margin-bottom: 16px; }
.success-state .btn { display: inline-block; margin: 12px 0; text-decoration: none; }

/* Schema panel — sits above the chat input */
.schema-panel {
    background: var(--panel);
    border-top: 1px solid var(--border);
}
.schema-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
}
.schema-head:hover { background: var(--accent-soft); }
.schema-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.schema-toggle { margin-left: auto; color: var(--muted); }
.schema-panel.expanded .schema-body {
    padding: 12px 20px;
    max-height: 240px;
    overflow-y: auto;
}
.block-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin: 8px 0 6px 0;
}
.starters { margin-bottom: 12px; }
.starter-row { display: flex; flex-wrap: wrap; gap: 6px; }
.starter-chip {
    padding: 6px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text);
}
.starter-chip:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.measure-group { margin-bottom: 10px; }
.group-head {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 4px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
    padding: 3px 8px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 12px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    cursor: pointer;
}
.chip:hover { border-color: var(--accent); }

.tables-details { margin-top: 8px; font-size: 12px; }
.tables-details summary { cursor: pointer; color: var(--muted); }
.table-list {
    list-style: none;
    margin: 6px 0 0 0;
    padding: 0;
}
.table-list li { padding: 2px 0; }

.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: var(--panel);
    border-top: 1px solid var(--border);
}
.chat-input input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}
.chat-input input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}
.chat-input button {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-weight: 500;
    cursor: pointer;
}
.chat-input button:disabled {
    background: var(--muted);
    cursor: not-allowed;
}

.muted { color: var(--muted); }
.error { color: var(--error); }

/* Explore tab — column picker + data grid */
.explore {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
}
.explore-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.explore-head h2 { margin: 0; font-size: 16px; }
.explore-head p { margin: 2px 0 0 0; }
.explore-actions { display: flex; align-items: center; gap: 12px; }

.explore-body {
    display: grid;
    grid-template-columns: 280px 1fr;
    overflow: hidden;
}

/* Left: column picker */
.picker {
    background: var(--panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 10px 0;
}
.picker-table { padding: 8px 16px; border-bottom: 1px solid var(--border); }
.picker-table-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    user-select: none;
}
.picker-cols { margin-top: 4px; padding-left: 22px; }
.picker-col {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 13px;
    cursor: pointer;
}
.picker-col:hover .col-name { color: var(--accent); }
.col-name { flex: 1; }
.col-type { font-size: 11px; }

/* Right: data grid */
.grid-pane {
    display: grid;
    grid-template-rows: 1fr auto;
    overflow: hidden;
}
.grid-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}
.grid-scroll {
    overflow: auto;
    padding: 0;
}

.data-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--panel);
}
.data-grid th, .data-grid td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-grid th {
    position: sticky;
    top: 0;
    background: var(--bg);
    font-weight: 600;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
}
.data-grid tbody tr:hover { background: var(--accent-soft); }

.grid-foot {
    padding: 8px 20px;
    background: var(--panel);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}
.dax-peek summary { cursor: pointer; color: var(--muted); }
.dax-peek pre {
    margin-top: 8px;
    padding: 10px;
    background: #0f1220;
    color: #d5dbf2;
    border-radius: 6px;
    font-size: 12px;
    max-height: 160px;
    overflow: auto;
}

/* Saved prompts tab */
.saved-page {
    overflow-y: auto;
    padding: 20px 28px;
    height: 100%;
}
.saved-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
    gap: 16px;
    flex-wrap: wrap;
}
.saved-head h2 { margin: 0 0 4px 0; font-size: 18px; }
.saved-head p { margin: 0; }
.saved-actions { display: flex; align-items: center; gap: 12px; }

.saved-empty {
    background: var(--panel);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
}
.saved-empty h3 { margin: 0 0 6px 0; font-size: 15px; color: var(--text); }
.saved-empty p { margin: 0; }

.saved-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}
.saved-row {
    display: flex;
    gap: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    align-items: flex-start;
}
.saved-row:hover { border-color: var(--accent); }
.saved-meta { flex: 1; min-width: 0; }
.saved-question {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 6px;
}
.saved-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    align-items: center;
    margin-bottom: 4px;
}
.model-tag {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 500;
}
.schedule-tag {
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 500;
}
.schedule-manual   { background: #f0f0f0; color: var(--muted); }
.schedule-daily    { background: #dcfce7; color: #166534; }
.schedule-weekly   { background: #dbeafe; color: #1e40af; }
.schedule-monthly  { background: #fef3c7; color: #92400e; }
.format-tag {
    background: var(--bg);
    color: var(--text);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 11px;
}
.saved-last { font-size: 11px; }
.saved-row-actions {
    display: flex;
    gap: 6px;
    align-self: center;
    flex-wrap: wrap;
}
.saved-foot-note { margin-top: 18px; }

/* History answer preview line */
.history-preview {
    margin: 2px 0 4px;
    font-size: 13px;
    line-height: 1.4;
    opacity: 0.85;
}

/* "Run & deliver" status banner */
.saved-deliver-msg {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 6px 0 14px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
}
.saved-deliver-msg.ok    { background: #ecfdf3; border: 1px solid #abefc6; color: #067647; }
.saved-deliver-msg.error { background: #fef3f2; border: 1px solid #fecdca; color: #b42318; }
.saved-deliver-msg a     { font-weight: 600; }
.saved-deliver-msg .link-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.8;
}

/* Schedule modal sizing */
.modal-wide { max-width: 720px; }
.schedule-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px dashed var(--border);
    margin-top: 8px;
}
.schedule-grid .full-row { grid-column: 1 / -1; }

/* Setup / diagnostics page */
.setup-page {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 32px 48px 32px;
    overflow-y: auto;
    height: 100%;
}
.setup-header h1 { margin: 0 0 6px 0; font-size: 22px; }
.setup-header p { margin: 0 0 20px 0; }

/* Subtle secondary "back" affordance — overrides the loud accent .btn fill so
   it reads as navigation, not the page's primary action. */
.back-link {
    display: inline-block;
    margin: 0 0 14px 0;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    text-decoration: none;
}
.back-link:hover:not(:disabled) {
    background: var(--panel);
    color: var(--text);
}

.setup-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 22px;
    margin-bottom: 18px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.section-head h2 { margin: 0; font-size: 16px; font-weight: 600; }

dl.config {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 8px 16px;
    margin: 0;
}
dl.config dt {
    font-weight: 500;
    color: var(--muted);
}
dl.config dd {
    margin: 0;
}
dl.config code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 12px;
    word-break: break-all;
}

ul.scope-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
ul.scope-list li { padding: 2px 0; }

.actions {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.btn {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--accent-strong); }
.btn:disabled { background: var(--muted); cursor: not-allowed; }

/* Amber call-to-action — the headline action on a screen (Generate, etc.). */
.btn-accent {
    padding: 8px 16px;
    background: var(--accent-2);
    color: #3a2a00;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-2-strong); color: #fff; }
.btn-accent:disabled { background: #f0d9a8; color: #8a7a55; cursor: not-allowed; }
.btn-secondary {
    padding: 8px 16px;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.btn-secondary.small { padding: 4px 10px; font-size: 12px; }
.btn-secondary:hover { background: var(--accent-soft); }
.ok { color: var(--status-completed); font-size: 13px; }
.note { margin-top: 12px; font-size: 13px; }
.warn { color: #b07700; font-size: 13px; }

/* Editable form rows */
.setup-form { display: grid; gap: 14px; }
.setup-field {
    display: grid;
    gap: 4px;
}
.setup-field .label {
    font-weight: 500;
    color: var(--muted);
    font-size: 13px;
}
.setup-field input[type="text"],
.setup-field input[type="password"],
.setup-field select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}
.setup-field input.readonly,
.setup-field input[readonly] {
    background: var(--bg);
    color: var(--muted);
}
.setup-field input:focus, .setup-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}
.setup-field small { font-size: 11px; }
.setup-field.checkbox-field {
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
    align-items: start;
}
.setup-field.checkbox-field input[type="checkbox"] { margin-top: 4px; }
.setup-field.checkbox-field .label { grid-column: 2; }
.setup-field.checkbox-field small { grid-column: 2; }

.checkbox-row { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.checkbox-row label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* Multi-value input (Workspace IDs list) */
.multi-input { display: grid; gap: 6px; }
.multi-row { display: flex; gap: 6px; }
.multi-row input { flex: 1; }
.x-btn {
    width: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--muted);
    font-size: 16px;
}
.x-btn:hover { color: var(--error); border-color: var(--error); }
.add-btn {
    align-self: start;
    padding: 6px 12px;
    background: transparent;
    color: var(--accent);
    border: 1px dashed var(--accent);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.setup-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Secret row */
.secret-display, .secret-edit {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.secret-input {
    flex: 1;
    min-width: 240px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12px;
}

/* Disclosures block under each section */
.disclosures {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 12px;
    color: var(--text);
}
.disclosures p { margin: 6px 0; }
.disclosures strong { font-weight: 600; }

/* "Settings saved" confirmation banner (changes apply live) */
.saved-banner {
    background: #e8f7ee;
    border: 1px solid #4caf72;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #1f6b3b;
}
.saved-banner strong { color: #145228; }

/* Centered primary connect action (Connect MS-Fabric) */
.connect-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.connect-action .btn { min-width: 220px; }
.connect-action small { max-width: 420px; }

.setup-form-inline {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}
.setup-form-inline input { flex: 1; }

/* Blazor framework defaults — keep these for form validation hints + error overlay */
h1:focus { outline: none; }
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

.blazor-error-boundary {
    background: #b32121;
    color: white;
    padding: 1rem 1rem 1rem 3.7rem;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* =========================================================================
 *  /Account/Usage + /Account/Settings pages
 * ========================================================================= */
.account-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}
.account-page h1 { font-size: 22px; margin: 0 0 4px; }
.account-page h2 { font-size: 16px; margin: 24px 0 12px; }
.account-page .muted    { color: var(--muted); font-size: 14px; }
.account-page .hint     { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 4px 0 14px; }
.account-page .footnote { color: var(--muted); font-size: 12px; margin-top: 18px; }

.account-page .period-summary { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.account-page .estimate-note  {
    background: #f6f7fa; border-left: 3px solid var(--muted);
    padding: 10px 14px; font-size: 13px; line-height: 1.55; border-radius: 4px;
    margin: 16px 0 8px;
}

/* Info / warn / unprovisioned banners */
.info-box {
    background: #eef3ff;
    border: 1px solid #c4d2ee;
    color: #1b3a86;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.55;
    margin: 12px 0 20px;
}
.info-box.warn { background: #fff7e6; border-color: #f0c674; color: #5a4500; }

/* Snapshot cards */
.usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin: 6px 0 12px;
}
.usage-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
}
.usage-card.credit { background: #f0f8ff; border-color: #bcd9f1; }
.usage-card-label  { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.usage-card-value  { font-size: 28px; font-weight: 600; margin: 4px 0 6px; }
.usage-card-sub    { font-size: 12px; color: var(--muted); }
.usage-card-sub.warn { color: #b06700; font-weight: 500; }

/* Calls table */
.calls-table {
    width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px;
}
.calls-table th, .calls-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.calls-table th { background: #f6f7fa; font-weight: 600; }
.calls-table td.num, .calls-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.calls-table tr.failed td { color: #b32121; }
.calls-table code { font-size: 12px; }
.pager { display: flex; align-items: center; gap: 14px; margin: 14px 0 0; font-size: 13px; }
.pager button { padding: 4px 10px; }
.pager button:disabled { opacity: 0.4; cursor: default; }

/* Settings form */
.settings-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 22px;
    margin-bottom: 18px;
}
.threshold-row {
    display: flex; align-items: center; gap: 14px; margin: 8px 0 6px;
}
.dollar-input { display: inline-flex; align-items: center; font-weight: 600; font-size: 15px; }
.dollar-input input {
    width: 110px; margin-left: 4px; padding: 4px 8px; font-size: 15px;
    border: 1px solid var(--border); border-radius: 4px;
}
.actions { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.actions button.primary {
    background: var(--accent); color: white; border: 0;
    padding: 6px 16px; border-radius: 4px; cursor: pointer; font-size: 14px;
}
.actions button.primary:hover  { background: #1f47b8; }
.actions button.primary:disabled { background: #888; cursor: default; }
.saved-ok { color: #1b6d3b; font-size: 13px; }
.save-err { color: #b32121; font-size: 13px; }

/* =========================================================================
 *  Report builder — list (/Reports) + editor (/Reports/{id})
 * ========================================================================= */

/* ---- Shared bits ---- */
.count-pill {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 7px;
    background: var(--accent-soft); color: var(--accent);
    border-radius: 999px; font-size: 12px; font-weight: 600;
    vertical-align: middle;
}

/* ---- Reports list page ---- */
.reports-hero { margin-bottom: 18px; }
.reports-hero h1 { margin: 0 0 4px; }
.reports-hero-actions {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px;
}
.auto-report-cta { text-decoration: none; }

/* ---- Published reports (Portal) page ---- */
.page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 24px 60px;
    /* Own the scroll: .app-main is overflow:hidden at a fixed 100vh. */
    height: 100%;
    overflow-y: auto;
}
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; margin: 0 0 6px; }
.page-head .muted { font-size: 14px; line-height: 1.5; margin: 0 0 14px; max-width: 70ch; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th,
.data-table td {
    text-align: left;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}
.data-table th {
    font-weight: 600;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
}
.data-table td:first-child { font-weight: 600; white-space: normal; }
.data-table tbody tr:hover { background: var(--accent-soft); }
.data-table td:last-child { text-align: right; }
.data-table .report-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.data-table .report-link:hover { text-decoration: underline; }

/* Auto Report page */
.auto-report-form { max-width: 520px; }
.auto-report-form .run-btn { margin-top: 8px; }
.auto-report-breadcrumb {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 14px;
}
.auto-report-breadcrumb .ar-chip {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    background: #eef4ff; border: 1px solid #c7ddfb; color: #1d4ed8;
    font-size: 12px; font-weight: 600; text-transform: capitalize;
}
.auto-report-refine {
    margin: 4px 0 16px; padding: 12px 14px;
    background: #fafbfd; border: 1px solid var(--border); border-radius: 10px;
}
.auto-report-refine .arr-row { display: flex; gap: 8px; align-items: center; }
.auto-report-refine .arr-row .field-input { flex: 1; }
.auto-report-refine .arr-msg { margin: 8px 0 0; }

.create-report-bar {
    display: flex; gap: 10px; align-items: center;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; padding: 12px 14px; margin-bottom: 20px;
}
.create-report-input {
    flex: 1; padding: 10px 12px; font-size: 14px;
    border: 1px solid var(--border); border-radius: 6px;
}
.create-report-input:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.reports-empty {
    background: var(--panel); border: 1px dashed var(--border);
    border-radius: 12px; padding: 48px 24px; text-align: center;
}
.reports-empty-icon { font-size: 40px; margin-bottom: 8px; }
.reports-empty h3 { margin: 0 0 6px; font-size: 16px; }

.page-head-actions { display: flex; gap: 8px; align-items: center; }

/* Deliver — inline per-row actions cell */
.data-table td.row-actions { white-space: nowrap; }
.data-table td.row-actions .chip-btn { margin-right: 4px; }

/* Portal — collapsible "what is AIAB / why publish here" explainer */
.aiab-explainer { margin: 8px 0 24px; }
.aiab-summary {
    cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text);
    padding: 8px 0; list-style: none; user-select: none;
}
.aiab-summary::-webkit-details-marker { display: none; }
.aiab-summary::before { content: "▸ "; color: var(--muted); }
.aiab-explainer[open] .aiab-summary::before { content: "▾ "; }
.aiab-explainer-grid {
    display: grid; gap: 16px; margin: 8px 0 0;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.aiab-explainer-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px 18px;
}
.aiab-explainer-card h3 { margin: 6px 0 8px; font-size: 15px; }
.aiab-explainer-card p { margin: 0; font-size: 13px; line-height: 1.55; }
.aiab-icon { font-size: 24px; line-height: 1; }
.aiab-why { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.aiab-why li { margin-bottom: 6px; }

.report-card-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.report-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px 18px; cursor: pointer;
    display: flex; flex-direction: column; gap: 8px; min-height: 140px;
    transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.report-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 18px rgba(36, 81, 214, 0.10);
    transform: translateY(-1px);
}
.report-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.report-card-title { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.3; }
.report-card-desc { margin: 0; font-size: 13px; color: var(--text); line-height: 1.45; flex: 1; }
.report-card-foot {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border);
}
.report-card-open { color: var(--accent); font-size: 13px; font-weight: 500; }

/* ---- Report editor page ---- */
.report-editor-page {
    max-width: 1280px; margin: 0 auto; padding: 20px 20px 60px;
    /* Own the scroll: .app-main is overflow:hidden at a fixed 100vh, so a tall
       report (wizard + preview) must scroll itself — same pattern as .setup-page.
       Without this, the page below the fold is unreachable until you zoom out. */
    height: 100%; overflow-y: auto;
}
.report-editor-page h1 { font-size: 22px; margin: 0; }
.report-editor-page h2 { font-size: 15px; margin: 0 0 12px; }
.report-editor-page .hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 14px; }

.report-editor-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin: 6px 0 14px; flex-wrap: wrap;
}
.report-editor-head-actions { display: flex; align-items: center; gap: 10px; }
.run-btn { background: #1b6d3b; }
.run-btn:hover:not(:disabled) { background: #15592f; }
.run-btn:disabled { background: #9bbcab; cursor: not-allowed; }

/* Progress bar */
.report-progress { margin: 0 0 16px; }
.report-progress-track {
    height: 8px; background: var(--accent-soft);
    border-radius: 999px; overflow: hidden;
}
.report-progress-bar {
    height: 100%; background: var(--accent);
    border-radius: 999px; transition: width .3s ease;
}
.report-progress-label { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* Result download card */
.report-result-card {
    display: flex; align-items: center; gap: 14px;
    background: #ecfdf3; border: 1px solid #abefc6;
    border-radius: 10px; padding: 12px 16px; margin: 0 0 18px;
}
.report-result-card .rrc-icon { font-size: 26px; }
.report-result-card .rrc-meta { flex: 1; min-width: 0; }
.report-result-card .rrc-name { font-weight: 600; font-size: 14px; word-break: break-all; }
.rrc-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Two-pane layout */
.report-editor-grid {
    display: grid; gap: 20px; align-items: start;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
@media (max-width: 980px) {
    .report-editor-grid { grid-template-columns: 1fr; }
}
.report-build-pane { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* Form fields */
.field { display: grid; gap: 4px; margin: 0 0 12px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field-label em { font-weight: 400; font-style: normal; opacity: 0.75; }
.field-input {
    width: 100%; padding: 8px 10px; font-size: 14px; font-family: inherit;
    border: 1px solid var(--border); border-radius: 6px; background: var(--panel);
}
.field-input:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}
textarea.field-input { resize: vertical; }

.date-hint {
    margin: -4px 0 14px; font-size: 12.5px; color: var(--muted);
    background: var(--accent-soft); border-radius: 6px; padding: 7px 10px;
}
.date-hint strong { color: var(--accent); }

/* Section cards */
.sections-empty {
    border: 1px dashed var(--border); border-radius: 8px;
    padding: 18px; text-align: center;
}
.report-sections { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.report-section-card {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px 12px;
    transition: border-color .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.report-section-card:hover { border-color: #c7d2ec; }
.report-section-card.dragging { opacity: 0.45; }
.report-section-card.drop-target {
    border-color: var(--accent);
    box-shadow: 0 -3px 0 var(--accent) inset;
}
.rsc-handle {
    cursor: grab; color: var(--muted); font-size: 16px; line-height: 1.4;
    user-select: none; padding: 0 2px;
}
.rsc-handle:active { cursor: grabbing; }
.rsc-num {
    flex: none; width: 22px; height: 22px; border-radius: 6px;
    background: var(--bg); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; color: var(--muted);
}
.rsc-body { flex: 1; min-width: 0; }
.rsc-title { font-weight: 600; font-size: 14px; line-height: 1.35; }
.rsc-prompt summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 2px; }
.rsc-prompt code {
    display: block; margin-top: 6px; padding: 8px 10px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
    font-size: 12px; white-space: pre-wrap; word-break: break-word;
}
.icon-btn {
    flex: none; width: 26px; height: 26px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--panel);
    color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1;
}
.icon-btn.danger:hover { border-color: var(--error); color: var(--error); background: #fef3f2; }
.drag-hint-glyph { font-family: inherit; }

.add-section {
    margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border);
}
.add-section h3 { font-size: 13px; margin: 0 0 10px; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.04em; }

/* Live preview pane */
.report-preview-pane {
    position: sticky; top: 16px; min-width: 0;
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
    overflow: hidden;
}
.preview-toolbar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.preview-toolbar-title { font-size: 12px; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.04em; }

/* "paper" document */
.report-doc {
    background: var(--panel); margin: 16px; padding: 28px 32px;
    border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 2px 10px rgba(15, 18, 32, 0.05);
    /* No inner scroll — the doc flows in the page's single scrollbar (see
       .report-preview-scroll). A 70vh inner cap here created the nested
       scrollbar-within-a-scrollbar the user reported. */
}
.report-doc .doc-title { font-size: 22px; margin: 0 0 6px; font-weight: 700; }
.report-doc .doc-desc { margin: 0 0 12px; color: var(--text); }
.report-doc .doc-meta { margin: 0 0 18px; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.report-doc .doc-empty { padding: 24px 0; text-align: center; }
.doc-section { padding: 14px 0; border-top: 1px solid var(--border); }
.doc-section:first-of-type { border-top: none; }
.doc-section-title { font-size: 16px; margin: 0 0 6px; font-weight: 600; }
.doc-question { margin: 0 0 8px; font-style: italic; color: var(--muted); }
.doc-placeholder { margin: 0; }
.doc-answer { margin: 0 0 8px; white-space: pre-wrap; line-height: 1.55; }
.doc-error { margin: 0 0 8px; }

/* Inline compose box + "or" divider in the add-section area */
.compose-box { margin-bottom: 12px; }
.add-divider {
    display: flex; align-items: center; text-align: center;
    color: var(--muted); font-size: 12px; margin: 14px 0;
}
.add-divider::before, .add-divider::after {
    content: ""; flex: 1; border-top: 1px solid var(--border);
}
.add-divider span { padding: 0 12px; }

/* ============ Auto Report wizard ============ */
.wizard-step {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    margin: 16px 0;
}
.wizard-step-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.wizard-step-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.wizard-step-head h2 em { color: var(--muted); font-weight: 400; font-style: normal; font-size: 13px; }
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex: 0 0 auto;
}

/* Step rail */
.step-rail {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}
.step-rail li {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}
.step-rail li .sr-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 999px;
    background: var(--border); color: var(--panel); font-weight: 700; font-size: 11px;
}
.step-rail li.active { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); font-weight: 600; }
.step-rail li.active .sr-num { background: var(--accent); color: #fff; }
.step-rail li.done .sr-num { background: var(--accent-2); color: #3a2a00; }

/* Model pane — vertical list (like the main screen) */
.model-pane {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 480px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    background: var(--bg);
}
.model-pick-row {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--panel);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.1s ease;
}
.model-pick-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.model-pick-row.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.mpr-dot { font-size: 16px; }
.mpr-name { flex: 1; }

/* Field picker — grouped, plain-language chips */
.field-picker { display: flex; flex-direction: column; gap: 14px; margin: 10px 0 4px; }
.field-group { display: block; }
.field-group h3 {
    margin: 0 0 6px; font-size: 12px; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--muted);
}
.field-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 12px; margin: 0 6px 6px 0;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--bg); cursor: pointer; font-size: 13px;
    transition: all 0.1s ease;
}
.field-chip:hover { border-color: var(--accent); }
.field-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.field-chip input { accent-color: var(--accent); }

/* Wizard nav */
.wizard-nav { display: flex; gap: 10px; margin-top: 18px; }

/* Layout cards (Step 4) + mini thumbnails */
.layout-cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.layout-card {
    flex: 1 1 160px; max-width: 220px; text-align: left;
    background: var(--bg); border: 2px solid var(--border); border-radius: 12px;
    padding: 12px; cursor: pointer; transition: all 0.12s ease;
}
.layout-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.layout-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.lc-name { font-size: 14px; font-weight: 600; margin: 8px 0 2px; }
.lc-blurb { font-size: 11px; color: var(--muted); line-height: 1.35; }

.layout-thumb {
    height: 84px; border-radius: 6px; background: #fff;
    border: 1px solid var(--border); padding: 8px; display: flex;
    flex-direction: column; gap: 5px;
}
.layout-thumb span { background: var(--accent-soft); border-radius: 3px; display: block; }

/* Vertical — one wide title spanning the top, then full-width section bands. */
.th-vertical .t-title { height: 13px; }
.th-vertical .t-band  { flex: 1; }

/* Horizontal — two columns, EACH with its own small title above a fill. */
.th-horizontal { flex-direction: row; gap: 6px; }
.th-horizontal .t-col { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.th-horizontal .t-title.sm { height: 8px; width: 70%; }
.th-horizontal .t-fill { flex: 1; }

/* Dashboard — emphasized KPI chips across the top, then a row of tiles. */
.th-dashboard .t-kpis  { display: flex; gap: 4px; }
.th-dashboard .t-kpis span { flex: 1; height: 15px; background: var(--accent); }
.th-dashboard .t-tiles { flex: 1; display: flex; gap: 4px; }
.th-dashboard .t-tiles span { flex: 1; }

/* Line detail — a matrix: bold header row + bold left category column. */
.th-linedetail { gap: 3px; }
.th-linedetail .t-mrow { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 3px; flex: 1; }
.th-linedetail .t-mrow span { background: #ece9f7; }
.th-linedetail .t-mrow .t-cat { background: #d3cdec; }
.th-linedetail .t-head span { background: var(--accent); opacity: .55; }

/* ---- Step 5 live sample preview (each layout is genuinely different) ---- */
.layout-preview { margin: 14px 0 6px; }
.lp-caption { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.lp-caption strong { color: var(--text); }
.lp-report {
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 16px; display: grid; gap: 12px; align-items: start;
    box-shadow: 0 1px 3px rgba(20,30,80,.05);
}
.lp-title { grid-column: 1 / -1; font-size: 14px; font-weight: 700; color: var(--text); }
.lp-title.sm { font-size: 12.5px; }
.lp-kpis { display: flex; gap: 10px; }
.lp-kpi {
    flex: 1; background: var(--accent-soft); border-radius: 8px; padding: 8px 10px;
    display: flex; flex-direction: column; gap: 2px;
}
.lp-kpi-v { font-size: 16px; font-weight: 700; color: var(--accent); }
.lp-kpi-l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lp-chart {
    display: flex; align-items: flex-end; gap: 6px; height: 90px;
    background: #fafbff; border: 1px solid var(--border); border-radius: 8px; padding: 8px;
}
.lp-chart i { flex: 1; background: linear-gradient(180deg, var(--accent), var(--accent-soft)); border-radius: 3px 3px 0 0; }
.lp-table { display: flex; flex-direction: column; font-size: 11px; }
.lp-tr { display: grid; grid-template-columns: 2fr 1fr 1fr; padding: 5px 6px; border-bottom: 1px solid var(--border); }
.lp-tr span:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.lp-th { font-weight: 700; color: var(--muted); border-bottom: 2px solid var(--border); }

/* Section with its own heading (Horizontal columns + Dashboard tiles). */
.lp-sec, .lp-tile { display: flex; flex-direction: column; gap: 8px; }
.lp-sec-title {
    font-size: 12px; font-weight: 700; color: var(--text);
    border-bottom: 1px solid var(--border); padding-bottom: 4px;
}

/* Vertical — one large title spanning the page, then KPIs → chart → table. */
.lp-vertical { grid-template-columns: 1fr; }
.lp-title-xl {
    font-size: 19px; font-weight: 800; text-align: center; letter-spacing: -.01em;
    padding-bottom: 10px; border-bottom: 2px solid var(--accent-soft);
}

/* Horizontal — two side-by-side sections, each with its OWN title. No KPI strip. */
.lp-horizontal { grid-template-columns: 1fr 1fr; }

/* Dashboard — KPI tiles emphasized across the top, then a grid of titled tiles. */
.lp-dashboard { grid-template-columns: 1fr 1fr; }
.lp-kpis-top { grid-column: 1 / -1; }
.lp-dashboard .lp-kpi { background: var(--accent); }
.lp-dashboard .lp-kpi-v { color: #fff; }
.lp-dashboard .lp-kpi-l { color: rgba(255,255,255,.82); }
.lp-tile { background: #fafbff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.lp-tile .lp-chart { height: 72px; background: #fff; }

/* Line detail — a dense matrix: bold months across the top, bold category at left. */
.lp-linedetail { grid-template-columns: 1fr; }
.lp-matrix { display: flex; flex-direction: column; font-size: 11.5px; }
.lp-mr { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); padding: 6px 6px; border-bottom: 1px solid var(--border); }
.lp-mr span:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.lp-mhead { font-weight: 700; color: var(--text); border-bottom: 2px solid var(--border); }
.lp-cat { font-weight: 700; color: var(--text); }
.lp-mtotal { border-top: 2px solid var(--border); font-weight: 700; }

@media (max-width: 720px) {
    .lp-horizontal, .lp-dashboard { grid-template-columns: 1fr; }
}

/* Preview frame + scroll */
.report-html-frame {
    border: 1px solid var(--border); border-radius: 10px;
    overflow: hidden; margin: 14px 0; background: #fff;
}
/* No inner scroll — the preview flows in the page so there's a single
   page scrollbar instead of a scrollbar-within-a-scrollbar. */
.report-preview-scroll { padding: 16px; background: #fff; }

/* Report section LAYOUT variants (the 4 looks) */
.doc-sections.layout-vertical { display: block; }
.doc-sections.layout-horizontal { display: flex; flex-wrap: wrap; gap: 18px; }
.doc-sections.layout-horizontal .doc-section { flex: 1 1 320px; min-width: 280px; }
.doc-sections.layout-dashboard { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.doc-sections.layout-dashboard .doc-section {
    border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--bg);
}
.doc-sections.layout-linedetail .doc-section { margin-bottom: 10px; }
.doc-sections.layout-linedetail .doc-answer { font-size: 12px; }
.doc-sections.layout-linedetail .answer-chart,
.doc-sections.layout-linedetail .msg-dax { display: none; }

/* Excel-style crosstab matrix (Line detail layout) */
.report-matrix-wrap { overflow-x: auto; margin: 14px 0 20px; }
.report-matrix { border-collapse: collapse; font-size: 12px; width: 100%; }
.report-matrix th,
.report-matrix td {
    border: 1px solid var(--border); padding: 4px 10px;
    text-align: right; white-space: nowrap;
}
.report-matrix thead th { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.report-matrix thead th.rm-corner { text-align: left; }
.report-matrix .rm-rowhead {
    text-align: left; font-weight: 500; background: #f8fafc;
    position: sticky; left: 0;
}
.report-matrix .rm-agg { font-weight: 600; background: #f1f5f9; }
.report-matrix tbody tr:hover td { background: #f8fafc; }

/* Filter step — value chips */
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.filter-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--accent-soft); color: var(--accent);
    border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12px; font-weight: 500;
}
.filter-chip .fc-x {
    border: none; background: none; cursor: pointer; color: inherit;
    font-size: 14px; line-height: 1; padding: 0 2px; opacity: .7;
}
.filter-chip .fc-x:hover { opacity: 1; }

/* Schedule grid */
.schedule-grid { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0 12px; }
.schedule-grid .field { flex: 1 1 160px; }


/* Report-type sub-nav (chooser / Question / Canvas) */
.rsub { display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
        padding: 10px 0 14px; margin-bottom: 6px; }
.rsub__t { font-size: 13px; color: #374151; text-decoration: none;
           padding: 6px 12px; border-radius: 8px; display: inline-flex; align-items: center; gap: 7px; }
.rsub__t:hover { background: #f1f5f9; }
.rsub__t.on { background: #eef2ff; color: #4f46e5; font-weight: 600; }
