/* Base */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: var(--font-mono); font-size: 0.9em; }

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

/* Top nav */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.nav {
    background: var(--panel);
    border-bottom: var(--border-w) solid var(--border);
    padding: 0 24px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav .brand {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-primary);
}

.nav .brand-secondary {
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.nav .status {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
}

.nav .nav-link {
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.nav .nav-link:hover {
    color: var(--text-primary);
    background: var(--card);
    text-decoration: none;
}

/* Body */
.body {
    padding: 32px 24px;
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 24px;
    color: var(--text-primary);
}

/* Cards */
.card {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

/* Section labels (ALL CAPS, letter-spaced — signature pattern) */
.label-caps {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    background: var(--card);
    color: var(--text-secondary);
    border: var(--border-w) solid var(--border);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
    letter-spacing: 0.05em;
    transition: opacity 120ms ease;
}

.btn:hover { opacity: 0.85; }
.btn:active { opacity: 0.7; }

.btn-primary {
    background: var(--accent);
    color: #FFFFFF;
    border-color: var(--accent);
}

/* Inputs */
.input {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    width: 100%;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.field label {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    font-weight: 600;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 360px;
}

.login-card .logo-wrap {
    text-align: center;
    margin-bottom: 20px;
}

.login-card .logo-mark {
    width: 48px;
    height: 48px;
    margin: 0 auto;
    background: var(--accent);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.login-card h1 {
    font-size: 11px;
    font-weight: 700;
    margin: 0 0 24px;
    text-align: center;
    color: var(--text-secondary);
    letter-spacing: 0.15em;
}

/* Banners */
.error-banner {
    background: var(--error-bg);
    border: var(--border-w) solid var(--error-border);
    color: var(--error-fg);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
}

/* Empty state */
.empty-state {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 64px 24px;
    text-align: center;
}

.empty-state .label-caps { color: var(--text-secondary); }
.empty-state p { font-size: 13px; margin: 8px 0 0; color: var(--text-muted); }
.empty-state code {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-secondary);
}

/* Page header */
.page-header { margin-bottom: 20px; }
.page-header.dense { margin-bottom: 12px; }
.page-header.dense .page-title { font-size: 16px; margin-bottom: 4px; }
.page-subtitle {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 920px;
}
.page-header.dense .page-subtitle { font-size: 11px; margin: 2px 0 0; }

/* Stat strip */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0 24px;
}

@media (max-width: 880px) {
    .stat-strip { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    text-decoration: none;
    color: inherit;
    transition: background 120ms ease, border-color 120ms ease;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-card:hover {
    background: var(--card-hover);
    text-decoration: none;
    border-color: var(--accent);
}

.stat-card.stat-info { cursor: default; }
.stat-card.stat-info:hover { background: var(--card); border-color: var(--border); }

.stat-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-card.stat-critical  .stat-value { color: var(--severity-critical); }
.stat-card.stat-analyzing .stat-value { color: var(--severity-medium); }
.stat-card.stat-error     .stat-value { color: var(--error-fg); }

/* Filter row */
.filters {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filters.dense { padding: 8px 12px; gap: 6px; }
.filters.dense .filter-row { gap: 8px; }
.filters.dense .filter-row.chip-row { gap: 4px; row-gap: 6px; }
.filter-divider { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }

.filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-row.chip-row { gap: 6px; }

.filter-label-caps {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--text-muted);
}

.filter-select {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12px;
    padding: 5px 10px;
    min-width: 200px;
    cursor: pointer;
}

.filter-select:focus { outline: none; border-color: var(--accent); }

.search-wrap { flex: 1; min-width: 220px; }

.filter-search {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12px;
    padding: 5px 10px;
    flex: 1;
    min-width: 240px;
}

.filter-search:focus { outline: none; border-color: var(--accent); }
.filter-search::placeholder { color: var(--text-muted); }

.filter-clear {
    font-size: 11px;
    color: var(--text-muted);
    border: var(--border-w) solid var(--border);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.05em;
}

.filter-clear:hover {
    color: var(--text-primary);
    background: var(--panel);
    text-decoration: none;
}

/* Filter chips (multi-select toggles) — dense, no-frills */
.chip {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 2px 7px;
    border-radius: 3px;
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    color: var(--text-muted);
    text-decoration: none;
    line-height: 1.5;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.chip:hover {
    background: var(--card-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.chip.active {
    background: var(--card-selected);
    color: var(--text-primary);
    border-color: var(--accent);
}

.chip-severity-critical.active { color: var(--severity-critical); border-color: var(--severity-critical); }
.chip-severity-high.active     { color: var(--severity-high);     border-color: var(--severity-high); }
.chip-severity-medium.active   { color: var(--severity-medium);   border-color: var(--severity-medium); }
.chip-severity-low.active      { color: var(--severity-low);      border-color: var(--severity-low); }

.chip-status-complete.active   { color: var(--severity-low);      border-color: var(--severity-low); }
.chip-status-error.active      { color: var(--error-fg);          border-color: var(--error-border); }
.chip-status-analyzing.active,
.chip-status-received.active   { color: var(--severity-medium);   border-color: var(--severity-medium); }

/* Tenant label — color-coded plain text, no chip/badge styling. The color
   identifies the tenant; the weight makes it readable alongside other table
   columns. No background, no border, no padding. */
.tenant-pill {
    font-size: 12px;
    font-weight: 600;
    color: var(--tenant-color);
    white-space: nowrap;
}

/* Bundle table — dense, support-tool style */
.bundle-table-wrap {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.bundle-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.bundle-table thead th {
    text-align: left;
    background: var(--panel);
    border-bottom: var(--border-w) solid var(--border);
    padding: 7px 10px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.bundle-table thead th a {
    color: var(--text-muted);
    text-decoration: none;
}

.bundle-table thead th a:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.bundle-table tbody tr {
    border-bottom: var(--border-w) solid var(--border);
    cursor: pointer;
    transition: background 80ms ease;
}

.bundle-table tbody tr:last-child { border-bottom: none; }

.bundle-table tbody tr:hover { background: var(--card-hover); }

.bundle-table tbody td {
    padding: 6px 10px;
    color: var(--text-secondary);
    vertical-align: middle;
    line-height: 1.4;
}

.bundle-table .num { text-align: right; }
.bundle-table .mono { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }

/* Severity-colored 3px left bar on the row's first cell — column-order-independent */
.bundle-table tbody tr > td:first-child {
    border-left: 3px solid var(--text-muted);
    padding-left: 8px;
}
.bundle-table tbody tr.sev-critical > td:first-child { border-left-color: var(--severity-critical); }
.bundle-table tbody tr.sev-high     > td:first-child { border-left-color: var(--severity-high); }
.bundle-table tbody tr.sev-medium   > td:first-child { border-left-color: var(--severity-medium); }
.bundle-table tbody tr.sev-low      > td:first-child { border-left-color: var(--severity-low); }
.bundle-table tbody tr.sev-unknown  > td:first-child { border-left-color: var(--text-muted); }

.bundle-table .col-sev { width: 90px; }

.severity-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.severity-bg-critical { background: var(--severity-critical); }
.severity-bg-high     { background: var(--severity-high); }
.severity-bg-medium   { background: var(--severity-medium); }
.severity-bg-low      { background: var(--severity-low); }

.sev-text {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.15em;
}

.bundle-table .col-status   { width: 92px; }
.bundle-table .col-tenant   { width: 160px; }
.bundle-table .col-scenario { width: 80px; }
.bundle-table .col-ticket   { width: 100px; }
.bundle-table .col-hostname {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bundle-table .col-component {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bundle-table .col-issues   { width: 56px; }
.bundle-table .col-created  { width: 130px; white-space: nowrap; }

.bundle-table .tenant-pill { font-size: 12px; }
.bundle-table .status-pill { font-size: 9px; padding: 2px 6px; }

.table-footer {
    margin-top: 6px;
    padding: 0 4px;
    font-size: 11px;
}

/* Legacy card-list styles kept here for the bundle-list classes still used
   in places (severity strip in summary card etc.). The list itself is gone. */
.bundle-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bundle-card {
    display: flex;
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    transition: background 120ms ease;
}

.bundle-card:hover {
    background: var(--card-hover);
    text-decoration: none;
}

.bundle-card-accent {
    width: 3px;
    background: var(--text-muted);
    flex-shrink: 0;
}

.bundle-card.severity-critical .bundle-card-accent { background: var(--severity-critical); }
.bundle-card.severity-high     .bundle-card-accent { background: var(--severity-high); }
.bundle-card.severity-medium   .bundle-card-accent { background: var(--severity-medium); }
.bundle-card.severity-low      .bundle-card-accent { background: var(--severity-low); }

.bundle-card-body {
    flex: 1;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bundle-card-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.bundle-card-summary {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.bundle-card-summary .component {
    color: var(--text-primary);
    font-weight: 600;
}

.bundle-card-summary.error-text { color: var(--error-fg); }

.bundle-card-row.tenant-row { margin-top: 0; }
.small { font-size: 11px; }
.host { font-size: 11px; }
.ts { font-size: 11px; }
.ticket { font-size: 12px; color: var(--text-secondary); font-family: var(--font-mono); }

.status-pill {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.15em;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--panel);
    color: var(--text-muted);
    border: var(--border-w) solid var(--border);
}

.status-pill.status-complete { color: var(--severity-low); border-color: var(--severity-low); }
.status-pill.status-error    { color: var(--error-fg); border-color: var(--error-border); }
.status-pill.status-analyzing,
.status-pill.status-received { color: var(--severity-medium); border-color: var(--severity-medium); }

.severity-chip {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.15em;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--panel);
    border: var(--border-w) solid var(--border);
}

.severity-fg-critical { color: var(--severity-critical); border-color: var(--severity-critical); }
.severity-fg-high     { color: var(--severity-high);     border-color: var(--severity-high); }
.severity-fg-medium   { color: var(--severity-medium);   border-color: var(--severity-medium); }
.severity-fg-low      { color: var(--severity-low);      border-color: var(--severity-low); }

/* Bundle detail */
.back-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.back-link {
    font-size: 11px;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    border: var(--border-w) solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
}

.back-link:hover {
    color: var(--text-primary);
    background: var(--card);
    text-decoration: none;
}

.summary-card {
    display: flex;
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.summary-card.severity-critical .bundle-card-accent { background: var(--severity-critical); }
.summary-card.severity-high     .bundle-card-accent { background: var(--severity-high); }
.summary-card.severity-medium   .bundle-card-accent { background: var(--severity-medium); }
.summary-card.severity-low      .bundle-card-accent { background: var(--severity-low); }

.summary-body {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.summary-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.component-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.summary-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    min-width: 100px;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    margin-top: 4px;
}

.summary-text {
    font-size: 13px;
    line-height: 1.7;
    margin: 0;
    color: var(--text-secondary);
}

/* Issue grid (left list + right detail) */
.issues-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .issues-grid { grid-template-columns: 1fr; }
}

.issues-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.issues-list > .label-caps { margin-bottom: 6px; }

.issue-card {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    text-align: left;
    color: inherit;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: background 120ms ease, border-color 120ms ease;
}

.issue-card:hover { background: var(--card-hover); }
.issue-card.active {
    background: var(--card-selected);
    border-color: var(--accent);
}

.issue-card-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.issue-card-title {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.issue-card.active .issue-card-title { color: var(--text-primary); }

/* Issue detail card */
.issue-detail-card {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.issue-detail-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.category-pill {
    font-size: 11px;
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.escalate-pill {
    font-size: 11px;
    background: var(--error-bg);
    border: var(--border-w) solid var(--error-border);
    border-radius: 4px;
    padding: 2px 8px;
    color: var(--error-fg);
    margin-left: auto;
    letter-spacing: 0.1em;
}

.issue-detail-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px;
}

.issue-section { margin-bottom: 16px; }
.issue-section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.issue-text { font-size: 12px; color: var(--text-secondary); line-height: 1.8; margin: 8px 0 0; }

.issue-impact {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 16px;
}

.fix-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fix-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.fix-step-num {
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--card-selected);
    border: var(--border-w) solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 1px;
}

.fix-step-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Recommendations */
.recommendations { padding: 20px 24px; }
.recommendations-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recommendations-list li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.rec-chevron {
    color: var(--accent);
    font-size: 14px;
    margin-top: 1px;
    flex-shrink: 0;
}

/* Status card (when analysis isn't ready) */
.status-card {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.status-card p { font-size: 13px; color: var(--text-secondary); margin: 8px 0 0; }
.status-card .error-text { color: var(--error-fg); }

/* Top nav improvements (active link, spacer) */
.nav-spacer { flex: 1; }
.nav-link.active { color: var(--accent); }

/* Tab nav (Analysis | Files on bundle detail) */
.tab-nav {
    display: flex;
    gap: 0;
    border-bottom: var(--border-w) solid var(--border);
    margin-bottom: 20px;
}

.tab {
    display: inline-block;
    padding: 10px 18px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 120ms ease, border-color 120ms ease;
}

.tab:hover { color: var(--text-primary); text-decoration: none; }

.tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

/* Files tab — toolbar + split layout */
.files-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

.files-toolbar .btn-sm {
    margin-left: auto;
    padding: 6px 14px;
    font-size: 11px;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 11px;
}

.files-layout {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 2fr;
    gap: 16px;
    min-height: 480px;
}

@media (max-width: 920px) {
    .files-layout { grid-template-columns: 1fr; }
}

/* File tree */
.file-tree {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    overflow-y: auto;
    max-height: 720px;
}

.tree-dir-header {
    color: var(--accent);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.05em;
    margin: 10px 0 4px;
    padding-bottom: 4px;
    border-bottom: var(--border-w) dashed var(--border);
}

.tree-dir-header:first-child { margin-top: 0; }

.tree-file {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 4px 0 4px 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.tree-file.root { padding-left: 0; }
.tree-file:hover { color: var(--text-primary); }

.tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-size {
    font-family: var(--font-mono);
    font-size: 10px;
    text-align: right;
    min-width: 56px;
}

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

.action-link {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    padding: 2px 8px;
    border-radius: 3px;
    border: var(--border-w) solid transparent;
}

.action-link:hover {
    color: var(--accent);
    text-decoration: none;
    background: var(--card-hover);
}

/* File viewer */
.file-viewer {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.file-viewer-empty {
    padding: 40px 24px;
    text-align: center;
}

.file-viewer-empty p { font-size: 12px; margin-top: 8px; }
.file-viewer-empty code {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
}

.file-viewer-loaded {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.file-viewer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: var(--border-w) solid var(--border);
    background: var(--panel);
}

.file-viewer-header .path {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.file-viewer-actions { margin-left: auto; }

.file-content {
    flex: 1;
    margin: 0;
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg);
    overflow: auto;
    max-height: 720px;
    white-space: pre;
    line-height: 1.5;
}

/* Bundle Explorer page */
.explorer-layout {
    display: grid;
    grid-template-columns: minmax(420px, 1fr) 2fr;
    gap: 16px;
    min-height: 540px;
    align-items: start;
}

@media (max-width: 1100px) {
    .explorer-layout { grid-template-columns: 1fr; }
}

.explorer-tree-pane {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.explorer-tenant {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.explorer-tenant-header,
.explorer-month-header,
.explorer-bundle-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 120ms ease;
    flex-wrap: wrap;
}

.explorer-tenant-header:hover,
.explorer-month-header:hover,
.explorer-bundle-header:hover { background: var(--card-hover); }

.caret {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    width: 12px;
    flex-shrink: 0;
}

.explorer-months {
    border-top: var(--border-w) solid var(--border);
    padding: 4px 0;
}

.explorer-month {
    border-top: var(--border-w) solid var(--border);
}

.explorer-month:first-child { border-top: none; }

.explorer-month-header {
    padding-left: 28px;
    font-size: 12px;
}

.month-label {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 12px;
}

.explorer-bundles {
    background: var(--bg);
}

.explorer-bundle {
    border-top: var(--border-w) solid var(--border);
}

.explorer-bundle-header {
    padding-left: 44px;
    font-size: 12px;
}

.explorer-bundle-header .ticket {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.explorer-bundle-header .action-link { margin-left: auto; }

.explorer-bundle-body {
    padding: 12px 18px 14px 44px;
    background: var(--panel);
    border-top: var(--border-w) solid var(--border);
}

.explorer-bundle-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.explorer-tree {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    max-height: 360px;
}

.explorer-empty-tenant {
    padding: 10px 14px 14px 28px;
}

.explorer-viewer {
    position: sticky;
    top: 16px;
    max-height: 80vh;
}

/* Re-analyze button on the analysis tab */
.reanalyze-form {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.reanalyze-form .muted { font-size: 11px; }

/* LLM I/O tab */
.llm-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.llm-card {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.llm-card.llm-error {
    border-color: var(--error-border);
}

.llm-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 8px;
    border-bottom: var(--border-w) solid var(--border);
}

.provider-pill {
    font-size: 10px;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.llm-section {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.llm-section > summary {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: center;
    user-select: none;
    list-style: none;
}

.llm-section > summary::-webkit-details-marker { display: none; }

.llm-section > summary::before {
    content: "▸";
    font-family: var(--font-mono);
    color: var(--text-muted);
    width: 12px;
}

.llm-section[open] > summary::before { content: "▾"; }

.llm-section > summary:hover { background: var(--card-hover); }

.llm-section .file-content {
    border-top: var(--border-w) solid var(--border);
    max-height: 480px;
    margin: 0;
}

.llm-error-block {
    background: var(--error-bg);
    border: var(--border-w) solid var(--error-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.llm-error-block .file-content {
    background: transparent;
    color: var(--error-fg);
    padding: 6px 0 0;
    margin: 0;
    max-height: 200px;
}

/* Chat tab */
.chat-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    max-height: 580px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-empty {
    text-align: center;
    padding: 32px 16px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 85%;
}

.chat-message.chat-user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message.chat-assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 9px;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.chat-bubble {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    line-height: 1.55;
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-message.chat-user .chat-bubble {
    background: var(--card-selected);
    border-color: var(--accent);
    color: var(--text-primary);
}

.chat-message.chat-error .chat-bubble {
    border-color: var(--error-border);
}

.chat-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: var(--font-sans);
}

/* Markdown-rendered assistant content — drop pre-wrap (markdown handles
   paragraphs) and style common GFM elements inline with the chat bubble. */
.chat-content.chat-markdown {
    white-space: normal;
}

.chat-markdown > *:first-child { margin-top: 0; }
.chat-markdown > *:last-child  { margin-bottom: 0; }

.chat-markdown p {
    margin: 0 0 10px;
    line-height: 1.55;
}

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4 {
    color: var(--text-primary);
    margin: 14px 0 6px;
    line-height: 1.3;
    font-weight: 700;
}
.chat-markdown h1 { font-size: 16px; }
.chat-markdown h2 { font-size: 14px; }
.chat-markdown h3 { font-size: 13px; letter-spacing: 0.02em; }
.chat-markdown h4 { font-size: 12px; }

.chat-markdown ul,
.chat-markdown ol {
    margin: 4px 0 10px;
    padding-left: 22px;
}

.chat-markdown li { margin: 3px 0; }
.chat-markdown li > p { margin: 0; }

.chat-markdown strong { color: var(--text-primary); font-weight: 700; }
.chat-markdown em { color: var(--text-primary); }

.chat-markdown a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.chat-markdown code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    color: var(--text-primary);
}

.chat-markdown pre {
    background: var(--bg);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 8px 0;
    overflow-x: auto;
}

.chat-markdown pre code {
    background: transparent;
    border: 0;
    padding: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: pre;
}

.chat-markdown blockquote {
    margin: 8px 0;
    padding: 4px 12px;
    border-left: 3px solid var(--accent);
    background: var(--panel);
    color: var(--text-secondary);
}

.chat-markdown hr {
    border: 0;
    border-top: var(--border-w) solid var(--border);
    margin: 12px 0;
}

.chat-markdown table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 8px 0;
}

.chat-markdown th,
.chat-markdown td {
    text-align: left;
    padding: 5px 8px;
    border-bottom: var(--border-w) solid var(--border);
}

.chat-markdown th {
    background: var(--panel);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    font-size: 11px;
}

.chat-markdown del {
    text-decoration: line-through;
    color: var(--text-muted);
}

.chat-error-block {
    color: var(--error-fg);
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: pre-wrap;
}

.chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.chat-input {
    flex: 1;
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 8px 10px;
    line-height: 1.5;
    resize: vertical;
    min-height: 56px;
}

.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send {
    align-self: stretch;
    min-width: 96px;
}

.chat-busy.htmx-indicator { display: none; }
.chat-busy.htmx-indicator.htmx-request { display: inline-block; }
form.chat-form.htmx-request .chat-busy { display: inline-block; }

.htmx-request .chat-send { opacity: 0.6; cursor: wait; }

/* Comments (Jira-style — used on bundle detail and tenant detail) */
.section-heading {
    font-size: 13px;
    font-weight: 700;
    margin: 28px 0 10px;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

.comments-section {
    margin-top: 28px;
    border-top: var(--border-w) solid var(--border);
    padding-top: 16px;
}

.comments-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.comments-header .section-heading { margin: 0; }

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.comment {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}

.comment-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
    font-size: 11px;
}

.comment-author {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 12px;
}

.comment-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.mention {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    padding: 0 4px;
    border-radius: 3px;
    font-weight: 600;
}

.comments-empty { padding: 8px 0 14px; }

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-input {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 10px 12px;
    line-height: 1.55;
    resize: vertical;
    min-height: 78px;
}

.comment-input:focus { outline: none; border-color: var(--accent); }
.comment-input::placeholder { color: var(--text-muted); }

.comment-form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.comment-form-actions .btn { margin-left: auto; }

/* Tenant pages — form + nav improvements */
.tenant-form {
    max-width: 560px;
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

/* Per-tenant Collector build card on the tenant detail page */
.build-card {
    background: var(--card);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 24px;
}

.build-cmd-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin: 6px 0 12px;
}

.build-cmd {
    flex: 1;
    background: var(--bg);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

.build-cmd-row .btn {
    align-self: stretch;
    min-width: 70px;
}

button[data-copied] { color: var(--severity-low); }

.build-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 6px 16px;
    padding: 8px 0;
    border-top: var(--border-w) dashed var(--border);
}

.build-meta .label-caps { margin-right: 6px; }
.build-meta code {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
}

/* ── Multi-file correlated analysis ─────────────────────────────────── */

.root-cause {
    margin-top: 14px;
    padding: 10px 12px;
    background: var(--panel);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
}

.root-cause p {
    margin: 4px 0 0;
}

.correlated-issues {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.correlated-issue {
    padding: 16px 18px;
    border-left-width: 3px;
    border-left-style: solid;
}

.correlated-issue.severity-critical { border-left-color: var(--severity-critical); }
.correlated-issue.severity-high     { border-left-color: var(--severity-high); }
.correlated-issue.severity-medium   { border-left-color: var(--severity-medium); }
.correlated-issue.severity-low      { border-left-color: var(--severity-low); }

.correlated-issue-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.correlated-issue-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
}

.correlated-issue-description {
    margin: 0 0 12px;
    color: var(--text-primary);
}

.correlation-explanation,
.correlated-issue .impact {
    margin-top: 10px;
    padding: 8px 10px;
    background: var(--panel);
    border-radius: var(--radius-sm);
}

.correlation-explanation p,
.correlated-issue .impact p {
    margin: 4px 0 0;
}

.correlated-issue .fix-steps {
    margin-top: 12px;
}

.correlated-issue .fix-steps ol {
    list-style: none;
    padding: 0;
    margin: 6px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.correlated-issue .fix-steps li {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.correlated-issue .fix-meta {
    margin-top: 8px;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.affected-components {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 4px;
}

.component-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Component health table */

.component-health {
    margin-top: 24px;
}

.component-health-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.component-health-table th,
.component-health-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: var(--border-w) solid var(--border);
    vertical-align: top;
}

.component-health-table th {
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.component-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    letter-spacing: 0.12em;
    font-weight: 600;
}

.component-status-healthy  { background: rgba(74, 222, 128, 0.12); color: var(--severity-low); }
.component-status-warning  { background: rgba(245, 196, 0, 0.14);  color: var(--severity-medium); }
.component-status-degraded { background: rgba(255, 122, 0, 0.14);  color: var(--severity-high); }
.component-status-critical { background: rgba(239, 68, 68, 0.14);  color: var(--severity-critical); }

/* Missing-items manifest card */

.missing-items {
    margin-top: 24px;
}

.missing-items-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.missing-items-table {
    width: 100%;
    border-collapse: collapse;
}

.missing-items-table th,
.missing-items-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: var(--border-w) solid var(--border);
    vertical-align: top;
    font-size: 13px;
}

.missing-items-table th {
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.missing-items-table code {
    background: var(--panel);
    border: var(--border-w) solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

.missing-reason {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 9px;
    letter-spacing: 0.12em;
    font-weight: 600;
    border: var(--border-w) solid var(--border);
    background: var(--panel);
    color: var(--text-muted);
}

.missing-reason-not_present  { color: var(--text-muted); }
.missing-reason-access_denied { color: var(--severity-high); border-color: var(--severity-high); }
.missing-reason-timed_out    { color: var(--severity-medium); border-color: var(--severity-medium); }
.missing-reason-parse_error  { color: var(--severity-critical); border-color: var(--severity-critical); }

/* Theme toggle in the top nav */

.theme-toggle-form {
    margin: 0;
    padding: 0;
    display: inline-flex;
}

.theme-toggle {
    background: transparent;
    border: var(--border-w) solid var(--border);
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.theme-toggle:hover {
    background: var(--card-hover);
    border-color: var(--accent);
    color: var(--accent);
}

/* Tenant archive */
.archived-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    background: transparent;
    vertical-align: middle;
}

.archived-row td {
    opacity: 0.55;
}

.archive-banner {
    border: 1px solid var(--severity-critical);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    background: var(--card);
    padding: 12px 14px;
    margin: 0 0 18px;
}

.archive-banner-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.archive-banner-head .label-caps {
    color: var(--severity-critical);
}

.archive-banner-reason {
    margin: 4px 0 0;
    color: var(--text-primary);
    font-size: 13px;
    white-space: pre-wrap;
}

.archive-banner-note {
    margin: 8px 0 0;
}

.danger-heading {
    color: var(--severity-critical);
    margin-top: 28px;
}

.danger-card {
    border: 1px solid var(--severity-critical);
    border-radius: var(--radius-sm);
    background: var(--card);
    padding: 10px 14px;
    margin-top: 8px;
}

.danger-card > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--severity-critical);
    letter-spacing: 0.05em;
    list-style: none;
    user-select: none;
}

.danger-card > summary::-webkit-details-marker { display: none; }

.btn-danger {
    background: var(--severity-critical);
    border-color: var(--severity-critical);
    color: #FFFFFF;
}
