:root {
    color-scheme: light;
    --color-canvas: #f5f5f7;
    --color-surface: #ffffff;
    --color-surface-secondary: #f9f9fb;
    --color-text: #1d1d1f;
    --color-text-secondary: #6e6e73;
    --color-text-weak: #86868b;
    --color-line: rgba(0, 0, 0, 0.08);
    --color-line-strong: rgba(0, 0, 0, 0.14);
    --color-accent: #0071e3;
    --color-accent-hover: #0077ed;
    --color-accent-active: #006edb;
    --color-success: #248a3d;
    --color-warning: #8a4b00;
    --color-error: #d70015;
    --shadow-floating: 0 12px 36px rgba(0, 0, 0, 0.11);
    --shadow-dialog: 0 24px 64px rgba(0, 0, 0, 0.2);
    --radius-control: 8px;
    --radius-button: 10px;
    --radius-panel: 14px;
    --radius-dialog: 18px;
    --font-ui: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 900px;
    min-height: 100%;
    background: var(--color-canvas);
    font-family: var(--font-ui);
}

body {
    min-width: 900px;
    min-height: 100vh;
    margin: 0;
    color: var(--color-text);
    background: var(--color-canvas);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

code,
.numeric,
.record-count,
.version-chip {
    font-variant-numeric: tabular-nums;
}

code {
    overflow-wrap: anywhere;
    font-family: "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
    font-size: 0.92em;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 6px;
    font-size: 28px;
    font-weight: 600;
    line-height: 36px;
    letter-spacing: -0.02em;
}

h2 {
    margin-bottom: 4px;
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
    letter-spacing: -0.01em;
}

h3 {
    margin-bottom: 4px;
    font-size: 17px;
    font-weight: 600;
    line-height: 24px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 12px;
    left: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-button);
    color: #ffffff;
    background: var(--color-accent);
    transform: translateY(-160%);
    transition: transform 140ms ease-out;
}

.skip-link:focus {
    transform: translateY(0);
}

:focus-visible {
    outline: 3px solid rgba(0, 113, 227, 0.52);
    outline-offset: 2px;
}

.app-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 24px 16px 20px;
    border-right: 1px solid var(--color-line);
    background: rgba(249, 249, 251, 0.94);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 48px;
    padding: 4px 8px 18px;
    text-decoration: none;
}

.brand-mark {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    color: #ffffff;
    background: var(--color-accent);
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
}

.brand-mark-large {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    font-size: 21px;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 15px;
    font-weight: 650;
}

.brand small {
    margin-top: 1px;
    color: var(--color-text-secondary);
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--radius-button);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-weight: 550;
    transition: color 140ms ease, background-color 140ms ease;
}

.nav-link:hover {
    color: var(--color-text);
    background: rgba(0, 0, 0, 0.035);
}

.nav-link.is-active {
    color: var(--color-accent);
    background: rgba(0, 113, 227, 0.09);
}

.privacy-note {
    margin: auto 8px 0;
    color: var(--color-text-weak);
    font-size: 12px;
    line-height: 18px;
}

.app-column {
    min-width: 0;
}

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 32px;
    border-bottom: 1px solid var(--color-line);
    background: rgba(245, 245, 247, 0.82);
    backdrop-filter: blur(18px) saturate(160%);
}

.topbar > div {
    display: flex;
    gap: 10px;
    align-items: baseline;
}

.topbar-label {
    color: var(--color-text-secondary);
    font-size: 12px;
}

.main-content {
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: 32px clamp(24px, 2.5vw, 40px) 48px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    min-height: 74px;
    margin-bottom: 24px;
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--color-accent);
    font-size: 12px;
    font-weight: 650;
    line-height: 18px;
    letter-spacing: 0.04em;
}

.page-description,
.section-heading p,
.operation-copy p,
.settings-copy p {
    margin-bottom: 0;
    color: var(--color-text-secondary);
}

.workspace-panel,
.detail-panel,
.receipt-panel {
    overflow: hidden;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-panel);
    background: var(--color-surface);
}

.operation-row {
    display: grid;
    grid-template-columns: minmax(230px, 0.8fr) minmax(380px, 1.2fr);
    gap: 32px;
    align-items: end;
    padding: 24px;
    border-bottom: 1px solid var(--color-line);
}

.operation-row-primary {
    background: rgba(0, 113, 227, 0.035);
}

.operation-copy p {
    max-width: 540px;
}

.inline-form,
.query-form,
.extend-form,
.action-grid {
    display: flex;
    gap: 12px;
    align-items: end;
}

.query-form,
.field-grow {
    min-width: 0;
}

