/* ==========================================================================
   Nexus AI — control panel styling
   Hand-written to match the project mockup. No build step and no CDN, so the
   panel keeps working even if this box has no outbound network.
   ========================================================================== */

:root {
    --bg:            #060911;
    --bg-2:          #0a0f1c;
    --panel:         rgba(255, 255, 255, 0.028);
    --panel-solid:   #0e1424;
    --panel-hover:   rgba(255, 255, 255, 0.055);
    --border:        rgba(255, 255, 255, 0.075);
    --border-strong: rgba(255, 255, 255, 0.14);

    --text:          #e8ebf5;
    --text-dim:      #98a1b8;
    --text-faint:    #5f6880;

    --violet:        #8b5cf6;
    --violet-dim:    #6d3fe0;
    --indigo:        #6366f1;
    --cyan:          #22d3ee;
    --green:         #34d399;
    --amber:         #fbbf24;
    --red:           #f87171;
    --pink:          #ec4899;

    --radius:        16px;
    --radius-sm:     10px;
    --sidebar-w:     248px;

    --shadow:        0 8px 32px rgba(0, 0, 0, 0.45);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
            'Helvetica Neue', Arial, sans-serif;
    --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    background-image:
        radial-gradient(1100px 700px at 78% -12%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(900px 600px at 8% 105%, rgba(34, 211, 238, 0.08), transparent 60%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- App shell ---------------------------------------------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    padding: 20px 14px;
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(13, 18, 32, 0.92), rgba(8, 11, 20, 0.92));
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 20px 24px 48px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ---------- Brand -------------------------------------------------------- */

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 0; }

.brand-mark {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--violet), var(--indigo) 55%, var(--cyan));
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    flex: 0 0 40px;
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-name {
    font-size: 15px; font-weight: 700; letter-spacing: 0.02em;
    display: flex; align-items: center; gap: 7px;
}
.brand-sub { font-size: 11px; color: var(--text-faint); }

.brand-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

/* ---------- Navigation --------------------------------------------------- */

.nav-label {
    font-size: 10px; font-weight: 700; letter-spacing: 0.13em;
    color: var(--text-faint); text-transform: uppercase;
    padding: 0 10px; margin-bottom: 6px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 13.5px; font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    border: 1px solid transparent;
}
.nav-item:hover { background: var(--panel-hover); color: var(--text); }

.nav-item.is-active {
    background: linear-gradient(96deg, rgba(139, 92, 246, 0.9), rgba(99, 102, 241, 0.75));
    color: #fff;
    box-shadow: 0 6px 18px rgba(109, 63, 224, 0.35);
    border-color: rgba(255, 255, 255, 0.1);
}

.nav-item.is-disabled { opacity: 0.34; cursor: not-allowed; }
.nav-item.is-disabled:hover { background: transparent; color: var(--text-dim); }

.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; }

.nav-phase {
    margin-left: auto;
    font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em;
    padding: 2px 6px; border-radius: 5px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-faint);
}

/* ---------- Sidebar footer ---------------------------------------------- */

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }

.user-card {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: var(--radius-sm);
    background: var(--panel); border: 1px solid var(--border);
}
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--violet), var(--cyan));
    font-weight: 700; font-size: 13px; color: #fff;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-faint); }

.btn-signout {
    background: none; border: 0; padding: 4px; margin-left: auto;
    color: var(--text-faint); cursor: pointer; border-radius: 6px;
    display: grid; place-items: center;
}
.btn-signout:hover { color: var(--red); background: rgba(248, 113, 113, 0.1); }
.btn-signout svg { width: 16px; height: 16px; }

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

.topbar { display: flex; align-items: center; gap: 14px; }

.topbar-title h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-title p  { margin: 2px 0 0; font-size: 12.5px; color: var(--text-faint); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.icon-btn {
    width: 38px; height: 38px; border-radius: 11px;
    display: grid; place-items: center;
    background: var(--panel); border: 1px solid var(--border);
    color: var(--text-dim); cursor: pointer;
    transition: all 0.15s ease;
}
.icon-btn:hover { background: var(--panel-hover); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }

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

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
    padding: 18px;
}

