:root {
    --red: #a62b2b;
    --red-dark: #7c1f24;
    --ink: #202327;
    --muted: #687078;
    --line: #d9dde0;
    --soft: #f3f5f6;
    --surface: #fff;
    --green: #176b5d;
    --orange: #8a5b0a;
    --shell: 1240px;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--soft); font: 15px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
a { color: inherit; }
.admin-shell { width: min(calc(100% - 40px), var(--shell)); margin-inline: auto; }
.admin-header { color: #fff; background: #24282c; }
.header-row { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.admin-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.admin-brand span, .auth-brand span { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid #aeb4b9; border-radius: 50%; font-family: "KaiTi", serif; }
.admin-brand strong { font-size: 16px; }
.account-actions { display: flex; align-items: center; gap: 16px; color: #c8cdd1; font-size: 13px; }
.account-actions a, .account-actions button { color: #fff; background: transparent; border: 0; padding: 0; cursor: pointer; }
.account-actions form { margin: 0; }
.admin-nav { background: #fff; border-bottom: 1px solid var(--line); }
.admin-nav .admin-shell { display: flex; gap: 6px; overflow-x: auto; }
.admin-nav a { flex: 0 0 auto; padding: 14px 12px 11px; color: #535a60; border-bottom: 3px solid transparent; text-decoration: none; font-weight: 650; }
.admin-nav a:hover { color: var(--ink); }
.admin-nav a.is-active { color: var(--red-dark); border-color: var(--red); }
.admin-main { padding-block: 32px 70px; }
.page-heading { display: flex; min-height: 88px; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 24px; }
.page-heading p { margin: 0 0 5px; color: var(--red); font-size: 11px; font-weight: 800; }
.page-heading h1 { margin: 0; font-size: 28px; line-height: 1.2; }
.heading-count { color: var(--muted); font-size: 14px; }
.primary-button, .secondary-button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
}
.primary-button { color: #fff; background: var(--red); }
.primary-button:hover { background: var(--red-dark); }
.secondary-button { color: var(--ink); background: #fff; border-color: #bcc2c6; }
.secondary-button:hover { border-color: #777f85; }
.flash { margin: 0 0 14px; padding: 12px 14px; border-left: 4px solid; background: #fff; }
.flash-success { color: #125c4e; border-color: var(--green); }
.flash-error { color: #842929; border-color: var(--red); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.stats-grid > div { min-height: 126px; display: flex; flex-direction: column; justify-content: center; padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.stats-grid strong { font-size: 27px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stats-grid span { margin-top: 8px; color: var(--muted); font-size: 13px; }
.admin-section { margin-top: 18px; padding: 26px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.section-heading > a { color: var(--red-dark); font-size: 13px; }
.action-list { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.action-list a { min-height: 105px; display: flex; flex-direction: column; justify-content: center; padding: 20px; border-right: 1px solid var(--line); text-decoration: none; }
.action-list a:last-child { border-right: 0; }
.action-list a:hover { background: #f8f9fa; }
.action-list strong, .action-list span { display: block; }
.action-list span { margin-top: 4px; color: var(--muted); font-size: 13px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.filter-bar { display: flex; align-items: end; gap: 12px; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.filter-bar label { flex: 1 1 240px; }
.filter-bar label span, .admin-form label > span, .auth-form label > span { display: block; margin-bottom: 6px; color: #4c5359; font-size: 13px; font-weight: 700; }
.filter-bar input, .filter-bar select, .admin-form input, .admin-form select, .admin-form textarea, .auth-form input {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #bfc5c9;
    border-radius: 5px;
    outline: none;
}
.filter-bar input:focus, .filter-bar select:focus, .admin-form input:focus, .admin-form select:focus, .admin-form textarea:focus, .auth-form input:focus { border-color: #1467b8; box-shadow: 0 0 0 3px rgba(20,103,184,.14); }
.filter-bar > a { align-self: center; color: var(--red-dark); }
.table-section { padding: 0; overflow: hidden; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; min-width: 900px; border-collapse: collapse; table-layout: fixed; }
.admin-table th, .admin-table td { padding: 13px 14px; border-bottom: 1px solid #e1e4e6; text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
.admin-table thead th { color: #5f666c; background: #edf0f2; font-size: 12px; }
.admin-table tbody th { font-size: 14px; }
.admin-table tbody th small { display: block; margin-top: 3px; color: #92989d; font-weight: 400; }
.cell-note { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.admin-qr-thumb { display: block; width: 54px; height: 54px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.admin-table tbody tr:last-child > * { border-bottom: 0; }
.admin-table tbody tr:hover > * { background: #fbfbfc; }
.admin-table th:nth-child(1) { width: 21%; }
.admin-table th:nth-child(2) { width: 17%; }
.admin-table th:nth-child(3) { width: 20%; }
.admin-table th:nth-child(4) { width: 20%; }
.admin-table th:nth-child(5) { width: 10%; }
.admin-table th:nth-child(6) { width: 12%; }
.admin-price { color: var(--red-dark); font-weight: 750; }
.status { display: inline-block; padding: 3px 7px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.status-on { color: #125b4f; background: #e0f1ed; }
.status-off { color: #6d747a; background: #e8ebed; }
.row-actions { display: flex; align-items: center; gap: 10px; }
.row-actions a, .row-actions button { padding: 0; color: var(--red-dark); background: transparent; border: 0; cursor: pointer; font-size: 13px; }
.row-actions button:disabled { color: #a8adb1; cursor: not-allowed; }
.row-actions form { margin: 0; }
.empty-cell { padding: 38px !important; color: var(--muted); text-align: center !important; }
.form-section { scroll-margin-top: 20px; }
.admin-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.admin-form label { min-width: 0; }
.admin-form textarea { min-height: 86px; resize: vertical; }
.admin-form .span-2 { grid-column: 1 / -1; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: 18px; min-height: 18px; height: 18px; margin: 0; }
.check-label > span { margin: 0 !important; }
.form-actions { display: flex; justify-content: flex-start; padding-top: 4px; }
.narrow-section { max-width: 720px; }
.admin-form.single-column { grid-template-columns: 1fr; }
.article-editor textarea[name="content"] { min-height: 360px; line-height: 1.75; }
.upload-preview { display: flex; align-items: center; gap: 18px; padding: 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 5px; }
.upload-preview > img { display: block; width: 128px; height: 128px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.form-hint { margin: 0; color: var(--muted); font-size: 13px; }

.auth-body { min-height: 100vh; background: #fff; }
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, .85fr) minmax(480px, 1.15fr); }
.auth-intro { display: flex; flex-direction: column; justify-content: center; padding: 8vw; color: #fff; background: var(--red-dark); }
.auth-brand { position: absolute; top: 36px; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.auth-intro > p { margin: 0 0 8px; color: #f1c5c5; font-size: 13px; font-weight: 800; }
.auth-intro h1 { max-width: 440px; margin: 0; font-size: 38px; line-height: 1.25; }
.auth-points { display: grid; gap: 8px; margin-top: 35px; color: rgba(255,255,255,.72); font-size: 14px; }
.auth-points span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 10px; background: #f2bd62; border-radius: 50%; }
.auth-form-wrap { display: grid; place-items: center; padding: 42px; background: #f5f6f7; }
.auth-form-inner { width: min(100%, 450px); }
.back-link { display: inline-block; margin-bottom: 36px; color: var(--red-dark); font-size: 13px; }
.auth-form-inner h2 { margin: 0; font-size: 26px; }
.auth-form-inner > p { margin: 7px 0 24px; color: var(--muted); }
.auth-form { display: grid; gap: 16px; }
.auth-submit { width: 100%; margin-top: 4px; }

:focus-visible { outline: 3px solid #1467b8; outline-offset: 3px; }

@media (max-width: 850px) {
    .admin-shell { width: min(calc(100% - 28px), var(--shell)); }
    .account-actions > span { display: none; }
    .admin-main { padding-block: 22px 50px; }
    .page-heading { min-height: 72px; }
    .page-heading h1 { font-size: 24px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .action-list { grid-template-columns: 1fr; }
    .action-list a { min-height: 84px; border-right: 0; border-bottom: 1px solid var(--line); }
    .action-list a:last-child { border-bottom: 0; }
    .filter-bar { flex-wrap: wrap; }
    .admin-form { grid-template-columns: 1fr; }
    .admin-form .span-2 { grid-column: auto; }
    .auth-layout { grid-template-columns: 1fr; }
    .auth-intro { min-height: 300px; padding: 92px 28px 42px; }
    .auth-brand { top: 25px; }
    .auth-intro h1 { font-size: 31px; }
    .auth-points { grid-template-columns: 1fr 1fr; margin-top: 24px; }
    .auth-form-wrap { min-height: calc(100vh - 300px); padding: 42px 24px; }
}

@media (max-width: 520px) {
    .account-actions { gap: 11px; }
    .admin-brand strong { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .page-heading { align-items: flex-start; flex-direction: column; justify-content: center; gap: 12px; }
    .stats-grid { gap: 9px; }
    .stats-grid > div { min-height: 105px; padding: 17px; }
    .stats-grid strong { font-size: 23px; }
    .admin-section { padding: 19px; }
    .table-section { padding: 0; }
    .auth-points { grid-template-columns: 1fr; }
}
