:root {
    color-scheme: light;
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-subtle: #f8fafb;
    --line: #d9e0e5;
    --line-strong: #bcc8cf;
    --text: #172126;
    --muted: #64737b;
    --teal: #0f766e;
    --teal-dark: #0a5a55;
    --teal-soft: #e5f5f2;
    --blue: #2563eb;
    --amber: #b45309;
    --amber-soft: #fff7e8;
    --red: #b42318;
    --red-soft: #fff0ee;
    --green: #177245;
    --shadow: 0 12px 32px rgba(23, 33, 38, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 12px;
    letter-spacing: 0;
    line-height: 1.55;
}

button,
input {
    font: inherit;
    letter-spacing: 0;
}

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

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

svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
    flex: 0 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
    align-items: center;
    min-height: 66px;
    padding: 0 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    width: max-content;
}

.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 7px;
    background: var(--teal);
    color: #fff;
}

.brand-mark svg {
    width: 21px;
    height: 21px;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 15px;
    font-weight: 720;
}

.brand small {
    margin-top: 1px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface-subtle);
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 106px;
    height: 36px;
    padding: 0 14px;
    border-radius: 5px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
}

.main-nav a:hover,
.main-nav a.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(23, 33, 38, 0.1);
}

.account-menu {
    display: flex;
    align-items: center;
    justify-self: end;
    gap: 10px;
}

.account-menu form {
    margin: 0;
}

.account-name {
    max-width: 160px;
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.secure-indicator {
    display: inline-flex;
    align-items: center;
    justify-self: end;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.secure-indicator span,
.status-dot,
.config-state span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #25a36f;
    box-shadow: 0 0 0 4px rgba(37, 163, 111, 0.12);
}

.global-notice {
    position: fixed;
    top: 78px;
    right: 24px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 15px;
    border: 1px solid #9fd4bd;
    border-radius: 7px;
    background: #effbf5;
    color: var(--green);
    box-shadow: var(--shadow);
    font-size: 12px;
}

.global-notice.error {
    border-color: #efb2ab;
    background: var(--red-soft);
    color: var(--red);
}

.auth-page {
    background: var(--bg);
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 500px) minmax(280px, 360px);
    gap: 72px;
    align-items: center;
    width: min(1040px, calc(100% - 48px));
    min-height: calc(100vh - 66px);
    margin: 0 auto;
    padding: 52px 0;
}

.auth-shell.setup-shell {
    grid-template-columns: minmax(0, 620px) minmax(280px, 340px);
    width: min(1120px, calc(100% - 48px));
}

.auth-shell.single {
    grid-template-columns: minmax(0, 520px);
    justify-content: center;
}

.auth-shell.login-shell {
    grid-template-columns: minmax(0, 1fr);
    justify-content: center;
    width: min(460px, calc(100% - 32px));
    min-height: 100vh;
    min-height: 100dvh;
    gap: 0;
    padding: 32px 0;
}

.auth-tool {
    width: 100%;
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.account-dropdown {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 30;
    max-width: calc(100% - 48px);
}

.account-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-weight: 650;
    list-style: none;
    cursor: pointer;
}

.account-entry::-webkit-details-marker {
    display: none;
}

.account-label {
    min-width: 0;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-avatar {
    display: grid;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 50%;
    background: var(--teal-soft);
    color: var(--teal);
}

.account-chevron {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.account-dropdown[open] .account-chevron {
    transform: rotate(180deg);
}

.account-entry:hover,
.account-entry:focus-visible {
    background: var(--surface-subtle);
    outline-color: var(--teal);
}

.account-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    max-width: calc(100vw - 24px);
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.account-settings,
.account-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 6px;
}

.account-settings:hover,
.account-settings:focus-visible {
    background: var(--teal-soft);
    color: var(--teal);
    outline-color: var(--teal);
}

.account-dropdown-panel form {
    margin: 6px 0 0;
    padding-top: 6px;
    border-top: 1px solid var(--line);
}

.account-logout {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--red);
    text-align: left;
    cursor: pointer;
}

.account-logout:hover,
.account-logout:focus-visible {
    background: var(--red-soft);
    outline-color: var(--red);
}

.section-heading {
    margin-bottom: 28px;
}

.eyebrow {
    display: block;
    margin-bottom: 7px;
    color: var(--teal);
    font-size: 11px;
    font-weight: 780;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-size: 20px;
    font-weight: 740;
    line-height: 1.25;
}

h2 {
    margin-bottom: 2px;
    font-size: 12px;
    font-weight: 720;
    line-height: 1.35;
}

.auth-context {
    align-self: center;
    padding: 12px 0;
}

