/*
 * X-Ray Integrations — Design System
 * Light, Claude-inspired aesthetic. DM Sans + DM Mono.
 * Sourced from the design bundle (Apr 2026 redesign).
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

:root {
    /* Fonts */
    --font-ui:   'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'DM Mono', 'Consolas', 'Courier New', monospace;

    /* Surfaces — warm off-white base */
    --bg:           #FAFAF8;
    --surface:      #FFFFFF;
    --surface-alt:  #F4F4F1;
    --surface-sunk: #F0EFEA;

    /* Borders */
    --border:       #E5E5E2;
    --border-mid:   #CFCFCA;
    --border-strong:#B5B5AE;

    /* Text */
    --text:         #1C1C1A;
    --text-sub:     #5A5A52;
    --text-muted:   #9A9A90;
    --text-ghost:   #C0C0B7;

    /* Accent — orange (primary CTA, brand stripe) */
    --orange:       #F68D2E;
    --orange-hov:   #E07C1E;
    --orange-deep:  #C66A14;
    --orange-pale:  #FFF4E8;
    --orange-ring:  rgba(246, 141, 46, 0.18);
    --orange-glow:  rgba(246, 141, 46, 0.30);

    /* Workday navy (badges, info accents) */
    --navy:         #00274D;
    --navy-light:   #EBF2FA;

    /* Kio purple (AI-enhanced markers) */
    --purple:       #6B3FA0;
    --purple-deep:  #4A2070;
    --purple-pale:  #F3EEF9;

    /* Semantic */
    --green:        #2D7A50;
    --green-pale:   #EBF7F1;
    --green-deep:   #1A5E36;
    --red:          #C0392B;
    --red-pale:     #FDF1EF;
    --red-deep:     #8B2016;
    --amber:        #B07020;
    --amber-pale:   #FEF9EC;
    --amber-deep:   #7A4A00;
    --blue:         #005CB9;
    --blue-pale:    #E5F0FA;
    --blue-deep:    #004A9A;

    /* Step type colors (for left-border accents) */
    --step-entry:       #2D7A50;
    --step-processing:  var(--purple);
    --step-routing:     var(--amber);
    --step-workday:     var(--orange-hov);
    --step-iterator:    #2E86AB;
    --step-error:       var(--red);

    /* Radius */
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 11px;
    --r-xl: 14px;
    --r-2xl: 18px;
    --r-pill: 999px;

    /* Spacing scale (4px base) */
    --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
    --s5: 20px; --s6: 24px; --s7: 28px; --s8: 32px;
    --s10: 40px; --s12: 48px; --s14: 56px; --s16: 64px;

    /* Shadows */
    --shadow-card:  0 1px 4px rgba(0,0,0,0.04);
    --shadow-card-hover: 0 4px 14px rgba(0,0,0,0.07);
    --shadow-float: 0 12px 48px rgba(0,0,0,0.14);
    --shadow-fab:   0 4px 22px rgba(107, 63, 160, 0.40);
    --shadow-cta:   0 4px 22px rgba(246, 141, 46, 0.28);
    --shadow-active:0 0 0 3px var(--orange-ring);

    /* Layout */
    --max-w-index:   780px;
    --max-w-report:  1300px;
    --max-w-upgrade: 1600px;
    --nav-h: 60px;

    /* Transitions */
    --t-fast: 0.15s ease;
    --t-base: 0.20s ease;
    --t-slow: 0.30s ease;
    --t-bounce: 0.40s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── RESET ─────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbars — quiet */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ─── ANIMATIONS ─────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes float  { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes floatSlow { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-5px) rotate(4deg); } }
