/* ============================================================
   friends-of-dax — web chat UI
   Riffs on dax-diagnostics / Dr Sparky: dark FUI, sci-fi,
   a hint of retro. Same palette and primitives as that repo's
   styles.css so the two tools read as one family.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Jura:wght@300..700&display=swap');

/* ── CSS Custom Properties ──────────────────────────────────── */
:root {
    --bg-primary-color:      #000000;
    --bg-secondary-color:    #080E10;
    --fg-primary-color:      #18242B;
    --filterbar-color:       #0D161A;
    --font-primary-color:    #FFFFFFE5;
    --font-secondary-color:  #6FBDCC;
    --font-terciary-color:   #ccc36f;
    --font-muted:            #ffffff85;

    --nav-height: 52px;
    --teal-glow:        rgba(111, 189, 204, 0.18);
    --teal-glow-strong: rgba(111, 189, 204, 0.45);
    --amber-glow:       rgba(204, 195, 111, 0.2);

    --danger-color:    #f87171;
    --danger-bg:       rgba(248, 113, 113, 0.12);
    --danger-border:   rgba(248, 113, 113, 0.4);
    --success-color:   #6fcc94;
    --warn-color:      var(--font-terciary-color);

    --mono: 'Courier New', monospace;
}

@font-face {
    font-family: scifi;
    src: local("Jura"), local("Jura Regular");
    font-weight: 100 900;
    font-style: normal;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary-color);
    color: var(--font-primary-color);
    font-family: 'Jura', scifi, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
}
button { cursor: pointer; user-select: none; }
button:disabled { cursor: not-allowed; }
select option {
    color: var(--font-primary-color);
    background: var(--bg-secondary-color);
}
[hidden] { display: none !important; }

/* ── Custom Scrollbars ───────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    background-clip: padding-box;
    border-radius: 9999px;
    background-color: #3a4a50;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--font-secondary-color); }
::-webkit-scrollbar-track {
    background-color: #0a1216;
    border-radius: 9999px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

/* ── Typography helpers ──────────────────────────────────────── */
.text-teal   { color: var(--font-secondary-color) !important; }
.text-amber  { color: var(--font-terciary-color) !important; }
.text-muted  { color: var(--font-muted) !important; }
.text-danger { color: var(--danger-color) !important; }

/* ── Nav Bar ─────────────────────────────────────────────────── */
#nav-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--bg-secondary-color);
    border-bottom: 1px solid rgba(111, 189, 204, 0.18);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 500;
    gap: 16px;
    box-shadow: 0 2px 24px rgba(0, 0, 0, 0.6);
}
.nav-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    min-width: 0;
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Logo */
.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    flex-shrink: 0;
}
.nav-logo-mark {
    font-size: 1.3rem;
    color: var(--font-secondary-color);
    line-height: 1;
    filter: drop-shadow(0 0 6px var(--font-secondary-color));
    animation: pulse-glow 3s ease-in-out infinite;
}
.nav-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--font-primary-color);
    white-space: nowrap;
}
.nav-title-sub {
    color: var(--font-secondary-color);
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    margin-left: 6px;
}

/* Agent selector (riff on the bot selector) */
.nav-field {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 0;
}
.nav-field-label {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: var(--font-muted);
    font-weight: 600;
}
.nav-select-wrap {
    position: relative;
    min-width: 180px;
}
.nav-select-wrap::after {
    content: '▾';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--font-muted);
    font-size: 0.75rem;
    pointer-events: none;
}
.nav-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    background: var(--fg-primary-color);
    border: 1px solid rgba(111, 189, 204, 0.22);
    border-radius: 5px;
    padding: 5px 28px 5px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.nav-select:hover,
.nav-select:focus {
    border-color: var(--font-secondary-color);
    background: #1f3038;
}

/* Status cluster */
.nav-status-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-status-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.nav-status-label {
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    color: var(--font-muted);
    line-height: 1;
}
.nav-status-value {
    font-size: 0.78rem;
    color: var(--font-secondary-color);
    font-weight: 600;
    line-height: 1.2;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-status-sep {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.08);
}
.nav-version {
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--font-muted);
}
.nav-icon-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--font-muted);
    border-radius: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: color 0.15s, border-color 0.15s;
}
.nav-icon-btn:hover {
    color: var(--danger-color);
    border-color: var(--danger-border);
}

/* Threads drawer toggle — mobile only */
.nav-mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    color: var(--font-primary-color);
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.nav-mobile-toggle:hover,
.nav-mobile-toggle.fod-active {
    border-color: var(--font-secondary-color);
    color: var(--font-secondary-color);
    background: rgba(111, 189, 204, 0.1);
}

