:root {
    color-scheme: dark;
    --bg: #101210;
    --ink: #f4f1e8;
    --muted: #a5a99e;
    --line: rgba(244, 241, 232, 0.16);
    --panel: rgba(244, 241, 232, 0.055);
    --panel-strong: rgba(244, 241, 232, 0.1);
    --green: #8acb65;
    --blue: #78a8ff;
    --danger: #f08072;
    --shadow: rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    min-height: 100svh;
    margin: 0;
    background:
        linear-gradient(90deg, rgba(244, 241, 232, 0.035) 1px, transparent 1px),
        linear-gradient(rgba(244, 241, 232, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(138, 203, 101, 0.06), transparent 340px),
        var(--bg);
    background-size: 56px 56px, 56px 56px, auto, auto;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection {
    background: rgba(138, 203, 101, 0.34);
    color: var(--ink);
}

a {
    color: inherit;
    text-decoration: none;
}

h1,
h2,
h3,
p,
span,
strong,
code {
    overflow-wrap: anywhere;
}

.page {
    display: grid;
    width: min(1120px, calc(100% - 32px));
    min-height: 100svh;
    margin: 0 auto;
    grid-template-rows: auto 1fr auto;
}

.page-narrow {
    width: min(760px, calc(100% - 32px));
}

.page-auth {
    width: min(1120px, calc(100% - 32px));
}

.page-account {
    width: min(1040px, calc(100% - 32px));
}

.page-login .auth-main {
    align-content: center;
    padding: 28px 0;
}

.page-login {
    grid-template-rows: 1fr auto;
}

.site-header {
    display: flex;
    min-width: 0;
    min-height: 76px;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
}

.nav-actions,
.logout-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.logout-form {
    margin: 0;
}

.button,
button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
}

.button-primary,
button:not(.button-secondary) {
    border-color: var(--green);
    background: var(--green);
    color: #101210;
}

.button-secondary {
    background: var(--panel-strong);
    color: var(--ink);
}

.button:hover,
button:hover,
.button:focus-visible,
button:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(138, 203, 101, 0.16);
}

.messages {
    display: grid;
    gap: 8px;
    width: min(640px, 100%);
    margin-bottom: 18px;
}

.message,
.messages p {
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
}

.auth-main {
    display: grid;
    min-width: 0;
    align-content: start;
    justify-items: center;
    padding: 16px 0 76px;
}

.panel,
.auth-panel {
    display: grid;
    width: min(720px, 100%);
    gap: 18px;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(244, 241, 232, 0.075), rgba(244, 241, 232, 0.035)),
        rgba(16, 18, 16, 0.84);
    box-shadow: 0 28px 90px var(--shadow);
}

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

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

.sso-panel {
    width: min(640px, 100%);
}

.auth-heading {
    display: grid;
    gap: 8px;
}

.auth-heading-center {
    justify-items: center;
    text-align: center;
}

.eyebrow {
    margin: 0;
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: 2.55rem;
    line-height: 1;
    letter-spacing: 0;
}

h2 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.15;
    letter-spacing: 0;
}

p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.auth-form,
.panel form,
.auth-panel form {
    display: grid;
    gap: 14px;
    max-width: none;
}

.form-field,
.field-group {
    display: grid;
    gap: 7px;
    min-width: 0;
}

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

