:root {
    color-scheme: dark;
    --bg: #0f1110;
    --panel: #171b19;
    --panel-strong: #1e2521;
    --panel-soft: rgba(23, 27, 25, .96);
    --line: #2b3430;
    --text: #eef5f1;
    --muted: #9ba9a3;
    --green: #62d391;
    --cyan: #69c7ee;
    --amber: #f3b950;
    --red: #f07178;
    --ink: #07110d;
    --shadow: 0 18px 50px rgba(0, 0, 0, .32);
    --topbar-bg: rgba(15, 17, 16, .88);
    --topbar-border: rgba(255, 255, 255, .08);
    --button-bg: #161b19;
    --input-bg: #101413;
    --field-bg: #141817;
    --pill-bg: #223029;
    --brand-bg: #13241b;
    --toast-bg: #202720;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #eef3ef;
    --panel: #ffffff;
    --panel-strong: #edf4ef;
    --panel-soft: rgba(255, 255, 255, .96);
    --line: #d5ded8;
    --text: #13201a;
    --muted: #607069;
    --green: #0e8f55;
    --cyan: #177fa8;
    --amber: #a76604;
    --red: #c93d44;
    --ink: #ffffff;
    --shadow: 0 18px 42px rgba(37, 55, 45, .14);
    --topbar-bg: rgba(249, 252, 250, .88);
    --topbar-border: rgba(19, 32, 26, .12);
    --button-bg: #ffffff;
    --input-bg: #ffffff;
    --field-bg: #ffffff;
    --pill-bg: #e4f2e9;
    --brand-bg: #e3f4e9;
    --toast-bg: #ffffff;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100%;
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
input,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex: 0 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    padding: 14px clamp(14px, 4vw, 34px);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    border-bottom-color: var(--topbar-border);
    background: var(--topbar-bg);
    backdrop-filter: blur(16px);
}

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

.brand-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(98, 211, 145, .45);
    border-radius: 8px;
    background: var(--brand-bg);
    color: var(--green);
    font-weight: 800;
}

.brand-mark strong,
.brand-mark small {
    display: block;
    overflow: hidden;
    max-width: 56vw;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-mark strong {
    font-size: 18px;
}

.brand-mark small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

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

.icon-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--button-bg);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
    border-color: var(--cyan);
    color: var(--cyan);
    outline: none;
}

.icon-button.loading svg {
    animation: spin .9s linear infinite;
}

.app-shell {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 18px clamp(12px, 3vw, 30px) 34px;
}

.status-band {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
    box-shadow: var(--shadow);
}

.metric {
    min-height: 86px;
    padding: 16px;
    background: var(--panel-soft);
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.metric strong {
    display: block;
    margin-top: 8px;
    color: var(--text);
    font-size: 28px;
    line-height: 1;
}

.metric small {
    display: block;
    margin-top: 6px;
    overflow: hidden;
    max-width: 100%;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.control-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
}

.filter-board {
    display: grid;
    grid-template-columns: minmax(150px, 190px) minmax(230px, 310px) minmax(280px, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin: 18px 0;
}

.filter-field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

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

.filter-field select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    background: var(--field-bg);
    color: var(--text);
    outline: 0;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field-bg);
    color: var(--muted);
}

.search-box input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
}

.segments {
    display: grid;
    grid-template-columns: repeat(3, 86px);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field-bg);
}

.status-filter {
    align-self: end;
}

.segments.compact {
    grid-template-columns: repeat(3, minmax(62px, 1fr));
    width: 100%;
}

.segment {
    min-height: 36px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.segment.active {
    background: var(--green);
    color: var(--ink);
    font-weight: 700;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.alerts-panel,
.markets-panel,
.settings-form,
.login-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    box-shadow: var(--shadow);
}

.alerts-panel,
.markets-panel {
    overflow: hidden;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

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

.section-head h1 {
    margin: 3px 0 0;
    font-size: 22px;
    line-height: 1.1;
}

.pill,
.user-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--pill-bg);
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
}

.alerts-list,
.events-list {
    display: grid;
    gap: 1px;
    background: var(--line);
}

.alert-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.panel-note {
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 12px;
}

.empty-state {
    padding: 28px 18px;
    background: var(--panel);
    color: var(--muted);
}

.alert-item {
    display: grid;
    gap: 12px;
    padding: 16px;
    background: var(--panel);
}

.alert-item.high {
    border-left: 4px solid var(--red);
}

.alert-item.medium {
    border-left: 4px solid var(--amber);
}

.alert-item.low {
    border-left: 4px solid var(--cyan);
}

.alert-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-weight: 750;
}

.alert-market-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.alert-market-line strong {
    overflow-wrap: anywhere;
}

.alert-market-detail {
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.alert-quote-line {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.alert-quote-line span {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 9px;
    background: var(--input-bg);
    color: var(--muted);
    font-size: 12px;
}

.alert-quote-line small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.alert-meta,
.market-meta,
.event-meta {
    color: var(--muted);
    font-size: 12px;
}

.alert-click-hint {
    color: var(--muted);
    font-size: 12px;
}

.alert-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.text-button,
.odds-link,
.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    background: var(--button-bg);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}

.primary-button {
    border-color: var(--green);
    background: var(--green);
    color: var(--ink);
    font-weight: 800;
}

.text-button:hover,
.odds-link:hover,
.primary-button:hover {
    transform: translateY(-1px);
}

.event-item {
    display: grid;
    gap: 14px;
    padding: 16px;
    background: var(--panel);
}

.event-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.teams {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 19px;
    line-height: 1.2;
}

.status-tag {
    min-width: 74px;
    min-height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 800;
}

.status-tag.live {
    background: var(--red);
}

.status-tag.pending {
    background: var(--cyan);
}

.market-groups {
    display: grid;
    gap: 8px;
}

.quote-section {
    display: grid;
    gap: 8px;
    padding-top: 4px;
}

.quote-section + .quote-section {
    margin-top: 14px;
}

.quote-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 32px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.quote-section:first-child .quote-section-head {
    border-top: 0;
    padding-top: 0;
}

.quote-section-head span {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
}

.quote-section-head strong {
    min-width: 28px;
    min-height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pill-bg);
    color: var(--green);
    font-size: 12px;
}

