:root {
    --bg-main: #101114;
    --bg-panel: #171a20;
    --bg-panel-alt: #1f232c;
    --text-main: #ebedf2;
    --text-muted: #9ea7b7;
    --line: #2b3240;
    --accent-scorp: #d81d33;
    --accent-who: #ff5ca8;
    --accent-spl: #4f87ff;
    --ok: #4bbf73;
    --warn: #f7b955;
    --off: #7f8796;
}

* {
    box-sizing: border-box;
}

body {
    position: relative;
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #1b1f27 0%, var(--bg-main) 55%);
    color: var(--text-main);
    min-height: 100vh;
}

body::before,
body::after {
    content: "";
    position: fixed;
    top: -120px;
    width: 360px;
    height: 300px;
    pointer-events: none;
    z-index: 0;
}

body::before {
    left: -120px;
    background: radial-gradient(circle, rgba(216, 29, 51, 0.22) 0%, rgba(255, 95, 107, 0.12) 35%, transparent 70%);
}

body::after {
    right: -120px;
    background: radial-gradient(circle, rgba(208, 35, 55, 0.2) 0%, rgba(115, 55, 76, 0.1) 35%, transparent 70%);
}

.page-shell {
    position: relative;
    z-index: 1;
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px 18px 36px;
}

.hero {
    background: linear-gradient(160deg, #151821 0%, #12151b 72%, #101521 100%);
    border: 1px solid #252b36;
    border-radius: 8px;
    padding: 20px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 12px 30px rgba(0, 0, 0, 0.22);
}

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

.hero-brand-centered {
    justify-content: center;
}

.hero-brand h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
}

.hero-logo {
    display: block;
}

.hero-logo-scorp {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.hero-copy {
    margin: 14px auto 0;
    max-width: 1180px;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid rgba(65, 80, 111, 0.35);
    background: linear-gradient(180deg, rgba(22, 30, 45, 0.5) 0%, rgba(14, 19, 30, 0.4) 100%);
}

.hero-intro,
.hero-signature {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.45;
    text-align: center;
}

.hero-signature {
    margin-top: 10px;
}

.app-logos {
    display: flex;
    gap: 14px;
    margin-top: 16px;
    justify-content: center;
}

.app-logo-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 9px 14px;
    color: #d6deee;
    font-size: 18px;
    font-weight: 600;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.app-logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.app-logo-wrap:first-child {
    background: rgba(255, 92, 168, 0.14);
    color: #ff93c8;
    border-color: rgba(255, 92, 168, 0.35);
    box-shadow: 0 0 14px rgba(255, 92, 168, 0.18);
}

.app-logo-wrap:last-child {
    background: rgba(79, 135, 255, 0.16);
    color: #8db3ff;
    border-color: rgba(79, 135, 255, 0.35);
    box-shadow: 0 0 14px rgba(79, 135, 255, 0.18);
}

.dashboard {
    margin-top: 16px;
}

.info-grid {
    display: grid;
    grid-template-columns: minmax(520px, 1.8fr) repeat(2, minmax(170px, auto));
    gap: 12px;
    align-items: stretch;
}

.info-card {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 16px;
}

.info-card h2 {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--text-muted);
}

.info-card p {
    margin: 6px 0;
    font-size: 15px;
    color: #f1f3f9;
    word-break: break-word;
}

.info-card-source {
    min-width: 0;
}

#meta-source-table {
    font-family: Consolas, "SFMono-Regular", Menlo, Monaco, "Liberation Mono", monospace;
    font-size: 14px;
    letter-spacing: 0;
}

.toolbar {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 170px minmax(220px, 1fr);
    gap: 12px;
    align-items: end;
}

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

.control span {
    color: var(--text-muted);
    font-size: 12px;
}

input {
    height: 40px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--bg-panel);
    color: var(--text-main);
    padding: 0 12px;
    outline: none;
}

input:focus {
    border-color: var(--accent-scorp);
}

.app-filter-dropdown {
    position: relative;
}

.app-filter-trigger {
    height: 40px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--bg-panel);
    color: var(--text-main);
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.app-filter-trigger:hover {
    border-color: #55627c;
}

.app-filter-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #171c25;
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.app-filter-option {
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #d8e1ef;
    text-align: left;
    padding: 8px 10px;
    cursor: pointer;
}

.app-filter-option[data-value="all"]:hover {
    background: rgba(235, 237, 242, 0.08);
    border-color: rgba(235, 237, 242, 0.34);
}

.app-filter-option[data-value="all"].is-active {
    background: rgba(235, 237, 242, 0.14);
    border-color: rgba(235, 237, 242, 0.58);
    color: #ffffff;
}

.app-filter-option[data-value="who"]:hover {
    background: rgba(255, 92, 168, 0.12);
    border-color: rgba(255, 92, 168, 0.32);
    color: #ffadd3;
}

.app-filter-option[data-value="who"].is-active {
    background: rgba(255, 92, 168, 0.24);
    border-color: rgba(255, 92, 168, 0.56);
    color: #ff9ccc;
}

.app-filter-option[data-value="spl"]:hover {
    background: rgba(79, 135, 255, 0.12);
    border-color: rgba(79, 135, 255, 0.32);
    color: #a9c8ff;
}