/* ── Main Container ───────────────────────────────────────────── */
#main-container {
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0; bottom: 0;
    overflow: hidden;
    background: var(--bg-primary-color);
}
.fod-main {
    position: relative;
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ── Buttons (dax-btn) ───────────────────────────────────────── */
.fod-btn {
    background: var(--bg-secondary-color);
    color: var(--font-primary-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    padding: 7px 16px;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    transition: border-color 0.15s, background 0.15s;
}
.fod-btn:hover:not(:disabled) {
    border-color: var(--font-secondary-color);
    background: var(--fg-primary-color);
}
.fod-btn:disabled { opacity: 0.35; }
.fod-btn-sm {
    padding: 3px 9px;
    font-size: 0.7rem;
    border-radius: 4px;
}
.fod-btn-primary {
    border-color: var(--font-secondary-color);
    color: var(--font-secondary-color);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.fod-btn-primary:hover:not(:disabled) {
    background: rgba(111, 189, 204, 0.12);
    border-color: var(--font-secondary-color);
}
.fod-btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(111, 189, 204, 0.3);
}

/* ── Thread rail ─────────────────────────────────────────────── */
.fod-threads-panel {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--filterbar-color);
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    overflow: hidden;
}
.fod-threads-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.fod-threads-title {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--font-muted);
    user-select: none;
}
.fod-threads-list {
    flex: 1;
    overflow-y: auto;
    padding: 5px 0;
}

.fod-thread-item {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 10px;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    user-select: none;
}
.fod-thread-item:hover { background: rgba(111, 189, 204, 0.05); }
.fod-thread-item:hover .fod-thread-delete { opacity: 1; }
.fod-thread-item.active {
    background: rgba(111, 189, 204, 0.08);
    border-left-color: var(--font-secondary-color);
}
.fod-thread-item-body { flex: 1; min-width: 0; }
.fod-thread-item-title {
    font-size: 0.75rem;
    color: var(--font-primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}
.fod-thread-item.active .fod-thread-item-title { color: var(--font-secondary-color); }
.fod-thread-item-meta {
    font-size: 0.62rem;
    color: var(--font-muted);
    margin-top: 2px;
    opacity: 0.75;
}
.fod-thread-delete {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--font-muted);
    font-size: 0.6rem;
    border-radius: 3px;
    opacity: 0;
    margin-top: 2px;
    transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.fod-thread-delete:hover {
    background: rgba(248, 113, 113, 0.15);
    color: var(--danger-color);
    opacity: 1;
}
.fod-threads-empty {
    padding: 18px 12px;
    text-align: center;
    color: var(--font-muted);
    font-size: 0.7rem;
    opacity: 0.7;
    line-height: 1.7;
}
.fod-thread-backdrop { display: none; }

/* ── Chat area ───────────────────────────────────────────────── */
.fod-chat-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header: agent identity + per-request context */
.fod-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 18px;
    min-height: 50px;
    background: var(--bg-secondary-color);
    border-bottom: 1px solid rgba(111, 189, 204, 0.2);
    box-shadow: 0 1px 0 rgba(111, 189, 204, 0.06), inset 0 -1px 24px rgba(0, 0, 0, 0.25);
}
.fod-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.fod-logo-mark {
    color: var(--font-secondary-color);
    font-size: 1.1rem;
    opacity: 0.9;
}
.fod-title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--font-secondary-color);
    white-space: nowrap;
}
.fod-header-sep {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.75rem;
}
.fod-tier {
    font-size: 0.8rem;
    color: var(--font-muted);
    white-space: nowrap;
}
.fod-header-right {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    flex-shrink: 0;
}

/* Underline fields (form-input) */
.fod-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.fod-field-label {
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    color: var(--font-muted);
    line-height: 1;
    user-select: none;
}
.fod-field-input {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0;
    padding: 3px 2px;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: var(--font-primary-color);
    caret-color: var(--font-secondary-color);
    outline: none;
    min-width: 150px;
    transition: border-color 0.15s;
}
.fod-field-input::placeholder {
    color: rgba(255, 255, 255, 0.22);
    font-style: italic;
    text-transform: none;
}
.fod-field-input:focus { border-bottom-color: var(--font-secondary-color); }
select.fod-field-input { cursor: pointer; padding-right: 16px; }
.fod-select-wrap { position: relative; }
.fod-select-wrap::after {
    content: '▾';
    position: absolute;
    right: 2px;
    bottom: 5px;
    color: var(--font-muted);
    font-size: 0.7rem;
    pointer-events: none;
}
#ticket {
    width: 9.5rem;
    min-width: 0;
    text-transform: uppercase;
    font-family: var(--mono);
    font-size: 0.82rem;
}

/* ── Empty state ─────────────────────────────────────────────── */
.fod-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--font-muted);
    text-align: center;
}
.fod-empty-icon {
    font-size: 2.8rem;
    color: var(--font-secondary-color);
    opacity: 0.25;
    line-height: 1;
}
.fod-empty-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--font-primary-color);
    opacity: 0.35;
}
.fod-empty-subtitle {
    font-size: 0.8rem;
    color: var(--font-muted);
    opacity: 0.7;
    max-width: 36rem;
    line-height: 1.6;
}

/* ── Chat body ───────────────────────────────────────────────── */
.fod-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    /* subtle scanline texture — very low opacity to keep it understated */
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.018) 3px,
        rgba(0, 0, 0, 0.018) 4px
    );
}
.fod-messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 20px;
    max-width: 900px;
    margin: 0 auto;
}