.query-form .field-grow {
    flex: 1 1 auto;
}

.field-group {
    display: grid;
    gap: 6px;
}

.field-group label,
.settings-copy label {
    font-weight: 600;
}

.field-compact {
    min-width: 148px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    scroll-margin-top: 84px;
    padding: 9px 12px;
    border: 1px solid var(--color-line-strong);
    border-radius: var(--radius-control);
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea {
    min-height: 124px;
    resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
    border-color: rgba(0, 0, 0, 0.25);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.16);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: var(--color-error);
}

input::placeholder {
    color: var(--color-text-weak);
}

.field-hint,
.field-error {
    font-size: 12px;
    line-height: 18px;
}

.field-hint {
    color: var(--color-text-weak);
}

.field-error {
    color: var(--color-error);
}

.field-error:empty,
.validation-summary-valid {
    display: none;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-button);
    text-decoration: none;
    white-space: nowrap;
    font-weight: 600;
    line-height: 20px;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, transform 120ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:active:not(:disabled) {
    transform: translateY(0);
}

.button:disabled {
    color: var(--color-text-weak);
    background: var(--color-surface-secondary);
    border-color: var(--color-line);
    cursor: not-allowed;
    opacity: 0.72;
}

.button-primary {
    min-height: 44px;
    color: #ffffff;
    background: var(--color-accent);
}

.button-primary:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.button-primary:active:not(:disabled) {
    background: var(--color-accent-active);
}

.button-secondary,
.button-quiet,
.button-danger-quiet {
    color: var(--color-text);
    border-color: var(--color-line-strong);
    background: var(--color-surface-secondary);
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
    background: #f0f0f3;
}

.button-quiet {
    min-height: 44px;
    padding-inline: 14px;
}

.button-danger-quiet {
    color: #a20010;
    background: #fff7f7;
    border-color: rgba(215, 0, 21, 0.2);
}

.button-danger,
.dialog-symbol-danger {
    color: #ffffff;
    background: var(--color-error);
}

.button-danger:hover:not(:disabled) {
    background: #bd0012;
}

.button-full {
    width: 100%;
}

.table-section {
    padding-top: 6px;
}

.section-heading {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
}

.table-heading {
    border-bottom: 1px solid var(--color-line);
}

.section-heading h2,
.section-heading h3 {
    margin-bottom: 2px;
}

.record-count,
.version-chip,
.receipt-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    color: var(--color-text-secondary);
    background: var(--color-surface-secondary);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

table {
    width: 100%;
    min-width: 880px;
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--color-line);
    vertical-align: middle;
}

th:first-child,
td:first-child {
    padding-left: 24px;
}

th:last-child,
td:last-child {
    padding-right: 24px;
}

th {
    color: var(--color-text-secondary);
    background: var(--color-surface-secondary);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: rgba(0, 113, 227, 0.025);
}

.table-action {
    text-align: right;
    white-space: nowrap;
}

.text-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--color-accent);
    font-weight: 600;
    text-underline-offset: 3px;
}

.status-badge,
.audit-result {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border: 1px solid var(--color-line);
    border-radius: 999px;
    color: var(--color-text-secondary);
    background: var(--color-surface-secondary);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-active {
    color: #176b2c;
    border-color: rgba(36, 138, 61, 0.2);
    background: rgba(36, 138, 61, 0.08);
}

.status-unbound {
    color: #005ebd;
    border-color: rgba(0, 113, 227, 0.2);
    background: rgba(0, 113, 227, 0.08);
}

.status-disabled,
.status-expired,
.status-invalid,
.status-device-conflict {
    color: #a20010;
    border-color: rgba(215, 0, 21, 0.18);
    background: rgba(215, 0, 21, 0.06);
}

.empty-state {
    padding: 48px 24px;
    text-align: center;
    background: var(--color-surface-secondary);
}

.empty-state strong {
    display: block;
    margin-bottom: 4px;
    font-size: 17px;
}

.empty-state p {
    margin-bottom: 0;
    color: var(--color-text-secondary);
}

.empty-state .button {
    margin-top: 16px;
}

.empty-state-error {
    background: #fffafa;
}

.detail-panel {
    margin-top: 24px;
}

.detail-heading {
    border-bottom: 1px solid var(--color-line);
}

.detail-grid,
.receipt-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
}

.detail-grid > div,
.receipt-meta > div {
    min-width: 0;
    padding: 18px 24px;
    border-right: 1px solid var(--color-line);
    border-bottom: 1px solid var(--color-line);
}

.detail-grid > div:nth-child(3n),
.receipt-meta > div:nth-child(3n) {
    border-right: 0;
}

