:root {
    color-scheme: dark;
    --livepro-bg: #08090b;
    --livepro-surface: rgba(22, 24, 29, 0.82);
    --livepro-surface-strong: #111318;
    --livepro-line: rgba(255, 255, 255, 0.12);
    --livepro-ink: #f5f7fa;
    --livepro-muted: #aeb6c2;
    --livepro-primary: #e22b35;
    --livepro-primary-strong: #ff414c;
    --livepro-cool: #43d9c6;
    --livepro-warning: #f4c542;
    --livepro-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--livepro-ink);
    background:
        radial-gradient(circle at top left, rgba(226, 43, 53, 0.16), transparent 34rem),
        linear-gradient(135deg, #08090b 0%, #111318 48%, #090b10 100%);
}

a {
    color: inherit;
}

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

h1:focus {
    outline: none;
}

.livepro-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.livepro-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 28px;
    border-bottom: 1px solid var(--livepro-line);
    background: rgba(8, 9, 11, 0.86);
    backdrop-filter: blur(18px);
}

.livepro-brand {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    text-decoration: none;
}

.livepro-brand span {
    color: var(--livepro-primary-strong);
    font-weight: 800;
}

.livepro-brand strong {
    font-weight: 700;
}

.livepro-nav {
    display: flex;
    gap: 6px;
}

.livepro-nav a {
    min-width: 74px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--livepro-muted);
    text-align: center;
    text-decoration: none;
    font-size: 0.92rem;
}

.livepro-nav a.active,
.livepro-nav a:hover {
    color: var(--livepro-ink);
    border-color: rgba(226, 43, 53, 0.42);
    background: rgba(226, 43, 53, 0.14);
    box-shadow: 0 0 24px rgba(226, 43, 53, 0.16);
}

.livepro-main {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 44px 0 72px;
}

.dashboard-hero,
.page-heading {
    margin-bottom: 28px;
}

.dashboard-hero h1,
.page-heading h1,
.auth-panel h1 {
    margin: 0 0 12px;
    font-size: clamp(2rem, 4vw, 3.6rem);
    line-height: 1.05;
}

.dashboard-hero p:not(.eyebrow) {
    max-width: 760px;
    margin: 0;
    color: var(--livepro-muted);
    font-size: 1.08rem;
    line-height: 1.6;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--livepro-primary-strong);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.with-action {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.metric-grid,
.content-grid {
    display: grid;
    gap: 16px;
}

.metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.content-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.metric-card,
.glass-panel,
.livepro-status-panel {
    border: 1px solid var(--livepro-line);
    border-radius: 8px;
    background: var(--livepro-surface);
    box-shadow: var(--livepro-shadow);
}

.metric-card {
    min-height: 112px;
    display: grid;
    align-content: space-between;
    padding: 18px;
}

.metric-link {
    text-decoration: none;
}

.metric-with-avatar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.metric-card span,
.muted,
.data-row small,
.details-grid dt {
    color: var(--livepro-muted);
}

.metric-card strong {
    color: var(--livepro-ink);
    font-size: 1.8rem;
    line-height: 1.1;
}

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

.glass-panel,
.livepro-status-panel {
    padding: 22px;
}

.glass-panel h2,
.livepro-status-panel h2 {
    margin: 0 0 16px;
    font-size: 1.1rem;
}

.data-list {
    display: grid;
    gap: 8px;
}

.data-row {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px;
    border: 1px solid var(--livepro-line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none;
}

.data-row:hover {
    border-color: rgba(226, 43, 53, 0.46);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0 0 20px;
}

.details-grid div {
    display: grid;
    gap: 4px;
}

.details-grid dd {
    margin: 0;
}

.auth-wrap {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
}

.auth-panel {
    width: min(480px, 100%);
}

.form-grid {
    display: grid;
    gap: 12px;
}

.form-field {
    display: grid;
    gap: 7px;
}

.form-field label {
    color: var(--livepro-muted);
    font-weight: 700;
}

.form-field small {
    color: var(--livepro-muted);
}

.required-marker {
    color: var(--livepro-primary-strong);
}

.two-column,
.toolbar-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.toolbar-row {
    align-items: end;
    margin-bottom: 18px;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    color: var(--livepro-muted);
}

.input-livepro {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--livepro-line);
    border-radius: 6px;
    color: var(--livepro-ink);
    background: rgba(255, 255, 255, 0.06);
}

.input-livepro option {
    color: #f5f7fa;
    background: #111318;
}

.input-livepro:focus {
    outline: 2px solid rgba(226, 43, 53, 0.45);
    outline-offset: 1px;
}

.app-select {
    position: relative;
    width: 100%;
}

.app-select-trigger {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--livepro-line);
    border-radius: 6px;
    color: var(--livepro-ink);
    background: rgba(255, 255, 255, 0.06);
    text-align: left;
    cursor: pointer;
}

