:root {
    --ink: #20272c;
    --ink-soft: #526068;
    --muted: #7d898f;
    --line: #dfe4e5;
    --line-strong: #cbd3d5;
    --surface: #ffffff;
    --canvas: #f3f5f4;
    --sidebar: #20282d;
    --sidebar-soft: #2d373d;
    --teal: #137c6d;
    --teal-dark: #0c6659;
    --teal-soft: #e4f2ef;
    --amber: #b86109;
    --amber-soft: #fff1d8;
    --danger: #b43d3d;
    --danger-soft: #fdeaea;
    --shadow: 0 16px 42px rgba(24, 34, 38, 0.08);
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html {
    min-width: 320px;
    color-scheme: light;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

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

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

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

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    width: 248px;
    flex-direction: column;
    color: #eef3f2;
    background: var(--sidebar);
}

.brand {
    display: flex;
    height: 78px;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 6px;
    color: #fff;
    background: var(--teal);
    font-size: 18px;
    font-weight: 800;
}

.brand-copy,
.login-brand > span:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.brand-copy strong,
.login-brand strong {
    font-size: 17px;
    line-height: 1.15;
}

.brand-copy small {
    margin-top: 3px;
    color: #8fa0a7;
    font-size: 11px;
}

.nav-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    padding: 26px 14px;
}

.nav-label {
    padding: 0 12px 9px;
    color: #7f9097;
    font-size: 11px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    border-radius: 6px;
    color: #aebbc0;
    font-weight: 600;
    transition: color 160ms ease, background 160ms ease;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.is-active {
    color: #fff;
    background: var(--teal);
}

.nav-item svg {
    width: 19px;
    height: 19px;
}

.sidebar-footer {
    padding: 16px 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-profile {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    align-items: center;
    gap: 10px;
}

.avatar {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 50%;
    color: #bfe7df;
    background: var(--sidebar-soft);
    font-weight: 700;
}

.admin-profile > span:nth-child(2) {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.admin-profile strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
}

.admin-profile small {
    color: #82949b;
    font-size: 11px;
}

.admin-profile form {
    margin: 0;
}

.icon-button {
    display: inline-grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 5px;
    color: var(--ink-soft);
    background: transparent;
    cursor: pointer;
}

.icon-button:hover {
    color: var(--ink);
    background: #edf0f0;
}

.icon-button-dark {
    color: #82949b;
}

.icon-button-dark:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.main-content {
    min-height: 100vh;
    margin-left: 248px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    height: 78px;
    align-items: center;
    gap: 14px;
    padding: 0 36px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.topbar h1 {
    margin: 1px 0 0;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.2;
}

.topbar-context {
    color: var(--muted);
    font-size: 11px;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: var(--ink-soft);
    font-size: 12px;
}

.connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2b9c66;
    box-shadow: 0 0 0 4px #e5f4eb;
}

.menu-button,
.sidebar-scrim {
    display: none;
}

.page-content {
    width: min(1120px, calc(100% - 56px));
    margin: 0 auto;
    padding: 34px 0 56px;
}

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

.eyebrow {
    display: block;
    margin-bottom: 5px;
    color: var(--teal);
    font-size: 10px;
    font-weight: 800;
}

.page-heading h2,
.records-heading h3 {
    margin: 0;
    font-size: 26px;
    font-weight: 750;
    line-height: 1.25;
}

.page-heading p {
    margin: 7px 0 0;
    color: var(--ink-soft);
    font-size: 13px;
}

.module-tabs {
    display: flex;
    min-height: 48px;
    align-items: flex-end;
    gap: 24px;
    margin: -6px 0 22px;
    border-bottom: 1px solid var(--line-strong);
}

.module-tabs a {
    position: relative;
    display: inline-flex;
    min-height: 47px;
    align-items: center;
    gap: 8px;
    padding: 0 2px;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 650;
}

.module-tabs a::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: transparent;
    content: "";
}

.module-tabs a:hover,
.module-tabs a.is-active {
    color: var(--teal-dark);
}

.module-tabs a.is-active::after {
    background: var(--teal);
}

.module-tabs svg {
    width: 17px;
    height: 17px;
}

.status-badge,
.table-status {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.status-badge > span,
.table-status > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
}

.status-ready {
    color: var(--teal-dark);
    border-color: #b9dcd4;
    background: var(--teal-soft);
}

.status-ready > span,
.table-status.is-success > span {
    background: #268c62;
}

.status-pending {
    color: var(--amber);
    border-color: #efd5a8;
    background: var(--amber-soft);
}

.status-pending > span,
.table-status.is-pending > span {
    background: #d08413;
}

.alert,
.validation-summary {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: 6px;
    font-size: 13px;
}

.alert svg,
.validation-summary > svg {
    width: 18px;
    height: 18px;
    margin-top: 1px;
}

.alert-success {
    color: #17654d;
    border-color: #b7dfd3;
    background: #e9f6f2;
}

.alert-error,
.validation-summary {
    color: #963535;
    border-color: #efc1c1;
    background: var(--danger-soft);
}

.alert-close {
    width: 28px;
    height: 28px;
    margin: -5px -6px -5px auto;
    color: currentColor;
}

.validation-summary p {
    margin: 0;
}

.validation-summary p + p {
    margin-top: 3px;
}

.tool-panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.form-section {
    margin: 0;
    padding: 28px 30px 30px;
    border: 0;
    border-bottom: 1px solid var(--line);
}

.form-section legend {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 0 0 22px;
}

.form-section legend > span:last-child,
.member-form-head > div > span:last-child {
    display: flex;
    flex-direction: column;
}

.form-section legend strong,
.member-form-head strong {
    font-size: 15px;
}

.form-section legend small,
.member-form-head small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
}