@keyframes spinTool { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes scanLine { 0% { top: 8%; opacity: 0; } 10% { opacity: 1; } 88% { opacity: 1; } 100% { top: 90%; opacity: 0; } }
@keyframes blink   { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes wiggle  { 0%, 100% { transform: rotate(0deg); } 30% { transform: rotate(-10deg); } 70% { transform: rotate(10deg); } }
@keyframes progress{ from { width: 0%; } to { width: 100%; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulseRing { 0% { box-shadow: 0 0 0 0 rgba(246,141,46,0.30); } 70% { box-shadow: 0 0 0 8px rgba(246,141,46,0); } 100% { box-shadow: 0 0 0 0 rgba(246,141,46,0); } }
/* CLAR file's float — combined with its centered translate so the keyframe
   doesn't blow away the centering. Bobs DOWN at peak so it doesn't crowd
   the speech bubble that sits just above the CLAR's top edge. */
@keyframes floatClar {
    0%, 100% { transform: translate(-50%, -54%); }
    50%      { transform: translate(-50%, calc(-54% + 6px)); }
}

.fade-up    { animation: fadeUp 0.45s ease both; }
.fade-in    { animation: fadeIn 0.35s ease both; }
.scale-in   { animation: scaleIn 0.40s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.slide-up   { animation: slideUp 0.45s ease both; }

/* ─── TYPE ─────────────────────────────────────── */
.text-hero {
    font-size: 2.7rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.04em;
    line-height: 1.15;
}
.text-hero .accent { color: var(--orange); }

h1, .h1 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    letter-spacing: -0.02em;
}
h2, .h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
h3, .h3 {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
}

.eyebrow {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
}
.text-body { font-size: 0.92rem; color: var(--text-sub); line-height: 1.7; }
.text-sm { font-size: 0.82rem; color: var(--text-sub); }
.text-mono { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-sub); }
.text-mute { color: var(--text-muted); }

/* ─── BADGES & CHIPS ─────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.66rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    padding: 3px 9px; border-radius: var(--r-sm);
}
.badge-orange  { background: var(--orange-pale); color: var(--orange-deep); border: 1px solid rgba(246,141,46,0.30); }
.badge-orange-solid { background: var(--orange); color: #fff; }
.badge-green   { background: var(--green-pale); color: var(--green-deep); border: 1px solid rgba(45,122,80,0.25); }
.badge-red     { background: var(--red-pale); color: var(--red-deep); border: 1px solid rgba(192,57,43,0.25); }
.badge-amber   { background: var(--amber-pale); color: var(--amber-deep); border: 1px solid rgba(176,112,32,0.25); }
.badge-purple  { background: var(--purple-pale); color: var(--purple-deep); border: 1px solid rgba(107,63,160,0.25); }
.badge-blue    { background: var(--blue-pale); color: var(--blue-deep); border: 1px solid rgba(0,92,185,0.25); }
.badge-soft    { background: var(--surface-alt); color: var(--text-sub); border: 1px solid var(--border); }
.badge-ai {
    background: linear-gradient(135deg, #7B2D8E, #005CB9);
    color: #fff;
    border: none;
    letter-spacing: 0.4px;
}
.badge-kio-enhanced {
    display: inline-flex; align-items: center; gap: 4px;
    background: linear-gradient(135deg, rgba(107,63,160,0.10), rgba(0,92,185,0.10));
    border: 1px solid rgba(107,63,160,0.20);
    color: var(--purple);
    font-size: 0.7rem; font-weight: 600;
    padding: 3px 10px; border-radius: 8px;
}

/* ─── BUTTONS ─────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-weight: 600;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    padding: 10px 22px;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all var(--t-base);
    line-height: 1.2;
    letter-spacing: -0.005em;
}
.btn-primary {
    background: var(--orange);
    color: #fff;
    box-shadow: 0 2px 12px rgba(246,141,46,0.25);
}
.btn-primary:hover:not(:disabled) {
    background: var(--orange-hov);
    transform: translateY(-1px);
    box-shadow: var(--shadow-cta);
}
.btn-primary:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}
.btn-ghost {
    background: var(--surface);
    color: var(--text-sub);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    border-color: var(--orange);
    color: var(--orange);
}
.btn-success {
    background: var(--green);
    color: #fff;
}
.btn-lg {
    padding: 14px 32px;
    font-size: 0.96rem;
    border-radius: var(--r-lg);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 0.78rem;
    border-radius: 7px;
}
.btn:disabled { cursor: not-allowed; transform: none !important; }

/* ─── NAVBAR ─────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(250, 250, 248, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--s10);
    height: var(--nav-h);
}
.navbar-brand {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer;
    color: var(--text);
}
.navbar-brand svg { height: 24px; width: auto; }
.navbar-brand .name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}
.navbar-crumb {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex; align-items: center; gap: 8px;
}
.navbar-crumb .sep { color: var(--border-mid); }

/* ─── CARDS ─────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-card);
}
.card-pad { padding: var(--s5) var(--s6); }
.card:hover.interactive { box-shadow: var(--shadow-card-hover); }
.card-strong-border { border-color: var(--border-mid); }

/* ─── TYPE CARDS (integration type selector) ─── */
.type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s3);
}
.type-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--r-xl);
    padding: 22px 18px;
    text-align: left;
    cursor: pointer;
    transition: all var(--t-base);
    box-shadow: var(--shadow-card);
    font-family: inherit;
    color: var(--text);
}
.type-card:hover:not(.is-active) {
    border-color: var(--border-mid);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}
.type-card.is-active {
    border-color: var(--orange);
    background: var(--orange-pale);
    box-shadow: var(--shadow-active);
}
.type-card .icon { font-size: 1.5rem; margin-bottom: 10px; line-height: 1; }
.type-card .name { font-size: 0.94rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.type-card .desc { font-size: 0.76rem; color: var(--text-sub); line-height: 1.55; }

/* ─── DROP / UPLOAD ZONES ─────────────────────── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--r-xl);
    padding: 36px 24px;
    text-align: center;
    background: var(--surface);
    cursor: pointer;
    transition: all var(--t-base);
}
.drop-zone:hover, .drop-zone.is-drag {
    border-color: var(--orange);
    background: var(--orange-pale);
}
.drop-zone.has-file {
    border-color: var(--green);
    background: var(--green-pale);
    border-style: solid;
    padding: 22px 24px;
}
.drop-zone .placeholder-icon {
    font-size: 2rem;
    opacity: 0.35;
    margin-bottom: 10px;
}
.drop-zone .heading { font-size: 0.92rem; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.drop-zone .sub    { font-size: 0.78rem; color: var(--text-muted); }
.drop-zone .file-row {
    display: flex; align-items: center; justify-content: center; gap: 14px;
}
.drop-zone .file-icon {
    width: 44px; height: 44px;
    background: var(--green-pale);
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.drop-zone .file-name { font-weight: 600; color: var(--text); font-size: 0.92rem; }
.drop-zone .file-state { font-size: 0.76rem; color: var(--green-deep); margin-top: 3px; }

.optional-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s2);
    margin-top: var(--s3);
}
.optional-tile {
    border: 1.5px dashed var(--border);
    border-radius: var(--r-md);
    padding: 12px;
    text-align: center;
    background: var(--surface);
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--t-fast);
}
.optional-tile:hover { border-color: var(--orange); }
.optional-tile.has-file {
    border-color: var(--green);
    color: var(--green-deep);
    background: var(--green-pale);
    border-style: solid;
}

/* ─── INPUTS ─────────────────────────────────────── */
.input, .textarea, .select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 0.88rem;
    color: var(--text);
    font-family: inherit;
    outline: none;
    transition: border-color var(--t-base);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--orange); }