/* ── User message ────────────────────────────────────────────── */
.fod-msg-user {
    display: flex;
    justify-content: flex-end;
    margin: 6px 0;
    animation: fod-msg-in 0.2s ease both;
}
.fod-user-bubble {
    max-width: 68%;
    background: rgba(111, 189, 204, 0.1);
    border: 1px solid rgba(111, 189, 204, 0.28);
    border-radius: 12px 12px 2px 12px;
    padding: 10px 14px;
    color: var(--font-primary-color);
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Bot message ─────────────────────────────────────────────── */
.fod-msg-bot {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 8px 0;
}
.fod-msg-bot.fod-appear { animation: fod-msg-in 0.2s ease both; }
.fod-bot-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(111, 189, 204, 0.08);
    border: 1px solid rgba(111, 189, 204, 0.3);
    border-radius: 50%;
    color: var(--font-secondary-color);
    font-size: 0.78rem;
    margin-top: 2px;
    transition: box-shadow 0.3s, border-color 0.3s;
}
.fod-bot-avatar.fod-streaming {
    border-color: var(--teal-glow-strong);
    box-shadow: 0 0 10px var(--teal-glow);
    animation: fod-pulse-opacity 1.5s ease-in-out infinite;
}
.fod-bot-content {
    flex: 1;
    min-width: 0;
}

/* ── Route pill ──────────────────────────────────────────────── */
/* Which prompt-cache lineage answered this turn and why (SSE `route`). */
.fod-route {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 3px 10px;
    margin-bottom: 8px;
    background: rgba(111, 189, 204, 0.05);
    border: 1px solid rgba(111, 189, 204, 0.18);
    border-radius: 99px;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    color: var(--font-muted);
    animation: fod-card-in 0.18s ease both;
}
.fod-route-icon { color: var(--font-secondary-color); flex-shrink: 0; }
.fod-route-label { color: var(--font-secondary-color); font-weight: 600; flex-shrink: 0; }
.fod-route-reason {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.02em;
    font-style: italic;
    opacity: 0.85;
}
.fod-route-variant {
    background: rgba(204, 195, 111, 0.05);
    border-color: rgba(204, 195, 111, 0.25);
}
.fod-route-variant .fod-route-icon,
.fod-route-variant .fod-route-label { color: var(--font-terciary-color); }

/* ── Shared card bits ────────────────────────────────────────── */
.fod-chevron {
    flex-shrink: 0;
    color: var(--font-muted);
    font-size: 0.7rem;
    transition: transform 0.15s;
}
.fod-open > button .fod-chevron { transform: rotate(90deg); }
.fod-tool-pre,
.fod-thinking-text {
    margin: 0;
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.55;
}

/* ── Thinking card ───────────────────────────────────────────── */
/* One card per thinking block, in narrative order. Collapsed it shows a
   live tail of the summarized reasoning; click to read all of it. */
.fod-thinking {
    margin-bottom: 8px;
    background: var(--filterbar-color);
    border: 1px solid rgba(204, 195, 111, 0.18);
    border-radius: 6px;
    overflow: hidden;
    animation: fod-card-in 0.2s ease both;
    transition: opacity 0.3s, border-color 0.3s;
}
.fod-thinking:not(.fod-live):not(.fod-open) { opacity: 0.6; }
.fod-thinking:hover, .fod-thinking.fod-open { opacity: 1; border-color: rgba(204, 195, 111, 0.35); }
.fod-thinking-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 5px 12px;
    background: none;
    border: 0;
    color: var(--font-terciary-color);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-align: left;
}
.fod-thinking-head:disabled { cursor: default; }
.fod-thinking-icon { font-size: 0.85rem; opacity: 0.8; flex-shrink: 0; }
.fod-thinking.fod-live .fod-thinking-icon { animation: fod-spin 1.4s linear infinite; }
.fod-thinking-label { flex-shrink: 0; }
.fod-thinking-preview {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--font-muted);
    font-size: 0.72rem;
    font-style: italic;
    letter-spacing: 0.02em;
}
.fod-thinking-body { border-top: 1px solid rgba(204, 195, 111, 0.12); }
.fod-thinking-text {
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--font-muted);
}

/* ── Tool call card ──────────────────────────────────────────── */
/* Header: name, compact input, duration, CALLING -> RUNNING -> DONE/ERROR.
   Body: the full input and the result the model got back (plain text --
   results are user-authored data, never rendered as HTML). */
