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

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: #f4faf6;
    color: #121212;
    font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    caret-color: #121212;
}

::selection {
    background: #d8ff3e;
    color: #121212;
}

.admin-shell {
    color-scheme: light;
}

.num {
    font-family: "DIN Alternate", "Avenir Next Condensed", "PingFang SC", sans-serif;
    font-variant-numeric: tabular-nums;
}

.pill {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.pill-on {
    background: #d8ff3e;
    color: #121212;
}

.pill-off {
    background: #e7eaee;
    color: #3e4651;
    font-weight: 500;
}

.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;
}

.login-page {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 400px);
    background: #ffffff;
    border-radius: 16px;
    padding: 40px 32px 32px;
    box-shadow: 0 1px 0 #eceef2;
}

.login-title {
    margin: 0 0 28px;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: center;
}

.alert {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #eef0f3;
    color: #121212;
    font-size: 14px;
}

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

.login-form .btn-primary {
    width: 100%;
    margin-top: 4px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-label {
    font-size: 14px;
    font-weight: 500;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #7a838d;
    border-radius: 10px;
    background: #ffffff;
    color: #121212;
    font: inherit;
}

.field textarea {
    min-height: 88px;
    resize: vertical;
    line-height: 1.5;
}

.field select {
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5' stroke='%23121212' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
}

.field input::placeholder,
.field textarea::placeholder {
    color: #4e5660;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid #121212;
    outline-offset: 2px;
    border-color: #121212;
}

.field-hint {
    color: #3e4651;
    font-size: 12px;
    line-height: 1.4;
}

.field.check-field,
.check-field {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.field.check-field input[type="checkbox"],
.check-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    accent-color: #121212;
}

.btn-primary {
    margin-top: 4px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: #121212;
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

a.btn-primary,
a.btn-primary:visited,
a.btn-primary:hover {
    color: #ffffff;
}

.btn-primary:hover {
    opacity: 0.92;
}

.btn-primary:active,
.btn-secondary:active {
    opacity: 0.72;
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary:focus-visible {
    outline: 2px solid #d8ff3e;
    outline-offset: 2px;
}

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

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 24px 16px 20px;
    background: #ffffff;
    border-right: 1px solid #7a838d;
}

.sidebar-brand {
    margin-bottom: 28px;
    padding: 0 8px;
    font-family: "DIN Alternate", "Avenir Next Condensed", "PingFang SC", sans-serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.16em;
}

.nav-group {
    margin-bottom: 20px;
}

.nav-heading {
    margin: 0 0 8px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 600;
    color: #3e4651;
    text-transform: none;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 10px;
    border-radius: 8px;
    color: #121212;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 160ms ease-out, color 160ms ease-out, opacity 160ms ease-out;
}

.nav-link:hover {
    background: #e7eeea;
}

.nav-link.is-active,
.nav-link.is-active:hover {
    background: #121212;
    color: #ffffff;
    font-weight: 600;
}

.nav-link:focus-visible {
    outline: 2px solid #121212;
    outline-offset: 2px;
}

.nav-link.is-active:focus-visible {
    outline-color: #d8ff3e;
}

.logout-form {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #7a838d;
}

.logout-btn {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 24px;
}

.content-card {
    min-height: calc(100vh - 48px);
    background: #ffffff;
    border-radius: 16px;
    padding: 28px 32px;
    box-shadow: 0 1px 0 #eceef2;
}

.page-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.btn-inline {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
    text-decoration: none;
    text-align: center;
    white-space: nowrap;
}

.btn-secondary {
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid #7a838d;
    border-radius: 10px;
    background: #ffffff;
    color: #121212;
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #f4faf6;
}

.btn-secondary:focus-visible {
    outline: 2px solid #121212;
    outline-offset: 2px;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 20px;
}

.field-inline {
    min-width: 180px;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 480px;
    margin-bottom: 24px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eceef2;
    text-align: left;
}

.data-table th {
    font-weight: 600;
    color: #121212;
    opacity: 0.7;
}

.data-table a {
    color: #121212;
    font-weight: 500;
}

.empty-state {
    padding: 24px 0;
    color: #121212;
    opacity: 0.8;
}

.empty-state a {
    color: #121212;
    font-weight: 600;
}

.meta-row,
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    font-size: 14px;
}

.inline-form {
    display: inline;
}

.field-readonly {
    padding: 8px 0;
}

.section-block {
    margin-top: 32px;
}

.section-title {
    margin: 0 0 12px;
    font-size: 18px;
}

.grant-pill {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: #e7eaee;
    color: #3e4651;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.grant-pill.pill-on {
    background: #d8ff3e;
    color: #121212;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px 20px;
    margin-bottom: 24px;
    font-size: 14px;
}

.detail-label {
    display: block;
    font-size: 12px;
    opacity: 0.6;
    margin-bottom: 4px;
}

.price-note,
.muted {
    font-size: 12px;
    opacity: 0.65;
}

dialog {
    border: 1px solid #7a838d;
    border-radius: 16px;
    padding: 20px 22px;
    max-width: 400px;
    color: #121212;
    box-shadow: 0 16px 40px rgba(18, 18, 18, 0.16);
}

dialog::backdrop {
    background: rgba(18, 18, 18, 0.45);
}

dialog.sheet-dialog {
    width: min(640px, calc(100vw - 32px));
    max-width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #7a838d;
    border-radius: 16px;
    background: #ffffff;
    color: #121212;
}

dialog.sheet-dialog:not(:has(.editor-form)) {
    width: min(400px, calc(100vw - 32px));
    max-width: min(400px, calc(100vw - 32px));
    padding: 20px 22px;
    overflow: auto;
}

.dialog-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.dialog-actions .btn-primary,
.dialog-actions .btn-secondary {
    width: auto;
    margin-top: 0;
}

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

.desk,
.catalog {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    min-width: 0;
}

.desk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
}