.textarea { resize: vertical; line-height: 1.55; }

/* Toggle */
.toggle {
    width: 44px;
    height: 26px;
    border-radius: 13px;
    background: var(--border);
    position: relative;
    cursor: pointer;
    transition: background var(--t-base);
    flex-shrink: 0;
    border: none;
    padding: 0;
}
.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: left var(--t-bounce);
}
.toggle.is-on { background: var(--orange); }
.toggle.is-on::after { left: 21px; }

/* ─── KIO (mascot + scene) ─────────────────────── */
.kio-canvas {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.kio-scene {
    position: relative;
    width: 460px;
    height: 300px;
    margin: 0 auto;
    user-select: none;
    max-width: 100%;
}
.kio-scene .clar-file {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -54%);
    width: 130px; height: 158px;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 6px 28px rgba(0,0,0,0.07);
    transition: border-color 0.5s ease, box-shadow 0.5s ease;
    overflow: hidden;
    z-index: 10;
    animation: floatClar 4.2s ease-in-out infinite;
}
/* During analyse, freeze the CLAR so the scan-beam reads cleanly. */
.kio-scene.is-analyzing .clar-file { animation: none; }
.kio-scene .clar-file::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 30px; height: 30px;
    background: var(--bg);
    border-left: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
    border-radius: 0 12px 0 0;
    clip-path: polygon(0 0, 100% 100%, 100% 0);
    transition: border-color 0.5s;
}
.kio-scene .clar-file .label {
    margin: 14px 12px 8px;
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--orange);
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}
.kio-scene .clar-file .lines { padding: 0 12px; }
.kio-scene .clar-file .lines i {
    display: block;
    height: 4px;
    margin-bottom: 6px;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.3s;
}
.kio-scene.is-analyzing .clar-file {
    border-color: var(--orange);
    box-shadow: 0 0 0 4px var(--orange-ring), 0 16px 48px rgba(246,141,46,0.12);
}
.kio-scene.is-analyzing .clar-file::before { border-color: var(--orange); }
.kio-scene.is-analyzing .clar-file .lines i {
    background: linear-gradient(90deg, var(--orange), var(--orange-hov));
}
.kio-scene .scan-beam {
    position: absolute;
    left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--orange), transparent);
    z-index: 20;
    display: none;
}
.kio-scene.is-analyzing:not(.is-done) .scan-beam {
    display: block;
    animation: scanLine 1.4s ease-in-out infinite;
}
.kio-scene .done-overlay {
    position: absolute; inset: 0;
    background: rgba(255,255,255,0.93);
    display: none;
    align-items: center; justify-content: center;
    z-index: 30;
}
.kio-scene .done-overlay .check {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.kio-scene.is-done .done-overlay { display: flex; animation: fadeIn 0.4s ease; }
.kio-scene .kio-spot {
    position: absolute;
    left: 28px; bottom: 12px;
    animation: float 3.2s ease-in-out infinite;
}
.kio-scene.is-analyzing .kio-spot { animation: none; }
/* Speech bubble: top-left, thought-cloud style with a trail of dots leading
   down to Kio's head. Avoids overlapping the centered CLAR file. */
.kio-scene .speech {
    position: absolute;
    left: 16px; top: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 9px 14px;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text);
    box-shadow: 0 4px 18px rgba(0,0,0,0.06);
    max-width: 250px;
    line-height: 1.4;
    /* fadeUp on entry, then float continuously — float's 1s delay starts
       just after fadeUp finishes (0.3s + 0.5s = 0.8s). */
    animation: fadeUp 0.5s ease 0.3s both, float 3.8s ease-in-out 1s infinite;
    z-index: 15;
}
.kio-scene.is-analyzing:not(.is-done) .speech {
    border-color: var(--orange);
    box-shadow: 0 4px 16px var(--orange-ring);
}
.kio-scene.is-done .speech {
    border-color: var(--green);
    color: var(--green-deep);
}

/* Thought-trail dots: small white circles cascading from the bubble down
   toward Kio's head — a comic-book "thinking" cloud trail. */
.kio-scene .thought {
    position: absolute;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    z-index: 14;
    animation: float 3.6s ease-in-out infinite;
}
.kio-scene .thought.t1 { width: 9px;  height: 9px;  top: 60px;  left: 70px; animation-delay: 0.1s; }
.kio-scene .thought.t2 { width: 6px;  height: 6px;  top: 92px;  left: 86px; animation-delay: 0.3s; }
.kio-scene .thought.t3 { width: 4px;  height: 4px;  top: 122px; left: 100px; animation-delay: 0.5s; }
.kio-scene.is-analyzing:not(.is-done) .thought { border-color: var(--orange); }
.kio-scene.is-done .thought { border-color: var(--green); }
.kio-scene .tools > * { position: absolute; }
/* All four tools live on the right side, orbiting the CLAR. The left side
   stays clear for Kio + speech bubble + thought trail (the "thinking" zone),
   the right side is the "tool" zone. */
.kio-scene .tool-mag   { right: 14px; top: 120px; }
.kio-scene .tool-gear  { right: 52px; top: 16px; }
.kio-scene .tool-wrench{ right: 22px; bottom: 62px; }
.kio-scene .tool-scan  { right: 108px; top: 22px; }

