:root {
    --bg: #f6f6f3;
    --card: #fff;
    --ink: #1d1e22;
    --muted: #74757c;
    --line: #e6e5e0;
    --soft: #f1f1ed;
    --blue: #2c5fd0;
    --blue-50: #edf2fe;
    --red: #d23a2f;
    --red-50: #fdeeec;
    --green: #1f8a4c;
    --green-50: #e8f5ee;
    --amber: #a8670f;
    --amber-50: #fdf3e2;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 6px 20px rgba(20, 20, 30, .04);
    font-family: "IBM Plex Sans KR", Pretendard, "Malgun Gothic", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

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

h1 {
    font-size: 26px;
    margin: 0;
    letter-spacing: -.02em;
    line-height: 1.25;
}

h2 {
    font-size: 17px;
    margin: 0 0 12px;
    letter-spacing: -.01em;
}

p {
    margin: 0 0 8px;
}

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

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

.small {
    font-size: 13px;
}

.center {
    text-align: center;
}

.mt {
    margin-top: 20px;
}

.mb {
    margin-bottom: 16px;
}

.nowrap {
    white-space: nowrap;
}

.text-red {
    color: var(--red);
    font-weight: 700;
}

.text-amber {
    color: var(--amber);
    font-weight: 700;
}

.link {
    color: var(--blue);
    font-weight: 600;
}

.link-quiet:hover {
    text-decoration: underline;
}

/* 상단 메뉴 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.topbar-in {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 20px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.logo {
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -.03em;
    white-space: nowrap;
}

.logo b {
    color: var(--blue);
}

.nav {
    display: flex;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
}

.nav a {
    padding: 8px 12px;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.nav a:hover {
    color: var(--ink);
    background: var(--soft);
}

.nav a.on {
    color: var(--ink);
    background: var(--soft);
}

.user-area {
    display: flex;
    gap: 8px;
    align-items: center;
}

body.admin {
    --bg: #f3f4f6;
}

body.admin .topbar {
    background: #18191d;
    border-color: #18191d;
    color: #fff;
}

body.admin .logo b {
    color: #8fb0ff;
}

body.admin .nav a {
    color: #a3a4ab;
}

body.admin .nav a:hover, body.admin .nav a.on {
    background: #2b2c33;
    color: #fff;
}

body.admin .user-area .btn {
    background: #2b2c33;
    border-color: #3a3b43;
    color: #fff;
}

main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 20px 96px;
}

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

.back {
    display: inline-block;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.back:hover {
    color: var(--ink);
}

/* 카드 · 레이아웃 */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

.card.narrow {
    max-width: 620px;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.summary {
    position: sticky;
    top: 84px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cols-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 22px;
}

.line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}

.line:last-child {
    border-bottom: 0;
}

.line.total {
    border-top: 2px solid var(--ink);
    border-bottom: 0;
    margin-top: 4px;
    font-size: 16px;
}

.price-lg {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.02em;
}

.status-lg {
    font-size: 18px;
    font-weight: 700;
    padding: 4px 0 6px;
}

.status-lg .badge {
    font-size: 16px;
    padding: 6px 12px;
}

/* 버튼 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}

.btn:hover {
    border-color: #cfcec8;
    background: #fafaf8;
}

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

.btn.primary:hover {
    background: #2552b8;
}

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

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

.btn.ghost-danger:hover {
    background: var(--red-50);
    border-color: #f2c5c0;
}

.btn.block {
    width: 100%;
}

.btn.lg {
    height: 48px;
    font-size: 16px;
}

.btn.sm {
    height: 32px;
    padding: 0 11px;
    font-size: 13px;
    border-radius: 8px;
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.btn-row .btn {
    flex: 1;
}

.icon-btn {
    border: 0;
    background: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--muted);
}

.icon-btn:hover {
    background: var(--soft);
    color: var(--red);
}

/* 입력 */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.field > span {
    font-size: 13px;
    font-weight: 600;
    color: #4b4c52;
}

.field input, .field select, .field textarea, .toolbar input, .toolbar select, .stock-input {
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    outline: none;
    width: 100%;
}

.field textarea {
    height: auto;
    padding: 10px 12px;
    resize: vertical;
}

.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .toolbar select:focus, .stock-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-50);
}

.field input[readonly] {
    background: var(--soft);
}

.field .invalid {
    border-color: var(--red);
}

.field .err {
    color: var(--red);
    font-size: 13px;
    font-style: normal;
    min-height: 0;
}