.section-number {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 5px;
    color: var(--teal-dark);
    background: var(--teal-soft);
    font-size: 11px;
    font-weight: 800;
}

.field-grid {
    display: grid;
    gap: 20px;
}

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

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

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

.field-label {
    display: flex;
    min-height: 21px;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    color: #344046;
    font-size: 13px;
    font-weight: 650;
}

.field-label b {
    color: var(--danger);
}

.field-hint {
    min-height: 18px;
    margin: -2px 0 7px;
    color: var(--muted);
    font-size: 11px;
}

.saved-mark {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: var(--teal);
    font-size: 10px;
    font-style: normal;
    font-weight: 650;
}

.saved-mark svg {
    width: 13px;
    height: 13px;
    stroke-width: 2.5;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    outline: none;
    background: #fff;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

input,
select {
    height: 43px;
    padding: 0 12px;
}

textarea {
    min-height: 148px;
    padding: 11px 12px;
    resize: vertical;
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 12px;
    line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
    color: #a5aeb2;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(19, 124, 109, 0.12);
}

input:disabled,
select:disabled,
textarea:disabled {
    color: #8e979a;
    background: #f0f2f2;
    cursor: not-allowed;
}

.secret-input,
.password-input {
    position: relative;
    display: block;
}

.secret-input input,
.password-input input {
    padding-right: 44px;
}

.secret-input .password-toggle,
.password-input .password-toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
}

.segmented-control {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #edf0ef;
}

.segmented-wide {
    width: min(100%, 430px);
}

.segmented-control label {
    position: relative;
    cursor: pointer;
}

.segmented-control input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.segmented-control label > span {
    display: flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 16px;
    border-radius: 4px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.segmented-control input:checked + span {
    color: var(--teal-dark);
    background: #fff;
    box-shadow: 0 1px 3px rgba(25, 36, 40, 0.1);
}

.segmented-control input:focus-visible + span {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
}

.form-actions {
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 30px;
    background: #fafbfa;
}

.last-updated {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 11px;
}

.last-updated svg {
    width: 15px;
    height: 15px;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 17px;
    border: 1px solid transparent;
    border-radius: 5px;
    font-weight: 650;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

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

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

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

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

.button-secondary:hover {
    border-color: #9ca9ad;
    background: #f8f9f9;
}

.button:disabled {
    color: #849096;
    border-color: #d5dadd;
    background: #e6e9ea;
    cursor: not-allowed;
    transform: none;
}

.member-form {
    padding-top: 0;
}

.member-form-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 30px;
    border-bottom: 1px solid var(--line);
}

.member-form-head > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.document-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--teal);
    font-size: 12px;
    font-weight: 650;
}