.kio-progress {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    display: none;
}
.kio-scene.is-analyzing:not(.is-done) .kio-progress {
    display: block;
    animation: fadeUp 0.3s ease;
}
.kio-progress .bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.kio-progress .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--orange), var(--orange-hov));
    border-radius: 2px;
    animation: progress 2.1s ease forwards;
}
.kio-progress .label {
    text-align: center;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ─── FAB CHAT WIDGET ─────────────────────────── */
.fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7B2D8E, #005CB9);
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-fab);
    z-index: 500;
    transition: transform var(--t-fast);
    display: flex; align-items: center; justify-content: center;
}
.fab:hover { transform: scale(1.08); }

.chat-panel {
    position: fixed;
    bottom: 94px;
    right: 28px;
    width: 360px;
    height: 460px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-float);
    display: none;
    flex-direction: column;
    z-index: 500;
    overflow: hidden;
    transform-origin: bottom right;
}
.chat-panel.is-open {
    display: flex;
    animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chat-panel .head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #7B2D8E, #005CB9);
    color: #fff;
}
.chat-panel .head .title { font-weight: 700; font-size: 0.9rem; }
.chat-panel .head .sub { font-size: 0.7rem; opacity: 0.85; }
.chat-panel .head .close {
    background: transparent; border: none; color: #fff;
    cursor: pointer; font-size: 1.05rem; padding: 4px 8px;
    border-radius: 4px; opacity: 0.85;
}
.chat-panel .body {
    flex: 1; overflow-y: auto;
    padding: 14px 16px;
    background: var(--bg);
    display: flex; flex-direction: column; gap: 8px;
}
.chat-msg {
    padding: 10px 13px;
    border-radius: 10px;
    font-size: 0.82rem;
    line-height: 1.55;
    max-width: 85%;
}
.chat-msg.user {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    align-self: flex-end;
}
.chat-msg.kio {
    background: var(--purple-pale);
    border: 1px solid rgba(107,63,160,0.2);
    color: var(--purple-deep);
    align-self: flex-start;
}
.chat-msg .label { font-weight: 700; margin-right: 4px; }
.chat-msg.is-typing { display: inline-flex; align-items: center; gap: 6px; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--purple-deep, #5B3A8C);
    animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-3px); opacity: 1; }
}
.chat-panel .composer {
    display: flex; gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.chat-panel .composer input {
    flex: 1;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--text);
    outline: none;
    transition: border-color var(--t-fast);
}
.chat-panel .composer input:focus { border-color: var(--orange); }
.chat-panel .composer .send {
    background: var(--orange); color: #fff;
    border: none; border-radius: 8px;
    padding: 0 16px; font-weight: 600; font-size: 0.82rem;
    cursor: pointer;
}

/* ─── REPORT — META STRIP ─────────────────────── */
.meta-strip {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--surface);
    width: fit-content;
    flex-wrap: wrap;
}
.meta-strip .cell {
    padding: 11px 22px;
    border-right: 1px solid var(--border);
}
.meta-strip .cell:last-child { border-right: none; }
.meta-strip .l {
    font-size: 0.66rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 3px;
}
.meta-strip .v { font-size: 0.9rem; font-weight: 600; color: var(--text); }

/* ─── REPORT — STEP CARDS ─────────────────────── */
.summary-callout {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--navy);
    border-radius: 0 var(--r-xl) var(--r-xl) 0;
    padding: 18px 22px;
    font-size: 0.92rem;
    color: var(--text-sub);
    line-height: 1.75;
}
.summary-callout.kio-enhanced {
    border-left-color: var(--purple);
}

.step-list {
    display: flex; flex-direction: column;
    gap: 8px;
}
.step-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--navy);
    border-radius: var(--r-xl);
    overflow: hidden;
    transition: all var(--t-base);
}
.step-card:hover { box-shadow: var(--shadow-card-hover); }
.step-card.is-open {
    border-color: var(--border-mid);
    box-shadow: 0 2px 14px rgba(0,0,0,0.07);
}
.step-card.entry         { border-left-color: var(--step-entry); }
.step-card.processing    { border-left-color: var(--step-processing); }
.step-card.routing       { border-left-color: var(--step-routing); }
.step-card.workday_call,
.step-card.workday-out-soap,
.step-card.workday-out-rest { border-left-color: var(--step-workday); }
.step-card.iterator      { border-left-color: var(--step-iterator); }
.step-card.error         { border-left-color: var(--step-error); }

.step-head {
    display: flex; align-items: center;
    gap: 14px;
    padding: 16px 18px;
    cursor: pointer;
    transition: background var(--t-fast);
}
.step-head:hover { background: var(--surface-alt); }
.step-num {
    width: 30px; height: 30px;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.74rem; font-weight: 700;
    color: var(--text-sub);
}
.step-id {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.step-condition {
    font-size: 0.72rem;
    color: var(--amber-deep);
    background: var(--amber-pale);
    border: 1px solid rgba(176,112,32,0.25);
    border-radius: var(--r-sm);
    padding: 3px 9px;
    font-family: var(--font-mono);
    max-width: 220px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.step-type-badge {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--r-sm);
}
.step-toggle { color: var(--text-muted); font-size: 0.82rem; }
.step-body {
    padding: 4px 22px 22px 62px;
    animation: fadeUp 0.2s ease;
    border-top: 1px solid var(--surface-alt);
}
.step-card:not(.is-open) .step-body { display: none; }
.step-body p { font-size: 0.87rem; color: var(--text-sub); line-height: 1.7; margin-bottom: 12px; }

.kio-note {
    background: var(--purple-pale);
    border-left: 3px solid var(--purple);
    border-radius: 0 var(--r-md) var(--r-md) 0;
    padding: 12px 16px;
    font-size: 0.82rem;
    color: var(--purple-deep);
    line-height: 1.6;
    margin-bottom: 12px;
}
.kio-note .label { font-weight: 700; margin-right: 4px; }

/* ─── KIO SIDEBAR (report) ─────────────────── */
.kio-sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 22px 18px;
    text-align: center;
    box-shadow: 0 2px 14px rgba(0,0,0,0.05);
}
.kio-sidebar .name { font-weight: 700; color: var(--text); font-size: 0.92rem; margin-top: 12px; margin-bottom: 3px; }
.kio-sidebar .role { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 16px; }
.kio-sidebar .bubble {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 13px 15px;
    font-size: 0.79rem;
    color: var(--text-sub);
    line-height: 1.65;
    text-align: left;
    position: relative;
}
.kio-sidebar .bubble::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 7px solid var(--border);
}

