:root {
    --page: #f5f7f8;
    --panel: #ffffff;
    --panel-border: #d8dee4;
    --text: #1f2933;
    --muted: #667085;
    --teal: #006d77;
    --teal-dark: #00545c;
    --amber: #b76e00;
    --green: #157347;
    --red: #b42318;
    --ink: #101828;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--page);
    font-family: "Segoe UI", Arial, sans-serif;
}

button {
    font: inherit;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 32px;
}

.top-band {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 0 22px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--teal);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    color: var(--ink);
    letter-spacing: 0;
}

h1 {
    font-size: 2rem;
    line-height: 1.12;
}

h2 {
    font-size: 1.05rem;
    line-height: 1.25;
}

.status-cluster,
.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 650;
}

.status-pill.ready {
    border-color: #a8dec9;
    color: var(--green);
}

.status-pill.busy {
    border-color: #9fd5db;
    color: var(--teal-dark);
}

.status-pill.pending {
    border-color: #f0c475;
    color: var(--amber);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(220px, 0.85fr) repeat(2, minmax(260px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.panel {
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel);
    padding: 18px;
}

.action-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.bluetooth-box {
    display: grid;
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--panel-border);
}

.bluetooth-box span,
.bluetooth-box small {
    display: block;
    color: var(--muted);
}

.bluetooth-box span {
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.bluetooth-box strong {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: 0.98rem;
}

.bluetooth-box small {
    margin-top: 3px;
    line-height: 1.35;
}

.device-button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.button-row {
    flex-direction: column;
}

.category-read-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.category-read-row select {
    min-width: 0;
    min-height: 42px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 8px 10px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-weight: 650;
}

.category-button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.category-button-row .secondary-action {
    width: 100%;
    white-space: nowrap;
}

.primary-action,
.secondary-action {
    min-height: 42px;
    width: 100%;
    border-radius: 8px;
    padding: 9px 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

.primary-action {
    color: #ffffff;
    background: var(--teal);
}

.primary-action:not(:disabled):hover {
    background: var(--teal-dark);
}

.secondary-action {
    color: var(--ink);
    background: #f7faf9;
    border-color: var(--panel-border);
}

.secondary-action:not(:disabled):hover {
    border-color: #9fd5db;
    background: #edf8f7;
}

.snapshot-list {
    display: grid;
    gap: 12px;
    margin: 16px 0 0;
}

.snapshot-list div {
    min-width: 0;
}

.snapshot-list dt {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
}

.snapshot-list .did-code {
    color: #8b95a1;
    font-weight: 650;
    text-transform: none;
}

.metric-label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
}

.metric-label > span:first-child {
    min-width: 100%;
}

.tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    outline: none;
}

.tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 1px solid #b8c7d0;
    border-radius: 50%;
    background: #f7faf9;
    color: var(--teal-dark);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    text-transform: none;
    cursor: help;
}

.tooltip-panel {
    position: absolute;
    z-index: 20;
    left: 0;
    top: calc(100% + 8px);
    display: none;
    width: min(300px, calc(100vw - 40px));
    padding: 10px 12px;
    border: 1px solid #b8c7d0;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.16);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.45;
    text-transform: none;
}

.tooltip-panel span {
    display: block;
}

.tooltip-panel span + span {
    margin-top: 6px;
}

.tooltip-title {
    color: var(--ink);
    font-weight: 800;
}

.tooltip-wrap:hover .tooltip-panel,
.tooltip-wrap:focus .tooltip-panel,
.tooltip-wrap:focus-within .tooltip-panel {
    display: block;
}

.tooltip-wrap:hover .tooltip-trigger,
.tooltip-wrap:focus .tooltip-trigger,
.tooltip-wrap:focus-within .tooltip-trigger {
    border-color: var(--teal);
    background: #edf8f7;
}

.snapshot-list dd {
    margin: 2px 0 0;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: 0.98rem;
    font-weight: 650;
}

.snapshot-list .hash {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.82rem;
    line-height: 1.45;
}

.snapshot-list .unavailable dd {
    color: var(--muted);
}

.empty-state {
    margin-top: 16px;
    color: var(--muted);
}

.diagnostics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 16px;
    margin-top: 16px;
    align-items: start;
}

.diagnostics-panel {
    min-width: 0;
}

.diagnostics-list {
    gap: 10px;
}

.log-panel {
    margin-top: 16px;
    padding: 0;
    overflow: hidden;
}

.log-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--panel-border);
}

.log-heading span {
    color: var(--muted);
    font-size: 0.88rem;
}

.log-list {
    max-height: 460px;
    overflow: auto;
}

.log-row {
    display: grid;
    grid-template-columns: 76px 68px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 18px;
    border-bottom: 1px solid #edf0f2;
}

.log-row time {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.log-row span {
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.log-row p {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.log-row.ok span {
    color: var(--green);
}

.log-row.warn span {
    color: var(--amber);
}

.log-row.error span {
    color: var(--red);
}

.log-row.trace span {
    color: var(--muted);
}

#blazor-error-ui {
    color-scheme: light only;
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

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

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

.loading-progress circle:last-child {
    stroke: var(--teal);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

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

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

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

    .action-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 700px) {
    .app-shell {
        width: min(100% - 20px, 1180px);
        padding-top: 16px;
    }

    .top-band {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .log-row {
        grid-template-columns: 64px 58px minmax(0, 1fr);
        padding: 10px 12px;
    }
}