.document-link svg:last-child {
    width: 13px;
    height: 13px;
}

.member-form > .field-grid {
    padding: 28px 30px;
}

.cashier-fields {
    margin: 0 30px 30px;
    padding: 22px;
    border: 1px solid #bddbd5;
    border-radius: 6px;
    background: #f2f9f7;
}

.cashier-fields[hidden] {
    display: none;
}

.card-private-fields {
    margin-top: 0;
}

[data-public-mark][hidden] {
    display: none;
}

.card-records-table {
    min-width: 920px;
}

.cashier-fields legend {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 8px;
    color: var(--teal-dark);
    font-size: 12px;
    font-weight: 700;
}

.cashier-fields legend svg {
    width: 16px;
    height: 16px;
}

.records-section {
    margin-top: 34px;
}

.records-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 15px;
}

.records-heading h3 {
    font-size: 19px;
}

.record-count {
    color: var(--muted);
    font-size: 12px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.records-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    text-align: left;
}

.records-table th {
    height: 43px;
    padding: 0 18px;
    color: var(--muted);
    background: #f7f8f8;
    font-size: 11px;
    font-weight: 700;
}

.records-table td {
    height: 62px;
    padding: 10px 18px;
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 12px;
}

.member-code {
    color: #2d383e;
    font-family: Consolas, "SFMono-Regular", monospace;
    font-weight: 650;
}

.record-person {
    display: flex;
    flex-direction: column;
    color: #344046;
}

.record-person small {
    margin-top: 2px;
    color: var(--muted);
}

.table-status {
    min-height: 26px;
    padding: 3px 9px;
    font-size: 10px;
}

.table-status.is-success {
    color: #1e7257;
    border-color: #c7e2d9;
    background: #edf8f4;
}

.table-status.is-pending {
    color: #9a570a;
    border-color: #efd9b7;
    background: #fff7e8;
}

.table-status.is-failed {
    color: #9c3b3b;
    border-color: #ecc5c5;
    background: #fff0f0;
}

.table-status.is-failed > span {
    background: #c65353;
}

.empty-cell {
    height: 150px !important;
    text-align: center;
}

.empty-cell svg,
.empty-cell strong {
    display: block;
    margin: 0 auto;
}

.empty-cell svg {
    width: 26px;
    height: 26px;
    margin-bottom: 8px;
    color: #9ba6aa;
}

.empty-cell strong {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

/* Login */
.login-page {
    min-height: 100vh;
    background: #fff;
}

.login-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(410px, 44%) minmax(0, 1fr);
}

.login-identity {
    position: relative;
    display: flex;
    overflow: hidden;
    flex-direction: column;
    padding: 42px 52px;
    color: #f2f6f5;
    background: var(--sidebar);
}

.login-identity::before,
.login-identity::after {
    position: absolute;
    content: "";
    pointer-events: none;
}

.login-identity::before {
    top: 118px;
    right: -90px;
    width: 310px;
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(-38deg);
}

.login-identity::after {
    right: 52px;
    bottom: 118px;
    width: 86px;
    height: 86px;
    border-right: 1px solid rgba(97, 208, 188, 0.35);
    border-bottom: 1px solid rgba(97, 208, 188, 0.35);
}