.form-section {
    display: grid;
    gap: 12px;
    margin-top: 2px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

label {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 750;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(11, 13, 11, 0.72);
    color: var(--ink);
    font: inherit;
    transition:
        border-color 120ms ease,
        background-color 120ms ease,
        box-shadow 120ms ease;
}

input:hover,
select:hover,
textarea:hover {
    border-color: rgba(244, 241, 232, 0.28);
    background: rgba(18, 21, 18, 0.86);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    border-color: rgba(138, 203, 101, 0.76);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(138, 203, 101, 0.16);
}

textarea {
    min-height: 104px;
    resize: vertical;
}

.password-field {
    position: relative;
    display: grid;
}

.password-field input {
    padding-right: 82px;
}

.password-toggle {
    position: absolute;
    top: 6px;
    right: 6px;
    min-height: 32px;
    padding: 0 11px;
    border-color: rgba(244, 241, 232, 0.16);
    background: rgba(244, 241, 232, 0.08);
    color: var(--ink);
    font-size: 0.86rem;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    border-color: rgba(138, 203, 101, 0.62);
}

input[type="checkbox"] {
    width: 18px;
    min-width: 18px;
    height: 18px;
    min-height: 18px;
    padding: 0;
    accent-color: var(--green);
}

.checkbox-field {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(244, 241, 232, 0.045);
}

.checkbox-field span {
    min-width: 0;
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 800;
}

.auth-submit {
    width: 100%;
    margin-top: 4px;
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    column-gap: 14px;
    row-gap: 8px;
    color: var(--muted);
}

.auth-links-center {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.auth-links span {
    color: var(--muted);
}

.auth-links a {
    color: var(--ink);
    font-weight: 800;
}

.helptext,
.form-note {
    color: var(--muted);
}

.errorlist {
    display: grid;
    gap: 6px;
    padding: 0;
    margin: 0;
    color: var(--danger);
    list-style: none;
}

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

.recovery-option {
    display: grid;
    min-width: 0;
    gap: 8px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(244, 241, 232, 0.045);
}

.recovery-option:hover,
.recovery-option:focus-visible {
    outline: 0;
    border-color: rgba(138, 203, 101, 0.62);
    box-shadow: 0 0 0 3px rgba(138, 203, 101, 0.12);
}

.recovery-option strong {
    color: var(--ink);
    font-size: 1rem;
}

.recovery-option span {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.4;
}

.qr-panel {
    display: grid;
    gap: 14px;
    justify-items: center;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(244, 241, 232, 0.045);
}

.qr,
.qr-panel img {
    width: min(240px, 100%);
    height: auto;
    padding: 12px;
    border-radius: 8px;
    background: #f4f1e8;
}

.manual-secret,
.manual-secret-block {
    display: grid;
    width: 100%;
    gap: 6px;
}

.manual-secret span,
.manual-secret-block span {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 750;
}

.code,
.manual-secret code,
.manual-secret-block code {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(11, 13, 11, 0.72);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.code-grid {
    display: grid;
    max-width: 720px;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.code-token {
    min-width: 0;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.95rem;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.account-main {
    display: grid;
    min-width: 0;
    align-content: start;
    gap: 18px;
    padding: 42px 0 88px;
}

.account-hero {
    display: flex;
    min-width: 0;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
}

.account-hero h1 {
    margin-top: 8px;
    font-size: 3.3rem;
    line-height: 1;
}

.account-summary {
    display: grid;
    min-width: 0;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-item,
.account-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(244, 241, 232, 0.07), rgba(244, 241, 232, 0.035)),
        rgba(16, 18, 16, 0.82);
}

.summary-item {
    display: grid;
    min-width: 0;
    gap: 8px;
    padding: 18px;
}

.summary-item span {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 750;
}

.summary-item strong {
    min-width: 0;
    font-size: 1.25rem;
    overflow-wrap: anywhere;
}

.summary-item-wide strong {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 1rem;
}

.account-section {
    display: grid;
    min-width: 0;
    gap: 18px;
    padding: 22px;
}

.section-heading,
.account-actions,
.sso-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.account-action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.status-pill {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 1px solid rgba(138, 203, 101, 0.38);
    border-radius: 8px;
    background: rgba(138, 203, 101, 0.09);
    color: var(--green);
    font-weight: 850;
}

.management-list,
.event-list,
.data-list {
    display: grid;
    gap: 0;
}

.management-row,
.event-row,
.data-row {
    display: grid;
    min-width: 0;
    gap: 10px;
    padding: 13px 0;
    border-top: 1px solid rgba(244, 241, 232, 0.1);
}

.management-row:first-child,
.event-row:first-child,
.data-row:first-child {
    border-top: 0;
}

.management-row {
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.85fr);
    align-items: center;
}

.event-row {
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.7fr) minmax(120px, 0.6fr);
    align-items: center;
}

.data-row-apps,
.data-row-events {
    align-items: center;
    grid-template-columns: minmax(180px, 1.1fr) minmax(120px, 0.55fr) minmax(160px, 0.75fr);
}

.data-row-heading {
    padding-top: 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
    text-transform: uppercase;
}

.management-row span,
.event-row span,
.event-row time,
.data-row span,
.data-row time {
    min-width: 0;
    overflow-wrap: anywhere;
}

.management-row small,
.event-row span,
.event-row time,
.data-row span,
.data-row time {
    color: var(--muted);
}

.empty-state {
    margin: 0;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 750;
}

.account-section > .empty-state {
    padding: 2px 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(244, 241, 232, 0.1);
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 750;
}

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

.pagination .button {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.88rem;
}

.button.is-disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.button.is-disabled:hover {
    box-shadow: none;
}

.button-danger {
    border-color: rgba(240, 128, 114, 0.52);
    background: rgba(240, 128, 114, 0.14);
    color: var(--ink);
}

.scope-list {
    display: grid;
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.scope-list li {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(244, 241, 232, 0.045);
    color: var(--ink);
}

.site-footer {
    display: flex;
    min-width: 0;
    min-height: 74px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 750;
}

@media (max-width: 720px) {
    .page,
    .page-narrow,
    .page-auth,
    .page-account {
        width: min(1120px, calc(100% - 24px));
    }

    .site-header {
        align-items: stretch;
        flex-direction: column;
        justify-content: center;
        padding: 16px 0;
    }

    .nav-actions {
        width: 100%;
        flex-direction: column;
        justify-content: stretch;
    }

    .button,
    .nav-actions a,
    .logout-form,
    .logout-form button,
    .status-pill {
        width: 100%;
    }

    .auth-main {
        padding: 22px 0 58px;
    }

    .panel,
    .auth-panel {
        padding: 22px;
    }

    h1,
    .auth-panel h1 {
        font-size: 2.45rem;
    }

    .form-grid,
    .management-row,
    .event-row,
    .data-row-apps,
    .data-row-events,
    .code-grid,
    .recovery-options {
        grid-template-columns: 1fr;
    }

    .account-main {
        padding: 24px 0 58px;
    }

    .account-hero,
    .section-heading,
    .account-actions,
    .sso-actions,
    .site-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .account-action-buttons {
        flex-direction: column;
    }

    .account-hero h1 {
        font-size: 2.45rem;
    }

    .account-summary {
        grid-template-columns: 1fr;
    }

    .data-row-heading {
        display: none;
    }

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

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

@media (max-width: 420px) {
    .panel,
    .auth-panel,
    .account-section,
    .summary-item {
        padding: 18px;
    }

    h1,
    .auth-panel h1,
    .account-hero h1 {
        font-size: 2rem;
    }
}

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