:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d9dee8;
    --primary: #1463ff;
    --primary-dark: #0e48bd;
    --green: #16855f;
    --amber: #b86e00;
    --red: #c23838;
    --ink: #111827;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 1px solid var(--primary);
    border-radius: 6px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    min-height: 36px;
    padding: 0 14px;
}

button:hover {
    background: var(--primary-dark);
}

button:disabled {
    border-color: var(--line);
    background: #e4e7ee;
    color: var(--muted);
    cursor: not-allowed;
}

input,
select {
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    padding: 0 10px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 28px;
    background: var(--ink);
    color: #ffffff;
}

.eyebrow {
    margin: 0 0 4px;
    color: #9fb2d6;
    font-size: 13px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.brand-logo {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    max-width: 48px;
    max-height: 48px;
    border-radius: 8px;
    background: #ffffff;
    object-fit: contain;
    padding: 4px;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 17px;
}

.auth-panel {
    display: flex;
    gap: 8px;
    align-items: center;
}

.auth-panel input {
    width: 190px;
}

.shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

.tabs,
.toolbar,
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.tab,
.preset,
.ghost-button {
    border-color: var(--line);
    background: #ffffff;
    color: var(--text);
}

.tab.active,
.preset.active {
    border-color: var(--primary);
    background: #eaf1ff;
    color: var(--primary);
}

.toolbar {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.toolbar label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.preset-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-line {
    min-height: 22px;
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 13px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.metric {
    min-height: 92px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 14px;
}

.metric .label {
    color: var(--muted);
    font-size: 13px;
}

.metric .value {
    margin-top: 10px;
    color: var(--text);
    font-size: 26px;
    font-weight: 700;
}

.split {
    display: grid;
    grid-template-columns: minmax(320px, 0.8fr) minmax(420px, 1.2fr);
    gap: 16px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 16px;
    margin-bottom: 16px;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 12px;
}

.panel-heading span {
    color: var(--muted);
    font-size: 13px;
}

.funnel {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.funnel-row {
    display: grid;
    grid-template-columns: 110px 1fr 80px;
    gap: 10px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
}

.funnel-bar {
    min-width: 2px;
    height: 22px;
    border-radius: 4px;
    background: var(--primary);
}

.funnel-row:nth-child(2) .funnel-bar {
    background: var(--green);
}

.funnel-row:nth-child(3) .funnel-bar {
    background: var(--amber);
}

canvas {
    display: block;
    width: 100%;
    min-height: 260px;
}

.filters {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.filters input {
    width: 180px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    font-size: 13px;
}

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

th {
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

tr.clickable {
    cursor: pointer;
}

tr.clickable:hover {
    background: #f0f5ff;
}

.event-title {
    max-width: 260px;
    color: var(--primary);
    font-weight: 600;
}

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

.pagination {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.info-item {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.info-item .label {
    color: var(--muted);
    font-size: 12px;
}

.info-item .value {
    margin-top: 6px;
    overflow-wrap: anywhere;
    font-size: 14px;
}

@media (max-width: 1080px) {
    .metric-grid {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }

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

@media (max-width: 720px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
        padding: 18px;
    }

    .brand-logo {
        width: 42px;
        height: 42px;
    }

    .auth-panel,
    .toolbar label,
    .toolbar input,
    .filters input,
    .filters select {
        width: 100%;
    }

    .shell {
        padding: 14px;
    }

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

    .funnel-row {
        grid-template-columns: 90px 1fr 64px;
    }
}