.desk-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.desk-meta {
    margin: 0;
    color: #3e4651;
    font-size: 14px;
    white-space: nowrap;
}

.desk-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
}

.desk-actions form {
    display: flex;
    margin: 0;
}

.desk-actions .btn-primary,
.desk-actions .btn-secondary,
.desk-bar > .btn-primary,
.desk-bar > a.btn-primary,
.editor-actions .btn-primary,
.editor-actions .btn-secondary,
.pending-row .btn-primary {
    width: auto;
    min-height: 40px;
    margin-top: 0;
    padding: 8px 16px;
    flex: 0 0 auto;
}

.catalog .filter-form,
.desk .filter-form {
    margin-bottom: 0;
}

.quiet-link {
    color: #121212;
    font-weight: 600;
}

.banner {
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.banner-ok {
    background: #e7f3bc;
    color: #121212;
}

.banner-error {
    background: #121212;
    color: #ffffff;
}

.banner-error:focus {
    outline: 2px solid #d8ff3e;
    outline-offset: 2px;
}

.sheet,
.panel {
    background: #ffffff;
    border: 1px solid #7a838d;
    border-radius: 16px;
    width: 100%;
    min-width: 0;
}

.sheet {
    overflow: hidden;
}

.pending-band {
    padding: 14px 16px 8px;
}

.pending-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.editor-bar h2 {
    margin: 0;
    min-width: 0;
    overflow: hidden;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pending-head p {
    margin: 6px 0 0;
    max-width: 68ch;
    color: #3e4651;
    font-size: 13px;
}

.pending-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 12px;
    margin: 0;
    padding: 12px 0;
    border-top: 1px solid #7a838d;
}

.pending-row:first-of-type {
    border-top: 0;
}

.pending-id {
    flex: 1 1 180px;
    min-width: 0;
    padding-bottom: 8px;
}

.pending-name,
.pending-price {
    margin: 0;
}

.pending-name {
    font-weight: 600;
}

.pending-price {
    color: #3e4651;
    font-size: 14px;
}

.pending-row .field {
    flex: 1 1 140px;
    width: auto;
    min-width: 0;
    max-width: 180px;
    gap: 6px;
}

.pending-row .btn-primary {
    margin-left: auto;
}

.ledger-empty {
    padding: 32px 16px 36px;
}

.ledger-empty p {
    margin: 0;
    color: #121212;
    font-weight: 600;
}

.ledger-empty p + p {
    margin-top: 4px;
    color: #3e4651;
    font-size: 14px;
    font-weight: 400;
}

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

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #7a838d;
    background: #ffffff;
}

.pager-link,
.pager-edge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid #7a838d;
    border-radius: 10px;
    background: #ffffff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.pager-link {
    color: #121212;
    text-decoration: none;
}

.pager-link:hover {
    background: #f4faf6;
}

.pager-link:focus-visible {
    outline: 2px solid #121212;
    outline-offset: 2px;
}

.pager-edge {
    color: #7a838d;
}

.pager-status {
    margin: 0;
    color: #3e4651;
    font-size: 14px;
}

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: #ffffff;
    font-size: 14px;
}

.ledger-table th,
.ledger-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #7a838d;
    text-align: left;
    vertical-align: middle;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ledger-table th {
    background: #f6f8f7;
    color: #3e4651;
    font-size: 12px;
    font-weight: 600;
}

.ledger-table .col-main {
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
}

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

.ledger-table .num,
.ledger-table .num-col {
    text-align: left;
    white-space: nowrap;
    overflow-wrap: normal;
}