.context-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    font-size: 16px;
}

.status-dot.warning {
    background: #e0932e;
    box-shadow: 0 0 0 4px rgba(224, 147, 46, 0.14);
}

.policy-list {
    margin: 0;
    border-top: 1px solid var(--line);
}

.policy-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 52px;
    border-bottom: 1px solid var(--line);
}

.policy-list dt {
    color: var(--muted);
    font-size: 13px;
}

.policy-list dd {
    margin: 0;
    color: var(--text);
    font-size: 13px;
    font-weight: 690;
    text-align: right;
}

.policy-list.compact > div {
    min-height: 48px;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

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

.form-action-row {
    align-items: end;
}

.form-action-row > .button {
    width: 100%;
    min-height: 46px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.field > span:first-child,
.field > label:first-child {
    color: #405058;
    font-size: 12px;
    font-weight: 670;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-wrap > svg {
    position: absolute;
    left: 13px;
    z-index: 1;
    width: 17px;
    height: 17px;
    color: #829099;
    pointer-events: none;
}

.input-wrap input {
    width: 100%;
    height: 46px;
    padding: 0 42px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    outline: none;
    background: #fff;
    color: var(--text);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input-wrap input::placeholder {
    color: #9aa6ad;
}

.input-wrap input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.field-icon {
    position: absolute;
    right: 7px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.field-icon:hover {
    background: var(--surface-subtle);
    color: var(--text);
}

.code-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 170px;
    gap: 10px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 17px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

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

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

.button.primary {
    border-color: var(--teal);
    background: var(--teal);
    color: #fff;
}

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

.button.secondary {
    border-color: var(--line-strong);
    background: #fff;
    color: #33434b;
}

.button.secondary:hover:not(:disabled) {
    border-color: #8b9aa3;
    background: var(--surface-subtle);
}

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

.stable-button {
    width: 170px;
    min-width: 170px;
}

.icon-button {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
}

.icon-button:hover {
    border-color: var(--line-strong);
    color: var(--teal);
}

.icon-button.copied {
    border-color: #8acbb0;
    background: #effbf5;
    color: var(--green);
}

.form-alert {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 18px;
    padding: 11px 12px;
    border: 1px solid #a7d5c3;
    border-radius: 6px;
    background: #effbf5;
    color: var(--green);
    font-size: 12px;
}

.form-alert.error {
    border-color: #efb2ab;
    background: var(--red-soft);
    color: var(--red);
}

.form-alert[hidden] {
    display: none;
}

.form-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 760;
    text-transform: uppercase;
}

.form-divider::before,
.form-divider::after {
    height: 1px;
    flex: 1;
    background: var(--line);
    content: "";
}

.button-row,
.inline-action {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline-action {
    margin-top: 12px;
}

.page-shell {
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    padding: 42px 0 64px;
}

.page-shell.settings-shell {
    width: min(960px, calc(100% - 32px));
}

.settings-shell .settings-grid {
    align-items: stretch;
}

.settings-shell .page-heading form {
    margin: 0;
}

.settings-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
}

.settings-actions > form {
    margin: 0;
}

.settings-actions .button {
    white-space: nowrap;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 26px;
}

.metric-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.metric-strip > div {
    min-width: 0;
    padding: 20px 22px;
    border-right: 1px solid var(--line);
}

.metric-strip > div:last-child {
    border-right: 0;
}

.metric-strip span,
.metric-strip strong {
    display: block;
}

.metric-strip span {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.metric-strip strong {
    font-size: 22px;
    font-weight: 740;
}

.state-text {
    font-size: 17px !important;
}

.state-text.good {
    color: var(--green);
}

.state-text.warn {
    color: var(--amber);
}

.workspace-grid,
.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    gap: 24px;
    margin-bottom: 24px;
}

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

.panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

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

.panel-heading p {
    max-width: 620px;
    margin-bottom: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-icon {
    color: var(--teal);
}

.policy-panel .policy-list {
    padding: 0 20px 16px;
    border-top: 0;
}

.endpoint-list {
    width: 100%;
}

.endpoint-row {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) 36px;
    gap: 14px;
    align-items: center;
    min-height: 72px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
}

.endpoint-row:last-child {
    border-bottom: 0;
}

.endpoint-row code,
.endpoint-row small {
    display: block;
    min-width: 0;
}

.endpoint-row code {
    overflow: hidden;
    color: #23323a;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.endpoint-row small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.method-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 25px;
    border-radius: 5px;
    background: var(--teal-soft);
    color: var(--teal-dark);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    font-weight: 780;
}

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

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

th,
td {
    height: 50px;
    padding: 9px 18px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--surface-subtle);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
}

td {
    overflow: hidden;
    color: #394951;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

th:first-child,
td:first-child {
    width: 180px;
}

th:nth-child(2),
td:nth-child(2) {
    width: 210px;
}

.empty-cell {
    height: 90px;
    color: var(--muted);
    text-align: center;
}

.event-tag {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 0 8px;
    border-radius: 5px;
    background: #eef2f5;
    color: #415159;
    font-size: 11px;
    font-weight: 680;
}

td code {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.settings-panel {
    padding-bottom: 20px;
}

.settings-panel > .form-stack,
.settings-panel > .inline-action,
.settings-panel > .settings-actions,
.settings-panel > .form-divider {
    margin-right: 20px;
    margin-left: 20px;
}

.settings-panel > .form-stack {
    margin-top: 20px;
}

.account-panel > .form-stack {
    gap: 8px;
}

.account-panel > .form-stack + .form-stack {
    margin-top: 10px;
}

.settings-panel > .form-divider {
    margin-top: 24px;
    margin-bottom: 18px;
}

.config-state {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid #9fd4bd;
    border-radius: 6px;
    background: #effbf5;
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
}

.config-state.missing {
    border-color: #efca93;
    background: var(--amber-soft);
    color: var(--amber);
}

.config-state.missing span {
    background: #e0932e;
    box-shadow: 0 0 0 4px rgba(224, 147, 46, 0.14);
}

.endpoint-panel.wide {
    margin-top: 24px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    text-align: center;
}

.empty-state > svg {
    width: 42px;
    height: 42px;
    color: var(--teal);
}

@media (max-width: 900px) {
    .topbar {
        grid-template-columns: 1fr auto;
        padding: 0 20px;
        backdrop-filter: none;
    }

    .main-nav {
        position: fixed;
        right: 16px;
        bottom: 16px;
        left: 16px;
        z-index: 30;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        box-shadow: var(--shadow);
    }

    .main-nav a {
        width: 100%;
    }

    .account-name,
    .secure-indicator {
        display: none;
    }

    .auth-shell,
    .auth-shell.setup-shell {
        grid-template-columns: minmax(0, 1fr);
        gap: 30px;
        width: min(620px, calc(100% - 32px));
        padding: 32px 0 48px;
    }

    .auth-context {
        padding: 0 6px;
    }

    .workspace-grid,
    .settings-grid {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .metric-strip > div:nth-child(2) {
        border-right: 0;
    }

    .metric-strip > div:nth-child(-n+2) {
        border-bottom: 1px solid var(--line);
    }

    .page-shell {
        width: min(720px, calc(100% - 32px));
        padding-top: 30px;
        padding-bottom: 96px;
    }
}

@media (max-width: 620px) {
    .account-dropdown {
        top: 12px;
        right: 12px;
        max-width: calc(100% - 24px);
    }

    .topbar {
        min-height: 60px;
        padding: 0 14px;
    }

    .brand-mark {
        width: 33px;
        height: 33px;
    }

    .brand strong {
        max-width: 180px;
        overflow: hidden;
        font-size: 14px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .brand small {
        display: none;
    }

    .auth-shell,
    .auth-shell.setup-shell {
        min-height: calc(100vh - 60px);
        width: calc(100% - 24px);
        padding: 20px 0 36px;
    }

    .auth-tool {
        padding: 24px 18px;
    }

    h1 {
        font-size: 20px;
    }

    .form-grid.two,
    .code-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .stable-button {
        width: 100%;
        min-width: 0;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-heading .button {
        width: 100%;
    }

    .metric-strip {
        grid-template-columns: minmax(0, 1fr);
    }

    .metric-strip > div {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .metric-strip > div:last-child {
        border-bottom: 0;
    }

    .endpoint-row {
        grid-template-columns: 48px minmax(0, 1fr) 34px;
        gap: 10px;
        padding: 12px;
    }

    .method-badge {
        width: 48px;
    }

    .panel-heading {
        padding: 14px;
    }

    .panel-heading p {
        max-width: 230px;
    }

    .settings-panel > .form-stack,
    .settings-panel > .inline-action,
    .settings-panel > .settings-actions,
    .settings-panel > .form-divider {
        margin-right: 14px;
        margin-left: 14px;
    }

    .button-row,
    .inline-action,
    .button-row .button,
    .inline-action .button {
        width: 100%;
    }

    th:first-child,
    td:first-child {
        width: 155px;
    }

    th:nth-child(2),
    td:nth-child(2) {
        width: 170px;
    }

    .global-notice {
        top: 70px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
}

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