.detail-grid dt,
.receipt-meta dt {
    margin-bottom: 5px;
    color: var(--color-text-secondary);
    font-size: 12px;
}

.detail-grid dd,
.receipt-meta dd {
    margin: 0;
    font-weight: 550;
}

.action-section {
    padding-bottom: 22px;
}

.compact-heading {
    padding-bottom: 12px;
}

.action-grid {
    flex-wrap: wrap;
    padding: 0 24px;
}

.extend-form {
    padding-left: 12px;
    border-left: 1px solid var(--color-line);
}

.extend-form input {
    width: 112px;
}

.inline-note {
    align-self: center;
    margin: 0;
    color: var(--color-text-secondary);
}

.action-section > .field-hint {
    margin: 10px 24px 0;
}

.alert {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-button);
    color: var(--color-text);
    background: var(--color-surface);
}

.alert:empty {
    display: none;
}

.alert-success {
    color: #176b2c;
    border-color: rgba(36, 138, 61, 0.2);
    background: #f4fbf5;
}

.alert-error {
    color: #8f0010;
    border-color: rgba(215, 0, 21, 0.18);
    background: #fff7f7;
}

.validation-summary {
    align-items: flex-start;
}

.validation-summary strong {
    display: block;
    margin-bottom: 3px;
}

.validation-summary ul {
    margin: 0;
    padding-left: 20px;
}

.validation-summary a {
    color: inherit;
    text-underline-offset: 3px;
}

.confirm-dialog {
    width: min(460px, calc(100vw - 48px));
    padding: 0;
    border: 0;
    border-radius: var(--radius-dialog);
    color: var(--color-text);
    background: var(--color-surface);
    box-shadow: var(--shadow-dialog);
}

.confirm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(2px);
}

.confirm-dialog form {
    padding: 28px;
}

.confirm-dialog h2 {
    margin: 16px 0 8px;
}

.confirm-dialog p {
    margin-bottom: 22px;
    color: var(--color-text-secondary);
}

.dialog-symbol,
.status-symbol {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-weight: 750;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.receipt-panel {
    max-width: 920px;
}

.receipt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid var(--color-line);
}

.receipt-header h2 {
    margin: 6px 0 0;
}

.receipt-kicker {
    color: var(--color-accent);
    background: rgba(0, 113, 227, 0.08);
}

.card-key-reveal {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 28px 24px;
    border-bottom: 1px solid var(--color-line);
    background: #f4f8fd;
}

.card-key-reveal > span {
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.card-key-reveal code {
    color: #003f7d;
    font-size: 16px;
    font-weight: 650;
    letter-spacing: 0.025em;
}

.receipt-warning {
    display: flex;
    gap: 10px;
    align-items: baseline;
    margin: 20px 24px 24px;
    padding: 14px 16px;
    border-radius: var(--radius-control);
    color: #6f3b00;
    background: #fff8ee;
}

.receipt-warning span {
    color: var(--color-text-secondary);
}

.page-actions {
    margin-top: 18px;
}

.configuration-panel .section-heading {
    border-bottom: 1px solid var(--color-line);
}

.settings-row {
    display: grid;
    grid-template-columns: minmax(250px, 0.75fr) minmax(360px, 1.25fr);
    gap: 32px;
    padding: 24px;
    border-bottom: 1px solid var(--color-line);
}

.settings-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 24px;
}

.settings-actions p {
    margin: 0;
    color: var(--color-text-secondary);
}

.login-body {
    display: grid;
    place-items: center;
    padding: 48px 24px;
    background: var(--color-canvas);
}

.login-shell {
    width: min(100%, 480px);
}

.login-panel {
    padding: 36px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-dialog);
    background: var(--color-surface);
    box-shadow: var(--shadow-floating);
}

.login-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 12px;
}

.login-brand h1 {
    margin-bottom: 0;
}

.stack-form {
    display: grid;
    gap: 18px;
    margin-top: 26px;
}

.login-boundary {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--color-line);
    color: var(--color-text-weak);
    font-size: 12px;
}

.error-panel {
    text-align: center;
}

.status-symbol-error {
    margin: 0 auto 16px;
    color: #ffffff;
    background: var(--color-error);
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 204px minmax(0, 1fr);
    }

    .topbar {
        padding-inline: 24px;
    }

    .main-content {
        padding-top: 24px;
    }

    .operation-row,
    .settings-row {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-grid > div:nth-child(3n) {
        border-right: 1px solid var(--color-line);
    }

    .detail-grid > div:nth-child(2n) {
        border-right: 0;
    }
}

@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;
    }
}