.card-head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 15px;
}
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -0.005em; }
.card-head .spacer { margin-left: auto; }

/* ---------- Hero --------------------------------------------------------- */

.hero {
    position: relative; overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background:
        radial-gradient(560px 200px at 88% 50%, rgba(139, 92, 246, 0.3), transparent 70%),
        linear-gradient(100deg, rgba(20, 26, 44, 0.9), rgba(11, 15, 28, 0.9));
    padding: 26px 28px;
    display: flex; align-items: center; gap: 24px;
}
.hero h2 { margin: 0 0 6px; font-size: 25px; font-weight: 750; letter-spacing: -0.02em; }
.hero p  { margin: 0; color: var(--text-dim); font-size: 14px; }
.hero-orb {
    margin-left: auto; flex: 0 0 116px;
    width: 116px; height: 116px; border-radius: 50%;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(10, 14, 26, 1) 38%, transparent 40%),
        conic-gradient(from 210deg, var(--cyan), var(--violet), var(--indigo), var(--cyan));
    box-shadow: 0 0 46px rgba(139, 92, 246, 0.4);
    display: grid; place-items: center;
    animation: pulse 5s ease-in-out infinite;
}
.hero-orb span {
    width: 46px; height: 46px; border-radius: 50%;
    background: radial-gradient(circle at 35% 32%, rgba(255,255,255,0.9), rgba(139,92,246,0.25) 60%, transparent);
}
@keyframes pulse {
    0%, 100% { transform: scale(1);    box-shadow: 0 0 40px rgba(139, 92, 246, 0.32); }
    50%      { transform: scale(1.04); box-shadow: 0 0 62px rgba(139, 92, 246, 0.5); }
}

/* ---------- Grids -------------------------------------------------------- */