.fod-tool {
    margin-bottom: 8px;
    background: var(--fg-primary-color);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    overflow: hidden;
    animation: fod-card-in 0.18s ease both;
    transition: border-color 0.15s;
}
.fod-tool:hover, .fod-tool.fod-open { border-color: rgba(111, 189, 204, 0.25); }
.fod-tool.fod-tool-failed { border-color: var(--danger-border); }
.fod-tool-head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 12px;
    background: none;
    border: 0;
    text-align: left;
}
.fod-tool-icon {
    color: var(--font-secondary-color);
    font-size: 0.8rem;
    flex-shrink: 0;
}
.fod-tool-name {
    flex-shrink: 0;
    max-width: 45%;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--font-secondary-color);
    font-family: var(--mono);
    letter-spacing: 0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fod-tool-args {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--font-muted);
}
.fod-tool-time {
    flex-shrink: 0;
    font-size: 0.65rem;
    color: var(--font-muted);
    letter-spacing: 0.04em;
}
.fod-tool-status {
    font-size: 0.68rem;
    color: var(--font-muted);
    letter-spacing: 0.06em;
    flex-shrink: 0;
}
.fod-tool-status.fod-running {
    color: var(--font-secondary-color);
    animation: fod-pulse-opacity 1.5s ease-in-out infinite;
}
.fod-tool-status.fod-done { color: var(--success-color); }
.fod-tool-status.fod-error { color: var(--danger-color); }
.fod-tool-status.fod-stopped { color: var(--danger-color); }
.fod-tool-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.fod-tool-section-label {
    margin-bottom: 4px;
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    color: var(--font-secondary-color);
}
.fod-tool-pre {
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--font-primary-color);
}
.fod-tool-failed .fod-tool-result { color: var(--danger-color); }

/* ── Response text ───────────────────────────────────────────── */
.fod-text {
    color: var(--font-primary-color);
    font-size: 0.88rem;
    line-height: 1.7;
    word-break: break-word;
    margin-bottom: 8px;
}
.fod-text:last-child { margin-bottom: 0; }
.fod-text p { margin: 0 0 0.75em; }
.fod-text p:last-child { margin-bottom: 0; }
.fod-text strong { color: var(--font-secondary-color); font-weight: 600; }
.fod-text em { color: var(--font-muted); font-style: italic; }
.fod-text code {
    font-family: var(--mono);
    font-size: 0.82em;
    background: rgba(111, 189, 204, 0.1);
    border: 1px solid rgba(111, 189, 204, 0.15);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--font-secondary-color);
}
.fod-text pre {
    background: #050b0e;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 6px;
    padding: 12px 14px;
    overflow-x: auto;
    margin: 10px 0;
}
.fod-text pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--font-primary-color);
    font-size: 0.82rem;
}
.fod-text ul, .fod-text ol {
    padding-left: 1.5em;
    margin: 0 0 0.75em;
}
.fod-text li { margin-bottom: 0.25em; }
.fod-text h1, .fod-text h2, .fod-text h3, .fod-text h4 {
    color: var(--font-secondary-color);
    font-weight: 600;
    letter-spacing: 0.03em;
    margin: 1em 0 0.4em;
}
.fod-text h1 { font-size: 1.1rem; }
.fod-text h2 { font-size: 1rem; }
.fod-text h3 { font-size: 0.9rem; }
.fod-text h4 { font-size: 0.85rem; }
.fod-text blockquote {
    border-left: 3px solid rgba(111, 189, 204, 0.4);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--font-muted);
}
.fod-text a {
    color: var(--font-secondary-color);
    text-decoration: none;
    border-bottom: 1px solid rgba(111, 189, 204, 0.3);
}
.fod-text a:hover { border-color: var(--font-secondary-color); }
.fod-text hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 12px 0;
}
.fod-text table {
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.82rem;
    display: block;
    max-width: 100%;
    overflow-x: auto;
}
.fod-text th, .fod-text td {
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 5px 10px;
    text-align: left;
    vertical-align: top;
}
.fod-text th {
    background: rgba(111, 189, 204, 0.06);
    color: var(--font-secondary-color);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.fod-text tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }
/* Cells keep whole words; a wide table scrolls inside its own box instead. */
.fod-text th, .fod-text td { word-break: normal; overflow-wrap: normal; white-space: nowrap; }
.fod-text td { white-space: normal; min-width: 6rem; }

/* PROWAG citations — validated server-side, linked here */
.fod-text a.cite {
    font-family: var(--mono);
    font-size: 0.85em;
    white-space: nowrap;
    border-bottom: 1px dotted var(--font-secondary-color);
}
.fod-text a.cite:hover { border-bottom-style: solid; }
.fod-text .cite.unknown {
    font-family: var(--mono);
    font-size: 0.85em;
    color: var(--danger-color);
    border-bottom: 1px dashed var(--danger-color);
    cursor: help;
    white-space: nowrap;
}

/* Streaming cursor — injected before the last closing tag each delta */
.fod-cursor {
    display: inline;
    color: var(--font-secondary-color);
    font-size: 0.9em;
    line-height: 1;
    margin-left: 1px;
    vertical-align: baseline;
    user-select: none;
    animation: fod-cursor-blink 1s step-end infinite;
}

