:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #17191a;
    --muted: #66717c;
    --line: #d9e1ea;
    --brand: #1475b8;
    --brand-strong: #0d5f9a;
    --brand-soft: #e7f2fb;
    --accent: #17191a;
    --bad: #b42318;
    --warn: #b7791f;
    --ok: #177245;
    --blue: #1475b8;
    --shadow: 0 18px 45px rgba(20, 42, 66, .12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

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

a {
    color: inherit;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 480px);
    gap: 28px;
    align-items: center;
    padding: 48px;
    background:
        linear-gradient(135deg, rgba(20, 117, 184, .1), rgba(255, 255, 255, 0) 38%),
        linear-gradient(90deg, #ffffff 0%, #ffffff 58%, #edf4fb 58%, #edf4fb 100%);
}

.login-brand {
    min-height: 640px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 56px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.login-brand::after {
    content: "";
    position: absolute;
    right: -120px;
    bottom: -120px;
    width: 360px;
    height: 360px;
    border: 42px solid rgba(20, 117, 184, .1);
    transform: rotate(12deg);
}

.login-brand img {
    width: min(560px, 92%);
    height: auto;
    margin-bottom: 46px;
}

.brand-block {
    width: 82px;
    height: 82px;
    background: var(--brand);
    margin-bottom: 24px;
}

.login-brand h1 {
    font-size: clamp(34px, 4.4vw, 62px);
    line-height: 1.06;
    margin-bottom: 18px;
}

.login-brand p:not(.eyebrow) {
    max-width: 620px;
    margin: 0;
    color: #4d5964;
    font-size: 18px;
    line-height: 1.8;
}

.login-panel {
    width: min(460px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 34px;
    box-shadow: var(--shadow);
}

.login-logo {
    display: none;
    width: 260px;
    max-width: 100%;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

h1,
h2 {
    margin: 0 0 12px;
    letter-spacing: 0;
}

h1 {
    font-size: 30px;
}

h2 {
    font-size: 20px;
}

.muted,
.hint {
    color: var(--muted);
}

.hint {
    margin: 18px 0 0;
    font-size: 13px;
    line-height: 1.6;
}

.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: #2f3942;
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #c8d5e2;
    border-radius: 6px;
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
    font-weight: 400;
}

textarea {
    resize: vertical;
}

button,
.link-button {
    border: 0;
    border-radius: 6px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}

button:disabled,
button[disabled] {
    cursor: not-allowed;
    opacity: .62;
    box-shadow: none;
}

form.is-submitting {
    cursor: progress;
}

form.is-submitting button {
    pointer-events: none;
}

.submit-status {
    margin: 10px 0 0;
    border: 1px solid #c6dff1;
    border-radius: 6px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
}

.required-status {
    margin: 10px 0 0;
    border: 1px solid #f0c7c4;
    border-radius: 6px;
    background: #fff4f3;
    color: var(--bad);
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
}

.required-status.ok {
    border-color: #b9dec8;
    background: #eef8f2;
    color: var(--ok);
}

.primary {
    background: var(--brand);
    color: #fff;
    font-weight: 700;
}

.primary:hover {
    background: var(--brand-strong);
}

.secondary,
.link-button {
    background: var(--brand-soft);
    color: var(--brand-strong);
    border: 1px solid #c6dff1;
}

.ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.multi-select-count {
    display: block;
    margin-top: 6px;
}

option:disabled {
    color: #97a3af;
}

label.is-readonly select[multiple] {
    background: #f3f6f9;
    color: var(--muted);
    border-style: dashed;
}

.inline-warning {
    display: block;
    margin-top: 6px;
    color: var(--bad);
    font-size: 13px;
    line-height: 1.5;
}

.import-line-count {
    display: block;
    margin-top: 6px;
}

.import-source-hint {
    display: block;
    margin-top: 6px;
}

.small {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 13px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 3;
    background: rgba(255, 255, 255, .98);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    box-shadow: 0 8px 28px rgba(22, 37, 54, .06);
}

.brand-mark,
.topbar nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.brand-mark img {
    width: 210px;
    height: auto;
    display: block;
}

.topbar span {
    color: var(--muted);
    font-size: 14px;
}

.topbar a {
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--muted);
}

.topbar a.active {
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 700;
}

.topbar form {
    margin: 0;
}

.page {
    width: min(1240px, calc(100% - 32px));
    margin: 24px auto 48px;
}

.notice {
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid #bdd8ca;
    background: #eef8f2;
    color: #145c36;
}

.notice.bad {
    border-color: #f2b8b5;
    background: #fff0ef;
    color: var(--bad);
}

.next-step-hint {
    border-top: 1px solid rgba(20, 92, 54, 0.18);
    margin: 12px 0 0;
    padding-top: 10px;
    color: #24313d;
    line-height: 1.6;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.summary-grid div,
.summary-grid .summary-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 10px 24px rgba(20, 42, 66, .05);
}

.summary-grid .summary-card {
    color: inherit;
    text-decoration: none;
}

.summary-grid .danger-card {
    border-color: #f2b8b5;
    background: #fff0ef;
}

.summary-grid .danger-card span,
.summary-grid .danger-card strong {
    color: var(--bad);
}

.summary-grid span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.summary-grid strong {
    display: block;
    margin-top: 6px;
    font-size: 28px;
}

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

.stats-grid strong {
    font-size: 22px;
}

.section-head {
    margin-bottom: 16px;
}

.sort-panel {
    margin-bottom: 16px;
}

.sort-form {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sort-form > span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.sort-form label {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 7px 10px;
    background: #fff;
    cursor: pointer;
}

.sort-form input {
    width: auto;
    margin: 0;
}

.compact-button {
    min-height: 36px;
    padding: 7px 12px;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
    gap: 12px;
    align-items: end;
}

.records-filter {
    grid-template-columns: repeat(5, minmax(140px, 1fr)) auto auto;
}

.active-filter-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
    padding: 10px 12px;
    background: #f4f8fb;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.active-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.filter-pill {
    background: #ffffff;
    color: var(--ink);
}

.admin-sections {
    display: grid;
    gap: 22px;
}

.store-switcher {
    margin-bottom: 12px;
}

.store-switcher select {
    width: min(360px, 100%);
}

.store-name {
    margin: 0 0 12px;
    font-weight: 700;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

th,
td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
}

th {
    background: #edf4fb;
    color: #46534e;
    font-size: 13px;
}

td p {
    margin: 6px 0 0;
    line-height: 1.5;
}

.empty-state-row td {
    padding: 0;
}

.empty-state {
    padding: 18px 16px;
}

.empty-state strong {
    display: block;
    font-size: 15px;
}

.empty-state p {
    margin: 8px 0 0;
    max-width: 720px;
}

.thumb {
    width: 92px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
    display: block;
}

.photo-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.photo-thumb-button {
    display: block;
    padding: 0;
    min-height: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
}

.photo-thumb-button:focus-visible {
    outline: 3px solid rgba(20, 117, 184, .35);
    outline-offset: 2px;
}

.upload-preview {
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #f8fbfd;
}

.upload-field-hint {
    display: block;
    margin-top: 6px;
    line-height: 1.5;
}

.upload-preview-summary {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.upload-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.upload-preview-clear {
    flex: 0 0 auto;
    min-height: 34px;
}

.upload-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}

.upload-preview-list {
    display: grid;
    gap: 6px;
}

.upload-preview-item {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px;
    background: #fff;
}

.upload-preview-item img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 6px;
}

.upload-preview-item span,
.upload-preview-item strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 12px;
    line-height: 1.35;
}