.grid { display: grid; gap: 16px; }
.grid-stats  { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main   { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
.grid-halves { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }

/* ---------- Stat tiles --------------------------------------------------- */

.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 17px;
    display: flex; flex-direction: column; gap: 11px;
    position: relative; overflow: hidden;
}
.stat::after {
    content: ''; position: absolute; inset: 0 0 auto 0; height: 2px;
    background: linear-gradient(90deg, var(--violet), var(--cyan));
    opacity: 0.55;
}
.stat.is-warn::after { background: linear-gradient(90deg, var(--amber), #f59e0b); opacity: 0.9; }
.stat.is-crit::after { background: linear-gradient(90deg, var(--red), var(--pink)); opacity: 1; }

.stat-top { display: flex; align-items: center; gap: 9px; }
.stat-label { font-size: 11.5px; color: var(--text-dim); font-weight: 500; letter-spacing: 0.02em; }
.stat-icon {
    width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px;
    display: grid; place-items: center;
    background: rgba(139, 92, 246, 0.14); color: var(--violet);
}
.stat-icon svg { width: 15px; height: 15px; }
.stat.is-warn .stat-icon { background: rgba(251, 191, 36, 0.14); color: var(--amber); }
.stat.is-crit .stat-icon { background: rgba(248, 113, 113, 0.14); color: var(--red); }

.stat-value {
    font-size: 27px; font-weight: 700; letter-spacing: -0.03em;
    line-height: 1.1; font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: 14px; font-weight: 600; color: var(--text-dim); margin-left: 2px; }
.stat-sub { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.meter {
    height: 6px; border-radius: 99px; overflow: hidden;
    background: rgba(255, 255, 255, 0.07);
}
.meter i {
    display: block; height: 100%; border-radius: 99px;
    background: linear-gradient(90deg, var(--violet), var(--indigo));
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat.is-warn .meter i { background: linear-gradient(90deg, #f59e0b, var(--amber)); }
.stat.is-crit .meter i { background: linear-gradient(90deg, #dc2626, var(--red)); }

/* ---------- Chart -------------------------------------------------------- */

.chart-wrap { position: relative; width: 100%; height: 200px; }
.chart-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }

.chart-legend { display: flex; gap: 15px; align-items: center; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-dim); }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }

.chart-empty {
    height: 200px; display: grid; place-items: center;
    color: var(--text-faint); font-size: 13px; text-align: center;
}

/* ---------- Service list ------------------------------------------------- */

.svc-group + .svc-group { margin-top: 16px; }
.svc-group-label {
    font-size: 10px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase;
    color: var(--text-faint); margin-bottom: 7px; display: flex; align-items: center; gap: 8px;
}
.svc-group-label::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

.svc {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: background 0.15s ease;
}
.svc:hover { background: var(--panel-hover); border-color: var(--border); }

.svc-dot {
    width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px;
    background: var(--text-faint);
}
.svc.is-running .svc-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16); }
.svc.is-stopped .svc-dot { background: var(--red);   box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16); }
.svc.is-unknown .svc-dot { background: var(--text-faint); }

.svc-name { font-size: 13.5px; font-weight: 570; }
.svc-desc { font-size: 11.5px; color: var(--text-faint); }
.svc-meta { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.badge {
    font-size: 10.5px; font-weight: 650; letter-spacing: 0.02em;
    padding: 3px 9px; border-radius: 99px;
    background: rgba(255, 255, 255, 0.07); color: var(--text-dim);
    white-space: nowrap;
}
.badge-ok    { background: rgba(52, 211, 153, 0.13);  color: var(--green); }
.badge-bad   { background: rgba(248, 113, 113, 0.13); color: var(--red); }
.badge-warn  { background: rgba(251, 191, 36, 0.13);  color: var(--amber); }
.badge-muted { background: rgba(255, 255, 255, 0.06); color: var(--text-faint); }
.badge-violet{ background: rgba(139, 92, 246, 0.15);  color: #b39bff; }

.lock {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10.5px; color: var(--text-faint);
}
.lock svg { width: 11px; height: 11px; }

/* ---------- Key/value rows ---------------------------------------------- */

.kv { display: flex; align-items: center; padding: 9px 0; font-size: 13px; }
.kv + .kv { border-top: 1px solid var(--border); }
.kv-key { color: var(--text-dim); }
.kv-val { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv-val.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- Banners ------------------------------------------------------ */

.banner {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 13px 15px; border-radius: var(--radius-sm);
    font-size: 13px; line-height: 1.5;
    border: 1px solid var(--border);
    background: var(--panel);
}
.banner svg { width: 17px; height: 17px; flex: 0 0 17px; margin-top: 1px; }
.banner-warn { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.28); color: #fde68a; }
.banner-ok   { background: rgba(52, 211, 153, 0.08); border-color: rgba(52, 211, 153, 0.28); color: #a7f3d0; }
.banner-bad  { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.3); color: #fecaca; }
.banner-info { background: rgba(99, 102, 241, 0.08); border-color: rgba(99, 102, 241, 0.3); color: #c7d2fe; }
.banner strong { font-weight: 680; }

/* ---------- Forms -------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 17px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field .hint { font-size: 11.5px; color: var(--text-faint); line-height: 1.5; }

.input, .select {
    width: 100%;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.28);
    color: var(--text);
    font-family: inherit; font-size: 13.5px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus, .select:focus {
    outline: none;
    border-color: var(--violet);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.16);
}
.input.is-invalid { border-color: var(--red); }
.select { appearance: none; cursor: pointer; }

.error { font-size: 12px; color: var(--red); }

.switch { display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
    width: 40px; height: 22px; border-radius: 99px; flex: 0 0 40px;
    background: rgba(255, 255, 255, 0.11);
    border: 1px solid var(--border);
    position: relative; transition: background 0.2s ease;
}
.switch .track::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--text-dim); transition: all 0.2s ease;
}
.switch input:checked + .track { background: var(--violet); border-color: var(--violet); }
.switch input:checked + .track::after { left: 20px; background: #fff; }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer;
    font-family: inherit; font-size: 13.5px; font-weight: 620;
    transition: all 0.15s ease;
}
.btn-primary {
    background: linear-gradient(96deg, var(--violet), var(--indigo));
    color: #fff; box-shadow: 0 6px 18px rgba(109, 63, 224, 0.32);
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost {
    background: var(--panel); border-color: var(--border); color: var(--text-dim);
}
.btn-ghost:hover { background: var(--panel-hover); color: var(--text); }
.btn svg { width: 15px; height: 15px; }

/* ---------- Tables ------------------------------------------------------- */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    text-align: left; padding: 9px 11px;
    font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-faint); border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 11px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:hover td { background: rgba(255, 255, 255, 0.02); }
.table .mono { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }

/* ---------- Login -------------------------------------------------------- */

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
    width: 100%; max-width: 400px;
    background: linear-gradient(165deg, rgba(19, 25, 43, 0.95), rgba(9, 12, 22, 0.95));
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 34px 32px;
    box-shadow: var(--shadow);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; text-align: center; }
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 16px; flex: 0 0 52px; }
.login-brand .brand-mark svg { width: 28px; height: 28px; }
.login-brand h1 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -0.01em; }
.login-brand p  { margin: 0; font-size: 12.5px; color: var(--text-faint); }

/* ---------- Utility ------------------------------------------------------ */

.muted   { color: var(--text-faint); }
.mono    { font-family: var(--mono); }
.nowrap  { white-space: nowrap; }
.stack   { display: flex; flex-direction: column; }
.gap-sm  { gap: 8px; }  .gap-md { gap: 14px; }  .gap-lg { gap: 18px; }
.row     { display: flex; align-items: center; }
.mt-sm   { margin-top: 10px; }  .mt-md { margin-top: 16px; }
.text-sm { font-size: 12px; }

.pulse-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--green);
    animation: blink 2.4s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Approvals & alerts ------------------------------------------- */

.approval {
    border: 1px solid rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.05);
    border-radius: var(--radius-sm);
    padding: 15px 16px;
}
.approval + .approval { margin-top: 11px; }

.approval-head { display: flex; align-items: flex-start; gap: 12px; }
.approval-title { font-size: 14.5px; font-weight: 650; }
.approval-meta {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap; margin-top: 5px;
}
.approval-reason {
    margin: 11px 0 0; font-size: 13px; line-height: 1.6;
    color: var(--text-dim);
    padding-left: 11px; border-left: 2px solid var(--border-strong);
}
.approval-actions {
    display: flex; align-items: center; gap: 9px;
    margin-top: 14px; flex-wrap: wrap;
}
.approval-actions form { display: contents; }

.alert-row {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 12px 0;
}
.alert-row + .alert-row { border-top: 1px solid var(--border); }
.alert-dot {
    width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; margin-top: 6px;
    background: var(--text-faint);
}
.alert-row.is-urgent  .alert-dot { background: var(--red);   box-shadow: 0 0 0 3px rgba(248,113,113,0.16); }
.alert-row.is-warning .alert-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(251,191,36,0.16); }
.alert-row.is-info    .alert-dot { background: var(--cyan);  box-shadow: 0 0 0 3px rgba(34,211,238,0.14); }

.alert-title { font-size: 13.5px; font-weight: 600; }
.alert-body {
    font-size: 12.5px; color: var(--text-dim); margin-top: 4px;
    white-space: pre-line; line-height: 1.55;
}

.action-row {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 13px 0;
}
.action-row + .action-row { border-top: 1px solid var(--border); }
.action-row .svc-dot { margin-top: 6px; }

.impact-note {
    display: flex; align-items: flex-start; gap: 7px;
    margin-top: 7px; padding: 7px 10px;
    border-radius: 8px;
    background: rgba(251, 191, 36, 0.07);
    border: 1px solid rgba(251, 191, 36, 0.22);
    color: #fde68a; font-size: 11.5px; line-height: 1.5;
}
.impact-note svg { width: 13px; height: 13px; flex: 0 0 13px; margin-top: 2px; }

.empty-row {
    display: flex; align-items: center; gap: 10px;
    padding: 22px 0; color: var(--text-faint); font-size: 13px;
    justify-content: center;
}
.empty-row svg { width: 16px; height: 16px; }

/* ---------- Chat --------------------------------------------------------- */

.chat-card { display: flex; flex-direction: column; min-height: 560px; }

.chat-log {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: 58vh;
    padding-right: 6px;
    display: flex; flex-direction: column; gap: 16px;
}

.chat-empty {
    margin: auto; text-align: center; display: flex;
    flex-direction: column; align-items: center; gap: 12px; padding: 30px 20px;
}
.chat-empty h3 { margin: 0; font-size: 17px; font-weight: 650; }
.chat-empty p  { margin: 0; font-size: 13px; max-width: 340px; }

.msg { display: flex; gap: 11px; align-items: flex-start; }
.msg-user { flex-direction: row-reverse; }

.msg-avatar {
    width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700; color: #fff;
    background: linear-gradient(140deg, var(--violet), var(--indigo));
}
.msg-user .msg-avatar { background: linear-gradient(140deg, #334155, #1e293b); color: var(--text-dim); }
.msg-avatar svg { width: 16px; height: 16px; }

.msg-body { min-width: 0; max-width: 78%; display: flex; flex-direction: column; gap: 5px; }
.msg-user .msg-body { align-items: flex-end; }

.msg-bubble {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 13.5px; line-height: 1.62;
    background: var(--panel-hover);
    border: 1px solid var(--border);
    word-wrap: break-word; overflow-wrap: anywhere;
}
.msg-user .msg-bubble {
    background: linear-gradient(96deg, rgba(139, 92, 246, 0.9), rgba(99, 102, 241, 0.78));
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.msg-bubble code {
    font-family: var(--mono); font-size: 12px;
    padding: 1px 5px; border-radius: 5px;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid var(--border);
    word-break: break-all;
}
.msg-user .msg-bubble code { background: rgba(0, 0, 0, 0.22); border-color: rgba(255,255,255,0.14); }
.msg-bubble strong { font-weight: 680; color: #fff; }
.msg-bubble .bullet { color: var(--violet); margin-right: 3px; }

.msg-thinking { display: flex; align-items: center; gap: 11px; }
.msg-failed {
    display: flex; align-items: flex-start; gap: 9px;
    background: rgba(248, 113, 113, 0.08);
    border-color: rgba(248, 113, 113, 0.3);
    color: #fecaca;
}
.msg-failed svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 2px; }

.msg-meta {
    display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
    font-size: 10.5px; color: var(--text-faint);
}

.dots { display: inline-flex; gap: 4px; }
.dots i {
    width: 6px; height: 6px; border-radius: 50%; background: var(--violet);
    animation: bounce 1.3s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: 0.18s; }
.dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0);    opacity: 0.45; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

.chat-form {
    display: flex; gap: 9px; align-items: center;
    padding-top: 15px; margin-top: 15px;
    border-top: 1px solid var(--border);
}
.chat-form .input { flex: 1 1 auto; }
.chat-form .btn:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-form .input:disabled { opacity: 0.55; cursor: not-allowed; }

.chat-suggestions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }

.chip {
    padding: 6px 12px; border-radius: 99px;
    background: var(--panel); border: 1px solid var(--border);
    color: var(--text-dim); font-family: inherit; font-size: 12px;
    cursor: pointer; transition: all 0.15s ease;
}
.chip:hover {
    background: var(--panel-hover); color: var(--text);
    border-color: var(--border-strong);
}

/* ---------- Responsive --------------------------------------------------- */

@media (max-width: 1180px) {
    .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main  { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
    .app { flex-direction: column; }
    .sidebar {
        width: 100%; flex: none; height: auto; position: static;
        border-right: 0; border-bottom: 1px solid var(--border);
    }
    .main { padding: 16px 14px 40px; }
    .grid-halves { grid-template-columns: minmax(0, 1fr); }
    .hero { flex-direction: column; align-items: flex-start; padding: 22px; }
    .hero-orb { margin-left: 0; }
}

@media (max-width: 520px) {
    .grid-stats { grid-template-columns: minmax(0, 1fr); }
    .hero h2 { font-size: 21px; }
}

/* Tables and wide content scroll inside their own container, never the page. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