/* ── Turn footer: usage + warnings ───────────────────────────── */
.fod-turn-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}
.fod-usage {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 99px;
    font-size: 0.65rem;
    color: var(--font-muted);
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.fod-usage-sep { opacity: 0.4; }
.fod-usage.fod-model { color: var(--font-secondary-color); font-weight: 600; }
.fod-usage.fod-warn {
    color: var(--font-terciary-color);
    border-color: rgba(204, 195, 111, 0.3);
    background: rgba(204, 195, 111, 0.06);
}
.fod-usage.fod-stopped {
    color: var(--danger-color);
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(248, 113, 113, 0.06);
}
.fod-usage.fod-inspect { cursor: pointer; user-select: none; }
.fod-usage.fod-inspect:hover {
    color: var(--font-secondary-color);
    border-color: rgba(111, 189, 204, 0.3);
}

/* ── Time-saved feedback strip (once per thread, chat.js maybe_ask_feedback) ── */
.fod-feedback {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 10px;
    border: 1px dashed rgba(111, 189, 204, 0.3);
    border-radius: 6px;
    font-size: 0.7rem;
    color: var(--font-muted);
    letter-spacing: 0.04em;
    animation: fod-card-in 0.2s ease both;
}
.fod-feedback-q { margin-right: 4px; }
.fod-feedback-chip {
    padding: 3px 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--font-primary-color);
    font-family: inherit;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    white-space: nowrap;
}
.fod-feedback-chip:hover:not(:disabled),
.fod-feedback-skip:hover:not(:disabled) {
    color: var(--font-secondary-color);
    border-color: rgba(111, 189, 204, 0.45);
    background: var(--teal-glow);
}
.fod-feedback-chip:disabled,
.fod-feedback-skip:disabled { opacity: 0.4; cursor: default; }
.fod-feedback-skip {
    margin-left: auto;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: none;
    color: var(--font-muted);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}
.fod-feedback.fod-feedback-done {
    border-style: solid;
    border-color: rgba(111, 189, 204, 0.18);
    opacity: 0.8;
}
.fod-feedback-ack { color: var(--success-color); }
.fod-feedback-note { flex-basis: 100%; }
.fod-feedback-note.fod-feedback-error { color: var(--danger-color); }

/* ── Notices, dividers, errors ───────────────────────────────── */
.fod-notice {
    align-self: center;
    max-width: 80%;
    text-align: center;
    color: var(--font-muted);
    font-size: 0.75rem;
    font-style: italic;
    letter-spacing: 0.03em;
    margin: 6px 0;
    opacity: 0.8;
}
.fod-turn-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
    user-select: none;
}
.fod-turn-divider::before,
.fod-turn-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}
.fod-error-block {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    margin: 6px 0;
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: 6px;
    color: var(--danger-color);
    font-size: 0.83rem;
    animation: fod-card-in 0.18s ease both;
}
.fod-error-icon { flex-shrink: 0; }

/* ── Typing indicator ────────────────────────────────────────── */
.fod-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 0 4px;
}
.fod-typing span {
    width: 5px;
    height: 5px;
    background: var(--font-secondary-color);
    border-radius: 50%;
    opacity: 0.5;
    animation: fod-dot-bounce 1.3s ease-in-out infinite;
}
.fod-typing span:nth-child(2) { animation-delay: 0.18s; }
.fod-typing span:nth-child(3) { animation-delay: 0.36s; }

/* ── Welcome banner ──────────────────────────────────────────── */
.fod-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 48px 20px 24px;
    color: var(--font-muted);
    font-size: 0.8rem;
    text-align: center;
    animation: fod-msg-in 0.25s ease both;
}
.fod-welcome-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--font-secondary-color);
}
.fod-welcome-desc {
    max-width: 36rem;
    line-height: 1.6;
    opacity: 0.8;
}
.fod-hints {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    max-width: 44rem;
}
.fod-hint {
    background: var(--bg-secondary-color);
    color: var(--font-primary-color);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 99px;
    padding: 5px 13px;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.fod-hint:hover {
    border-color: var(--font-secondary-color);
    color: var(--font-secondary-color);
    background: rgba(111, 189, 204, 0.08);
}

/* ── Input area ──────────────────────────────────────────────── */
.fod-input-wrap {
    flex-shrink: 0;
    width: 100%;
    background: var(--bg-secondary-color);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.fod-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 20px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}
.fod-input {
    flex: 1;
    background: var(--fg-primary-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--font-primary-color);
    font-size: 0.88rem;
    line-height: 1.5;
    resize: none;
    min-height: 42px;
    max-height: 180px;
    overflow-y: auto;
    outline: none;
    caret-color: var(--font-secondary-color);
    transition: border-color 0.15s;
}
.fod-input::placeholder { color: var(--font-muted); }
.fod-input:focus { border-color: rgba(111, 189, 204, 0.45); }
.fod-input:disabled { opacity: 0.5; }
.fod-send-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(111, 189, 204, 0.1);
    border: 1px solid rgba(111, 189, 204, 0.28);
    border-radius: 8px;
    color: var(--font-secondary-color);
    font-size: 0.9rem;
    transition: background 0.15s, border-color 0.15s;
}
.fod-send-btn:hover:not(:disabled) {
    background: rgba(111, 189, 204, 0.2);
    border-color: var(--font-secondary-color);
}
.fod-send-btn:disabled { opacity: 0.4; }
/* Stop mode — shown while a turn is streaming */
.fod-send-btn.fod-stop-mode {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.4);
    color: var(--danger-color);
}
.fod-send-btn.fod-stop-mode:hover {
    background: rgba(248, 113, 113, 0.2);
    border-color: var(--danger-color);
}