.login-brand {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark-light {
    color: var(--sidebar);
    background: #69c8b8;
}

.login-brand small {
    margin-top: 3px;
    color: #81959d;
    font-size: 9px;
    font-weight: 650;
}

.identity-content {
    position: relative;
    z-index: 1;
    width: min(100%, 480px);
    margin: auto 0;
}

.identity-index,
.identity-footer {
    color: #72cbbb;
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 10px;
    font-weight: 650;
}

.identity-content h1 {
    margin: 16px 0 24px;
    font-size: 38px;
    line-height: 1.35;
}

.identity-rule {
    width: 44px;
    height: 3px;
    margin-bottom: 34px;
    background: #67c7b6;
}

.identity-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.identity-stats > span {
    display: flex;
    min-height: 80px;
    flex-direction: column;
    justify-content: center;
    padding: 12px 18px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.identity-stats > span:first-child {
    padding-left: 0;
}

.identity-stats > span:last-child {
    border-right: 0;
}

.identity-stats strong {
    color: #dff6f1;
    font-size: 17px;
}

.identity-stats small {
    margin-top: 4px;
    color: #82959d;
    font-size: 10px;
}

.identity-footer {
    color: #6f8188;
}

.login-panel {
    display: grid;
    place-items: center;
    padding: 50px;
}

.login-form {
    width: min(100%, 390px);
}

.login-heading {
    margin-bottom: 30px;
}

.login-kicker {
    color: var(--teal);
    font-size: 12px;
    font-weight: 700;
}

.login-heading h2 {
    margin: 6px 0 5px;
    font-size: 28px;
    line-height: 1.3;
}

.login-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.login-form > .field {
    margin-bottom: 18px;
}

.input-with-icon > svg {
    position: absolute;
    top: 50%;
    left: 13px;
    z-index: 1;
    width: 17px;
    height: 17px;
    color: #849096;
    transform: translateY(-50%);
}

.input-with-icon input {
    height: 48px;
    padding-left: 42px;
}

.login-submit {
    width: 100%;
    min-height: 48px;
    margin-top: 10px;
}

.login-alert {
    margin-bottom: 20px;
}

@media (max-width: 980px) {
    .login-shell {
        grid-template-columns: minmax(340px, 40%) minmax(0, 1fr);
    }

    .login-identity {
        padding: 34px;
    }

    .identity-content h1 {
        font-size: 31px;
    }

    .identity-stats {
        grid-template-columns: 1fr;
    }

    .identity-stats > span {
        min-height: 58px;
        padding: 10px 0;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .identity-stats > span:last-child {
        border-bottom: 0;
    }
}

@media (max-width: 760px) {
    .sidebar {
        width: min(286px, calc(100vw - 46px));
        transform: translateX(-102%);
        transition: transform 200ms ease;
    }

    .sidebar-scrim {
        position: fixed;
        inset: 0;
        z-index: 35;
        background: rgba(18, 24, 27, 0.48);
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-shell.sidebar-open .sidebar-scrim {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .topbar {
        height: 66px;
        padding: 0 18px;
    }

    .menu-button {
        display: inline-grid;
        margin-left: -6px;
    }

    .topbar-meta {
        display: none;
    }

    .page-content {
        width: calc(100% - 28px);
        padding: 24px 0 38px;
    }

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

    .page-heading h2 {
        font-size: 22px;
    }

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

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

    .form-section,
    .member-form > .field-grid {
        padding: 22px 18px;
    }

    .member-form-head {
        padding: 20px 18px;
    }

    .form-actions {
        padding: 14px 18px;
    }

    .cashier-fields {
        margin: 0 18px 22px;
        padding: 18px;
    }

    .login-shell {
        display: block;
    }

    .login-identity {
        min-height: 220px;
        padding: 28px 24px;
    }

    .identity-content {
        margin: 32px 0 0;
    }

    .identity-content h1 {
        margin: 10px 0 0;
        font-size: 27px;
        line-height: 1.3;
    }

    .identity-rule,
    .identity-stats,
    .identity-footer {
        display: none;
    }

    .login-panel {
        min-height: calc(100vh - 220px);
        padding: 38px 24px;
        place-items: start center;
    }
}

@media (max-width: 520px) {
    .page-heading {
        flex-direction: column;
        gap: 14px;
    }

    .status-badge {
        align-self: flex-start;
    }

    .segmented-wide {
        width: 100%;
    }

    .segmented-control label > span {
        min-height: 44px;
        padding: 7px 9px;
        white-space: normal;
        text-align: center;
    }

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

    .form-actions .button {
        width: 100%;
    }

    .last-updated {
        justify-content: center;
    }

    .member-form-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .login-identity {
        min-height: 200px;
    }

    .login-panel {
        min-height: calc(100vh - 200px);
    }
}

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