/* PV2Hash Portal base UI */

:root {
    --bg: #0b1020;
    --surface: #121a2e;
    --surface-soft: #17213a;
    --border: rgba(255, 255, 255, 0.10);
    --text: #f4f7fb;
    --muted: #9aa8bd;
    --accent: #f7b733;
    --accent-soft: rgba(247, 183, 51, 0.16);
    --ok: #21c07a;
    --warn: #f7b733;
    --bad: #ff5c7a;
    --info: #7ab7ff;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(247, 183, 51, 0.13), transparent 28rem),
        radial-gradient(circle at bottom right, rgba(33, 192, 122, 0.10), transparent 30rem),
        var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
}

.site-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-main {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    flex: 1;
    padding: 2rem 0 4rem;
}

.site-header,
.site-footer {
    border-color: var(--border);
    border-style: solid;
}

.site-header {
    border-width: 0 0 1px;
    background: rgba(11, 16, 32, 0.82);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.site-header__inner,
.site-footer__inner {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 4.25rem;
    gap: 1rem;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    flex: 0 0 auto;
    min-width: max-content;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.site-brand__mark {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.7rem;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 900;
}

.portal-header-ticker {
    flex: 1 1 auto;
    min-width: 12rem;
    overflow: hidden;
}

.portal-header-ticker__viewport {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(247, 183, 51, 0.20);
    border-radius: 999px;
    background: rgba(247, 183, 51, 0.07);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.16);
}

.portal-header-ticker__viewport::before,
.portal-header-ticker__viewport::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 1;
    width: 2rem;
    pointer-events: none;
}

.portal-header-ticker__viewport::before {
    left: 0;
    background: linear-gradient(90deg, rgba(11, 16, 32, 0.94), transparent);
}

.portal-header-ticker__viewport::after {
    right: 0;
    background: linear-gradient(270deg, rgba(11, 16, 32, 0.94), transparent);
}

.portal-header-ticker__track {
    display: flex;
    width: max-content;
    animation: portal-ticker-scroll 28s linear infinite;
    will-change: transform;
}

.portal-header-ticker:hover .portal-header-ticker__track {
    animation-play-state: paused;
}

.portal-header-ticker__group {
    display: inline-flex;
    align-items: center;
    gap: 1.4rem;
    padding: 0.45rem 1.4rem;
    white-space: nowrap;
}

.portal-header-ticker__item {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    line-height: 1;
}

.portal-header-ticker__label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.portal-header-ticker__item strong {
    color: var(--accent);
    font-size: 0.9rem;
}

@keyframes portal-ticker-scroll {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-50%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-header-ticker__track {
        animation: none;
    }

    .portal-header-ticker__viewport {
        overflow-x: auto;
    }
}

.site-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.site-nav a,
.button-link {
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.55rem 0.9rem;
    background: rgba(255, 255, 255, 0.03);
    line-height: 1;
}

.site-nav a:hover,
.button-link:hover {
    background: rgba(255, 255, 255, 0.08);
}

.site-footer {
    border-width: 1px 0 0;
    color: var(--muted);
}

.site-footer__inner {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 1.25rem 0;
    font-size: 0.9rem;
}

.page-hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.hero-action {
    flex: 0 0 auto;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    font-weight: 900;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.5rem;
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1;
}

h2 {
    margin-bottom: 0.5rem;
}

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

.error-text {
    color: var(--bad);
    border: 1px solid rgba(255, 92, 122, 0.28);
    border-radius: 0.9rem;
    padding: 0.75rem 0.9rem;
    background: rgba(255, 92, 122, 0.10);
}

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

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.instance-card,
.empty-state,
.auth-card,
.health-card,
.pairing-card,
.detail-card,
.live-region,
.metric-card {
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
    box-shadow: var(--shadow);
}

.instance-card,
.empty-state,
.auth-card,
.health-card,
.pairing-card,
.detail-card,
.live-region,
.metric-card {
    padding: 1.5rem;
}

.auth-card,
.health-card {
    max-width: 720px;
}

.card-title-link {
    text-decoration: none;
}

.card-title-link:hover {
    color: var(--accent);
}

.card-footer {
    margin-top: 1.25rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-card--wide {
    margin-top: 1rem;
}

.detail-card__header,
.live-region__header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.live-region {
    margin-bottom: 1rem;
    border-color: rgba(247, 183, 51, 0.22);
}

.dashboard-live-region {
    margin-bottom: 1.5rem;
}

.dashboard-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.live-region__state {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: right;
}

.live-region__state[data-state="ok"] {
    color: var(--ok);
}

.live-region__state[data-state="error"] {
    color: var(--bad);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
}

.metric-card {
    box-shadow: none;
    background: rgba(255, 255, 255, 0.035);
}

.metric-card__label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.metric-card__value {
    display: block;
    font-size: clamp(1.35rem, 4vw, 2rem);
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.metric-card__value--small {
    font-size: 1.1rem;
}

.pairing-section {
    margin-bottom: 1.5rem;
}

.pairing-card {
    display: grid;
    grid-template-columns: minmax(220px, 0.45fr) 1fr;
    gap: 1.25rem;
    align-items: center;
    border-color: rgba(247, 183, 51, 0.28);
    background:
        radial-gradient(circle at top left, rgba(247, 183, 51, 0.14), transparent 18rem),
        linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.028));
}

