@import url('./icons.css');

:root {
    --ef-primary: #4f46e5;
    --ef-primary-dark: #3730a3;
    --ef-primary-light: #e0e7ff;
    --ef-accent: #06b6d4;
    --ef-success: #10b981;
    --ef-warning: #f59e0b;
    --ef-danger: #ef4444;
    --ef-bg: #f8fafc;
    --ef-card-bg: #ffffff;
    --ef-border: #e2e8f0;
    --ef-text-main: #0f172a;
    --ef-text-muted: #64748b;
    --ef-radius: 12px;
}

html, body {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--ef-bg);
    color: var(--ef-text-main);
}

.w-100 {
    width: 100% !important;
}

.h-100 {
    height: 100% !important;
}

.h-auto {
    height: auto !important;
}

.overflow-hidden {
    overflow: hidden !important;
}

/* Modern Card Styling */
.ef-card {
    background: var(--ef-card-bg);
    border: 1px solid var(--ef-border);
    border-radius: var(--ef-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 10px 15px -5px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .ef-card:hover {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 20px 25px -5px rgba(0, 0, 0, 0.04);
    }

.ef-card-header {
    background: transparent;
    border-bottom: 1px solid var(--ef-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* Hero & Header Banner */
.ef-hero-banner {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
    color: #ffffff;
    border-radius: var(--ef-radius);
    padding: 1.5rem 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.3);
}

    .ef-hero-banner::after {
        content: '';
        position: absolute;
        top: -50%;
        right: -10%;
        width: 300px;
        height: 300px;
        background: radial-gradient(circle, rgba(99, 102, 241, 0.4) 0%, rgba(0, 0, 0, 0) 70%);
        pointer-events: none;
    }

/* Health Score Pill & Circular Gauge */
.ef-health-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.875rem;
}

.ef-health-good {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.ef-health-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.ef-health-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Glow Badge */
.ef-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    animation: ef-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

    .ef-pulse-dot.danger {
        background-color: var(--ef-danger);
        box-shadow: 0 0 8px var(--ef-danger);
    }

    .ef-pulse-dot.success {
        background-color: var(--ef-success);
        box-shadow: 0 0 8px var(--ef-success);
    }

    .ef-pulse-dot.warning {
        background-color: var(--ef-warning);
        box-shadow: 0 0 8px var(--ef-warning);
    }

@keyframes ef-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.85);
    }
}

/* Code Snippet Box */
.ef-code-box {
    background-color: #ededed;
    border-radius: 8px;
    padding: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    position: relative;
    border: 1px solid #ededed;
}

    .ef-code-box pre {
        margin: 0;
        white-space: pre-wrap;
        word-wrap: break-word;
    }

    .ef-code-box .kw {
        color: #818cf8;
        font-weight: bold;
    }

    .ef-code-box .str {
        color: #34d399;
    }

    .ef-code-box .typ {
        color: #38bdf8;
    }

    .ef-code-box .cm {
        color: #94a3b8;
        font-style: italic;
    }

/* Waterfall Timeline */
.ef-waterfall-bar {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, #6366f1, #818cf8);
    position: relative;
    display: inline-block;
    min-width: 8px;
}

    .ef-waterfall-bar.slow {
        background: linear-gradient(90deg, #f59e0b, #ef4444);
    }

/* Quick Setup Pill Tabs */
.ef-step-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ef-primary);
    color: white;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    margin-right: 0.75rem;
}

.button-link {
    text-decoration: unset;
}

.main-content {
    align-items: center;
    display: flex;
    height: 100%;
    justify-content: center;
    width: 100%;
}

/* Product dashboard: clear hierarchy, plain language, one primary action. */
.product-page {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
    margin: .5rem 0 1.5rem;
}

    .page-heading h1 {
        margin: .2rem 0 .25rem;
        font-size: clamp(1.8rem, 3vw, 2.5rem);
        letter-spacing: -.04em;
        font-weight: 750;
    }

    .page-heading p {
        margin: 0;
        color: var(--ef-text-muted);
        font-size: 1rem;
    }