.upload-preview-item strong {
    margin-top: 3px;
    color: var(--bad);
}

.upload-preview-warning {
    border-color: rgba(192, 57, 43, .45);
    background: #fff7f6;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 700;
}

.status-ok,
.status-closed {
    background: #e7f5ed;
    color: var(--ok);
}

.status-issue {
    background: #fff0df;
    color: var(--warn);
}

.status-corrected {
    background: #e8f0fb;
    color: var(--blue);
}

.status-uninspected {
    background: #eef2f6;
    color: var(--muted);
}

.status-rejected,
.status-overdue {
    background: #fff0ef;
    color: var(--bad);
}

.reject-form {
    margin-top: 10px;
}

.actions {
    min-width: 190px;
}

.actions button,
.actions .link-button {
    margin: 0 6px 6px 0;
}

dialog {
    width: min(520px, calc(100% - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

dialog::backdrop {
    background: rgba(8, 16, 13, .5);
}

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

.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.dialog-head h2 {
    margin-bottom: 4px;
}

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

.timeline li {
    border-left: 3px solid var(--blue);
    border-radius: 6px;
    padding: 10px 12px;
    background: #f8fbfd;
}

.timeline strong,
.timeline span,
.timeline p {
    display: block;
}

.timeline span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.timeline p {
    margin: 8px 0 0;
    line-height: 1.5;
}

.photo-viewer {
    width: min(920px, calc(100% - 32px));
    padding: 14px;
}

.photo-viewer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.photo-viewer-count {
    display: block;
    margin-top: 3px;
}

.photo-viewer-status {
    display: block;
    min-height: 18px;
    margin-top: 3px;
    line-height: 1.4;
}

.photo-viewer-stage {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.photo-viewer img {
    display: block;
    width: 100%;
    max-height: 78vh;
    object-fit: contain;
    border-radius: 6px;
    background: #f2f5f8;
}

.photo-nav-button {
    min-width: 68px;
    min-height: 44px;
    white-space: nowrap;
}

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

.bulk-preview-list {
    display: grid;
    gap: 8px;
    max-height: 46vh;
    overflow: auto;
    padding-right: 4px;
}

.bulk-preview-item {
    display: grid;
    grid-template-columns: minmax(56px, .5fr) minmax(88px, .8fr) minmax(0, 2fr);
    gap: 10px;
    align-items: start;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    background: #f8fbfd;
}

.bulk-preview-item strong,
.bulk-preview-item span,
.bulk-preview-item p {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.bulk-preview-item span {
    color: var(--muted);
}

.admin-layout {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

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

.manual-card ol {
    margin: 8px 0 14px;
    padding-left: 22px;
    line-height: 1.8;
}

.manual-card li {
    margin-bottom: 6px;
}

.manual-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 12px;
}

.manual-context {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin: 10px 0 12px;
}

.manual-context div {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    background: #f8fbfd;
}

.manual-context span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.manual-context strong,
.manual-context .link-button {
    margin-top: 6px;
}

.manual-context p {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.store-scope-summary {
    display: block;
    margin-top: 6px;
    line-height: 1.6;
}

.import-helper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px dashed #c6dff1;
    border-radius: 6px;
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.import-helper strong {
    grid-column: 1 / -1;
}

.import-helper span {
    color: var(--text);
}

.status-guide {
    display: grid;
    grid-template-columns: minmax(88px, 120px) minmax(0, 1fr);
    gap: 8px 12px;
    margin: 10px 0 0;
}

.status-guide dt {
    font-weight: 700;
    color: #24313d;
}

.status-guide dd {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.restore-preview {
    margin-top: 16px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.restore-preview h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.restore-warning {
    margin: 12px 0;
    padding: 12px;
    border: 1px solid #f3c3bd;
    border-radius: 6px;
    background: #fff8f7;
}

.restore-warning h4 {
    margin: 0 0 8px;
    color: var(--bad);
    font-size: 14px;
}

.restore-error {
    border-color: #f2a9a1;
    background: #fff0ef;
}

.restore-danger-check {
    margin: 14px 0;
    padding: 12px;
    border: 1px solid #e2b26d;
    border-radius: 6px;
    background: #fff8ec;
    color: var(--ink);
}

.restore-danger-check strong {
    display: block;
    margin-bottom: 6px;
    color: #8a4f08;
}

.restore-danger-check ul {
    margin: 0;
    padding-left: 18px;
}

.restore-warning ul {
    margin: 0;
    padding-left: 18px;
}

@media (max-width: 820px) {
    .login-shell {
        grid-template-columns: 1fr;
        padding: 24px;
        background: #edf4fb;
    }

    .login-brand {
        display: none;
    }

    .login-panel {
        margin: auto;
    }

    .login-logo {
        display: block;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 10;
        display: block;
        padding: 12px 16px;
    }

    .brand-mark img {
        width: 170px;
    }

    .topbar nav {
        flex-wrap: nowrap;
        gap: 8px;
        margin-top: 10px;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .topbar a,
    .topbar nav button {
        min-height: 40px;
        white-space: nowrap;
    }

    .summary-grid,
    .admin-layout,
    .manual-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-layout,
    .manual-grid,
    .filter-bar,
    .records-filter {
        grid-template-columns: 1fr;
    }

    .manual-context {
        grid-template-columns: 1fr;
    }

    .import-helper {
        grid-template-columns: 1fr;
    }

    dialog {
        width: min(100% - 20px, 560px);
        max-height: calc(100dvh - 24px);
        overflow: auto;
        padding: 16px;
    }

    .wide-dialog {
        width: min(100% - 20px, 760px);
    }

    .dialog-actions {
        position: sticky;
        bottom: -16px;
        z-index: 2;
        flex-wrap: wrap;
        margin: 4px -16px -16px;
        padding: 12px 16px 16px;
        border-top: 1px solid var(--line);
        background: var(--panel);
    }

    .dialog-actions button {
        min-height: 44px;
    }

    table {
        min-width: 0;
    }

    .table-wrap {
        overflow: visible;
        background: transparent;
        border: 0;
        border-radius: 0;
    }

    thead {
        display: none;
    }

    tr {
        display: grid;
        margin-bottom: 12px;
        padding: 8px 0;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
        box-shadow: 0 8px 18px rgba(46, 62, 56, .06);
    }

    td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 12px;
        border-bottom: 0;
        padding: 8px 14px;
    }

    td + td {
        border-top: 1px solid #edf1ee;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 13px;
        font-weight: 700;
    }

    td .link-button,
    td button {
        width: fit-content;
        max-width: 100%;
    }

    .photo-gallery {
        max-width: 100%;
    }
}

@media (max-width: 560px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .topbar nav {
        width: 100%;
    }

    td {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .status-guide {
        grid-template-columns: 1fr;
    }

    .bulk-preview-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .upload-preview-head {
        align-items: stretch;
        flex-direction: column;
    }

    td::before {
        margin-bottom: -4px;
    }
}
