:root {
    color-scheme: light;
    --ink: #192226;
    --muted: #627078;
    --line: #d7e0e4;
    --panel: #ffffff;
    --page: #eef5f4;
    --teal: #0f766e;
    --blue: #2563eb;
    --green: #17803d;
    --amber: #b7791f;
    --red: #b42318;
    --shadow: 0 12px 36px rgba(31, 49, 54, .13);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    background: var(--page);
    color: var(--ink);
}

a {
    color: inherit;
}

.mobile-page {
    min-height: 100vh;
    background:
        linear-gradient(145deg, rgba(15, 118, 110, .14), transparent 34%),
        linear-gradient(25deg, rgba(37, 99, 235, .12), transparent 42%),
        var(--page);
}

.phone-shell {
    width: min(100%, 520px);
    margin: 0 auto;
    padding: 18px 14px 36px;
}

.hero-card {
    border-radius: 8px;
    padding: 22px;
    background: linear-gradient(135deg, #113c42, #0f766e 58%, #2f7d9a);
    color: #fff;
    box-shadow: var(--shadow);
}

.brand-row,
.panel-title,
.admin-top,
.toolbar,
.qr-actions,
.stat-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, .36);
    border-radius: 50%;
    font-weight: 800;
    background: rgba(255, 255, 255, .12);
}

.status-pill,
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.is-active,
.badge-active {
    background: rgba(23, 128, 61, .14);
    color: var(--green);
}

.hero-card .is-active {
    background: rgba(255, 255, 255, .18);
    color: #fff;
}

.is-pending,
.badge-pending {
    background: rgba(183, 121, 31, .15);
    color: var(--amber);
}

.hero-card .is-pending {
    background: rgba(255, 255, 255, .18);
    color: #fff6db;
}

.hero-card h1 {
    margin: 24px 0 8px;
    font-size: 31px;
    line-height: 1.16;
    letter-spacing: 0;
}

.hero-card p {
    margin: 0;
    opacity: .86;
    word-break: break-all;
}

.warranty-meter {
    margin-top: 22px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, .26);
    border-radius: 8px;
    background: rgba(255, 255, 255, .12);
}

.warranty-meter span,
.warranty-meter small {
    display: block;
    color: rgba(255, 255, 255, .78);
}

.warranty-meter strong {
    display: block;
    margin: 6px 0;
    font-size: 30px;
    line-height: 1.12;
    letter-spacing: 0;
}

.panel,
.notice {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(31, 49, 54, .07);
}

.panel {
    padding: 18px;
}

.panel-title {
    align-items: flex-start;
    margin-bottom: 14px;
}

.panel-title h2 {
    margin: 0;
    font-size: 19px;
    letter-spacing: 0;
}

.panel-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.notice {
    padding: 12px 14px;
    font-weight: 700;
}

.notice.success {
    color: var(--green);
    background: #f0fbf4;
}

.notice.error {
    color: var(--red);
    background: #fff4f2;
}

.form-stack {
    display: grid;
    gap: 13px;
}

.address-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.duration-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.form-stack label,
.field {
    display: grid;
    gap: 7px;
}

.form-stack span,
.field span {
    color: #37474f;
    font-size: 14px;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #cfd9de;
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

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

.primary-btn,
.secondary-btn,
.danger-btn,
.link-btn {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    font: inherit;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

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

.secondary-btn {
    background: #e7f0ef;
    color: #0d514c;
}

.danger-btn {
    background: #fff0ed;
    color: var(--red);
}

.link-btn {
    background: #eef2ff;
    color: #2343a0;
}

.detail-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.detail-list div {
    display: grid;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid #edf2f4;
}

.detail-list div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

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

.detail-list dd {
    margin: 0;
    line-height: 1.62;
    word-break: break-word;
}

.text-block {
    margin: 0;
    color: #29383e;
    line-height: 1.8;
    word-break: break-word;
}

.text-block strong {
    color: var(--ink);
}

.muted {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.admin-page {
    min-height: 100vh;
    background: #f4f7f7;
}

.admin-wrap {
    width: min(1160px, calc(100% - 28px));
    margin: 0 auto;
    padding: 22px 0 42px;
}

.admin-top {
    margin-bottom: 18px;
}

.admin-top h1 {
    margin: 0;
    font-size: 26px;
    letter-spacing: 0;
}

.admin-top p {
    margin: 5px 0 0;
    color: var(--muted);
}

.admin-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-grid {
    align-items: stretch;
    margin-bottom: 14px;
}

.stat {
    flex: 1;
    min-width: 150px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #fff;
}

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

.stat strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

.toolbar {
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.toolbar form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.table-panel {
    overflow-x: auto;
}

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

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid #e7eef0;
    text-align: left;
    vertical-align: top;
}

th {
    color: #45575f;
    font-size: 13px;
    background: #f7fbfb;
}

td {
    font-size: 14px;
}

.code-text {
    font-family: Consolas, "SFMono-Regular", monospace;
    font-weight: 800;
}

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

.batch-list-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #e3ecef;
    border-radius: 8px;
    background: #f8fbfb;
}

.check-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #37474f;
    font-size: 14px;
    font-weight: 700;
}

.check-field input,
.check-cell input {
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0;
    accent-color: var(--teal);
}

.check-cell {
    width: 58px;
    text-align: center;
}

.delete-confirm {
    display: grid;
    gap: 14px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #edf2f4;
}

.login-card {
    width: min(420px, calc(100% - 28px));
    margin: 9vh auto;
    padding: 24px;
}

.qr-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 18px;
}