/* ── Attachments: paperclip, pending chips, chips on a sent message ── */
.fod-attach-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(111, 189, 204, 0.06);
    border: 1px solid rgba(111, 189, 204, 0.28);
    border-radius: 8px;
    color: var(--font-secondary-color);
    transition: background 0.15s, border-color 0.15s;
}
.fod-attach-btn:hover:not(:disabled) {
    background: rgba(111, 189, 204, 0.2);
    border-color: var(--font-secondary-color);
}
.fod-attach-btn:disabled { opacity: 0.4; }
.fod-pending {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 10px 20px 0;
}
.fod-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    font-family: "Jura", sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    color: var(--font-primary-color);
    background: rgba(111, 189, 204, 0.08);
    border: 1px solid rgba(111, 189, 204, 0.28);
    border-radius: 6px;
    padding: 3px 8px;
}
.fod-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 18rem;
}
.fod-chip-meta { color: var(--font-muted); white-space: nowrap; }
.fod-chip-remove {
    background: none;
    border: none;
    padding: 0 0 0 2px;
    color: var(--font-muted);
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
}
.fod-chip-remove:hover { color: var(--danger-color); }
.fod-user-attachments {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
}
.fod-msg-user { flex-wrap: wrap; }
.fod-msg-user .fod-user-attachments { flex-basis: 100%; }
.fod-input-wrap.fod-dragging {
    outline: 2px dashed rgba(111, 189, 204, 0.6);
    outline-offset: -6px;
}

/* ── FUI overlays: scanlines + corner brackets ───────────────── */
.scanlines {
    pointer-events: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0px,
        rgba(0, 0, 0, 0) 2px,
        rgba(0, 0, 0, 0.04) 2px,
        rgba(0, 0, 0, 0.04) 4px
    );
    animation: scanlines-drift 12s linear infinite;
}
.corner-decor {
    pointer-events: none;
    position: fixed;
    width: 28px;
    height: 28px;
    z-index: 9998;
    opacity: 0.35;
}
.corner-decor.tl { top: 4px; left: 4px;
    border-top: 1px solid var(--font-secondary-color);
    border-left: 1px solid var(--font-secondary-color); }
.corner-decor.tr { top: 4px; right: 4px;
    border-top: 1px solid var(--font-secondary-color);
    border-right: 1px solid var(--font-secondary-color); }
.corner-decor.bl { bottom: 4px; left: 4px;
    border-bottom: 1px solid var(--font-secondary-color);
    border-left: 1px solid var(--font-secondary-color); }
.corner-decor.br { bottom: 4px; right: 4px;
    border-bottom: 1px solid var(--font-secondary-color);
    border-right: 1px solid var(--font-secondary-color); }