.quote-more {
    color: var(--muted);
    font-size: 12px;
}

.market-row,
.quote-row {
    display: grid;
    grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, .07);
}

.quote-row {
    grid-template-columns: minmax(220px, 320px) minmax(280px, 1fr);
    padding: 12px 0 4px;
}

.market-name {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.market-name strong,
.quote-info strong {
    overflow-wrap: anywhere;
}

.quote-info {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.market-type {
    width: fit-content;
    max-width: 100%;
    min-height: 24px;
    border-radius: 999px;
    padding: 4px 9px;
    background: var(--pill-bg);
    color: var(--green);
    font-size: 11px;
    font-weight: 800;
}

.quote-compare {
    display: grid;
    grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.best-quote,
.competitor-quote {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    background: var(--input-bg);
    color: var(--text);
    text-decoration: none;
}

.best-quote {
    border-color: var(--green);
    background: var(--panel-strong);
}

.best-quote.quote-stale,
.competitor-quote.quote-stale {
    border-color: var(--line);
    opacity: .58;
}

.best-quote.quote-stale strong,
.competitor-quote.quote-stale strong {
    color: var(--muted);
}

.quote-recent {
    animation: quotePulse 1.8s ease-out 3;
}

.best-quote.quote-up,
.competitor-quote.quote-up {
    border-color: var(--green);
    box-shadow: 0 0 0 1px rgba(98, 211, 145, .18), 0 0 18px rgba(98, 211, 145, .2);
}

.best-quote.quote-down,
.competitor-quote.quote-down {
    border-color: var(--red);
    box-shadow: 0 0 0 1px rgba(240, 113, 120, .18), 0 0 18px rgba(240, 113, 120, .2);
}

.quote-label,
.quote-book {
    display: block;
}

.quote-label {
    color: var(--muted);
    font-size: 11px;
}

.quote-book {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 12px;
}

.best-quote strong {
    color: var(--green);
    font-size: 18px;
}

.quote-up strong {
    color: var(--green);
}

.quote-down strong {
    color: var(--red);
}

.quote-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: 5px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
}

.quote-arrow.up {
    background: rgba(98, 211, 145, .16);
    color: var(--green);
}

.quote-arrow.down {
    background: rgba(240, 113, 120, .16);
    color: var(--red);
}

.competitor-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    min-width: 0;
}

.competitor-quote {
    min-height: 36px;
    min-width: 112px;
    padding: 6px 9px;
}

.competitor-quote .competitor-book {
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 11px;
}

.competitor-quote strong {
    color: var(--text);
}

.no-competitor {
    color: var(--muted);
    font-size: 12px;
}

.odds-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.odds-link {
    min-width: 96px;
    min-height: 42px;
    justify-content: space-between;
    background: var(--input-bg);
}

.odds-link.best {
    border-color: var(--green);
    background: var(--panel-strong);
    color: var(--green);
}

.odds-book {
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 11px;
}

.odds-price {
    font-weight: 850;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20;
    max-width: min(420px, calc(100vw - 36px));
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--toast-bg);
    box-shadow: var(--shadow);
}

.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.login-shell,
.settings-shell {
    width: min(760px, calc(100% - 28px));
    margin: 0 auto;
    padding: 28px 0;
}

.login-panel {
    width: min(440px, 100%);
    margin: 0 auto;
    padding: 24px;
}

.login-form,
.settings-form {
    display: grid;
    gap: 16px;
}

.login-form {
    margin-top: 24px;
}

.settings-form {
    padding: 20px;
}

.login-form label,
.settings-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.login-form input,
.settings-form input,
.settings-form textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--input-bg);
    color: var(--text);
    outline: 0;
}

.settings-form textarea {
    resize: vertical;
}

.login-form input:focus,
.settings-form input:focus,
.settings-form textarea:focus {
    border-color: var(--cyan);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.form-error {
    margin: 0;
    color: var(--red);
}

.notice {
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(98, 211, 145, .5);
    border-radius: 8px;
    background: var(--panel-strong);
    color: var(--green);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes quotePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(105, 199, 238, .26);
    }

    55% {
        box-shadow: 0 0 0 5px rgba(105, 199, 238, 0), 0 0 20px rgba(105, 199, 238, .22);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(105, 199, 238, 0);
    }
}

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

    .alerts-panel {
        order: -1;
    }
}

@media (max-width: 720px) {
    .topbar {
        min-height: 64px;
        padding: 10px 12px;
    }

    .brand-icon {
        width: 38px;
        height: 38px;
    }

    .icon-button {
        width: 38px;
        height: 38px;
    }

    .status-band {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .control-strip {
        grid-template-columns: 1fr;
    }

    .filter-board {
        grid-template-columns: 1fr;
    }

    .segments {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

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

    .alert-quote-line {
        grid-template-columns: 1fr;
    }

    .market-row,
    .quote-row,
    .quote-compare {
        grid-template-columns: 1fr;
    }

    .odds-link {
        min-width: calc(50% - 4px);
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 440px) {
    .top-actions {
        gap: 5px;
    }

    .brand-mark strong {
        font-size: 16px;
    }

    .metric {
        min-height: 78px;
        padding: 13px;
    }

    .metric strong {
        font-size: 24px;
    }

    .odds-link {
        width: 100%;
    }

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