.qr-box {
    display: grid;
    place-items: center;
    min-height: 320px;
    border: 1px dashed #b9c9ce;
    border-radius: 8px;
    background: #fbfefe;
}

.qr-box svg {
    width: min(288px, 100%);
    height: auto;
}

.qr-url {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfb;
    color: #26363c;
    word-break: break-all;
}

.batch-panel {
    overflow: hidden;
}

.batch-title {
    gap: 18px;
}

.batch-help {
    margin: -4px 0 16px;
}

.batch-print-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.batch-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 132px;
    gap: 14px;
    min-height: 180px;
    padding: 14px;
    border: 1px solid #cbd9de;
    border-radius: 8px;
    background: #fff;
    break-inside: avoid;
    page-break-inside: avoid;
}

.batch-card-copy {
    display: grid;
    align-content: start;
    gap: 8px;
    min-width: 0;
}

.batch-card-brand,
.batch-card-copy small,
.batch-card-qr-wrap small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.batch-card-copy strong {
    font-size: 22px;
    line-height: 1.18;
    letter-spacing: 0;
}

.batch-card-copy p {
    margin: 0;
    color: #3d4f56;
    font-size: 13px;
    line-height: 1.55;
}

.batch-code {
    display: block;
    padding-top: 4px;
    font-size: 14px;
    line-height: 1.35;
    word-break: break-all;
}

.batch-card-qr-wrap {
    display: grid;
    align-content: start;
    justify-items: center;
    gap: 7px;
}

.batch-card-qr {
    display: grid;
    place-items: center;
    width: 124px;
    height: 124px;
    border: 1px solid #e2ecef;
    background: #fff;
}

.batch-card-qr svg {
    display: block;
    width: 114px;
    height: 114px;
}

.batch-card-qr-error {
    padding: 8px;
    color: var(--red);
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
}

.edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.edit-grid .wide {
    grid-column: 1 / -1;
}

@media (max-width: 760px) {
    .admin-top,
    .toolbar,
    .stat-grid,
    .qr-actions,
    .batch-list-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-nav,
    .toolbar form,
    .actions {
        width: 100%;
    }

    .primary-btn,
    .secondary-btn,
    .danger-btn,
    .link-btn {
        width: 100%;
    }

    .qr-layout,
    .edit-grid,
    .address-picker,
    .duration-picker {
        grid-template-columns: 1fr;
    }

    .batch-title {
        flex-direction: column;
        align-items: stretch;
    }

    .batch-card {
        grid-template-columns: minmax(0, 1fr) 116px;
    }

    .batch-card-qr {
        width: 108px;
        height: 108px;
    }

    .batch-card-qr svg {
        width: 98px;
        height: 98px;
    }

    .hero-card h1 {
        font-size: 28px;
    }
}

@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    body {
        background: #fff;
    }

    .admin-top,
    .qr-actions,
    .detail-list,
    .qr-url,
    .field,
    .no-print {
        display: none;
    }

    .admin-wrap,
    .panel {
        width: auto;
        margin: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .qr-layout {
        display: block;
    }

    .qr-box {
        border: 0;
        min-height: 0;
    }

    .batch-panel {
        overflow: visible;
    }

    .batch-print-grid {
        grid-template-columns: repeat(2, 89mm);
        gap: 6mm;
        align-items: start;
        justify-content: start;
    }

    .batch-card {
        grid-template-columns: 1fr 31mm;
        gap: 4mm;
        width: 89mm;
        min-height: 54mm;
        padding: 4mm;
        border: 1px solid #111;
        border-radius: 2mm;
        box-shadow: none;
    }

    .batch-card-copy {
        gap: 2mm;
    }

    .batch-card-brand,
    .batch-card-copy small,
    .batch-card-qr-wrap small {
        color: #333;
        font-size: 8pt;
    }

    .batch-card-copy strong {
        font-size: 15pt;
    }

    .batch-card-copy p {
        color: #222;
        font-size: 8pt;
        line-height: 1.45;
    }

    .batch-code {
        font-size: 8.5pt;
    }

    .batch-card-qr {
        width: 31mm;
        height: 31mm;
        border: 0;
    }

    .batch-card-qr svg {
        width: 31mm;
        height: 31mm;
    }
}