.field .err:empty {
    display: none;
}

.image-preview {
    width: 160px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--soft);
}

.field input[type=file] {
    height: auto;
    padding: 8px 12px;
    cursor: pointer;
}

.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.toolbar .grow {
    flex: 1;
    min-width: 200px;
}

.toolbar select {
    width: auto;
    min-width: 120px;
}

.toolbar input[type=date] {
    width: auto;
}

.inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

/* 배지 */
.badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: middle;
}

.badge.blue {
    background: var(--blue-50);
    color: var(--blue);
}

.badge.green {
    background: var(--green-50);
    color: var(--green);
}

.badge.amber {
    background: var(--amber-50);
    color: var(--amber);
}

.badge.red {
    background: var(--red-50);
    color: var(--red);
}

.badge.gray {
    background: var(--soft);
    color: var(--muted);
}

/* 로그인 · 회원가입 */
.auth-card {
    max-width: 420px;
    margin: 32px auto 0;
    padding: 32px;
}

.auth-card.wide {
    max-width: 760px;
}

.auth-card h1 {
    margin-bottom: 22px;
}

.auth-card .btn.lg {
    margin-top: 6px;
}

.auth-card > p {
    margin-top: 18px;
}

.cols-2 > div:last-child {
    display: flex;
    flex-direction: column;
}

.auth-card .cols-2 > div:last-child .btn {
    margin-top: auto;
    margin-bottom: 14px;
}

/* 상품 */
.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.product-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .15s, box-shadow .15s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(20, 20, 30, .08);
}

.pc-body {
    padding: 12px 14px 16px;
}

.pc-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.pc-price {
    font-weight: 800;
    display: flex;
    gap: 8px;
    align-items: center;
}

.product-card.soldout .thumb {
    filter: grayscale(1);
    opacity: .55;
}

.product-card.soldout .pc-name, .product-card.soldout .pc-price {
    color: var(--muted);
}

.thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, hsl(var(--h, 220) 60% 94%), hsl(calc(var(--h, 220) + 40) 55% 86%));
    color: hsl(var(--h, 220) 35% 32%);
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -.02em;
    overflow: hidden;
}

.thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb.lg {
    border-radius: 12px;
    font-size: 40px;
}

.thumb.sm {
    width: 56px;
    aspect-ratio: 1;
    border-radius: 10px;
    font-size: 11px;
    flex: none;
}

.detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.detail-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-info .desc {
    line-height: 1.7;
}

.stock {
    font-weight: 600;
    color: var(--green);
    margin: 0;
}

.stock.low {
    color: var(--amber);
}

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

.qty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin: 6px 0 4px;
    font-weight: 600;
}

.stepper {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

.stepper button {
    width: 38px;
    height: 38px;
    border: 0;
    background: #fff;
    cursor: pointer;
    font-size: 18px;
}

.stepper button:hover:not(:disabled) {
    background: var(--soft);
}

.stepper button:disabled {
    color: #c8c8c4;
    cursor: not-allowed;
}

.stepper input {
    width: 48px;
    border: 0;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    text-align: center;
    outline: none;
}

.stepper.sm button {
    width: 30px;
    height: 30px;
    font-size: 15px;
}

.stepper.sm input {
    width: 38px;
    font-size: 14px;
}

/* 장바구니 */
.list-card {
    padding: 8px 22px;
}

.check-all {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    cursor: pointer;
}

.cart-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.cart-row:last-child {
    border-bottom: 0;
}

.cart-row.off {
    opacity: .55;
}

.cr-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
}

.cr-sum {
    width: 110px;
    text-align: right;
    font-weight: 700;
}

input[type=checkbox] {
    width: 18px;
    height: 18px;
    accent-color: var(--blue);
}

/* 주문 */
.order-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    transition: border-color .15s;
}

.order-row:hover {
    border-color: #cfcec8;
}

.or-title {
    font-weight: 700;
}

.or-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.center-card {
    max-width: 440px;
    margin: 40px auto 0;
    padding: 36px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.center-card .line {
    width: 100%;
}

.center-card .btn-row {
    width: 100%;
    margin-top: 12px;
}

.check-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--green-50);
    color: var(--green);
    display: grid;
    place-items: center;
    font-size: 28px;
    font-weight: 800;
}

/* 관리자 표 */
.table-card {
    padding: 0;
    overflow-x: auto;
}

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

