:root {
    --bg: #f3f3f1;
    --surface: #fff;
    --surface-soft: #fafafa;
    --text: #101010;
    --muted: #626262;
    --faint: #8a8a8a;
    --line: #dedede;
    --line-strong: #c9c9c9;
    --black: #0d0d0d;
    --danger: #9f1d1d;
    --shadow-sm: 0 8px 22px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 18px 46px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(180deg, #fff 0, var(--bg) 260px),
        var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    line-height: 1.65;
}

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

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    min-height: 70px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 clamp(18px, 4vw, 52px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
}

.admin-page {
    background:
        linear-gradient(180deg, #fff 0, #f4f4f2 220px),
        #f4f4f2;
}

.admin-topbar {
    border-bottom-color: #d8d8d8;
}

.admin-nav a {
    font-weight: 800;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
}

.brand::before {
    content: "";
    width: 10px;
    height: 28px;
    border-radius: 2px;
    background: var(--black);
}

.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    color: #242424;
    font-size: 14px;
}

.nav a {
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 6px;
}

.nav a:hover {
    background: #111;
    color: #fff;
}

.container {
    width: min(1160px, calc(100% - 36px));
    margin: 34px auto 58px;
}

.hero {
    position: relative;
    display: grid;
    gap: 10px;
    margin-bottom: 24px;
    padding: clamp(22px, 4vw, 34px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.hero::after {
    content: "";
    position: absolute;
    right: 24px;
    bottom: 18px;
    width: 96px;
    height: 8px;
    border-top: 2px solid #111;
    border-bottom: 2px solid #111;
    opacity: 0.08;
}

.hero h1 {
    margin: 0;
    font-size: clamp(32px, 5vw, 52px);
    line-height: 1.05;
    letter-spacing: 0;
}

.hero p {
    margin: 0;
    color: var(--muted);
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 18px;
}

.category-tabs a,
.badge {
    display: inline-flex;
    width: fit-content;
    min-height: 32px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 4px 12px;
    background: var(--surface);
    color: #222;
    font-size: 13px;
    font-weight: 700;
}

.category-tabs a {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
}

.category-tabs a:hover,
.category-tabs a.active {
    border-color: var(--black);
    background: var(--black);
    color: #fff;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
    gap: 18px;
}

.card,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card {
    position: relative;
    display: flex;
    min-height: 280px;
    flex-direction: column;
    padding: 22px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.product-image {
    width: 100%;
    aspect-ratio: 16 / 10;
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f2f2f2;
}

.product-image img,
.buy-image img,
.image-preview img,
.table-thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.buy-image {
    width: min(420px, 100%);
    aspect-ratio: 16 / 10;
    margin-bottom: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f2f2f2;
}

.image-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafafa;
    padding: 12px;
}

.image-preview img {
    width: 118px;
    height: 74px;
    flex: 0 0 auto;
    border-radius: 6px;
}

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

.table-thumb {
    width: 64px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f4f4f4;
}

.card:hover {
    border-color: #bdbdbd;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.badge {
    margin-bottom: 16px;
    background: var(--surface-soft);
    color: #1e1e1e;
}

.card h2 {
    margin: 0 0 10px;
    font-size: 23px;
    line-height: 1.25;
}

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

.card .muted {
    min-height: 54px;
    font-size: 15px;
}

.price {
    margin: 22px 0 14px;
    font-size: 34px;
    font-weight: 900;
    line-height: 1;
}

.stock {
    display: inline-flex;
    width: fit-content;
    min-height: 30px;
    align-items: center;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 3px 10px;
    background: #fbfbfb;
    color: #333;
    font-size: 13px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
}

.btn,
button.btn {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--black);
    border-radius: 6px;
    padding: 0 18px;
    background: var(--surface);
    color: var(--black);
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.btn:hover,
button.btn:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.10);
    transform: translateY(-1px);
}

.btn.primary,
button.btn.primary {
    background: var(--black);
    color: #fff;
}

.btn.primary:hover,
button.btn.primary:hover {
    background: #000;
}

.btn.danger {
    border-color: var(--danger);
    color: var(--danger);
}

.btn[disabled],
button[disabled] {
    border-color: #cfcfcf;
    background: #f6f6f6;
    color: var(--faint);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.panel {
    padding: clamp(20px, 3vw, 30px);
}

.panel + .panel,
.panel + .stats,
.stats + .panel {
    margin-top: 18px;
}

.panel h1,
.panel h2 {
    margin: 0 0 16px;
    line-height: 1.25;
}

.panel h1 {
    font-size: clamp(24px, 3vw, 32px);
}

.panel h2 {
    font-size: 22px;
}

.form-grid {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

label {
    display: grid;
    gap: 7px;
    color: #202020;
    font-size: 14px;
    font-weight: 800;
}

input,
textarea,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

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

input:focus,
textarea:focus,
select:focus {
    border-color: #111;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

hr {
    width: 100%;
    height: 1px;
    border: 0;
    background: var(--line);
}

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

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid #eeeeee;
    text-align: left;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: 0;
}

th {
    background: #f6f6f6;
    color: #3b3b3b;
    font-size: 13px;
    font-weight: 900;
}

tbody tr:hover {
    background: #fbfbfb;
}

.alert {
    margin: 0 0 16px;
    border: 1px solid var(--line-strong);
    border-left: 4px solid #111;
    border-radius: 8px;
    padding: 12px 14px;
    background: #fff;
    color: #222;
}

.alert-success {
    border-left-color: #111;
}

.alert-danger {
    border-color: #d8b7b7;
    border-left-color: var(--danger);
    color: var(--danger);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.admin-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: clamp(22px, 4vw, 34px);
    box-shadow: var(--shadow-sm);
}

.admin-hero h1 {
    margin: 8px 0 8px;
    font-size: clamp(30px, 4vw, 44px);
    line-height: 1.1;
}

.admin-hero p {
    max-width: 620px;
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    border: 1px solid #111;
    border-radius: 6px;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 900;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.metric-card {
    min-height: 138px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.metric-card span {
    color: #575757;
    font-size: 13px;
    font-weight: 900;
}

.metric-card strong {
    display: block;
    margin: 10px 0 8px;
    font-size: 30px;
    line-height: 1.1;
}

.metric-card small {
    color: var(--faint);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.status-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafafa;
    padding: 16px;
}

.status-item span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}

.status-item strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    line-height: 1;
}

.compact-list {
    display: grid;
    gap: 10px;
}

.compact-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafafa;
    padding: 12px 14px;
}

.compact-row span {
    overflow: hidden;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-row small {
    color: var(--faint);
}

.status-pill {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    border: 1px solid #d4d4d4;
    border-radius: 6px;
    padding: 2px 9px;
    background: #f8f8f8;
    color: #222;
    font-size: 13px;
    font-weight: 900;
}

.status-pill.danger {
    border-color: #d8b7b7;
    background: #fff7f7;
    color: var(--danger);
}

.stat {
    position: relative;
    min-height: 116px;
    overflow: hidden;
    border-radius: 8px;
    padding: 20px;
    background: var(--black);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.stat::after {
    content: "";
    position: absolute;
    right: 18px;
    bottom: 16px;
    width: 64px;
    height: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.38);
    border-bottom: 1px solid rgba(255, 255, 255, 0.38);
}

.stat span {
    color: rgba(255, 255, 255, 0.74);
    font-size: 13px;
    font-weight: 800;
}

.stat strong {
    display: block;
    margin-top: 8px;
    font-size: 32px;
    line-height: 1;
}

.cards-output {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.card-line {
    padding: 13px 14px;
    border: 1px dashed #bdbdbd;
    border-radius: 6px;
    background: #fafafa;
    white-space: pre-wrap;
    word-break: break-all;
}

.pay-waiting {
    margin-top: 16px;
    border: 1px dashed #bdbdbd;
    border-radius: 8px;
    background: #fafafa;
    padding: 13px 14px;
    color: var(--muted);
    font-weight: 800;
}

.footer {
    padding: 30px 16px;
    color: #777;
    font-size: 14px;
    text-align: center;
}

.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.58);
}

.modal-mask[hidden] {
    display: none;
}

.modal-box {
    width: min(520px, 100%);
    max-height: min(680px, calc(100vh - 36px));
    overflow: auto;
    border: 1px solid #111;
    border-radius: 8px;
    background: #fff;
    padding: 24px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

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

.modal-head h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.25;
}

.modal-body {
    color: #333;
    white-space: normal;
    word-break: break-word;
}

.icon-btn {
    display: inline-flex;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: #111;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.icon-btn:hover {
    background: #111;
    color: #fff;
}

.install-wrap {
    width: min(680px, calc(100% - 32px));
    margin: 52px auto;
}

.login-page {
    min-height: 100vh;
    background:
        linear-gradient(180deg, #fff 0, #f2f2f0 62%),
        #f2f2f0;
}

.login-topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 16px 0;
}

.login-shell {
    display: grid;
    min-height: calc(100vh - 88px);
    place-items: center;
    padding: 28px 16px 56px;
}

.login-panel {
    position: relative;
    width: min(440px, 100%);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 34px;
    box-shadow: var(--shadow-md);
}

.login-panel::before {
    content: "";
    display: block;
    width: 72px;
    height: 7px;
    margin-bottom: 24px;
    border-top: 2px solid #111;
    border-bottom: 2px solid #111;
}

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

.login-heading span {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    border: 1px solid #111;
    border-radius: 6px;
    padding: 2px 8px;
    color: #111;
    font-size: 12px;
    font-weight: 900;
}

.login-heading h1 {
    margin: 14px 0 0;
    font-size: 36px;
    line-height: 1.1;
}

.login-submit {
    width: 100%;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px 18px;
    }

    .nav {
        justify-content: flex-start;
    }

    .container {
        width: min(100% - 28px, 1160px);
        margin-top: 24px;
    }

    .hero {
        padding: 22px;
    }

    .card {
        min-height: 0;
    }

    .login-panel {
        padding: 28px;
    }

    .admin-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .compact-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

@media (max-width: 560px) {
    .shop-page .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .shop-page .card {
        min-height: 0;
        padding: 8px;
        border-radius: 7px;
    }

    .shop-page .product-image {
        margin-bottom: 8px;
        border-radius: 6px;
        aspect-ratio: 16 / 9;
    }

    .shop-page .badge {
        min-height: 22px;
        margin-bottom: 6px;
        padding: 1px 6px;
        font-size: 10px;
    }

    .shop-page .card h2 {
        display: -webkit-box;
        overflow: hidden;
        min-height: 0;
        margin-bottom: 4px;
        font-size: 15px;
        line-height: 1.25;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .shop-page .card .muted {
        display: -webkit-box;
        overflow: hidden;
        min-height: 0;
        font-size: 11px;
        line-height: 1.35;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
    }

    .shop-page .price {
        margin: 8px 0 6px;
        font-size: 20px;
    }

    .shop-page .stock {
        min-height: 22px;
        padding: 1px 6px;
        font-size: 10px;
    }

    .shop-page .actions {
        margin-top: 8px;
    }

    .shop-page .btn,
    .shop-page button.btn {
        width: 100%;
        min-height: 32px;
        padding: 0 8px;
        border-radius: 6px;
        font-size: 12px;
    }

    .shop-page .category-tabs {
        gap: 8px;
        margin-bottom: 12px;
    }

    .shop-page .category-tabs a {
        min-height: 30px;
        padding: 3px 9px;
        font-size: 12px;
    }
}

@media (max-width: 390px) {
    .shop-page .grid {
        gap: 8px;
    }

    .shop-page .card {
        padding: 7px;
    }

    .shop-page .card h2 {
        font-size: 14px;
    }

    .shop-page .price {
        font-size: 19px;
    }
}