.pairing-code-button {
    display: inline-flex;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.pairing-code {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(247, 183, 51, 0.34);
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(247, 183, 51, 0.12);
    color: var(--accent);
    font-size: clamp(1.5rem, 5vw, 2.35rem);
    font-weight: 900;
    letter-spacing: 0.08em;
    transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.pairing-code-button:hover .pairing-code,
.pairing-code-button:focus-visible .pairing-code {
    transform: translateY(-1px);
    background: rgba(247, 183, 51, 0.18);
    border-color: rgba(247, 183, 51, 0.52);
}

.pairing-code-button.is-copied .pairing-code {
    background: rgba(33, 192, 122, 0.16);
    border-color: rgba(33, 192, 122, 0.42);
    color: var(--ok);
}

.pairing-code-hint,
.pairing-code-status {
    margin: 0.6rem 0 0;
    font-size: 0.95rem;
}

.pairing-code-hint {
    color: var(--muted);
}

.pairing-code-status {
    min-height: 1.3rem;
    color: var(--ok);
    font-weight: 700;
}

.pairing-card__body p:last-child {
    margin-bottom: 0;
}

.instance-card__header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.instance-card--disabled {
    opacity: 0.68;
}

.instance-card__uuid {
    max-width: 22rem;
    overflow-wrap: anywhere;
}

.instance-card__metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.instance-card__metrics div {
    border: 1px solid var(--border);
    border-radius: 0.95rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.035);
}

.instance-card__metrics span {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.instance-card__metrics strong {
    display: block;
    font-size: 1.1rem;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    white-space: nowrap;
}

.status-pill--online {
    background: rgba(33, 192, 122, 0.16);
    color: var(--ok);
}

.status-pill--warning,
.status-pill--stale {
    background: rgba(247, 183, 51, 0.16);
    color: var(--warn);
}

.status-pill--offline,
.status-pill--error {
    background: rgba(255, 92, 122, 0.16);
    color: var(--bad);
}

.meta-list {
    display: grid;
    gap: 0.75rem;
    margin: 1rem 0 0;
}

.meta-list div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.meta-list dt {
    color: var(--muted);
}

.meta-list dd {
    margin: 0;
    text-align: right;
    overflow-wrap: anywhere;
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state--compact {
    padding: 2rem 1rem;
}

.empty-state__icon {
    display: grid;
    place-items: center;
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    border-radius: 1.3rem;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 2rem;
    font-weight: 800;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.75rem;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    color: var(--text);
}

.toast-stack {
    position: fixed;
    top: 5rem;
    right: max(1rem, calc((100vw - 1120px) / 2));
    display: grid;
    gap: 0.75rem;
    width: min(420px, calc(100vw - 2rem));
    z-index: 100;
    pointer-events: none;
}

.toast-message {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 0.85rem 1rem;
    background: rgba(18, 26, 46, 0.94);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    animation: toast-in 180ms ease-out, toast-out 500ms ease-in 4.5s forwards;
}

.toast-message__dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    flex: 0 0 auto;
    background: var(--info);
    box-shadow: 0 0 0 0.25rem rgba(122, 183, 255, 0.14);
}

.toast-message--success .toast-message__dot {
    background: var(--ok);
    box-shadow: 0 0 0 0.25rem rgba(33, 192, 122, 0.14);
}

.toast-message--warning .toast-message__dot {
    background: var(--warn);
    box-shadow: 0 0 0 0.25rem rgba(247, 183, 51, 0.14);
}

.toast-message--error .toast-message__dot {
    background: var(--bad);
    box-shadow: 0 0 0 0.25rem rgba(255, 92, 122, 0.14);
}

.toast-message__text {
    min-width: 0;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-0.5rem) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-0.35rem) scale(0.98);
        visibility: hidden;
    }
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
.button-primary {
    border: 0;
    border-radius: 999px;
    padding: 0.7rem 1rem;
    background: var(--accent);
    color: #1b1300;
    font-weight: 800;
    cursor: pointer;
}

button:hover,
.button-primary:hover {
    filter: brightness(1.05);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 0.75rem 0.85rem;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    margin-right: 0.4rem;
}

label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-weight: 650;
}

form p {
    margin-bottom: 1rem;
}

.helptext,
.errorlist {
    font-size: 0.9rem;
}

.errorlist {
    color: var(--bad);
}

@media (max-width: 720px) {
    .site-header__inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 1rem 0;
    }

    .site-nav {
        justify-content: flex-start;
    }

    .page-hero {
        display: block;
    }

    .hero-action {
        margin-top: 1rem;
    }

    .pairing-card,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .toast-stack {
        top: auto;
        right: 1rem;
        bottom: 1rem;
    }
}

@media (max-width: 980px) {
    .site-header__inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 0.9rem 0;
    }

    .portal-header-ticker {
        order: -1;
        width: 100%;
        min-width: 0;
    }

    .portal-header-ticker__viewport {
        border-radius: 0.85rem;
    }

    .portal-header-ticker__group {
        padding: 0.5rem 1.2rem;
    }

    .site-nav {
        justify-content: flex-start;
    }
}