th {
    text-align: left;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: #fafaf8;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

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

th.r, td.r {
    text-align: right;
}

.stock-input {
    width: 84px;
    height: 32px;
    text-align: right;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat > span {
    color: var(--muted);
    font-weight: 600;
    font-size: 13px;
}

.stat > b {
    font-size: 26px;
    letter-spacing: -.02em;
}

.bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 180px;
    padding-top: 10px;
    border-bottom: 1px solid var(--line);
}

.bar {
    flex: 1;
    min-width: 3px;
    height: calc(var(--v) * 100%);
    min-height: 2px;
    background: var(--blue);
    border-radius: 4px 4px 0 0;
    opacity: .85;
}

.bar:hover {
    opacity: 1;
}

.bar.neg {
    background: var(--red);
}

.bars-axis {
    display: flex;
    justify-content: space-between;
    padding: 6px 0 10px;
}

.segmented {
    display: inline-flex;
    background: var(--soft);
    border-radius: 11px;
    padding: 4px;
    gap: 4px;
    margin: 8px 0 12px;
    flex-wrap: wrap;
}

.segmented > * {
    border: 0;
    background: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.25;
}

.segmented > * small {
    font-size: 11px;
    font-weight: 500;
}

.segmented > .on {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.rules {
    padding-left: 18px;
    margin: 4px 0 16px;
    line-height: 1.8;
}

/* 모달 · 토스트 */
.modal-back {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 26, .45);
    display: grid;
    place-items: center;
    z-index: 50;
    padding: 20px;
    animation: fade .15s;
}

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 26px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .2);
    animation: pop .18s;
}

.modal h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

.modal-actions .btn {
    flex: 1;
}

.pg-mock {
    border: 2px dashed #c8c8c4;
    border-radius: 12px;
    padding: 18px;
}

.pg-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.pg-head span {
    font-size: 12px;
    color: var(--amber);
    font-weight: 600;
}

.pg-amount {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 14px;
}

#toasts {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.toast {
    background: #222328;
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    display: flex;
    gap: 14px;
    align-items: center;
    font-weight: 500;
    animation: pop .2s;
    transition: opacity .3s, transform .3s;
}

.toast.error {
    background: var(--red);
}

.toast.success::before {
    content: "✓";
    color: #7ee2a8;
    font-weight: 800;
}

.toast a {
    color: #9fbcff;
    font-weight: 700;
}

.toast.out {
    opacity: 0;
    transform: translateY(8px);
}

@keyframes fade {
    from {
        opacity: 0;
    }
}

@keyframes pop {
    from {
        opacity: 0;
        transform: scale(.97) translateY(6px);
    }
}

/* 상태 표시 */
.loading {
    display: grid;
    place-items: center;
    padding: 60px 0;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--line);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: inline-block;
}

.spinner.lg {
    width: 44px;
    height: 44px;
    border-width: 4px;
    margin-bottom: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty h1 {
    color: var(--ink);
    font-size: 40px;
}

.pager {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 26px;
}

.pager a, .pager span {
    min-width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    font-weight: 600;
    color: var(--muted);
}

.pager a:hover {
    background: #fff;
}

.pager a.on {
    background: var(--ink);
    color: #fff;
}

.pager .dis {
    opacity: .35;
}

/* 관리자 로그인 시 손님 화면 상단의 작은 관리자 상자 */
.admin-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    background: #18191d;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.admin-chip b {
    font-size: 11px;
    color: #8fb0ff;
    font-weight: 700;
}

.admin-chip:hover {
    background: #2b2c33;
}

/* 미구현 안내 (결제 · 환불) */
.notice {
    background: var(--amber-50);
    color: var(--amber);
    border: 1px solid #f0d9a4;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 4px 0 0;
    line-height: 1.5;
}

.notice-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--amber-50);
    color: var(--amber);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 10px;
}

@media (max-width: 900px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

    .summary {
        position: static;
    }
}

@media (max-width: 680px) {
    .topbar-in {
        gap: 12px;
        height: auto;
        padding: 10px 16px;
        flex-wrap: wrap;
    }

    .nav {
        order: 3;
        flex-basis: 100%;
    }

    main {
        padding: 20px 16px 120px;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .detail, .cols-2, .stats {
        grid-template-columns: 1fr;
    }

    .cart-row {
        flex-wrap: wrap;
    }

    .cr-sum {
        width: auto;
    }

    .auth-card {
        padding: 22px;
    }
}