.app-select-trigger:hover,
.app-select-trigger:focus {
    border-color: rgba(226, 43, 53, 0.58);
    outline: 2px solid rgba(226, 43, 53, 0.36);
    outline-offset: 1px;
}

.app-select-trigger:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.app-select-chevron {
    color: var(--livepro-primary-strong);
    font-weight: 800;
}

.app-select-list {
    position: absolute;
    inset: calc(100% + 6px) 0 auto 0;
    z-index: 60;
    display: grid;
    max-height: 280px;
    overflow: auto;
    padding: 6px;
    border: 1px solid rgba(226, 43, 53, 0.38);
    border-radius: 8px;
    color: var(--livepro-ink);
    background: #111318;
    box-shadow: var(--livepro-shadow);
}

.app-select-option {
    min-height: 40px;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--livepro-ink);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.app-select-option:hover,
.app-select-option.active {
    border-color: rgba(226, 43, 53, 0.42);
    background: rgba(226, 43, 53, 0.16);
}

.app-select-option.selected {
    color: #fff;
    border-color: rgba(255, 65, 76, 0.65);
    background: rgba(226, 43, 53, 0.28);
}

.search-select-input {
    width: 100%;
    min-height: 40px;
    margin-bottom: 6px;
    padding: 9px 10px;
    border: 1px solid var(--livepro-line);
    border-radius: 6px;
    color: var(--livepro-ink);
    background: rgba(255, 255, 255, 0.06);
}

.search-select-input:focus {
    border-color: rgba(226, 43, 53, 0.58);
    outline: 2px solid rgba(226, 43, 53, 0.36);
}

.app-select-empty {
    padding: 10px;
    color: var(--livepro-muted);
}

.btn-primary,
.btn-secondary {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    border: 1px solid rgba(255, 65, 76, 0.65);
    color: white;
    background: linear-gradient(135deg, #e22b35, #8f1119);
    box-shadow: 0 0 28px rgba(226, 43, 53, 0.24);
}

.btn-secondary {
    border: 1px solid var(--livepro-line);
    color: var(--livepro-ink);
    background: rgba(255, 255, 255, 0.05);
}

.error-text {
    color: #ff9ca2;
}

.success-text {
    color: #8ff1d1;
}

.state-panel {
    margin: 14px 0;
    padding: 14px;
    border: 1px solid var(--livepro-line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
}

.error-state {
    color: #ffb5ba;
    border-color: rgba(226, 43, 53, 0.44);
    background: rgba(226, 43, 53, 0.10);
}

.success-state {
    color: #9bf5d6;
    border-color: rgba(67, 217, 198, 0.42);
    background: rgba(67, 217, 198, 0.08);
}

.empty-state strong {
    display: block;
    margin-bottom: 6px;
}

.empty-state p {
    margin: 0;
    color: var(--livepro-muted);
}

.card-grid {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.entity-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--livepro-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.entity-card strong {
    display: block;
    margin-bottom: 4px;
}

.entity-card small,
.device-meta {
    color: var(--livepro-muted);
}

.device-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.card-actions,
.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.battery-indicator {
    width: 86px;
    height: 24px;
    position: relative;
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--livepro-line);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.04);
}

.battery-indicator span {
    position: absolute;
    inset: 0 auto 0 0;
    background: linear-gradient(90deg, var(--livepro-primary), var(--livepro-cool));
    opacity: 0.65;
}

.battery-indicator em {
    position: relative;
    width: 100%;
    color: var(--livepro-ink);
    font-size: 0.75rem;
    font-style: normal;
    text-align: center;
}

.device-state-badge {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
}

.device-state-badge.connected {
    color: #9bf5d6;
    background: rgba(67, 217, 198, 0.14);
}

.device-state-badge.disconnected {
    color: #ffb5ba;
    background: rgba(226, 43, 53, 0.14);
}

.simulation-badge {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    color: #ffd8dc;
    background: rgba(226, 43, 53, 0.2);
    font-size: 0.76rem;
    font-weight: 800;
}

.profile-media-row,
.horse-list-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.profile-avatar {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--livepro-line);
    border-radius: 50%;
    color: var(--livepro-ink);
    background: rgba(255, 255, 255, 0.06);
    font-weight: 800;
}