.app-filter-option[data-value="spl"].is-active {
    background: rgba(79, 135, 255, 0.24);
    border-color: rgba(79, 135, 255, 0.56);
    color: #9cbfff;
}

.error-banner {
    margin-top: 12px;
    border: 1px solid #6f2231;
    background: #33171d;
    color: #ffcad0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

.is-hidden {
    display: none !important;
}

.table-card {
    margin-top: 12px;
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.table-header {
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.table-header h2 {
    margin: 0;
    font-size: 15px;
}

#visible-count-badge {
    color: var(--text-muted);
    font-size: 13px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    scrollbar-color: #4a5569 #151922;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1400px;
}

thead {
    background: var(--bg-panel-alt);
}

th,
td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    font-size: 14px;
}

.col-query-title {
    min-width: 370px;
}

.col-test-info {
    min-width: 370px;
}

th button[data-sort-key="opened_at"] {
    white-space: nowrap;
}

th:nth-child(4),
td:nth-child(4) {
    min-width: 180px;
    white-space: nowrap;
}

th {
    color: #cfd6e4;
    font-size: 12px;
    text-transform: uppercase;
}

.sort-trigger {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    padding: 0;
}

.sort-trigger:hover {
    color: #ffffff;
}

.sort-trigger.is-active {
    color: #ff97a4;
}

tr.data-row:hover {
    background: #1f2531;
}

.expander-btn {
    width: 30px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid #3d475a;
    background: #212734;
    color: #d7deec;
    cursor: pointer;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.expander-btn[aria-expanded="true"] {
    background: #293142;
}

.expander-btn .fi {
    line-height: 1;
}

.index-cell {
    white-space: nowrap;
}

.app-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.app-badge-logo {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.app-badge-who {
    background: rgba(255, 92, 168, 0.14);
    color: #ff93c8;
    border: 1px solid rgba(255, 92, 168, 0.35);
}

.app-badge-spl {
    background: rgba(79, 135, 255, 0.16);
    color: #8db3ff;
    border: 1px solid rgba(79, 135, 255, 0.35);
}

.app-badge-default {
    background: rgba(216, 29, 51, 0.14);
    color: #f67787;
    border: 1px solid rgba(216, 29, 51, 0.35);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid transparent;
}

.status-active {
    color: #9de6b8;
    background: rgba(75, 191, 115, 0.14);
    border-color: rgba(75, 191, 115, 0.35);
}

.status-paused,
.status-disabled {
    color: #ffc98f;
    background: rgba(247, 185, 85, 0.14);
    border-color: rgba(247, 185, 85, 0.35);
}

.status-default {
    color: #c4cad5;
    background: rgba(127, 135, 150, 0.16);
    border-color: rgba(127, 135, 150, 0.35);
}

.status-manual {
    color: #f3f6ff;
    background: rgba(232, 238, 250, 0.2);
    border-color: rgba(232, 238, 250, 0.62);
}

.expanded-row td {
    background: #161a23;
    color: #b9c2d3;
    font-size: 13px;
}

.query-title-link {
    color: #f3f7ff;
    text-decoration: none;
    border-bottom: 1px dashed rgba(186, 204, 235, 0.55);
    padding-bottom: 1px;
    transition: color 120ms ease, border-color 120ms ease;
}

.query-title-link:hover {
    color: #ffafba;
    border-color: rgba(255, 140, 156, 0.85);
}

.query-title-link-list {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.test-info-list {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.test-info-pill {
    border: 1px solid rgba(116, 132, 160, 0.42);
    border-radius: 999px;
    padding: 6px 12px;
    background: rgba(76, 90, 118, 0.16);
    color: #d8e2f5;
    white-space: nowrap;
    font-size: 12px;
}

.test-info-pill strong {
    color: #ffffff;
    font-weight: 700;
}

.query-title-chip {
    display: inline-flex;
    max-width: max-content;
    border: 1px solid rgba(128, 145, 178, 0.45);
    border-radius: 999px;
    padding: 5px 11px;
    color: #dce4f4;
    background: rgba(96, 114, 148, 0.12);
    white-space: nowrap;
    transition: border-color 1s linear, background-color 2s linear, box-shadow 1s linear;
}

.query-title-chip:hover {
    transition: border-color 3s linear, background-color 6s linear, box-shadow 3s linear;
    border-color: rgba(216, 29, 51, 0.65);
    background: rgba(216, 29, 51, 0.26);
    box-shadow: 0 0 18px rgba(216, 29, 51, 0.35);
}

.applied-filters-note {
    margin-top: 12px;
    color: rgba(158, 167, 183, 0.78);
    font-size: 12px;
    line-height: 1.5;
}

.empty-state {
    padding: 18px 14px;
    color: var(--text-muted);
}

@media (max-width: 980px) {
    .info-grid {
        grid-template-columns: minmax(0, 1fr) repeat(2, minmax(160px, auto));
    }
}

@media (max-width: 760px) {
    .hero-brand h1 {
        font-size: 22px;
    }

    .toolbar {
        grid-template-columns: 1fr;
    }

    .app-logos {
        flex-wrap: wrap;
    }

    .page-shell {
        padding: 16px 12px 24px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}