/* ─── UPGRADE — DIFF NODE TREE ────────────────── */
.diff-tree {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    line-height: 1.7;
    color: var(--text-sub);
}
.diff-node {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 6px;
    border-radius: var(--r-sm);
    margin-bottom: 2px;
    transition: background var(--t-fast);
}
.diff-node .toggle {
    color: var(--text-muted);
    width: 12px;
    font-size: 0.65rem;
    cursor: pointer;
    user-select: none;
}
.diff-node .name {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text);
}
.diff-node .used-dot { color: var(--purple); font-size: 0.7rem; line-height: 1; }
.diff-node .chip {
    font-size: 0.58rem; font-weight: 700;
    padding: 1px 6px; border-radius: 4px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.diff-node .chip.added { background: var(--green); }
.diff-node .chip.removed { background: var(--red); }
.diff-node .chip.cardinality { background: var(--amber); }
.diff-node .chip.renamed { background: var(--blue); }
.diff-node .note {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-style: italic;
}
.diff-node.s-added    { background: rgba(45, 122, 80, 0.09); }
.diff-node.s-added .name { color: var(--green-deep); }
.diff-node.s-removed  { background: rgba(192, 57, 43, 0.08); }
.diff-node.s-removed .name { color: var(--red-deep); }
.diff-node.s-renamed  { background: rgba(0, 92, 185, 0.07); }
.diff-node.s-renamed .name { color: var(--blue-deep); }
.diff-node.s-cardinality { background: rgba(176, 112, 32, 0.08); }
.diff-node.s-cardinality .name { color: var(--amber-deep); }
.diff-children {
    margin-left: 14px;
    padding-left: 10px;
    border-left: 1px dashed var(--border);
}

/* ─── UPGRADE — 4 COLUMN GRID ────────────────── */
.upgrade-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
@media (max-width: 1280px) {
    .upgrade-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
    .upgrade-grid-4 { grid-template-columns: 1fr; }
}
.col-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: all var(--t-slow);
}
.col-card.is-highlight {
    border: 1.5px solid var(--orange);
    box-shadow: var(--shadow-active);
}
.col-card .col-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.col-card .col-head .title {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.col-card .col-head .sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.col-card .col-body {
    padding: 14px 16px;
    max-height: 360px;
    overflow: auto;
}
.col-card pre {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-sub);
    line-height: 1.7;
    white-space: pre;
    margin: 0;
}
.col-card .empty-state {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 200px;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: center;
}

/* ─── UPGRADE — KIO SUMMARY CARDS ──────────────── */
.kio-summary-list {
    display: flex; flex-direction: column;
    gap: 10px;
}
.kio-summary-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--green);
    border-radius: 0 var(--r-xl) var(--r-xl) 0;
    padding: 14px 18px;
}
.kio-summary-card.is-warn {
    border-color: rgba(176,112,32,0.3);
    border-left-color: var(--amber);
}
.kio-summary-card.is-info {
    border-color: rgba(0,92,185,0.2);
    border-left-color: var(--navy);
}
.kio-summary-card .icon {
    width: 24px; height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--green-pale);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    margin-top: 1px;
}
.kio-summary-card.is-warn .icon { background: var(--amber-pale); }
.kio-summary-card.is-info .icon { background: var(--navy-light); }
.kio-summary-card .label { font-weight: 600; color: var(--text); font-size: 0.88rem; margin-bottom: 4px; }
.kio-summary-card .detail { font-size: 0.81rem; color: var(--text-sub); line-height: 1.6; }