.profile-avatar.large {
    width: 96px;
    height: 96px;
}

.profile-avatar.hero-avatar {
    width: 160px;
    height: 160px;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.disabled-link {
    pointer-events: none;
    opacity: 0.5;
}

.company-selector {
    color: var(--livepro-muted);
}

.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
}

.confirm-dialog {
    width: min(420px, 100%);
    padding: 20px;
    border: 1px solid var(--livepro-line);
    border-radius: 8px;
    background: var(--livepro-surface-strong);
    box-shadow: var(--livepro-shadow);
}

.assignment-row {
    align-items: start;
}

.livepro-status-panel dl {
    display: grid;
    gap: 14px;
    margin: 0;
}

.livepro-status-panel div {
    display: grid;
    grid-template-columns: minmax(140px, 220px) 1fr;
    gap: 12px;
}

.livepro-status-panel dt {
    color: var(--livepro-muted);
    font-weight: 600;
}

.livepro-status-panel dd {
    margin: 0;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 12px 16px;
    color: #fff;
    background: #8f1119;
}

#blazor-error-ui .reload {
    margin-left: 12px;
    color: #fff;
    font-weight: 700;
}

#blazor-error-ui .dismiss {
    float: right;
    cursor: pointer;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.14);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--livepro-primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
}

.loading-progress-text {
    position: absolute;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--livepro-muted);
    text-align: center;
    font-weight: 700;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (max-width: 900px) {
    .metric-grid,
    .content-grid,
    .details-grid,
    .two-column,
    .toolbar-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 680px) {
    .livepro-topbar {
        min-height: 64px;
        padding: 0 16px;
    }

    .livepro-nav {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 10px;
        z-index: 30;
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 4px;
        padding: 6px;
        border: 1px solid var(--livepro-line);
        border-radius: 8px;
        background: rgba(8, 9, 11, 0.94);
        backdrop-filter: blur(18px);
    }

    .livepro-nav a {
        min-width: 0;
        min-height: 42px;
        padding: 6px 4px;
        font-size: 0.72rem;
    }

    .livepro-nav a:first-child,
    .livepro-nav a:nth-child(2),
    .livepro-nav a:last-child {
        display: none;
    }

    .livepro-main {
        width: min(100% - 24px, 1120px);
        padding: 28px 0 92px;
    }

    .metric-grid,
    .content-grid,
    .details-grid,
    .two-column,
    .toolbar-row,
    .livepro-status-panel div {
        grid-template-columns: 1fr;
    }

    .with-action {
        align-items: stretch;
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary,
    .input-livepro,
    .app-select-trigger {
        min-height: 46px;
    }

    .app-select-list {
        max-height: 240px;
    }
}
