@font-face {
    font-family: "Inter";
    src: url("fonts/Inter-Variable.ttf") format("truetype");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("fonts/Inter-Italic-Variable.ttf") format("truetype");
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --bg: #100f1f;
    --bg-deep: #0c0b18;
    --surface: #17162b;
    --surface-soft: #1d1c35;
    --surface-raised: #24223e;
    --text: #f4f3f7;
    --muted: #b4afc7;
    --muted-strong: #d0ccdc;
    --yellow: #ffed40;
    --yellow-ink: #161637;
    --green: #57ed4c;
    --magenta: #ed34a2;
    --danger: #ef6379;
    --border: rgba(180, 175, 199, 0.16);
    --border-strong: rgba(180, 175, 199, 0.28);
    --shadow: 0 24px 80px rgba(5, 4, 15, 0.42);
    --radius: 24px;
    --radius-dense: 10px;
    --content: 1280px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% -8%, rgba(87, 237, 76, 0.13), transparent 28rem),
        radial-gradient(circle at 52% -16%, rgba(255, 237, 64, 0.11), transparent 30rem),
        radial-gradient(circle at 96% -4%, rgba(237, 52, 162, 0.14), transparent 28rem),
        var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
}

:focus-visible {
    outline: 3px solid var(--yellow);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    z-index: 1000;
    top: 12px;
    left: 12px;
    padding: 10px 16px;
    border-radius: 999px;
    color: var(--yellow-ink);
    background: var(--yellow);
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.brand-logo {
    display: block;
    width: min(210px, 52vw);
    height: auto;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--yellow);
    font-size: 0.77rem;
    font-weight: 750;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.button {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 750;
    text-decoration: none;
    transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button--primary {
    color: var(--yellow-ink);
    background: var(--yellow);
    box-shadow: 0 12px 28px rgba(255, 237, 64, 0.14);
}

.button--primary:hover {
    background: #fff36a;
}

.button--secondary {
    color: var(--text);
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.04);
}

.button--wide {
    width: 100%;
}

.notice {
    margin: 20px 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.93rem;
}

.notice--error {
    color: #ffd8de;
    border-color: rgba(239, 99, 121, 0.42);
    background: rgba(239, 99, 121, 0.09);
}

.notice--success {
    color: #d8ffd5;
    border-color: rgba(87, 237, 76, 0.36);
    background: rgba(87, 237, 76, 0.08);
}

/* Login and setup */

.auth-page {
    display: grid;
    place-items: center;
    padding: 36px 20px;
}

.auth-shell {
    width: 100%;
    max-width: 560px;
}

.auth-card {
    position: relative;
    overflow: hidden;
    padding: clamp(28px, 5vw, 48px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(155deg, rgba(29, 28, 53, 0.97), rgba(16, 15, 31, 0.97));
    box-shadow: var(--shadow);
}

.auth-card::before {
    content: "";
    position: absolute;
    z-index: 0;
    width: 260px;
    height: 260px;
    top: -170px;
    right: -120px;
    border-radius: 50%;
    background: var(--magenta);
    opacity: 0.17;
    filter: blur(50px);
    pointer-events: none;
}

.auth-card > * {
    position: relative;
    z-index: 1;
}

.auth-card .brand-logo {
    margin-bottom: 42px;
}

.auth-card h1 {
    margin: 0;
    font-size: clamp(2rem, 7vw, 3.25rem);
    line-height: 1.02;
    letter-spacing: -0.045em;
}

.auth-copy {
    margin: 18px 0 28px;
    color: var(--muted);
    font-size: 1rem;
}

.login-form,
.setup-form {
    display: grid;
    gap: 18px;
}

.login-form label,
.setup-form label,
.token-reveal label {
    display: grid;
    gap: 8px;
    color: var(--muted-strong);
    font-size: 0.84rem;
    font-weight: 700;
}

.login-form input,
.setup-form input,
.copy-field input {
    width: 100%;
    min-height: 50px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-dense);
    color: var(--text);
    background: rgba(8, 7, 20, 0.5);
    transition: border-color 160ms ease, background 160ms ease;
}

.login-form input:hover,
.setup-form input:hover,
.copy-field input:hover {
    border-color: var(--border-strong);
}

.security-note {
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    text-align: center;
}

.setup-card {
    max-width: 760px;
}

.setup-card fieldset {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
}

.setup-card legend {
    padding: 0 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 800;
}

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

.field-span {
    grid-column: 1 / -1;
}

.field-help {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.success-mark {
    display: grid;
    width: 56px;
    height: 56px;
    margin: 0 0 22px;
    place-items: center;
    border: 1px solid rgba(87, 237, 76, 0.35);
    border-radius: 50%;
    color: var(--green);
    background: rgba(87, 237, 76, 0.09);
    font-size: 1.6rem;
    font-weight: 800;
}

.token-reveal {
    margin: 24px 0;
    padding: 18px;
    border: 1px solid rgba(255, 237, 64, 0.28);
    border-radius: 16px;
    background: rgba(255, 237, 64, 0.06);
}

.token-reveal p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.copy-field {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.copy-field input {
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
}

/* App shell */

.app-header {
    position: sticky;
    z-index: 30;
    top: 0;
    border-bottom: 1px solid var(--border);
    background: rgba(12, 11, 24, 0.9);
    backdrop-filter: blur(18px);
}

.app-header__inner {
    display: flex;
    width: min(calc(100% - 48px), var(--content));
    min-height: 76px;
    margin: 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 0.82rem;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
}

.brand-link .brand-logo {
    width: 172px;
}

.brand-link span {
    padding-left: 18px;
    border-left: 1px solid var(--border-strong);
    color: var(--muted);
}

.account-nav {
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--muted-strong);
    font-size: 0.8rem;
}

.account-nav a,
.text-button {
    color: inherit;
    text-decoration: none;
}

.account-nav a:hover,
.text-button:hover {
    color: var(--text);
}

.account-nav form {
    margin: 0;
}

.text-button {
    padding: 0;
    border: 0;
    cursor: pointer;
    background: transparent;
}

.user-chip {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}

.user-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(87, 237, 76, 0.1);
}

.app-main {
    width: min(calc(100% - 48px), var(--content));
    margin: 0 auto;
    padding: clamp(50px, 7vw, 90px) 0 50px;
}

.page-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 48px;
    margin-bottom: 42px;
}