.eyebrow {
    display: block;
    color: #64748b;
    font-size: .69rem;
    letter-spacing: .13em;
    font-weight: 800;
}

.page-actions, .empty-actions {
    display: flex;
    gap: .65rem;
    flex-wrap: wrap;
}

.btn-primary-product, .btn-quiet, .health-action {
    border-radius: 9px;
    padding: .7rem 1rem;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-primary-product {
    color: white;
    background: #4338ca;
    box-shadow: 0 1px 2px rgba(67,56,202,.2);
}

    .btn-primary-product:hover {
        background: #3730a3;
    }

.btn-quiet {
    color: #334155;
    border-color: #cbd5e1;
    background: white;
}

    .btn-quiet:hover {
        background: #f8fafc;
    }

    .btn-primary-product:disabled, .btn-quiet:disabled {
        opacity: .55;
        cursor: wait;
    }

.empty-start {
    min-height: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: white;
    border: 1px solid var(--ef-border);
    border-radius: 16px;
    padding: 3rem;
}

    .empty-start h2 {
        margin: .65rem 0;
        font-size: 1.75rem;
    }

    .empty-start p {
        color: var(--ef-text-muted);
        max-width: 560px;
        margin: 0 0 1.5rem;
        line-height: 1.6;
    }

.empty-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 1rem;
    border-radius: 15px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 1.7rem;
}

.privacy-note {
    margin-top: 1.5rem;
    color: #94a3b8;
    font-size: .8rem;
}

.health-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid;
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    margin-bottom: 1rem;
}

.health-danger {
    background: #fff7f7;
    border-color: #fecaca;
}

.health-warning {
    background: #fffbeb;
    border-color: #fde68a;
}

.health-good {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.health-symbol {
    flex: 0 0 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: white;
    font-size: 1.25rem;
    font-weight: 800;
}

.health-danger .health-symbol {
    background: #dc2626;
}

.health-warning .health-symbol {
    background: #d97706;
}

.health-good .health-symbol {
    background: #16a34a;
}

.health-copy {
    flex: 1;
}

    .health-copy h2 {
        margin: .15rem 0;
        font-size: 1.25rem;
    }

    .health-copy p {
        margin: 0;
        color: #64748b;
    }

.health-action {
    margin-left: auto;
    background: #0f172a;
    color: white;
    white-space: nowrap;
}

    .health-action span {
        margin-left: .5rem;
    }

.metric-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 1rem 0;
}

.metric-card {
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid var(--ef-border);
    border-radius: 12px;
    padding: 0.8rem;
    min-width: 0;
}

    .metric-card > span {
        color: #64748b;
        font-size: .82rem;
        font-weight: 650;
    }

    .metric-card strong {
        margin: .4rem 0 .15rem;
        font-size: 1.5rem;
        letter-spacing: -.04em;
    }

        .metric-card strong em {
            font-style: normal;
            font-size: .9rem;
            color: #64748b;
            font-weight: 600;
        }

    .metric-card small {
        color: #94a3b8;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .metric-card .metric-time {
        font-size: 1.35rem;
        margin-top: .65rem;
    }

.danger-text {
    color: #dc2626;
}

.live-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: .3rem;
    border-radius: 50%;
    background: #22c55e;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, .85fr);
    gap: 1rem;
}

.content-card {
    background: white;
    border: 1px solid var(--ef-border);
    border-radius: 12px;
    overflow: hidden;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid #eef2f7;
}

    .section-heading h2 {
        margin: .2rem 0 0;
        font-size: 1.05rem;
    }

    .section-heading a {
        color: #4338ca;
        text-decoration: none;
        font-size: .82rem;
        font-weight: 700;
    }

.issue-stack, .route-list {
    display: flex;
    flex-direction: column;
}