/* ─── UPGRADE — REFINE PANEL ─────────────────── */
.refine-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-2xl);
    overflow: hidden;
}
.refine-panel .head {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.refine-panel .head .av {
    width: 36px; height: 36px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, #7B2D8E, #005CB9);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1rem;
}
.refine-panel .head h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.refine-panel .head .sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.refine-panel .prompts {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; gap: 8px; flex-wrap: wrap;
}
.refine-panel .prompt {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    padding: 6px 14px;
    font-size: 0.76rem;
    color: var(--text-sub);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--t-fast);
    font-family: inherit;
}
.refine-panel .prompt:hover {
    border-color: var(--orange);
    color: var(--orange);
    background: var(--orange-pale);
}
.refine-panel .log {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    max-height: 240px;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 8px;
}
.refine-panel .log:empty { display: none; }
.refine-panel .composer {
    padding: 16px 24px;
    display: flex; gap: 10px; align-items: flex-end;
}
.refine-panel .composer textarea {
    flex: 1;
    padding: 11px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    font-size: 0.86rem;
    color: var(--text);
    font-family: inherit;
    outline: none;
    resize: none;
    line-height: 1.55;
    transition: border-color var(--t-fast);
}
.refine-panel .composer textarea:focus { border-color: var(--orange); }
.refine-panel .composer .send-btn {
    background: var(--orange); color: #fff;
    border: none;
    padding: 12px 22px;
    border-radius: var(--r-lg);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all var(--t-fast);
    flex-shrink: 0;
}
.refine-panel .composer .send-btn:hover:not(:disabled) { background: var(--orange-hov); transform: translateY(-1px); }
.refine-panel .composer .send-btn:disabled {
    background: var(--border); color: var(--text-muted);
    cursor: not-allowed;
}
.refine-panel .composer-hint {
    padding: 0 24px 14px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ─── BANNERS / NOTICES ──────────────────────── */
.notice {
    border-radius: var(--r-md);
    padding: 12px 16px;
    font-size: 0.86rem;
    margin: var(--s4) 0;
    line-height: 1.6;
    border: 1px solid;
}
.notice-info  { background: var(--blue-pale); border-color: rgba(0,92,185,0.20); color: var(--blue-deep); }
.notice-warn  { background: var(--amber-pale); border-color: rgba(176,112,32,0.30); color: var(--amber-deep); }
.notice-error { background: var(--red-pale); border-color: rgba(192,57,43,0.25); color: var(--red-deep); }
.notice-ok    { background: var(--green-pale); border-color: rgba(45,122,80,0.25); color: var(--green-deep); }

.flash {
    background: var(--red-pale);
    color: var(--red-deep);
    border: 1px solid rgba(192,57,43,0.20);
    padding: 12px 16px;
    border-radius: var(--r-md);
    margin: 16px auto;
    font-size: 0.88rem;
    max-width: var(--max-w-index);
}
/* Category variants — .flash is red (errors) by default; success = green,
   info = blue. Applied via the flash() message category. */
.flash.flash-success,
.flash-banner .msg.flash-success {
    background: var(--green-pale); color: var(--green-deep);
    border-color: rgba(45,122,80,0.25);
}
.flash.flash-info,
.flash-banner .msg.flash-info {
    background: var(--blue-pale); color: var(--blue-deep);
    border-color: rgba(0,92,185,0.22);
}

/* ─── SECTION TITLES (eyebrows) ────────────────── */
.section-title {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 16px;
}

/* ─── SOAP / XML CODE ─────────────────────────── */
.code-block {
    background: var(--surface-sunk);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-sub);
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.code-block.dense { white-space: pre; word-break: normal; }

/* ─── AUTH PAGES (login, signup) ───────────────── */
.auth-shell {
    min-height: calc(100vh - var(--nav-h));
    display: flex; align-items: center; justify-content: center;
    padding: 40px 24px;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-card);
    padding: 36px 36px 30px;
    width: 100%;
    max-width: 420px;
    animation: fadeUp 0.5s ease both;
}
.auth-card.wide { max-width: 580px; }
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header h1 {
    font-size: 1.6rem; font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}
.auth-header p {
    font-size: 0.86rem;
    color: var(--text-sub);
    line-height: 1.5;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.auth-form.grid-2 .full-width { grid-column: 1 / -1; }
@media (max-width: 540px) {
    .auth-form.grid-2 { grid-template-columns: 1fr; }
}
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label {
    font-size: 0.74rem; font-weight: 600;
    color: var(--text-sub);
    letter-spacing: 0.01em;
}
.auth-field label .opt {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 4px;
    text-transform: none;
}
.auth-field input,
.auth-field select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 0.88rem;
    color: var(--text);
    font-family: inherit;
    outline: none;
    transition: border-color var(--t-fast);
}
.auth-field input:focus,
.auth-field select:focus { border-color: var(--orange); }
.auth-input-wrap { position: relative; }
.auth-input-wrap input { padding-right: 64px; }
.auth-toggle {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.74rem; font-weight: 500;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: inherit;
    transition: color var(--t-fast), background var(--t-fast);
}
.auth-toggle:hover { color: var(--orange); background: var(--surface-alt); }
.auth-row {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.78rem;
    margin-top: -2px;
}
.auth-row a {
    color: var(--text-sub);
    text-decoration: none;
}
.auth-row a:hover { color: var(--orange); text-decoration: underline; }
.auth-submit {
    margin-top: 6px;
    padding: 12px 16px;
    font-size: 0.92rem;
    width: 100%;
}
.auth-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 24px 0;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.sso-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.sso-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 7px;
    padding: 10px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 0.84rem; font-weight: 500;
    color: var(--text-sub);
    cursor: pointer;
    transition: all var(--t-fast);
    text-decoration: none;
    font-family: inherit;
}
.sso-btn:hover:not(.disabled) {
    border-color: var(--border-mid);
    color: var(--text);
    background: var(--surface-alt);
    transform: translateY(-1px);
}
.sso-btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: var(--surface-alt);
}
.sso-btn svg { flex-shrink: 0; }
.auth-foot {
    text-align: center;
    margin-top: 22px;
    font-size: 0.84rem;
    color: var(--text-sub);
}
.auth-foot a {
    color: var(--orange);
    font-weight: 500;
    text-decoration: none;
}
.auth-foot a:hover { text-decoration: underline; }

