/* EmilyAI Web UI – shared styles (ported from the demo platform) */

:root {
    --bg-primary: #0b1220;
    --bg-secondary: #111a2e;
    --bg-sidebar: #0a1224;
    --bg-header: #060c1a;
    --bg-card: #131e35;
    --bg-card-alt: #182441;
    --bg-hover: #1c2a4a;
    --text-primary: #e6edf7;
    --text-secondary: #9aa8c2;
    --text-muted: #6b7a96;
    --border-color: #1f2c4a;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.35);

    --critical: #ef4444;
    --high:     #f97316;
    --medium:   #eab308;
    --low:      #38bdf8;
    --info:     #6b7a96;
    --success:  #22c55e;
    --warn:     #f59e0b;

    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    --radius: 10px;
    --radius-sm: 6px;

    /* Aliases used by newer components */
    --border: var(--border-color);
    --surface: var(--bg-card);
    --surface-2: var(--bg-card-alt);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: radial-gradient(circle at top left, #15224a 0%, var(--bg-primary) 55%);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 14px;
}

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

/* ------------------------------------------------------------------ */
/* Layout                                                             */
/* ------------------------------------------------------------------ */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr auto;
    grid-template-areas:
        "sidebar header"
        "sidebar main"
        "footer  footer";
    min-height: 100vh;
}

.sidebar {
    grid-area: sidebar;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 0;
    display: flex;
    flex-direction: column;
}

.brand {
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 6px 18px var(--accent-glow);
}

.brand-text { line-height: 1.2; }
.brand-text .name { font-weight: 700; letter-spacing: 0.4px; }
.brand-text .tag  { font-size: 11px; color: var(--text-muted); }

.nav { padding: 14px 10px; flex: 1; }
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    margin-bottom: 4px;
    transition: background 0.2s, color 0.2s;
    font-size: 14px;
}
.nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav a.active {
    background: linear-gradient(90deg, rgba(59,130,246,0.22), rgba(59,130,246,0.04));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}
.nav a i { width: 18px; text-align: center; color: var(--accent); }

/* Section heading inside the sidebar nav. */
.nav-section {
    padding: 14px 12px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}
.nav-section:first-child {
    border-top: 0;
    margin-top: 0;
    padding-top: 2px;
}

.sidebar-foot {
    padding: 14px 18px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
}