.ledger-row {
    cursor: pointer;
    transition: background-color 160ms ease-out;
}

.ledger-table tbody td:has(> .row-link) {
    position: relative;
}

.ledger-row:hover {
    background: #f4faf6;
}

.ledger-row.is-selected,
.ledger-row.is-selected:hover {
    background: #e7eeea;
}

.ledger-row:focus-within {
    outline: 2px solid #121212;
    outline-offset: -2px;
}

.row-link {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    color: #121212;
    font-weight: 600;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.row-link::after {
    content: "";
    position: absolute;
    z-index: 1;
    inset: 0;
}

.row-spec {
    display: block;
    color: #3e4651;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
}

.editor-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #7a838d;
}

.sheet-dialog .editor-form {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 32px);
    min-height: 0;
}

.editor-body {
    padding: 16px 20px 20px;
    overflow: auto;
    max-height: min(70vh, 720px);
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #7a838d #ffffff;
}

.sheet-dialog .editor-bar,
.sheet-dialog .editor-actions {
    flex: 0 0 auto;
}

.sheet-dialog .editor-body {
    flex: 1 1 auto;
    max-height: calc(100vh - 220px);
}

.editor-body::-webkit-scrollbar {
    width: 10px;
}

.editor-body::-webkit-scrollbar-thumb {
    background: #7a838d;
    border: 2px solid #ffffff;
    border-radius: 999px;
}

.editor-body fieldset,
.editor fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.editor-body .field {
    gap: 6px;
}

.editor-body .field textarea {
    min-height: 72px;
}

.editor-body fieldset + fieldset,
.editor fieldset + fieldset {
    margin-top: 16px;
}

.editor-body legend,
.editor legend {
    margin: 0 0 10px;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    color: #3e4651;
}

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

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

.field[data-media-field] {
    position: relative;
}

.field input.media-file {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.media-preview {
    width: 168px;
    aspect-ratio: 16 / 10;
    border: 1px solid #7a838d;
    border-radius: 10px;
    overflow: hidden;
    background: #f7f8f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-preview:empty {
    display: none;
}

.media-preview.wide {
    width: 240px;
}

.media-preview img,
.media-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.member-identity.has-face {
    display: grid;
    grid-template-columns: 168px minmax(0, 1fr);
    align-items: start;
    gap: 16px 20px;
}

.member-identity.has-face .form-grid {
    justify-self: start;
    width: min(100%, 560px);
}

.face-portrait {
    display: block;
    width: 168px;
    aspect-ratio: 3 / 4;
    border: 1px solid #7a838d;
    border-radius: 10px;
    overflow: hidden;
    background: #f4faf6;
    text-decoration: none;
}

.face-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
}

.face-portrait:hover {
    border-color: #121212;
}

.face-portrait:focus-visible {
    outline: 2px solid #121212;
    outline-offset: 2px;
}

.face-grid {
    list-style: none;
    margin: 0;
    padding: 16px 20px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 20px 16px;
}

.face-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
}

.face-card-name,
.face-card-no {
    margin: 0;
    max-width: 168px;
    overflow-wrap: anywhere;
}

.face-card-name {
    font-size: 14px;
}

.media-preview video {
    object-fit: contain;
    background: #121212;
}

.media-file-name {
    margin: 0;
    padding: 8px;
    font-size: 12px;
    line-height: 1.4;
    word-break: break-all;
    text-align: center;
}

.media-actions,
.media-gallery {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}

.media-shot {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.media-error {
    margin: 0;
    color: #121212;
    font-weight: 600;
}

.media-error:empty {
    display: none;
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 12px 20px;
    border-top: 1px solid #7a838d;
}

.editor-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}

.editor-tools-end {
    margin-left: auto;
}

@media (max-width: 800px) {
    .shell {
        flex-direction: column;
    }

    .sidebar {
        width: auto;
        border-right: 0;
        border-bottom: 1px solid #7a838d;
        padding: 16px 12px 12px;
    }

    .sidebar-brand {
        margin-bottom: 12px;
    }

    .nav-group {
        margin-bottom: 8px;
    }

    .nav-list {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .nav-link {
        min-height: 44px;
    }

    .logout-form {
        margin-top: 4px;
        padding-top: 8px;
    }

    .main {
        padding: 16px 12px 24px;
    }

    .form-grid,
    .member-identity.has-face {
        grid-template-columns: 1fr;
    }

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

    .ledger-table .col-days,
    .ledger-table .col-source {
        display: none;
    }

    .ledger-table th,
    .ledger-table td {
        padding: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-link,
    .ledger-row,
    .btn-primary,
    .btn-secondary {
        transition: none;
    }
}