/* ─── AVATAR + DROPDOWN MENU (authenticated nav) ─── */
/* ─── Confirmation modal (logout, etc.) ─────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(28, 28, 26, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-card);
    padding: 24px 24px 20px;
    max-width: 380px;
    width: 100%;
    animation: fadeUp 0.18s ease both;
}
.modal-box h3 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 8px;
}
.modal-box p {
    font-size: 0.9rem;
    color: var(--text-sub);
    line-height: 1.6;
    margin-bottom: 20px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Native <dialog> logout confirm — promoted to the top layer by showModal(),
   so it is always viewport-centered with a blurred ::backdrop regardless of
   any backdrop-filter ancestor. (The .modal-overlay flavour above is still
   used by the admin console's logout modal.) The inner .modal-box supplies
   the card; the <dialog> itself is just a transparent, centered wrapper. */
.logout-dialog {
    /* The global reset (* { margin: 0 }) overrides the UA's margin:auto that
       normally centers a modal <dialog>, so center explicitly — fixed + 50/50
       + translate is immune to that reset and to any ancestor transform. */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    font-family: var(--font-ui);
    color: var(--text);
    max-width: 380px;
    width: calc(100% - 40px);
    max-height: calc(100% - 40px);
    overflow: visible;
}
.logout-dialog::backdrop {
    background: rgba(28, 28, 26, 0.5);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

/* Groups the general-feedback link + account avatar at the navbar's right edge. */
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-feedback-link { font-size: 0.82rem; padding: 7px 16px; }
.avatar-wrap { position: relative; }
.avatar-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    transition: box-shadow var(--t-fast);
}
.avatar-btn:hover,
.avatar-btn[aria-expanded="true"] {
    box-shadow: 0 0 0 3px var(--orange-ring);
}
.avatar {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--orange-pale);
    color: var(--orange-deep);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    border: 1px solid rgba(246,141,46,0.25);
    user-select: none;
}
.avatar.avatar-md { width: 40px; height: 40px; font-size: 0.86rem; }
.avatar.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }

.avatar-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-float);
    padding: 8px;
    z-index: 600;
    transform-origin: top right;
    animation: scaleIn 0.15s ease-out both;
}
.avatar-menu[hidden] { display: none !important; }
.avatar-meta {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px 10px;
}
.avatar-meta .name {
    font-weight: 600; font-size: 0.86rem;
    color: var(--text); line-height: 1.2;
}
.avatar-meta .email {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 160px;
}
.avatar-menu .menu-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}
.avatar-menu .item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    font-size: 0.86rem;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}
.avatar-menu .item:hover {
    background: var(--surface-alt);
    color: var(--text);
    text-decoration: none;
}
.avatar-menu .item svg {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color var(--t-fast);
}
.avatar-menu .item:hover svg { color: var(--orange); }
.avatar-menu .item.danger { color: var(--red-deep); }
.avatar-menu .item.danger svg { color: var(--red); }
.avatar-menu .item.danger:hover {
    background: var(--red-pale);
    color: var(--red-deep);
}

/* ─── PROFILE PAGE SHELL (sidebar + content) ───── */
.profile-shell {
    max-width: 1080px;
    margin: 0 auto;
    padding: 36px 40px 60px;
    display: flex;
    gap: 40px;
}
@media (max-width: 880px) {
    .profile-shell { flex-direction: column; padding: 24px 20px 60px; gap: 24px; }
}

.profile-sidebar { width: 220px; flex-shrink: 0; }
.profile-sidebar .group-label {
    font-size: 0.7rem; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 12px;
    margin-bottom: 8px;
}
.profile-sidebar .item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    font-size: 0.88rem;
    color: var(--text-sub);
    text-decoration: none;
    cursor: pointer;
    margin-bottom: 2px;
    transition: all var(--t-fast);
}
.profile-sidebar .item svg {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color var(--t-fast);
}
.profile-sidebar .item:hover {
    background: var(--surface-alt);
    color: var(--text);
    text-decoration: none;
}
.profile-sidebar .item:hover svg { color: var(--orange); }
.profile-sidebar .item.is-active {
    background: var(--orange-pale);
    color: var(--orange-deep);
    font-weight: 600;
}
.profile-sidebar .item.is-active svg { color: var(--orange-deep); }

.profile-content {
    flex: 1;
    min-width: 0;
    max-width: 720px;
    animation: fadeUp 0.4s ease both;
}
.profile-content h1 {
    font-size: 1.6rem; font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}
.profile-content .lede {
    font-size: 0.86rem; color: var(--text-sub);
    margin-bottom: 24px;
}

.profile-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 28px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-card);
}
.profile-section .section-head { margin-bottom: 18px; }
.profile-section .section-head h2 {
    font-size: 1rem; font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.profile-section .section-head p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.profile-avatar-row {
    display: flex; align-items: center; gap: 16px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 22px;
}
.profile-avatar-row .info .name {
    font-size: 1.06rem; font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.profile-avatar-row .info .meta {
    font-size: 0.84rem;
    color: var(--text-muted);
}

.profile-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 14px;
}
@media (max-width: 540px) {
    .profile-form .form-row { grid-template-columns: 1fr; }
}
.profile-form .form-row.full { grid-template-columns: 1fr; }

.profile-form .field-readonly {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}
.profile-form .field-readonly input {
    background: var(--surface-alt);
    color: var(--text-sub);
    cursor: not-allowed;
}
.profile-form .field-readonly .change-link {
    font-size: 0.74rem;
    color: var(--orange);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}
.profile-form .field-readonly .change-link:hover { text-decoration: underline; }

.profile-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

/* Tab content placeholder */
.profile-empty {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}
.profile-empty .icon {
    font-size: 2.4rem; margin-bottom: 12px; opacity: 0.4;
}
.profile-empty h3 {
    font-size: 1rem; color: var(--text); margin-bottom: 6px; font-weight: 600;
}
.profile-empty p { font-size: 0.86rem; line-height: 1.6; max-width: 340px; margin: 0 auto; }

/* ─── KIO AI TAB — provider cards ───────────────── */
.kio-notice {
    display: flex; align-items: flex-start; gap: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    margin-bottom: 18px;
    font-size: 0.83rem;
    color: var(--text-sub);
    line-height: 1.55;
}
.kio-notice .icon {
    font-size: 1rem;
    color: var(--orange);
    flex-shrink: 0;
    line-height: 1.4;
}
.kio-notice strong { color: var(--text); }

.provider-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    margin-bottom: 12px;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    overflow: hidden;
}
.provider-card.is-default {
    border-color: rgba(246,141,46,0.45);
    box-shadow: var(--shadow-active);
}