.page-intro h1 {
    max-width: 760px;
    margin: 0;
    font-size: clamp(2.6rem, 5vw, 4.8rem);
    line-height: 0.98;
    letter-spacing: -0.055em;
}

.page-intro > div > p:last-child {
    max-width: 680px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: clamp(1rem, 1.4vw, 1.15rem);
}

.status-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 10px;
}

.status-card {
    display: grid;
    min-width: 140px;
    gap: 8px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.025);
}

.status-card span {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
}

.status-card strong {
    font-size: 1.8rem;
    line-height: 1;
}

.status-card--open strong {
    color: var(--yellow);
}

.status-card--online strong {
    color: var(--green);
}

.table-panel {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(150deg, rgba(29, 28, 53, 0.88), rgba(18, 17, 34, 0.94));
    box-shadow: var(--shadow);
}

.table-toolbar {
    display: flex;
    min-height: 98px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px 26px;
    border-bottom: 1px solid var(--border);
}

.table-toolbar h2 {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.table-toolbar p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.76rem;
}

.search-field {
    display: flex;
    width: min(380px, 42vw);
    min-height: 46px;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(7, 6, 17, 0.35);
}

.search-field:focus-within {
    border-color: var(--yellow);
    box-shadow: 0 0 0 3px rgba(255, 237, 64, 0.08);
}

.search-field input {
    width: 100%;
    height: 44px;
    padding: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
}

.search-field input::placeholder {
    color: #8f8aa4;
}

.table-scroll {
    overflow-x: auto;
}

.content-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

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

.content-table th {
    color: var(--muted);
    background: rgba(5, 4, 15, 0.18);
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.content-table th:nth-child(1),
.content-table td:nth-child(1) {
    width: 38%;
}

.content-table th:nth-child(2),
.content-table td:nth-child(2) {
    width: 47%;
}

.content-table th:nth-child(3),
.content-table td:nth-child(3) {
    width: 15%;
}

.content-table tbody tr {
    transition: background-color 160ms ease, opacity 160ms ease;
}

.content-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.023);
}

.content-table tbody tr:last-child td {
    border-bottom: 0;
}

.content-table tr.is-saving {
    opacity: 0.62;
}

.content-table tr.is-saved {
    background: rgba(87, 237, 76, 0.045);
}

.source-link {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted-strong);
    font-size: 0.82rem;
    text-decoration: none;
}

.source-link span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-link span:last-child {
    flex: 0 0 auto;
    color: var(--yellow);
}

.source-link:hover {
    color: var(--text);
}

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

.editable-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.editable-field input {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    background: transparent;
}

.editable-field input:hover,
.editable-field input:focus {
    border-color: var(--border-strong);
    background: rgba(5, 4, 15, 0.28);
}

.save-button {
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted-strong);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.72rem;
    font-weight: 750;
    opacity: 0;
    transform: translateX(5px);
    transition: opacity 150ms ease, transform 150ms ease, border-color 150ms ease;
}

.row-form:focus-within .save-button,
.row-form.is-dirty .save-button {
    opacity: 1;
    transform: translateX(0);
}

.save-button:hover {
    border-color: var(--yellow);
    color: var(--yellow);
}

.row-meta {
    color: #817c95;
    font-size: 0.65rem;
}

.toggle {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.toggle__track {
    position: relative;
    display: block;
    width: 42px;
    height: 24px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: #2b2943;
    transition: background-color 160ms ease, border-color 160ms ease;
}

.toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 160ms ease, background-color 160ms ease;
}

.toggle input:checked + .toggle__track {
    border-color: rgba(87, 237, 76, 0.48);
    background: rgba(87, 237, 76, 0.18);
}

.toggle input:checked + .toggle__track .toggle__thumb {
    background: var(--green);
    transform: translateX(18px);
}