/* ── Login ───────────────────────────────────────────────────── */
.fod-auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% -10%, var(--teal-glow) 0%, rgba(0, 0, 0, 0) 35%),
        var(--bg-primary-color);
}
.fod-auth-panel {
    width: min(380px, 92vw);
    background: var(--bg-secondary-color);
    border: 1px solid rgba(111, 189, 204, 0.3);
    border-radius: 10px;
    padding: 26px 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 0 40px rgba(111, 189, 204, 0.12), 0 8px 32px rgba(0, 0, 0, 0.6);
    animation: fod-msg-in 0.3s ease both;
}
.fod-auth-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    user-select: none;
}
.fod-auth-panel h2 {
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    color: var(--font-muted);
    text-transform: uppercase;
}
.fod-auth-sub {
    font-size: 0.78rem;
    color: var(--font-muted);
    line-height: 1.6;
    opacity: 0.8;
    margin-bottom: 14px;
}
.fod-form-group { margin-bottom: 16px; }
.fod-form-group label {
    display: block;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: var(--font-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}
.fod-form-input {
    width: 100%;
    padding: 7px 2px;
    font-size: 0.95rem;
    letter-spacing: 0.03em;
    color: var(--font-primary-color);
    caret-color: var(--font-secondary-color);
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0;
    outline: none;
    transition: border-color 0.15s;
}
.fod-form-input::placeholder { color: rgba(255, 255, 255, 0.22); font-style: italic; }
.fod-form-input:focus { border-bottom-color: var(--font-secondary-color); }
/* Bury Chrome's autofill flash behind our own surface colour */
.fod-form-input:-webkit-autofill,
.fod-form-input:-webkit-autofill:hover,
.fod-form-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-secondary-color) inset !important;
    box-shadow: 0 0 0 1000px var(--bg-secondary-color) inset !important;
    -webkit-text-fill-color: var(--font-primary-color) !important;
    transition: background-color 9999s ease-in-out 0s;
}
.fod-auth-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 4px;
}
.fod-auth-footer .fod-btn-primary { padding: 8px 32px; }
.fod-auth-error {
    font-size: 0.78rem;
    color: var(--danger-color);
    letter-spacing: 0.03em;
    text-align: center;
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 4px var(--font-secondary-color)); opacity: 1; }
    50%      { filter: drop-shadow(0 0 10px var(--font-secondary-color)); opacity: 0.8; }
}
@keyframes scanlines-drift {
    from { background-position-y: 0; }
    to   { background-position-y: 200px; }
}
@keyframes fod-msg-in {
    from { opacity: 0; transform: translateY(7px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fod-card-in {
    from { opacity: 0; transform: translateX(-3px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes fod-pulse-opacity {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}
@keyframes fod-dot-bounce {
    0%, 80%, 100% { opacity: 0.4; transform: translateY(0); }
    40%           { opacity: 1;   transform: translateY(-4px); }
}
@keyframes fod-cursor-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}
@keyframes fod-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Nav compact (≤ 900px) ───────────────────────────────────── */
@media (max-width: 900px) {
    .nav-title-sub,
    .nav-version { display: none; }
    .nav-select-wrap { min-width: 150px; }
    .nav-left { gap: 12px; }
    .fod-header-right { gap: 12px; }
    .fod-field-input { min-width: 120px; }
}

/* ── Mobile (≤ 640px) ─────────────────────────────────────────── */
@media (max-width: 640px) {
    .nav-mobile-toggle { display: flex; }
    .nav-title,
    .nav-field-label,
    .nav-status-cluster { display: none; }
    #nav-bar { padding: 0 10px; gap: 8px; }
    .nav-right { gap: 8px; }
    .nav-select-wrap { min-width: 0; width: 100%; }
    .nav-field { flex: 1; min-width: 0; }

    /* Thread rail becomes a slide-in left drawer */
    .fod-threads-panel {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }
    .fod-main.fod-threads-open .fod-threads-panel { transform: translateX(0); }
    .fod-thread-backdrop {
        position: absolute;
        inset: 0;
        z-index: 19;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(1px);
    }
    .fod-main.fod-threads-open .fod-thread-backdrop { display: block; }
    .fod-thread-delete { opacity: 1; }

    /* Header: stack identity over context fields */
    .fod-header {
        flex-wrap: wrap;
        gap: 8px 16px;
        padding: 8px 12px;
    }
    .fod-header-right { gap: 14px; }
    .fod-field-input { min-width: 110px; }
    #ticket { width: 7.5rem; }

    .fod-messages { padding: 0 10px; }
    .fod-user-bubble { max-width: 85%; }
    .fod-input-row { padding: 10px 12px; }
    .fod-pending { padding: 8px 12px 0; }
    .fod-chip-name { max-width: 10rem; }
    .fod-bot-avatar { width: 24px; height: 24px; font-size: 0.68rem; }
    .fod-msg-bot { gap: 8px; }
    .corner-decor { display: none; }
}

/* ══════════════════════════════════════════════════════════════
   Impact dashboard (metrics.html / metrics.js)
   Chart marks use a slightly deeper teal than the UI accent (the
   accent sits below the chroma floor for data marks), a de-emphasis
   gray for "cost vs value", and one ordinal teal ramp for stacks --
   all validated against the dark surface.
   ══════════════════════════════════════════════════════════════ */
:root {
    --viz-accent: #4fa3b5;
    --viz-muted:  #7d878c;
    --viz-t1: #c9e9ef;
    --viz-t2: #8fd0dc;
    --viz-t3: #4fa3b5;
    --viz-t4: #2a6b7a;
    --viz-p1: #8fd0dc;
    --viz-p2: #3d8fa1;
}
/* #main-container is overflow:hidden for the chat layout; the id selector
   outranks a lone class, so the metrics page scopes its scroll rule with it. */
#main-container.fod-metrics-container { overflow-y: auto; overflow-x: hidden; }
.fod-metrics {
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 24px 64px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}
.nav-page-tag {
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    color: var(--font-secondary-color);
    border: 1px solid rgba(111, 189, 204, 0.35);
    border-radius: 3px;
    padding: 2px 7px;
    white-space: nowrap;
}
a.nav-icon-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

.fod-metrics-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.fod-metrics-kicker {
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    color: var(--font-muted);
}
.fod-metrics-title {
    margin: 2px 0 4px;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--font-primary-color);
}
.fod-metrics-sub { font-size: 0.85rem; color: var(--font-muted); }

/* Filter row: one row, above everything it scopes */
.fod-metrics-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 18px;
    padding: 12px 16px;
    background: var(--bg-secondary-color);
    border: 1px solid rgba(111, 189, 204, 0.18);
    border-radius: 8px;
}
.fod-metrics-controls .fod-field { min-width: 120px; }
.fod-metrics-controls .fod-num { width: 90px; }
.fod-metrics-controls .fod-btn { align-self: flex-end; }
.fod-metrics-status {
    margin-left: auto;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    color: var(--font-muted);
    align-self: center;
}
.fod-metrics-status-error { color: var(--danger-color); }
.fod-metrics-empty { position: static; min-height: 280px; }
#dash.fod-loading { opacity: 0.55; transition: opacity 0.15s; }

/* Hero figure: the one number the page leads with */
.fod-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 24px;
    padding: 22px 26px;
    background: var(--filterbar-color);
    border: 1px solid rgba(111, 189, 204, 0.28);
    border-radius: 10px;
    box-shadow: 0 0 40px rgba(111, 189, 204, 0.08), 0 8px 32px rgba(0, 0, 0, 0.5);
}
.fod-hero-label {
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    color: var(--font-muted);
}
.fod-hero-value {
    font-size: 3.6rem;
    font-weight: 700;
    line-height: 1.05;
    margin: 6px 0 8px;
    color: var(--font-primary-color);
    text-shadow: 0 0 24px rgba(111, 189, 204, 0.25);
}
.fod-hero-value.fod-hero-negative { color: var(--danger-color); text-shadow: none; }
.fod-hero-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--font-muted);
}
.fod-hero-op { color: var(--font-secondary-color); }
.fod-hero-side {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
}
.fod-hero-side .fod-usage { font-size: 0.7rem; padding: 5px 11px; }
.fod-usage.fod-good {
    color: var(--success-color);
    border-color: rgba(111, 204, 148, 0.35);
    background: rgba(111, 204, 148, 0.08);
}
.fod-hero-basis {
    flex-basis: 100%;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--font-muted);
}