.issue-row {
    display: grid;
    grid-template-columns: 10px minmax(0,1fr) minmax(120px,.45fr) 20px;
    gap: .8rem;
    align-items: center;
    width: 100%;
    padding: 1rem 1.2rem;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    background: white;
    text-align: left;
    cursor: pointer;
}

    .issue-row:hover {
        background: #f8fafc;
    }

    .issue-row:last-child {
        border-bottom: 0;
    }

.severity-mark {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}

    .severity-mark.critical {
        background: #dc2626;
        box-shadow: 0 0 0 4px #fee2e2;
    }

    .severity-mark.high {
        background: #f59e0b;
    }

    .severity-mark.medium {
        background: #3b82f6;
    }

.issue-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

    .issue-main strong {
        font-size: .9rem;
    }

    .issue-main small {
        color: #64748b;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        margin-top: .18rem;
    }

.issue-route {
    font: .76rem ui-monospace, monospace;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-arrow {
    color: #94a3b8;
}

.route-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid #f1f5f9;
}

    .route-row:last-child {
        border: 0;
    }

    .route-row div {
        min-width: 0;
        display: flex;
        flex-direction: column;
    }

    .route-row strong {
        font: .8rem ui-monospace, monospace;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .route-row small {
        color: #94a3b8;
        margin-top: .2rem;
    }

    .route-row > span {
        white-space: nowrap;
        font-weight: 750;
    }

.good-empty, .simple-empty {
    padding: 2rem;
    color: #64748b;
}

.good-empty {
    display: flex;
    gap: .8rem;
    align-items: center;
}

    .good-empty > span {
        display: grid;
        place-items: center;
        width: 34px;
        height: 34px;
        color: #15803d;
        background: #dcfce7;
        border-radius: 50%;
    }

    .good-empty p {
        margin: .15rem 0 0;
    }

.simple-empty {
    text-align: center;
}

@media (max-width: 1050px) {
    .metric-row {
        grid-template-columns: repeat(2,1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .health-banner {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .health-action {
        width: 100%;
        margin: .3rem 0 0;
    }

    .metric-row {
        grid-template-columns: 1fr;
    }

    .issue-row {
        grid-template-columns: 10px minmax(0,1fr) 20px;
    }

    .issue-route {
        display: none;
    }

    .drawer-content {
        padding: 1rem;
    }
}

/* Problems, SQL queries and request details */
.summary-pill {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .6rem .85rem;
    border: 1px solid var(--ef-border);
    border-radius: 999px;
    background: white;
    color: #64748b;
    font-size: .83rem;
    white-space: nowrap;
}

    .summary-pill strong {
        color: #0f172a;
    }

.summary-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
}

.problem-summary-row, .query-highlight-row, .request-highlight-row {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.problem-summary-row {
    grid-template-columns: repeat(4,1fr);
}

.query-highlight-row, .request-highlight-row {
    grid-template-columns: repeat(3,1fr);
}

    .summary-filter, .query-highlight-row article, .request-highlight-row article {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        min-width: 0;
        padding: 1rem 1.1rem;
        border: 1px solid var(--ef-border);
        border-radius: 11px;
        background: white;
        text-align: left;
    }

.summary-filter {
    cursor: pointer;
}

    .summary-filter:hover, .summary-filter.selected {
        border-color: #818cf8;
        box-shadow: 0 0 0 2px #e0e7ff;
    }

    .summary-filter span, .query-highlight-row span, .request-highlight-row span {
        color: #64748b;
        font-size: .78rem;
        font-weight: 650;
    }

    .summary-filter strong, .query-highlight-row strong, .request-highlight-row strong {
        margin: .25rem 0 .05rem;
        color: #0f172a;
        font-size: 1.45rem;
    }

    .summary-filter small, .query-highlight-row small, .request-highlight-row small {
        max-width: 100%;
        overflow: hidden;
        color: #94a3b8;
        font-size: .75rem;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

.critical-summary strong {
    color: #dc2626;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: 1rem;
    padding: .75rem;
    border: 1px solid var(--ef-border);
    border-radius: 11px;
    background: white;
}

.search-field {
    display: flex;
    align-items: center;
    flex: 1;
    gap: .5rem;
    padding: .6rem .75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

    .search-field span {
        color: #64748b;
        font-size: 1.1rem;
    }

    .search-field input {
        width: 100%;
        border: 0;
        outline: 0;
        background: transparent;
        color: #0f172a;
    }

.filter-bar select {
    min-width: 190px;
    padding: .65rem .8rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    color: #334155;
}

.clear-filter {
    border: 0;
    background: transparent;
    color: #4338ca;
    font-size: .8rem;
    font-weight: 700;
}

.problems-layout, .queries-layout, .requests-layout {
    display: grid;
    grid-template-columns: minmax(420px, .95fr) minmax(420px, 1.05fr);
    gap: 1rem;
    align-items: start;
}

    .queries-layout:has(.query-detail), .requests-layout:has(.trace-detail) {
        grid-template-columns: minmax(520px,1.15fr) minmax(390px,.85fr);
    }

    .queries-layout:not(:has(.query-detail)), .requests-layout:not(:has(.trace-detail)) {
        grid-template-columns: 1fr;
    }

.list-caption {
    display: flex;
    justify-content: space-between;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid #eef2f7;
    color: #64748b;
    font-size: .76rem;
}

    .list-caption strong {
        color: #334155;
    }

.problem-item {
    display: grid;
    grid-template-columns: 4px minmax(0,1fr) 18px;
    gap: .9rem;
    width: 100%;
    padding: 1rem 1.1rem;
    border: 0;
    border-bottom: 1px solid #eef2f7;
    background: white;
    text-align: left;
    cursor: pointer;
}

    .problem-item:hover, .problem-item.active, .query-table-row:hover, .query-table-row.active, .request-item:hover, .request-item.active {
        background: #f8fafc;
    }

    .problem-item.active, .query-table-row.active, .request-item.active {
        box-shadow: inset 3px 0 #4f46e5;
    }

.severity-line {
    width: 4px;
    height: 100%;
    min-height: 70px;
    border-radius: 4px;
    background: #94a3b8;
}

    .severity-line.critical {
        background: #dc2626;
    }

    .severity-line.high {
        background: #f59e0b;
    }

    .severity-line.medium {
        background: #3b82f6;
    }

.problem-item-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.problem-item-top, .problem-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
}

.problem-item-body > strong {
    margin: .35rem 0 .2rem;
    font-size: .92rem;
}

.problem-item-body > small {
    color: #64748b;
    line-height: 1.4;
}

.issues-grid {
    height: min(650px, calc(100vh - 330px));
    min-height: 420px;
}

.queries-grid {
    height: min(650px, calc(100vh - 330px));
    min-height: 420px;
}

    .queries-grid .dxbl-grid-table > tbody > tr {
        cursor: pointer;
    }

.query-grid-sql {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: .55rem;
    min-width: 0;
}

    .query-grid-sql code {
        overflow: hidden;
        color: #334155;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.issues-grid .dxbl-grid-table > tbody > tr {
    cursor: pointer;
}

.issue-grid-problem {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: .25rem;
    white-space: normal;
}

    .issue-grid-problem strong {
        color: #172033;
        font-size: .84rem;
    }

    .issue-grid-problem small {
        display: -webkit-box;
        overflow: hidden;
        color: #64748b;
        line-height: 1.35;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

.problem-time {
    color: #94a3b8;
    font-size: .72rem;
}

.problem-meta {
    margin-top: .65rem;
    color: #94a3b8;
    font-size: .72rem;
}

    .problem-meta code {
        max-width: 70%;
        overflow: hidden;
        color: #475569;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

.plain-severity {
    width: max-content;
    padding: .16rem .45rem;
    border-radius: 5px;
    background: #f1f5f9;
    color: #475569;
    font-size: .67rem;
    font-weight: 700;
}

    .plain-severity.critical {
        background: #fee2e2;
        color: #b91c1c;
    }

    .plain-severity.high {
        background: #fef3c7;
        color: #92400e;
    }

    .plain-severity.medium {
        background: #dbeafe;
        color: #1d4ed8;
    }

.problem-detail, .query-detail, .trace-detail {
    position: sticky;
    top: 0;
    max-height: calc(100vh - 4rem);
    overflow: auto;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem;
    border-bottom: 1px solid #eef2f7;
}

    .detail-header h2 {
        margin: .5rem 0 .2rem;
        font-size: 1.15rem;
    }

    .detail-header p {
        margin: 0;
        color: #64748b;
        font: .76rem ui-monospace,monospace;
    }

.icon-close {
    align-self: flex-start;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 1.2rem;
    cursor: pointer;
}

.detail-body {
    padding: 1.25rem;
}

.detail-placeholder {
    min-height: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #94a3b8;
    text-align: center;
}

    .detail-placeholder div {
        font-size: 2rem;
    }

    .detail-placeholder h2 {
        margin: .6rem 0 .2rem;
        color: #475569;
        font-size: 1.05rem;
    }

    .detail-placeholder p {
        margin: 0;
    }

.trace-grid-card {
    min-width: 0;
    overflow: hidden;
}

.trace-grid-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid #e8edf4;
}

    .trace-grid-heading div {
        display: flex;
        flex-direction: column;
        gap: .2rem;
    }

    .trace-grid-heading strong {
        color: #172033;
    }

    .trace-grid-heading span {
        color: #718096;
        font-size: .78rem;
    }

.trace-grid {
    
    min-height: 420px;
}

    .trace-grid .dxbl-grid-table > tbody > tr:not(.dxbl-grid-group-row) {
        cursor: pointer;
    }

.explanation-block {
    display: flex;
    gap: .8rem;
    margin-bottom: 1.25rem;
}

.block-number {
    flex: 0 0 25px;
    height: 25px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #eef2ff;
    color: #4338ca;
    font-size: .72rem;
    font-weight: 800;
}

.explanation-block h3, .detail-section-title h3 {
    margin: .1rem 0 .35rem;
    font-size: .9rem;
}

.explanation-block p {
    margin: 0;
    color: #64748b;
    line-height: 1.55;
}

.loading-copy {
    animation: ef-pulse 1.5s infinite;
}

.evidence-strip {
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 1px;
    margin-bottom: 1.3rem;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #e2e8f0;
}

    .evidence-strip > div {
        display: flex;
        flex-direction: column;
        padding: .8rem;
        background: #f8fafc;
    }

    .evidence-strip span {
        color: #64748b;
        font-size: .67rem;
    }

    .evidence-strip strong {
        margin-top: .2rem;
        font-size: .9rem;
    }

.technical-details {
    margin-top: 1rem;
    border-top: 1px solid #eef2f7;
    padding-top: 1rem;
}

    .technical-details summary {
        margin-bottom: .8rem;
        color: #475569;
        font-size: .8rem;
        font-weight: 700;
        cursor: pointer;
    }

.detail-actions {
    display: flex;
    gap: .6rem;
    margin-top: 1.3rem;
}

.w-100 {
    width: 100%;
}

.query-table-head, .query-table-row {
    display: grid;
    grid-template-columns: minmax(300px,1fr) 70px 90px 90px 18px;
    gap: .8rem;
    align-items: center;
}

.query-table-head {
    padding: .75rem 1rem;
    border-bottom: 1px solid #eef2f7;
    color: #94a3b8;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.query-table-row {
    width: 100%;
    padding: .9rem 1rem;
    border: 0;
    border-bottom: 1px solid #eef2f7;
    background: white;
    text-align: left;
    cursor: pointer;
}

.query-sql {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0,1fr);
    align-items: center;
    gap: .5rem;
}

    .query-sql code {
        overflow: hidden;
        color: #334155;
        font-size: .76rem;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .query-sql small {
        grid-column: 2;
        color: #94a3b8;
        font-size: .68rem;
    }

.query-kind, .method-badge {
    padding: .2rem .4rem;
    border-radius: 5px;
    background: #eef2ff;
    color: #4338ca;
    font-size: .62rem;
    font-weight: 800;
}

.duration-value {
    color: #334155;
    font-size: .78rem;
    font-weight: 700;
}

.duration-warning {
    color: #b45309 !important;
}

.duration-danger {
    color: #dc2626 !important;
}

.sql-box {
    max-height: 310px;
}

.detail-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0 .6rem;
}

    .detail-section-title span {
        color: #94a3b8;
        font-size: .68rem;
    }

.query-facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .7rem;
    margin-top: 1rem;
}

    .query-facts div {
        display: flex;
        flex-direction: column;
        padding: .8rem;
        border-radius: 8px;
        background: #f8fafc;
    }

    .query-facts span {
        color: #94a3b8;
        font-size: .68rem;
    }

    .query-facts strong {
        margin-top: .2rem;
        font-size: .78rem;
    }

.request-item {
    display: grid;
    grid-template-columns: 55px minmax(220px,1fr) 80px 90px 18px;
    gap: .9rem;
    align-items: center;
    width: 100%;
    padding: 1rem;
    border: 0;
    border-bottom: 1px solid #eef2f7;
    background: white;
    text-align: left;
    cursor: pointer;
}

.method-badge {
    text-align: center;
}

.request-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

    .request-main strong {
        overflow: hidden;
        font: .8rem ui-monospace,monospace;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .request-main small {
        margin-top: .25rem;
        color: #94a3b8;
    }

.request-metric {
    display: flex;
    flex-direction: column;
}

    .request-metric strong {
        font-size: .85rem;
    }

    .request-metric small {
        color: #94a3b8;
        font-size: .65rem;
    }

.trace-warning {
    display: flex;
    gap: .75rem;
    padding: .85rem;
    border: 1px solid #fde68a;
    border-radius: 9px;
    background: #fffbeb;
}

    .trace-warning > span {
        flex: 0 0 24px;
        height: 24px;
        display: grid;
        place-items: center;
        border-radius: 50%;
        background: #f59e0b;
        color: white;
        font-weight: 800;
    }

    .trace-warning strong {
        font-size: .8rem;
    }

    .trace-warning p {
        margin: .2rem 0 0;
        color: #92400e;
        font-size: .72rem;
    }

.timeline-list {
    display: flex;
    flex-direction: column;
}

.timeline-item {
    display: flex;
    gap: .65rem;
    padding: .65rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.timeline-index {
    flex: 0 0 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    font-size: .65rem;
}

.timeline-query {
    flex: 1;
    min-width: 0;
}

    .timeline-query > div:first-child {
        display: flex;
        justify-content: space-between;
        gap: .75rem;
    }

    .timeline-query code {
        overflow: hidden;
        color: #475569;
        font-size: .7rem;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .timeline-query strong {
        white-space: nowrap;
        font-size: .7rem;
    }

.timeline-track {
    height: 4px;
    margin-top: .45rem;
    overflow: hidden;
    border-radius: 4px;
    background: #f1f5f9;
}

    .timeline-track span {
        display: block;
        height: 100%;
        border-radius: 4px;
        background: #6366f1;
    }

        .timeline-track span.duration-warning {
            background: #f59e0b;
        }

        .timeline-track span.duration-danger {
            background: #ef4444;
        }

.trace-id {
    display: block;
    overflow-wrap: anywhere;
    padding: .6rem;
    border-radius: 6px;
    background: #f8fafc;
    color: #475569;
}

.positive-state {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

    .positive-state > span {
        font-size: 1.6rem;
    }

    .positive-state h2 {
        margin: .6rem 0 .2rem;
        color: #475569;
        font-size: 1rem;
    }

    .positive-state p {
        margin: 0;
    }

.compact-empty {
    min-height: 380px;
}

@media (max-width: 1100px) {
    .problems-layout, .queries-layout:has(.query-detail), .requests-layout:has(.trace-detail) {
        grid-template-columns: 1fr;
    }

    .problem-detail, .query-detail, .trace-detail {
        position: static;
        max-height: none;
    }

    .problem-summary-row {
        grid-template-columns: repeat(2,1fr);
    }
}

@media (max-width: 760px) {
    .query-highlight-row, .request-highlight-row {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        align-items: stretch;
        flex-direction: column;
    }

        .filter-bar select {
            width: 100%;
        }

    .query-table-head {
        display: none;
    }

    .query-table-row {
        grid-template-columns: minmax(0,1fr) 50px 65px 18px;
    }

        .query-table-row > :nth-child(4) {
            display: none;
        }

    .request-item {
        grid-template-columns: 48px minmax(0,1fr) 70px 18px;
    }

        .request-item > :nth-child(4) {
            display: none;
        }
}

@media (max-width: 520px) {
    .problem-summary-row {
        grid-template-columns: 1fr 1fr;
    }

    .query-table-row > :nth-child(2) {
        display: none;
    }

    .query-table-row {
        grid-template-columns: minmax(0,1fr) 65px 18px;
    }

    .evidence-strip {
        grid-template-columns: 1fr;
    }

    .request-item > :nth-child(3) {
        display: none;
    }

    .request-item {
        grid-template-columns: 48px minmax(0,1fr) 18px;
    }
}

.ai-analysis-card {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid #c7d2fe;
    border-radius: 11px;
    background: linear-gradient(145deg,#f8faff,#eef2ff);
}

.ai-analysis-heading {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
}

    .ai-analysis-heading h3 {
        margin: 0;
        font-size: .92rem;
    }

    .ai-analysis-heading p {
        margin: .18rem 0 0;
        color: #64748b;
        font-size: .72rem;
    }

.ai-mark {
    flex: 0 0 35px;
    height: 35px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: #4338ca;
    color: white;
    font-size: .7rem;
    font-weight: 900;
}

.provider-status {
    margin-left: auto;
    padding: .24rem .5rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    font-size: .65rem;
    font-weight: 750;
    white-space: nowrap;
}

    .provider-status.connected {
        background: #dcfce7;
        color: #15803d;
    }

        .provider-status.connected::before {
            content: '';
            display: inline-block;
            width: 6px;
            height: 6px;
            margin-right: .3rem;
            border-radius: 50%;
            background: #22c55e;
        }

.ai-loading {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem;
    border-radius: 8px;
    background: white;
}

    .ai-loading > span {
        width: 22px;
        height: 22px;
        border: 2px solid #c7d2fe;
        border-top-color: #4338ca;
        border-radius: 50%;
        animation: ai-spin .8s linear infinite;
    }

    .ai-loading strong {
        font-size: .78rem;
    }

    .ai-loading p {
        margin: .15rem 0 0;
        color: #64748b;
        font-size: .7rem;
    }

@keyframes ai-spin {
    to {
        transform: rotate(360deg);
    }
}

.ai-result-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: .3rem;
    color: #64748b;
    font-size: .68rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.source-badge {
    padding: .2rem .45rem;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    background: white;
    color: #4338ca;
    letter-spacing: 0;
    text-transform: none;
}

.ai-analysis-card h4 {
    margin: .8rem 0 .3rem;
    font-size: .9rem;
}

.ai-analysis-card > p {
    color: #64748b;
    font-size: .8rem;
    line-height: 1.5;
}

.ai-recommendation {
    margin: .8rem 0;
    padding: .8rem;
    border-left: 3px solid #6366f1;
    border-radius: 0 7px 7px 0;
    background: white;
}

    .ai-recommendation strong {
        font-size: .76rem;
    }

    .ai-recommendation p {
        margin: .25rem 0 0;
        color: #475569;
        font-size: .78rem;
        line-height: 1.5;
    }

.regenerate-link {
    margin-top: .8rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: #4338ca;
    font-size: .72rem;
    font-weight: 750;
    cursor: pointer;
}

.orm-source-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: .12rem .42rem;
    border-radius: 5px;
    background: #eef2ff;
    color: #4338ca;
    font-size: .68rem;
    font-weight: 700;
    white-space: nowrap;
}

.auth-page {
    min-height: calc(100vh - 4rem);
    display: grid;
    place-items: center;
    padding: 2rem;
}

.auth-card {
    width: min(460px, 100%);
    padding: 2.5rem;
    text-align: center;
}

    .auth-card h1 {
        margin: .7rem 0;
        color: #172033;
    }

    .auth-card p {
        color: #64748b;
        line-height: 1.55;
    }

    .auth-card small {
        display: block;
        margin-top: 1rem;
        color: #94a3b8;
    }

.auth-shield {
    font-size: 2.5rem;
    margin-bottom: .75rem;
}

.google-signin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .7rem;
    margin-top: 1.4rem;
    padding: .8rem 1rem;
    border: 1px solid #dbe2ea;
    border-radius: .65rem;
    background: #fff;
    color: #172033;
    font-weight: 700;
    text-decoration: none;
}

    .google-signin:hover {
        background: #f8fafc;
    }

    .google-signin span {
        display: grid;
        place-items: center;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        color: #4285f4;
        font-size: 1.1rem;
    }

.account-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.2rem;
    margin-bottom: 1rem;
}

    .account-profile img {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        object-fit: cover;
    }

    .account-profile div {
        display: flex;
        flex-direction: column;
        gap: .2rem;
    }

    .account-profile span, .account-section-head p, .account-key-row small {
        color: #64748b;
    }

.account-plan, .plan-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem;
    margin-bottom: 1rem;
}

    .account-plan h2, .account-plan p, .plan-notice p {
        margin: .2rem 0 0;
    }

    .account-plan p, .plan-notice p {
        color: #64748b;
    }

.plan-notice {
    border-color: #c7d2fe;
    background: linear-gradient(90deg, #f5f7ff, #fff);
}

    .plan-notice strong {
        color: #312e81;
    }

.new-key-card {
    padding: 1.3rem;
    margin-bottom: 1rem;
    border-color: #a5b4fc;
    background: #f5f7ff;
}

    .new-key-card code {
        display: block;
        overflow-wrap: anywhere;
        padding: .9rem;
        border-radius: .5rem;
        background: #172033;
        color: #e0e7ff;
        user-select: all;
    }

.account-keys {
    padding: 1.2rem;
}

.account-section-head, .account-key-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.account-section-head {
    padding-bottom: 1rem;
}

    .account-section-head h2, .account-section-head p {
        margin: 0 0 .25rem;
    }

.account-key-row {
    padding: 1rem 0;
    border-top: 1px solid #eef2f7;
}

    .account-key-row > div {
        display: flex;
        flex-direction: column;
        gap: .25rem;
    }

.account-key-actions {
    flex-direction: row !important;
    align-items: center;
}

.btn-quiet.danger {
    color: #b91c1c;
}

.billing-error {
    margin-bottom: 1rem;
    padding: .85rem 1rem;
    border-color: #fecaca;
    background: #fff7f7;
    color: #b91c1c;
}

@media (max-width: 620px) {
    .account-plan, .plan-notice {
        align-items: flex-start;
        flex-direction: column;
    }

    .ai-analysis-heading {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .provider-status {
        margin-left: 43px;
    }
}

.panel-splitter {
    min-height: 32rem;
    height: calc(100vh - 10rem);
}