/* Header */
.header {
    grid-area: header;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 26px;
}
.header .page-title {
    font-size: 17px;
    font-weight: 600;
}
.header .page-title .crumb {
    color: var(--text-muted);
    font-weight: 400;
    margin-right: 8px;
}
.header-actions { display: flex; align-items: center; gap: 18px; }
.search {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 7px 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    width: 280px;
}
.search input {
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--text-primary);
    flex: 1;
    font-size: 13px;
}
/* User menu */
.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #3b82f6);
    display: grid; place-items: center;
    font-weight: 700; font-size: 12px; color: white;
}
.user-menu { position: relative; }
.user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
    line-height: 1.2;
}
.user-menu-btn:hover { border-color: var(--accent); }
.user-menu-btn[aria-expanded="true"] { border-color: var(--accent); }
.user-menu-id {
    display: flex;
    flex-direction: column;
    text-align: left;
}
.user-menu-email { font-size: 13px; font-weight: 600; }
.user-menu-role  { font-size: 11px; color: var(--text-muted); }
.user-menu-caret { color: var(--text-muted); font-size: 10px; margin-left: 2px; }
.user-menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--critical, #ef4444);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--bg-card);
}
.user-menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 50;
}
.user-menu-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px;
}
.avatar.avatar-lg { width: 36px; height: 36px; font-size: 13px; }
.user-menu-header-name { font-size: 13px; font-weight: 600; }
.user-menu-header-role { font-size: 11px; color: var(--text-muted); }
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    background: transparent;
    border: 0;
    cursor: pointer;
}
.user-menu-item i { width: 16px; color: var(--text-muted); text-align: center; }
.user-menu-item:hover { background: var(--bg-hover); }
.user-menu-item.user-menu-alerts i { color: var(--critical, #ef4444); }
.user-menu-item.user-menu-signout i { color: var(--text-muted); }
.user-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 4px;
}
.user-menu-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    padding: 8px 10px 4px;
}
.user-menu-themes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 0 4px 4px;
}
.user-menu-themes .theme-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.user-menu-themes .theme-btn i { font-size: 14px; }
.user-menu-themes .theme-btn:hover { color: var(--text-primary); border-color: var(--accent); }
.user-menu-themes .theme-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
html[data-theme="vt100"] .user-menu-themes .theme-btn.active { color: #050807; }

/* Main */
main {
    grid-area: main;
    padding: 26px 30px 60px;
    overflow-x: hidden;
}

/* App footer */
.app-footer {
    grid-area: footer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 18px;
    padding: 10px 26px;
    background: var(--bg-header);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
}
.app-footer-left,
.app-footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.app-footer .app-footer-sep { color: var(--border-color); }
.app-footer .app-footer-version { color: var(--text-secondary); font-weight: 600; }
.app-footer .app-footer-build .mono { color: var(--text-secondary); }
.app-footer .app-footer-made i { color: var(--accent); margin-right: 4px; }
.app-footer-auth {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ------------------------------------------------------------------ */
/* Reusable components                                                */
/* ------------------------------------------------------------------ */
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-title h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.section-title .actions { display: flex; gap: 8px; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
.card h3 { font-size: 15px; margin-bottom: 12px; font-weight: 600; }

/* KPI grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}
.kpi {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: var(--accent);
}
.kpi.tone-critical::before { background: var(--critical); }
.kpi.tone-success::before  { background: var(--success); }
.kpi.tone-info::before     { background: var(--low); }
.kpi.tone-accent::before   { background: linear-gradient(90deg, #8b5cf6, #3b82f6); }

.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi .delta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; display:flex; align-items:center; gap: 6px; }
.kpi .delta.up   { color: var(--critical); }
.kpi .delta.down { color: var(--success); }
.kpi .delta.flat { color: var(--text-secondary); }
.kpi i.kpi-icon {
    position: absolute; right: 16px; top: 18px;
    font-size: 22px; color: var(--text-muted); opacity: 0.55;
}

/* Two-column layout */
.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 22px;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}
@media (max-width: 1000px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* Bars chart */
.bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 160px;
    padding: 8px 0 0;
}
.bars .bar {
    flex: 1;
    background: linear-gradient(180deg, var(--accent), #1e3a8a);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    position: relative;
    transition: filter 0.2s;
}
.bars .bar:hover { filter: brightness(1.3); }
.bars .bar::after {
    content: attr(data-value);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, -4px);
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}
.bars .bar:hover::after { opacity: 1; }
.chart-axis {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Severity breakdown */
.sev-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sev-row .label { width: 70px; font-size: 12px; color: var(--text-secondary); }
.sev-row .meter {
    flex: 1; height: 8px; background: var(--bg-hover); border-radius: 4px; overflow: hidden;
}
.sev-row .meter > div { height: 100%; border-radius: 4px; }
.sev-row .value { width: 30px; text-align: right; font-size: 12px; }

.fill-critical { background: var(--critical); }
.fill-high     { background: var(--high); }
.fill-medium   { background: var(--medium); }
.fill-low      { background: var(--low); }
.fill-info     { background: var(--info); }
.fill-success  { background: var(--success); }
.fill-warn     { background: var(--warn); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    border: 1px solid transparent;
}
.badge.critical { background: rgba(239,68,68,0.12);  color: #fca5a5; border-color: rgba(239,68,68,0.4); }
.badge.high     { background: rgba(249,115,22,0.12); color: #fdba74; border-color: rgba(249,115,22,0.4); }
.badge.medium   { background: rgba(234,179,8,0.14);  color: #fde68a; border-color: rgba(234,179,8,0.4); }
.badge.low      { background: rgba(56,189,248,0.12); color: #7dd3fc; border-color: rgba(56,189,248,0.4); }
.badge.info     { background: rgba(107,122,150,0.18);color: #cbd5e1; border-color: rgba(107,122,150,0.4); }
.badge.success  { background: rgba(34,197,94,0.12);  color: #86efac; border-color: rgba(34,197,94,0.4); }
.badge.warn     { background: rgba(245,158,11,0.14); color: #fcd34d; border-color: rgba(245,158,11,0.4); }
.badge.accent   { background: rgba(139,92,246,0.14); color: #c4b5fd; border-color: rgba(139,92,246,0.4); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Tables */
.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data th, table.data td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
}
table.data th {
    background: var(--bg-card-alt);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
table.data tbody tr { transition: background 0.15s; }

/* Right-aligned numeric columns, and tables whose rows do not navigate.
   `table.data tbody tr:hover` sets `cursor: pointer` because most tables
   here are row-linked; a table that is only figures must not offer a
   click it does not have. */
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data.static-rows tbody tr:hover { cursor: default; }
table.data tbody tr:hover { background: var(--bg-hover); cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .mono, .mono { font-family: 'Monaco', 'Menlo', 'Courier New', monospace; font-size: 12px; }

/* Health list */
.health-list { display: flex; flex-direction: column; gap: 10px; }
.health-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; background: var(--bg-card-alt); border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.health-item .name { font-weight: 500; }
.health-item .detail { font-size: 12px; color: var(--text-muted); }

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-bar .chip {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-card);
    transition: all 0.15s;
}
.filter-bar .chip:hover { color: #fff; border-color: var(--accent); }
.filter-bar .chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-bar .group-label {
    font-size: 11px; text-transform: uppercase; color: var(--text-muted); margin-right: 4px;
}

.btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    border: 0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); }
.btn.ghost:hover { color: #fff; border-color: var(--accent); background: var(--bg-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Event feed */
.event-feed {
    background: #060c1a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 18px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.65;
    max-height: 70vh;
    overflow-y: auto;
}
.event-feed .line { display: grid; grid-template-columns: 90px 130px 90px 80px 1fr; gap: 10px; padding: 4px 0; }
.event-feed .line:hover { background: rgba(59,130,246,0.06); }
.event-feed .ts   { color: #6b7a96; }
.event-feed .host { color: #93c5fd; }
.event-feed .src  { color: #c4b5fd; }
.event-feed .lvl  { font-weight: 700; }
.event-feed .lvl.ALERT { color: #fca5a5; }
.event-feed .lvl.ERROR { color: #fca5a5; }
.event-feed .lvl.CRITICAL { color: #fca5a5; }
.event-feed .lvl.WARN  { color: #fcd34d; }
.event-feed .lvl.WARNING { color: #fcd34d; }
.event-feed .lvl.INFO  { color: #86efac; }
.event-feed .msg  { color: #e6edf7; }

/* IOC table specifics */
.score-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
}
.score-pill.high { background: rgba(239,68,68,0.18); color: #fca5a5; }
.score-pill.med  { background: rgba(234,179,8,0.18); color: #fde68a; }
.score-pill.low  { background: rgba(56,189,248,0.15); color: #7dd3fc; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
}

/* AI Insights */
.insight {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 14px;
}
.insight .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.insight .title { font-weight: 600; font-size: 15px; }
.insight .confidence {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    color: #86efac;
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.3);
    border-radius: 4px;
    padding: 2px 8px;
}
.insight p { color: var(--text-secondary); line-height: 1.6; }
.insight .meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-muted); }
.insight .meta a { color: var(--accent); }

/* Chat */
.chat {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex; flex-direction: column;
    height: 520px;
}
.chat-stream { flex: 1; padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    font-size: 13px;
}
.bubble.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 2px;
}
.bubble.bot {
    align-self: flex-start;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}
.bubble.bot strong { color: #fde68a; }
.chat-input { border-top: 1px solid var(--border-color); padding: 12px 14px; display: flex; gap: 8px; }
.chat-input input {
    flex: 1; background: var(--bg-primary); border: 1px solid var(--border-color);
    border-radius: 999px; padding: 9px 14px; color: var(--text-primary); outline: none; font-size: 13px;
}
.chat-input input:focus { border-color: var(--accent); }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; }
.preset {
    font-size: 11px; padding: 4px 10px; border: 1px solid var(--border-color);
    border-radius: 999px; cursor: pointer; color: var(--text-secondary); background: transparent;
}
.preset:hover { color: white; border-color: var(--accent); }

/* Playbook cards */
.pb-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 18px 20px; }
.pb-card .top { display: flex; justify-content: space-between; align-items: flex-start; }
.pb-card h3 { font-size: 15px; }
.pb-card .cat { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.pb-card ol { margin: 12px 0 14px 18px; color: var(--text-secondary); font-size: 13px; line-height: 1.7; }
.pb-card .stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.pb-card .stats b { color: var(--text-primary); }
/* Alert detail */
.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
}
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.meta-list { list-style: none; padding: 0; margin: 0; }
.meta-list li {
    display: flex; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px dashed var(--border-color); font-size: 13px;
}
.meta-list li:last-child { border-bottom: none; }
.meta-list .k { color: var(--text-muted); }
.meta-list .v { color: var(--text-primary); }

.timeline { position: relative; padding-left: 22px; }
.timeline::before {
    content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px;
    width: 2px; background: var(--border-color);
}
.timeline .step { position: relative; padding: 0 0 14px 0; }
.timeline .step::before {
    content: ""; position: absolute; left: -22px; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.18);
}
.timeline .ts { color: var(--text-muted); font-size: 11px; font-family: 'Monaco', monospace; }
.timeline .text { color: var(--text-primary); font-size: 13px; }

/* 404 */
.notfound {
    display: grid; place-items: center; padding: 80px 20px;
    text-align: center;
}
.notfound h1 { font-size: 72px; margin-bottom: 10px; color: var(--accent); }
.notfound p { color: var(--text-secondary); margin-bottom: 20px; }

/* ------------------------------------------------------------------ */
/* Health (diagnostic) page                                           */
/* ------------------------------------------------------------------ */
.diag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}
.diag-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.diag-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 14px;
}
.diag-head h3 { font-size: 15px; font-weight: 600; }
.diag-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Circular speedometer dial built with a conic-gradient */
.dial {
    --pct: 0;
    --dial-color: var(--success);
    width: 140px;
    height: 140px;
    border-radius: 50%;
    margin: 6px auto 14px;
    background:
        conic-gradient(var(--dial-color) calc(var(--pct) * 1%),
                       rgba(255,255,255,0.06) 0);
    display: grid;
    place-items: center;
    position: relative;
    box-shadow: inset 0 0 0 1px var(--border-color);
}
.dial-success { --dial-color: var(--success); }
.dial-warn    { --dial-color: var(--warn); }
.dial-critical{ --dial-color: var(--critical); }
.dial-info    { --dial-color: var(--low); }
.dial-inner {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    display: grid;
    place-items: center;
    text-align: center;
}
.dial-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}
.dial-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-top: 4px;
}

.gauges { display: flex; flex-direction: column; gap: 10px; }
.gauge { font-size: 12px; }
.gauge-top {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 4px;
}
.gauge-label { color: var(--text-secondary); }
.gauge-value { font-weight: 600; color: var(--text-primary); font-size: 12px; }
.gauge-unit { color: var(--text-muted); font-weight: 400; margin-left: 4px; font-size: 10px; }
.gauge-bar {
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}
.gauge-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.fill-tone-success  { background: var(--success); }
.fill-tone-warn     { background: var(--warn); }
.fill-tone-critical { background: var(--critical); }
.fill-tone-info     { background: var(--low); }

/* Flow diagram */
.flow-list { display: flex; flex-direction: column; gap: 8px; }
.flow-row {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.flow-node {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}
.flow-row > .flow-node:last-child { text-align: right; }
.flow-arrow {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--success);
}
.flow-arrow .flow-line {
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg,
        rgba(34,197,94,0.1),
        currentColor 50%,
        rgba(34,197,94,0.1));
    border-radius: 2px;
}
.flow-arrow .flow-volume {
    font-size: 11px;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 2px 10px;
    white-space: nowrap;
}
.flow-arrow i { font-size: 16px; }
.flow-tone-success  { color: var(--success); }
.flow-tone-warn     { color: var(--warn); }
.flow-tone-critical { color: var(--critical); }
.flow-tone-info     { color: var(--low); }

@media (max-width: 700px) {
    .flow-row { grid-template-columns: 1fr; }
    .flow-row > .flow-node:last-child { text-align: left; }
    .flow-arrow { padding: 4px 0; }
}

/* ------------------------------------------------------------------ */
/* Login                                                              */
/* ------------------------------------------------------------------ */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 20px 80px;
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 30px 24px;
}
.login-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}
.login-sub {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 18px;
}
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.login-form input {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.login-form .btn { justify-content: center; padding: 11px 16px; margin-top: 4px; }
.login-error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.35);
    color: #fca5a5;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ------------------------------------------------------------------ */
/* Integrations                                                       */
/* ------------------------------------------------------------------ */
.int-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.int-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.int-card-top { display: flex; justify-content: space-between; align-items: center; }
.int-card h3 { font-size: 15px; font-weight: 600; }
.int-summary { color: var(--text-secondary); font-size: 13px; line-height: 1.55; }
.int-card-foot {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; color: var(--text-muted);
}
.int-card-foot i { color: var(--accent); }
.int-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 16px;
    background: var(--bg-hover);
    color: var(--accent);
    border: 1px solid var(--border-color);
}
.int-icon-success  { background: rgba(34,197,94,0.12);  color: #86efac; border-color: rgba(34,197,94,0.35); }
.int-icon-warn     { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.35); }
.int-icon-critical { background: rgba(239,68,68,0.12);  color: #fca5a5; border-color: rgba(239,68,68,0.35); }
.int-icon-info     { background: rgba(56,189,248,0.12); color: #7dd3fc; border-color: rgba(56,189,248,0.35); }
.int-icon-accent   { background: linear-gradient(135deg, rgba(139,92,246,0.18), rgba(59,130,246,0.18)); color: #c4b5fd; border-color: rgba(139,92,246,0.35); }
.int-icon-lg { width: 56px; height: 56px; font-size: 22px; border-radius: 14px; }

.int-detail-head {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.int-cat { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.int-name { font-size: 22px; font-weight: 700; margin: 2px 0 6px; }
.howto-list { color: var(--text-secondary); line-height: 1.8; font-size: 13px; padding-left: 18px; }
.howto-list li { margin-bottom: 4px; }
.howto-list a { color: var(--accent); }
.howto-list a:hover { text-decoration: underline; }

.snippet {
    background: #060c1a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
}
.snippet-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px;
    background: var(--bg-card-alt);
    border-bottom: 1px solid var(--border-color);
}
.snippet-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.snippet-lang  { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.snippet-body {
    margin: 0;
    padding: 14px 16px;
    color: #e6edf7;
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}

/* ------------------------------------------------------------------ */
/* Settings                                                           */
/* ------------------------------------------------------------------ */
.settings-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}
.settings-nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
}
.settings-nav a:hover { color: #fff; border-color: var(--accent); background: var(--bg-hover); }
.settings-nav a i { color: var(--accent); }

.settings-card { margin-bottom: 16px; scroll-margin-top: 80px; }
.settings-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}
.settings-card-head h3 { font-size: 15px; margin-bottom: 4px; }
.settings-card-head h3 i { color: var(--accent); margin-right: 6px; }
.settings-desc { color: var(--text-muted); font-size: 12px; }

.settings-table th { color: var(--text-muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
.settings-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    color: var(--text-primary);
    font-size: 12px;
}
.settings-input:focus { outline: none; border-color: var(--accent); }

/* ================================================================== */
/* Theme variants                                                     */
/* ================================================================== */

html[data-theme="light"] {
    --bg-primary:   #f5f7fb;
    --bg-secondary: #ffffff;
    --bg-sidebar:   #ffffff;
    --bg-header:    #ffffff;
    --bg-card:      #ffffff;
    --bg-card-alt:  #f1f4fa;
    --bg-hover:     #eaeff7;
    --text-primary:   #0b1220;
    --text-secondary: #475066;
    --text-muted:     #6b7a96;
    --border-color:   #d8dde8;
    --accent:       #2563eb;
    --accent-hover: #1d4ed8;
    --accent-glow:  rgba(37, 99, 235, 0.18);
    --info: #2563eb;
    --shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] body {
    background: linear-gradient(180deg, #eef3fa 0%, var(--bg-primary) 30%);
}
html[data-theme="light"] .brand-logo {
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06), 0 6px 18px var(--accent-glow);
}
html[data-theme="light"] .nav a.active {
    background: linear-gradient(90deg, rgba(37,99,235,0.12), rgba(37,99,235,0.02));
    color: var(--text-primary);
}
html[data-theme="light"] .event-feed,
html[data-theme="light"] .snippet,
html[data-theme="light"] .snippet-body {
    background: #0b1220;
    color: #e6edf7;
}
html[data-theme="light"] .badge.critical { background: rgba(220,38,38,0.10);  color: #b91c1c; }
html[data-theme="light"] .badge.high     { background: rgba(234,88,12,0.10);  color: #b45309; }
html[data-theme="light"] .badge.medium   { background: rgba(180,140,8,0.12);  color: #92660a; }
html[data-theme="light"] .badge.low      { background: rgba(14,165,233,0.12); color: #0369a1; }
html[data-theme="light"] .badge.info     { background: rgba(71,85,105,0.12);  color: #334155; }
html[data-theme="light"] .badge.success  { background: rgba(22,163,74,0.12);  color: #166534; }
html[data-theme="light"] .badge.warn     { background: rgba(202,138,4,0.14);  color: #854d0e; }

/* ---- VT100 / green-on-black terminal theme ------------------------- */
html[data-theme="vt100"] {
    --bg-primary:   #050807;
    --bg-secondary: #08110d;
    --bg-sidebar:   #06100c;
    --bg-header:    #030605;
    --bg-card:      #08120d;
    --bg-card-alt:  #0c1812;
    --bg-hover:     #102018;
    --text-primary:   #b9ffcc;
    --text-secondary: #6cd49a;
    --text-muted:     #2f7a56;
    --border-color:   #144030;
    --accent:       #25ff8a;
    --accent-hover: #6cff9c;
    --accent-glow:  rgba(37, 255, 138, 0.25);
    --critical: #ff5555;
    --high:     #ffa040;
    --medium:   #ffe650;
    --low:      #50d8ff;
    --info:     #6cd49a;
    --success:  #25ff8a;
    --warn:     #ffd24a;
    --shadow: 0 0 0 1px rgba(37, 255, 138, 0.08), 0 0 24px rgba(37, 255, 138, 0.12);
}
html[data-theme="vt100"] body {
    background:
        radial-gradient(circle at top, #0c1a14 0%, var(--bg-primary) 65%),
        repeating-linear-gradient(0deg, rgba(37,255,138,0.025) 0 2px, transparent 2px 4px);
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    color: var(--text-primary);
    text-shadow: 0 0 1px rgba(37, 255, 138, 0.25);
}
html[data-theme="vt100"] .brand-logo {
    background: linear-gradient(135deg, #144030, #25ff8a);
    color: #050807;
}
html[data-theme="vt100"] .nav a {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 12px;
}
html[data-theme="vt100"] .nav a.active {
    background: rgba(37,255,138,0.08);
    box-shadow: inset 3px 0 0 var(--accent);
    color: var(--accent);
}
html[data-theme="vt100"] .kpi,
html[data-theme="vt100"] .card,
html[data-theme="vt100"] .insight,
html[data-theme="vt100"] .greeting,
html[data-theme="vt100"] .funnel-card,
html[data-theme="vt100"] .table-wrap,
html[data-theme="vt100"] .pb-card,
html[data-theme="vt100"] .int-card,
html[data-theme="vt100"] .int-detail-head,
html[data-theme="vt100"] .login-card,
html[data-theme="vt100"] .diag-card,
html[data-theme="vt100"] .flow-row {
    background: var(--bg-card);
    border-color: var(--border-color);
}
html[data-theme="vt100"] .header,
html[data-theme="vt100"] .sidebar {
    border-color: var(--border-color);
}
html[data-theme="vt100"] .btn {
    background: var(--accent);
    color: #050807;
}
html[data-theme="vt100"] .btn:hover { background: var(--accent-hover); }
html[data-theme="vt100"] table.data thead th {
    color: var(--accent);
    background: var(--bg-card-alt);
    border-color: var(--border-color);
}
html[data-theme="vt100"] .bars .bar {
    background: linear-gradient(180deg, var(--accent), #144030);
}
html[data-theme="vt100"] .badge.critical { background: rgba(255,85,85,0.12);  color: #ff8080; border-color: rgba(255,85,85,0.4); }
html[data-theme="vt100"] .badge.high     { background: rgba(255,160,64,0.12); color: #ffc080; border-color: rgba(255,160,64,0.4); }
html[data-theme="vt100"] .badge.medium   { background: rgba(255,230,80,0.14); color: #ffe060; border-color: rgba(255,230,80,0.4); }
html[data-theme="vt100"] .badge.low      { background: rgba(80,216,255,0.12); color: #80d4ff; border-color: rgba(80,216,255,0.4); }
html[data-theme="vt100"] .badge.success  { background: rgba(37,255,138,0.12); color: var(--accent); border-color: rgba(37,255,138,0.4); }
html[data-theme="vt100"] .badge.warn     { background: rgba(255,210,74,0.14); color: #ffd24a; border-color: rgba(255,210,74,0.4); }
html[data-theme="vt100"] .insight .confidence {
    color: var(--accent); background: rgba(37,255,138,0.08); border-color: rgba(37,255,138,0.3);
}

/* ================================================================== */
/* Greeting panel                                                     */
/* ================================================================== */
.greeting {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 18px;
    align-items: center;
    background: linear-gradient(120deg, rgba(59,130,246,0.10), rgba(139,92,246,0.04));
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-bottom: 18px;
}
.greeting-line {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.2px;
    margin: 0 0 6px;
}
.greeting-sub {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.55;
    margin: 0 0 10px;
}
.greeting-sub b           { color: var(--text-primary); }
.greeting-sub b.awaiting  { color: #fca5a5; }
html[data-theme="vt100"] .greeting-sub b.awaiting { color: var(--high); }
html[data-theme="light"]  .greeting-sub b.awaiting { color: #b91c1c; }
.greeting-headline {
    color: var(--text-secondary);
    font-size: 13px;
    display: flex; align-items: center; gap: 8px;
    margin: 0;
}
.greeting-headline i { color: var(--medium); }
.greeting-headline a { color: var(--accent); }
.greeting-aside {
    display: flex; flex-direction: column; gap: 10px;
    border-left: 1px dashed var(--border-color);
    padding-left: 22px;
}
.greeting-aside-row { display: flex; flex-direction: column; gap: 2px; }
.greeting-aside-row .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.greeting-aside-row .v { font-size: 13px; color: var(--text-primary); }
.greeting-aside-row .v .muted { color: var(--text-muted); margin-left: 4px; }
@media (max-width: 900px) {
    .greeting { grid-template-columns: 1fr; }
    .greeting-aside { border-left: 0; border-top: 1px dashed var(--border-color); padding-left: 0; padding-top: 12px; }
}
/* ================================================================== */
/* MITRE chip                                                         */
/* ================================================================== */
.mitre-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(139, 92, 246, 0.14);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.35);
    font-size: 10px;
    font-family: 'Monaco', 'Menlo', monospace;
    letter-spacing: 0.3px;
    margin-right: 4px;
}
html[data-theme="vt100"] .mitre-chip {
    background: rgba(37,255,138,0.10);
    color: var(--accent);
    border-color: rgba(37,255,138,0.3);
}
html[data-theme="light"] .mitre-chip {
    background: rgba(124, 58, 237, 0.10);
    color: #6d28d9;
    border-color: rgba(124, 58, 237, 0.3);
}
.mitre-chip-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

/* ================================================================== */
/* Workbench table                                                    */
/* ================================================================== */
.workbench-table table.data .col-check { width: 36px; padding-right: 0; }
.workbench-table table.data .col-actions { width: 1%; white-space: nowrap; padding-right: 14px; }
.workbench-table table.data tbody tr.selected { background: rgba(59,130,246,0.10); }
html[data-theme="vt100"] .workbench-table table.data tbody tr.selected { background: rgba(37,255,138,0.08); }
html[data-theme="light"]  .workbench-table table.data tbody tr.selected { background: rgba(37, 99, 235, 0.08); }

.alert-title-line { font-weight: 500; }

.time-cell { display: flex; flex-direction: column; gap: 2px; }
.time-cell .time-abs { font-size: 11px; color: var(--text-muted); }
.time-cell .time-rel { font-size: 12px; color: var(--text-primary); }

/* Per-row action menu */
.row-actions { display: flex; gap: 6px; align-items: center; }
.action-menu { position: relative; }
.action-menu-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    width: 30px; height: 28px;
    cursor: pointer;
}
.action-menu-btn:hover { color: var(--text-primary); border-color: var(--accent); background: var(--bg-hover); }
.action-menu-pop {
    /* Positioned by JS to `fixed` on open — a row menu inside an
       `overflow-x: auto` table wrapper is clipped by that wrapper at any
       z-index, which hid every item below the first. `absolute` remains
       the fallback for a menu outside a scroll container. */
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 200px;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 4px;
    /* Above the sticky table header and the chat launcher, both of which
       would otherwise sit over an escaped menu. */
    z-index: 1200;
}
.action-menu-item {
    display: flex; align-items: center; gap: 8px;
    background: transparent; border: 0;
    padding: 6px 10px;
    color: var(--text-primary);
    width: 100%;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
}
.action-menu-item:hover { background: var(--bg-hover); }
.action-menu-item.danger { color: #fca5a5; }
html[data-theme="light"] .action-menu-item.danger { color: #b91c1c; }
html[data-theme="vt100"]  .action-menu-item.danger { color: var(--critical); }
.action-menu-item i { width: 14px; color: var(--accent); }
.action-menu-item.danger i { color: currentColor; }

/* Bulk-action bar */
.bulk-bar {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 12px;
    box-shadow: 0 0 0 4px var(--accent-glow);
    font-size: 13px;
}
.bulk-bar i.fa-check-double { color: var(--accent); }
.bulk-bar .bulk-hint { margin-left: auto; color: var(--text-muted); font-size: 11px; }
.bulk-bar kbd {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10px;
    font-family: 'Monaco', 'Menlo', monospace;
}

/* ================================================================== */
/* Alert detail head                                                  */
/* ================================================================== */
.alert-detail-head {
    margin-bottom: 18px;
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
}
.alert-detail-actions {
    margin-left: auto;
    display: flex; gap: 8px; flex-wrap: wrap;
}
.detail-action-btn.danger { border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.detail-action-btn.danger:hover { background: rgba(239,68,68,0.10); border-color: var(--critical); }
.btn.ghost.danger { border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.btn.ghost.danger:hover { background: rgba(239,68,68,0.10); border-color: var(--critical); }

/* ================================================================== */
/* Reasoning panel ("Why Emily thinks this")                          */
/* ================================================================== */
.reasoning {
    margin-top: 12px;
    border-top: 1px dashed var(--border-color);
    padding-top: 10px;
}
.reasoning > summary {
    cursor: pointer;
    list-style: none;
    font-size: 13px;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0;
    user-select: none;
}
.reasoning > summary::-webkit-details-marker { display: none; }
.reasoning > summary::before {
    content: "▸";
    color: var(--accent);
    font-size: 10px;
    transition: transform 0.15s;
    display: inline-block;
}
.reasoning[open] > summary::before { transform: rotate(90deg); }
.reasoning > summary i { color: var(--accent); }
.reasoning-note { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.reasoning-body {
    padding: 10px 4px 4px;
    display: flex; flex-direction: column; gap: 8px;
}
.reasoning-row {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}
.reasoning-row-label { display: flex; flex-direction: column; }
.reasoning-row-text  { color: var(--text-primary); }
.reasoning-row-source { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.reasoning-row-meter {
    height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden;
}
.reasoning-row-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: 3px;
}
html[data-theme="vt100"] .reasoning-row-fill { background: var(--accent); }
.reasoning-row-weight {
    text-align: right; font-family: 'Monaco', 'Menlo', monospace; font-size: 11px;
    color: var(--text-primary);
}
.reasoning-footer {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-style: italic;
}

/* ================================================================== */
/* Toast notifications                                                */
/* ================================================================== */
.toast-stack {
    position: fixed;
    right: 22px;
    bottom: 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-left-width: 4px;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13px;
    box-shadow: var(--shadow);
    max-width: 380px;
    transform: translateX(20px);
    opacity: 0;
    transition: transform 0.25s, opacity 0.25s;
    pointer-events: auto;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.toast-critical { border-color: var(--critical); }
.toast.toast-warn     { border-color: var(--warn); }
.toast.toast-success  { border-color: var(--success); }

/* Chat bubble markdown */
.bubble.bot h1, .bubble.bot h2, .bubble.bot h3 {
    font-size: 14px; margin: 8px 0 4px;
}
.bubble.bot h1 { font-size: 16px; }
.bubble.bot ul, .bubble.bot ol { padding-left: 22px; margin: 4px 0 8px; }
.bubble.bot p { margin: 4px 0; }
.bubble.bot code {
    background: rgba(255,255,255,0.08);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
}

/* ================================================================== */
/* Search box responsiveness                                          */
/* ================================================================== */
@media (max-width: 1400px) {
    .search { width: 200px; }
}
@media (max-width: 1150px) {
    .search { display: none; }
}

/* ================================================================== */
/* Users page                                                         */
/* ================================================================== */
.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.role-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
    overflow: hidden;
}
.role-card::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--accent);
}
.role-card.tone-critical::before { background: var(--critical); }
.role-card.tone-warn::before     { background: var(--warn); }
.role-card.tone-info::before     { background: var(--low); }
.role-card.tone-success::before  { background: var(--success); }
.role-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.role-card-head i { font-size: 22px; color: var(--accent); }
.role-card.tone-critical .role-card-head i { color: var(--critical); }
.role-card.tone-warn .role-card-head i     { color: var(--warn); }
.role-card.tone-info .role-card-head i     { color: var(--low); }
.role-card-title { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.role-card-count { font-size: 12px; color: var(--text-muted); }
.role-card-desc  { color: var(--text-secondary); font-size: 12px; line-height: 1.5; margin: 0; }

/* ================================================================== */
/* Settings shortcuts                                                 */
/* ================================================================== */
.settings-shortcut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
    margin-top: 4px;
}
.settings-shortcut {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}
.settings-shortcut:hover { border-color: var(--accent); background: var(--bg-hover); }
.settings-shortcut > i:first-child { font-size: 20px; color: var(--accent); flex: 0 0 auto; }
.settings-shortcut .t { font-weight: 600; font-size: 13px; }
.settings-shortcut .s { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.settings-shortcut .chev { margin-left: auto; color: var(--text-muted); }
.settings-shortcut:hover .chev { color: var(--accent); }

/* ================================================================== */
/* Ask Emily — global pull tab + slide-out chat panel                 */
/* ================================================================== */
.ask-emily-tab {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    background: var(--accent);
    color: white;
    border: none;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    transition: right 0.25s ease, background 0.15s;
}
.ask-emily-tab:hover { filter: brightness(1.08); }
.ask-emily-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.ask-emily-tab i { font-size: 16px; }
.ask-emily-tab-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-transform: uppercase;
}
html[data-theme="vt100"] .ask-emily-tab { color: #050807; }
body.ask-emily-open .ask-emily-tab {
    right: -64px;
    pointer-events: none;
}

.ask-emily-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(440px, 100vw);
    z-index: 1099;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
body.ask-emily-open .ask-emily-panel {
    transform: translateX(0);
}
.ask-emily-panel[hidden] { display: none; }

.ask-emily-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card-alt);
}
.ask-emily-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}
.ask-emily-panel-title i { color: var(--accent); }
.ask-emily-panel-scope {
    margin-left: auto;
    font-size: 11px;
}
.ask-emily-panel-close {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ask-emily-panel-close:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}
.ask-emily-panel .chat.ask-emily-chat {
    flex: 1;
    height: auto;
    min-height: 0;
    border: none;
    border-radius: 0;
    background: transparent;
}
@media (max-width: 600px) {
    .ask-emily-panel { width: 100vw; }
    .ask-emily-panel-scope { display: none; }
}

/* ================================================================== */
/* Playbook tabs / empty state                                        */
/* ================================================================== */
.pb-tabs {
    display: flex; gap: 8px; margin: 8px 0 16px;
    border-bottom: 1px solid var(--border-color);
}
.pb-tab {
    background: transparent; border: none; color: var(--text-secondary);
    padding: 10px 14px; cursor: pointer; font-size: 13px;
    display: inline-flex; align-items: center; gap: 8px;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    font-family: inherit;
}
.pb-tab:hover { color: var(--text-primary); }
.pb-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.pb-tab-count {
    background: var(--bg-hover); color: var(--text-secondary);
    border-radius: 999px; padding: 1px 8px; font-size: 11px;
}
.pb-tab.active .pb-tab-count { background: var(--accent); color: #fff; }
.pb-tab-source { color: var(--text-muted); font-size: 11px; margin-left: 4px; }

.pb-empty {
    text-align: center; padding: 48px 24px; color: var(--text-secondary);
    background: var(--bg-card); border: 1px dashed var(--border-color);
    border-radius: var(--radius);
}
.pb-empty i { font-size: 32px; color: var(--accent); margin-bottom: 12px; display: block; }
.pb-empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--text-primary); }
.pb-empty p { margin-bottom: 16px; }

/* ================================================================== */
/* Toggle switch                                                      */
/* ================================================================== */
.toggle { position: relative; display: inline-block; width: 38px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--bg-card-alt); border: 1px solid var(--border-color);
    border-radius: 22px;
    transition: 0.15s;
}
.toggle-slider::before {
    content: "";
    position: absolute; height: 16px; width: 16px;
    left: 2px; top: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.15s;
}
.toggle input:checked + .toggle-slider { background: rgba(34, 197, 94, 0.25); border-color: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: var(--success); }

/* ================================================================== */
/* Accessibility helpers                                              */
/* ================================================================== */
.sr-only {
    position: absolute;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ================================================================== */
/* Asset card — the alert detail page's right column                  */
/* Ported from the reference design so the appliance page and the     */
/* mock-up are the same page with different data.                     */
/* ================================================================== */
.asset-card.asset-crit-critical { border-left: 4px solid var(--critical); }
.asset-card.asset-crit-high     { border-left: 4px solid var(--high); }
.asset-card.asset-crit-medium   { border-left: 4px solid var(--medium); }
.asset-card.asset-crit-low      { border-left: 4px solid var(--low); }
.asset-card.asset-crit-unknown  { border-left: 4px solid var(--border-color); }
.asset-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.asset-card-icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--bg-hover);
    display: grid; place-items: center;
    color: var(--accent);
}
.asset-card-name { font-size: 14px; font-weight: 700; }
.asset-card-type { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.asset-card-head .badge { margin-left: auto; }

/* A field the platform has no value for. Rendered, not omitted: a
   shorter card would give no sign that a CMDB was never wired in. */
.meta-list .v.unrecorded { color: var(--text-muted); font-style: italic; }

/* A reasoning row with no recorded weight. The meter is omitted
   entirely rather than drawn at zero or at a guess — a bar is the most
   convincing thing on the panel and must never be invented. */
.reasoning-row.no-weight .reasoning-row-meter { display: none; }
.reasoning-row.no-weight .reasoning-row-weight {
    color: var(--text-muted); font-style: italic; font-size: 11px;
}

/* ================================================================== */
/* Playbook builder                                                    */
/* ================================================================== */
.pb-builder { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .pb-builder { grid-template-columns: 1fr; } }
.pb-palette {
    position: sticky; top: 16px;
    max-height: calc(100vh - 120px); overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 12px;
}
.pb-palette-title { font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
    color: var(--text-muted); margin-bottom: 6px; }
.pb-palette-help { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin: 0 0 8px; }
.pb-palette-card {
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 6px 8px; margin-bottom: 6px; cursor: grab; background: var(--bg-hover);
}
.pb-palette-card:active { cursor: grabbing; }
.pb-palette-card--match { border-style: dashed; }
.pb-palette-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pb-palette-card-desc { font-size: 10px; color: var(--text-muted); }
.pb-drag { color: var(--text-muted); }

.pb-canvas { display: flex; flex-direction: column; gap: 14px; }
.pb-section h3 { margin-top: 0; }
.pb-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pb-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 800px) { .pb-grid-2, .pb-grid-3 { grid-template-columns: 1fr; } }
.pb-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px;
    color: var(--text-secondary); margin-bottom: 10px; }

/* The drop target is visible before anything is dragged. An invisible
   target is one nobody discovers. */
.pb-drop {
    border: 1px dashed var(--border-color); border-radius: var(--radius-sm);
    padding: 10px; min-height: 54px; display: flex; flex-direction: column; gap: 8px;
    transition: border-color .12s, background .12s;
}
.pb-drop-over { border-color: var(--accent); background: var(--bg-hover); }
.pb-drop-hint { color: var(--text-muted); font-size: 12px; }
.pb-delta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pb-delta input, .pb-delta select { min-width: 0; }
.pb-cond-field { flex: 0 0 190px; }
.pb-cond-value { flex: 1 1 160px; }
.pb-delta-value { flex: 0 0 70px; }
.pb-delta-reason { flex: 0 0 180px; }
.pb-step { margin: 0; }
.pb-step-id { flex: 0 0 160px; }
.pb-preview { max-height: 340px; overflow: auto; }
.pb-preview-body p { margin: 4px 0; font-size: 12px; line-height: 1.5; }

/* Library cards */
.pb-portability { font-size: 11px; margin: 6px 0; color: var(--warn, #f59e0b); }
.pb-portability.ok { color: var(--text-muted); }
.pb-srcfile { font-size: 10px; color: var(--text-muted); }

/* Integration configuration panels */
.int-config {
    border-top: 1px solid var(--border-color);
    margin-top: 12px; padding-top: 12px;
}
.int-config .form-grid { gap: 10px; }
.int-config h4 { margin: 12px 0 6px; }

/* ---------------------------------------------------------------------
   Module diagnostics (health page)

   Tokens only — no literal colours — so the three themes (light, dark,
   VT100) all get this without a fourth set of rules. `--muted` gauges are
   deliberately flat and colourless: a measurement that could not be taken
   must not look like a measurement that came back fine.
   --------------------------------------------------------------------- */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.module-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 16px 12px;
}
.module-card.tone-success  { border-left-color: var(--success, #22c55e); }
.module-card.tone-warn     { border-left-color: var(--warn, #f59e0b); }
.module-card.tone-critical { border-left-color: var(--critical, #ef4444); }
.module-card.tone-info     { border-left-color: var(--accent, #8b5cf6); }

.module-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.module-head h3 { margin: 0; font-size: 14px; }
.module-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.module-score { position: absolute; top: 44px; right: 16px; text-align: right; }
.module-score-value { font-size: 26px; font-weight: 700; line-height: 1; }
.module-score-label { font-size: 9px; letter-spacing: 1px; color: var(--text-muted); }

.module-detail { font-size: 12px; color: var(--text-secondary); margin: 10px 60px 10px 0; line-height: 1.5; }

.module-gauges { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.module-gauge-top { display: flex; justify-content: space-between; font-size: 11px; }
.module-gauge-label { color: var(--text-muted); }
.module-gauge-value { color: var(--text-primary); }
.module-bar { height: 4px; border-radius: 2px; background: var(--bg-card-alt); margin-top: 4px; overflow: hidden; }
.module-bar-fill { display: block; height: 100%; border-radius: 2px; }
.module-bar-fill.ok    { background: var(--success, #22c55e); }
.module-bar-fill.warn  { background: var(--warn, #f59e0b); }
.module-bar-fill.bad   { background: var(--critical, #ef4444); }
/* No colour and no width: nothing was measured, and the bar says so by
   showing nothing rather than by showing zero. */
.module-bar-fill.muted { background: transparent; }

.module-unmeasured {
    margin-top: 10px; font-size: 11px; color: var(--text-muted);
    border-top: 1px dashed var(--border-color); padding-top: 8px; line-height: 1.5;
}
.module-formula { margin-top: 8px; font-size: 11px; color: var(--text-muted); }
.module-formula summary { cursor: pointer; }
.module-formula > div { margin-top: 6px; line-height: 1.6; }

html[data-theme="vt100"] .module-card {
    border-left-width: 1px;
    box-shadow: none;
}
html[data-theme="vt100"] .module-score-value { text-shadow: 0 0 6px currentColor; }

/* ---------------------------------------------------------------------
   Classes the views referenced and the stylesheet never defined.

   Found on 29 August by a scan of every `class="…"` in `app/views/`
   against the three stylesheets. The visible symptom was on the Threat
   Intel, Playbooks and Tenants pages: their KPI cards used `.kpi-row`,
   `.kpi-label`, `.kpi-value` and `.kpi-sub`, none of which existed, so
   the grid container did nothing and four cards stacked full-width down
   the page. Those views now use the existing `.kpi-grid` / `.label` /
   `.value` / `.delta` vocabulary instead of a second one.

   What follows is the rest of that scan — classes that carry real
   presentation and had none. `tests/no_undefined_classes.php` fails the
   build if another appears.
   --------------------------------------------------------------------- */

/* A table row that navigates on click. The JS in app.js handles the
   navigation from `data-href`; without this the row gave no sign it
   could be clicked. */
.linked-row { cursor: pointer; }
.linked-row:hover { background: var(--bg-hover); }
/* Opt out, for a row inside a clickable table that must not navigate. */
.no-row-nav, .no-row-nav:hover { cursor: default; background: inherit; }

/* One gauge inside a module card. The container `.module-gauges` sets
   the flex column and gap; this was relying on that alone. */
.module-gauge { min-width: 0; }

/* Muted state for a card or chip that is present but inactive. */
.tone-muted { opacity: 0.62; }

/* `.flash-critical` and `.flash-warn` existed; the informational tone
   did not, so settings.php was rendering an unstyled box. */
.flash-info {
    border-left-color: var(--low, #3b82f6);
    background: rgba(59, 130, 246, 0.10);
}

/* Layout odds and ends the views name. */
.greeting-text { display: block; }
.app-footer-product { color: var(--text-muted); }
.user-menu-header-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.settings-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; }
.handover-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.asset-crit-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.tenant-edit-row > td { background: var(--bg-card-alt); }
.alerts-workbench { width: 100%; }
.alert-row { vertical-align: top; }
.ai-analysis-page { display: block; }
.pb-pane { display: block; }
.pb-builder-intro { color: var(--text-secondary); line-height: 1.7; }

/* Why a feed has never run. A fact without a diagnosis sends the reader
   to the wrong fix, and "never run" has three causes needing three. */
.int-why {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-card-alt);
    border-left: 2px solid var(--low, #3b82f6);
    border-radius: 4px;
    padding: 8px 10px;
    margin: 8px 0 0;
    line-height: 1.5;
}

/* ---------------------------------------------------------------------
   Integrations — catalogue cards
   --------------------------------------------------------------------- */

/* A state lookup that failed, as opposed to a state that is empty. It
   has to look different from the blue advisory note, because the whole
   point of distinguishing them is lost if they read the same. */
.int-why-bad {
    border-left-color: var(--critical);
    background: rgba(239, 68, 68, 0.08);
}
.int-instances { display: flex; flex-direction: column; gap: 6px; }
.int-instance {
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 12px;
}
.int-instance-sub {
    font-size: 11px; color: var(--text-muted); margin-top: 2px;
    line-height: 1.5;
}
.int-field-help {
    font-size: 11px; color: var(--text-muted); line-height: 1.45;
    margin-top: 2px;
}
.int-config table.data td { vertical-align: top; }