.provider-head {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 20px;
}
.provider-emblem {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.94rem;
    color: #fff;
    flex-shrink: 0;
}
.provider-emblem.anthropic { background: #C8612D; }
.provider-emblem.openai    { background: #10A37F; }
.provider-emblem.google    { background: #4285F4; }

.provider-info {
    flex: 1; min-width: 0;
}
.provider-info .name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.96rem;
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}
.provider-info .tag {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 1px;
}
.provider-status {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--surface-alt);
    color: var(--text-muted);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.provider-status.is-connected {
    background: var(--green-pale);
    color: var(--green-deep);
    border-color: rgba(45,122,80,0.30);
}

/* State-driven visibility (only one of these is shown at a time per card) */
.provider-card .provider-view,
.provider-card .provider-empty-state,
.provider-card .provider-form-state { display: none; }
.provider-card.is-connected .provider-view { display: block; }
.provider-card.is-empty .provider-empty-state { display: block; }
.provider-card.is-editing .provider-form-state { display: block; }
.provider-card.is-editing .provider-view,
.provider-card.is-editing .provider-empty-state { display: none; }

.provider-body {
    padding: 0 20px 14px;
}
.provider-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
    font-size: 0.84rem;
}
.provider-row:first-child { border-top: none; padding-top: 0; }
.provider-row .label {
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 500;
}
.provider-row code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-sub);
    background: var(--surface-alt);
    padding: 3px 9px;
    border-radius: 5px;
    word-break: break-all;
    text-align: right;
}

.provider-actions {
    display: flex; align-items: center; gap: 4px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    flex-wrap: wrap;
}
.provider-actions form { display: inline; margin: 0; }
.provider-actions .spacer { flex: 1; }
.btn-link {
    background: transparent;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-sub);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--t-fast);
}
.btn-link:hover { color: var(--orange); background: var(--surface); }
.btn-link.danger { color: var(--red-deep); }
.btn-link.danger:hover { color: var(--red); background: var(--red-pale); }

.provider-empty-body {
    padding: 0 20px 16px;
    color: var(--text-sub);
    font-size: 0.84rem;
    line-height: 1.55;
}
.provider-empty-actions {
    padding: 0 14px 16px;
}

.provider-form {
    padding: 4px 20px 20px;
    animation: fadeUp 0.2s ease;
    border-top: 1px solid var(--border);
}
.provider-form .auth-field { margin-bottom: 14px; }
.provider-form-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    padding-top: 4px;
}

/* ─── Saved-key banner on /app BYOK section ─────── */
.saved-key-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--green-pale);
    border: 1px solid rgba(45,122,80,0.25);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.saved-key-banner .provider-emblem {
    width: 32px; height: 32px;
    font-size: 0.84rem;
}
.saved-key-banner .info {
    flex: 1;
    min-width: 220px;
}
.saved-key-banner .title {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--green-deep);
}
.saved-key-banner .meta {
    font-size: 0.78rem;
    color: var(--text-sub);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.saved-key-banner .meta code {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    background: var(--surface);
    padding: 2px 7px;
    border-radius: 4px;
    color: var(--text-sub);
    border: 1px solid var(--border);
}
.saved-key-banner .meta a {
    color: var(--orange);
    text-decoration: none;
    font-weight: 500;
}
.saved-key-banner .meta a:hover { text-decoration: underline; }
.saved-key-banner .actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Subscription stub specifics */
.plan-card {
    display: flex; justify-content: space-between; align-items: center;
    gap: 18px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 18px 20px;
    margin-bottom: 16px;
}
.plan-card .name { font-weight: 600; color: var(--text); font-size: 0.96rem; margin-bottom: 4px; }
.plan-card .meta { font-size: 0.82rem; color: var(--text-sub); line-height: 1.5; }
.plan-card .price-tag {
    background: var(--green-pale);
    color: var(--green-deep);
    border: 1px solid rgba(45,122,80,0.25);
    border-radius: var(--r-sm);
    padding: 4px 10px;
    font-size: 0.76rem; font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* Flash message — can show on any authed page */
.flash-banner {
    max-width: 1080px;
    margin: 14px auto 0;
    padding: 0 40px;
}
.flash-banner .msg {
    background: var(--green-pale);
    border: 1px solid rgba(45,122,80,0.25);
    color: var(--green-deep);
    padding: 10px 16px;
    border-radius: var(--r-md);
    font-size: 0.86rem;
}

/* ─── UTILITIES ─────────────────────────────────── */
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.center { text-align: center; }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; } .mb-10 { margin-bottom: 40px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