.toggle input:focus-visible + .toggle__track {
    outline: 3px solid var(--yellow);
    outline-offset: 3px;
}

.toggle__label {
    min-width: 30px;
    color: var(--muted-strong);
    font-size: 0.78rem;
    font-weight: 700;
}

.empty-state {
    margin: 0;
    padding: 46px 24px;
    color: var(--muted);
    text-align: center;
}

.app-footnote {
    margin: 18px 4px 0;
    color: #817c95;
    font-size: 0.72rem;
}

.toast {
    position: fixed;
    z-index: 100;
    right: 24px;
    bottom: 24px;
    max-width: min(380px, calc(100vw - 40px));
    padding: 13px 17px;
    border: 1px solid rgba(87, 237, 76, 0.35);
    border-radius: 12px;
    color: #e9ffe7;
    background: rgba(20, 37, 26, 0.96);
    box-shadow: var(--shadow);
    font-size: 0.85rem;
}

.toast.is-error {
    border-color: rgba(239, 99, 121, 0.42);
    color: #ffe6ea;
    background: rgba(50, 18, 27, 0.96);
}

/* Utility views */

.utility-main {
    width: min(calc(100% - 40px), 840px);
    margin: 0 auto;
    padding: clamp(44px, 8vw, 90px) 0;
}

.utility-card {
    padding: clamp(26px, 5vw, 48px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(150deg, rgba(29, 28, 53, 0.9), rgba(16, 15, 31, 0.96));
    box-shadow: var(--shadow);
}

.utility-card h1 {
    margin: 0;
    font-size: clamp(2.3rem, 6vw, 4rem);
    line-height: 1;
    letter-spacing: -0.05em;
}

.utility-card > p {
    color: var(--muted);
}

.detail-list {
    display: grid;
    gap: 0;
    margin: 26px 0;
    border-top: 1px solid var(--border);
}

.detail-list > div {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 18px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

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

.detail-list dd {
    margin: 0;
}

.status-pill {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 750;
}

.status-pill--online {
    color: #d9ffd5;
    background: rgba(87, 237, 76, 0.1);
}

.token-form {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 26px 0;
}

.token-form p {
    margin: 0;
    color: var(--muted);
    font-size: 0.76rem;
}

.api-notes {
    display: grid;
    gap: 9px;
    margin-top: 36px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.api-notes h2 {
    margin: 0 0 8px;
}

.api-notes code {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted-strong);
    background: rgba(5, 4, 15, 0.35);
    font-size: 0.78rem;
}

@media (max-width: 980px) {
    .account-nav .user-chip,
    .account-nav a:first-of-type {
        display: none;
    }

    .page-intro {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 28px;
    }

    .status-cards {
        width: min(100%, 330px);
    }

    .content-table th:nth-child(1),
    .content-table td:nth-child(1) {
        width: 34%;
    }

    .content-table th:nth-child(2),
    .content-table td:nth-child(2) {
        width: 48%;
    }

    .content-table th:nth-child(3),
    .content-table td:nth-child(3) {
        width: 18%;
    }
}

@media (max-width: 760px) {
    .app-header__inner,
    .app-main {
        width: min(calc(100% - 32px), var(--content));
    }

    .brand-link span,
    .account-nav a {
        display: none;
    }

    .brand-link .brand-logo {
        width: 146px;
    }

    .app-main {
        padding-top: 44px;
    }

    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .search-field {
        width: 100%;
    }

    .content-table,
    .content-table tbody,
    .content-table tr,
    .content-table td {
        display: block;
        width: 100% !important;
    }

    .content-table thead {
        display: none;
    }

    .content-table tr {
        padding: 12px 18px;
        border-bottom: 1px solid var(--border);
    }

    .content-table tr:last-child {
        border-bottom: 0;
    }

    .content-table td {
        display: grid;
        grid-template-columns: minmax(88px, 0.32fr) minmax(0, 1fr);
        gap: 14px;
        padding: 10px 0;
        border: 0;
    }

    .content-table td::before {
        content: attr(data-label);
        padding-top: 4px;
        color: var(--muted);
        font-size: 0.68rem;
        font-weight: 750;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .source-link {
        min-width: 0;
    }

    .editable-field {
        align-items: stretch;
        flex-direction: column;
    }

    .save-button {
        min-height: 42px;
        opacity: 1;
        transform: none;
    }

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

    .field-span {
        grid-column: auto;
    }

    .copy-field,
    .token-form {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .auth-page {
        padding: 0;
        place-items: stretch;
    }

    .auth-card {
        min-height: 100vh;
        padding: 30px 20px;
        border: 0;
        border-radius: 0;
    }

    .app-header__inner {
        min-height: 68px;
    }

    .page-intro h1 {
        font-size: 2.55rem;
    }

    .status-cards {
        width: 100%;
    }

    .status-card {
        min-width: 0;
    }

    .table-panel {
        margin-right: -8px;
        margin-left: -8px;
        border-radius: 18px;
    }

    .content-table td {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .content-table td::before {
        padding: 0;
    }

    .detail-list > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