/* KPI tiles */
.fod-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.fod-kpi {
    padding: 12px 14px;
    background: var(--filterbar-color);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    min-width: 0;
}
.fod-kpi-label {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--font-muted);
}
.fod-kpi-value {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 4px 0 2px;
    color: var(--font-primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fod-kpi-sub { font-size: 0.7rem; color: var(--font-muted); line-height: 1.4; }

/* Chart cards */
.fod-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 14px;
}
.fod-chart {
    margin: 0;
    padding: 14px 16px 12px;
    background: var(--filterbar-color);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fod-chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.fod-chart-title {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--font-primary-color);
}
.fod-chart-sub { font-size: 0.72rem; color: var(--font-muted); margin-top: 2px; }
.fod-chart-body { min-width: 0; }
.fod-chart-body svg { overflow: visible; font-family: inherit; outline: none; }
.fod-chart-body svg:focus-visible { outline: 1px solid rgba(111, 189, 204, 0.5); outline-offset: 4px; border-radius: 4px; }
.fod-chart-body svg text { font-family: 'Jura', scifi, sans-serif; font-variant-numeric: tabular-nums; }
.fod-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 0.7rem;
    color: var(--font-muted);
}
.fod-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.fod-legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.fod-legend-swatch.fod-legend-line { width: 14px; height: 2px; border-radius: 1px; }

/* Tooltip: values lead, labels follow */
.fod-tip {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    min-width: 140px;
    max-width: 280px;
    padding: 8px 10px;
    background: var(--bg-secondary-color);
    border: 1px solid rgba(111, 189, 204, 0.35);
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
    font-size: 0.72rem;
    color: var(--font-primary-color);
}
.fod-tip-title { color: var(--font-muted); letter-spacing: 0.06em; margin-bottom: 4px; }
.fod-tip-row { display: flex; align-items: center; gap: 7px; padding: 1px 0; font-variant-numeric: tabular-nums; }
.fod-tip-row strong { font-weight: 600; }
.fod-tip-key { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.fod-tip-key-line { width: 12px; height: 2px; border-radius: 1px; }
.fod-tip-label { color: var(--font-muted); }

/* Tables (the accessible twin of every chart, and the breakdowns) */
.fod-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.fod-table-card {
    padding: 14px 16px;
    background: var(--filterbar-color);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    min-width: 0;
}
.fod-table-card .fod-chart-title { margin-bottom: 8px; }
.fod-table-wrap { overflow-x: auto; }
.fod-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}
.fod-table th, .fod-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}
.fod-table th {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--font-muted);
    font-weight: 500;
}
.fod-table .fod-num-col { text-align: right; font-variant-numeric: tabular-nums; }
.fod-table tbody tr:hover { background: rgba(111, 189, 204, 0.05); }
.fod-table .fod-usage { margin-left: 4px; }

.fod-metrics-note {
    font-size: 0.72rem;
    line-height: 1.55;
    color: var(--font-muted);
    margin: 0;
}

@media (max-width: 900px) {
    .nav-page-tag { display: none; }
}
@media (max-width: 640px) {
    .fod-metrics { padding: 18px 12px 48px; gap: 16px; }
    .fod-hero { grid-template-columns: 1fr; padding: 18px; }
    .fod-hero-value { font-size: 2.6rem; }
    .fod-charts, .fod-tables { grid-template-columns: 1fr; }
    .fod-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fod-metrics-controls .fod-field { min-width: 100px; }
    .fod-metrics-status { flex-basis: 100%; margin-left: 0; }
}
