:root {
    color-scheme: light;
    --ink: #2c2440;
    --muted: #6f6784;
    --bg: #fff4ee;
    --card: #ffffff;
    --line: #f0e2d8;
    --coral: #ff6b57;
    --coral-deep: #ef5a46;
    --gold: #ffb703;
    --mint: #1fbfa0;
    --violet: #7b6cff;
    --shadow: 0 16px 40px rgba(92, 54, 72, 0.08);
    --radius: 18px;
    font-family: "Segoe UI", "Nunito", system-ui, sans-serif;
    color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(1200px 500px at 10% -10%, #ffe7c2 0%, transparent 55%), radial-gradient(900px 480px at 100% 0%, #efe7ff 0%, transparent 50%), var(--bg); }
img, svg, input, select, textarea, button { max-width: 100%; }
a { color: #d4534a; text-decoration: none; }
a:hover { color: var(--violet); }

.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; min-height: 100dvh; }
.topbar, .backdrop { display: none; }
.nav-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
}
aside {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    padding: 22px 16px 16px;
    background: rgba(255, 255, 255, 0.82);
    border-right: 1px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--ink); margin: 0 8px 16px; }
.mark {
    width: 28px; height: 28px; border-radius: 50%;
    background: conic-gradient(from 120deg, var(--coral), var(--gold), var(--mint), var(--violet), var(--coral));
    box-shadow: 0 6px 14px rgba(255, 107, 87, 0.35);
    flex: none;
}
.nav-label { margin: 14px 10px 4px; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
aside nav { display: grid; gap: 2px; }
aside nav a { padding: 8px 12px; border-radius: 12px; color: var(--ink); }
aside nav a:hover { background: #fff1ea; color: var(--coral-deep); }
aside nav a.active { background: linear-gradient(90deg, #ffe8e2, #fff6d8); color: #c24136; font-weight: 600; }
.logout { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 4px; }
.who { font-size: 0.92rem; color: var(--muted); }

main { padding: 32px 36px 48px; max-width: 1180px; }
h1 { margin: 0 0 18px; font-size: 2rem; letter-spacing: -0.03em; }
h2 { margin: 28px 0 10px; font-size: 1.15rem; }
main > p { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
main > p > a, h2 a {
    display: inline-block;
    background: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    margin: 8px 0 22px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
th { background: #fff8f3; color: var(--muted); font-weight: 600; font-size: 0.85rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th.qty, td.qty { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.qty.zero { color: var(--muted); }
.stock-board { overflow-x: auto; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fffaf7; }

.card, form.card, .panel form {
    display: grid;
    gap: 12px;
    background: var(--card);
    padding: 18px;
    margin: 8px 0 22px;
    border: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
label { display: grid; gap: 6px; font-size: 0.92rem; color: var(--muted); min-width: 0; }
label input, label select, label textarea { width: 100%; }
label input[type="checkbox"], label input[type="file"] { width: auto; }
input, select, textarea {
    font: inherit;
    color: var(--ink);
    padding: 10px 12px;
    border: 1.5px solid #f0ddd4;
    border-radius: 12px;
    background: #fffdfb;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(255, 107, 87, 0.25); border-color: var(--coral); }
textarea { min-height: 80px; }
button {
    font: inherit;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid #f0ddd4;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}
.card button, form.card > button, .panel button[type="submit"] {
    background: linear-gradient(90deg, var(--coral), #ff8a5b);
    color: white;
    border: 0;
    box-shadow: 0 8px 18px rgba(255, 107, 87, 0.28);
}
.card button[name="ship_now"] { background: #fff; color: var(--ink); box-shadow: none; border: 1px solid #f0ddd4; }
.line { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.line select, .line input { flex: 1; }
.avail { color: var(--mint); font-weight: 600; white-space: nowrap; }
.flash { padding: 12px 14px; border-radius: 14px; }
.flash.ok { background: #e5fbf4; color: #0d7a62; }
.flash.error { background: #ffe8e4; color: #b3382c; }
.check { display: flex; gap: 8px; align-items: center; }
td form, li form { display: inline; }

.stage {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 32px;
    align-items: center;
    max-width: 980px;
    margin: 0 auto;
    padding: 40px 24px;
}
.hello h2 { font-size: 2.4rem; line-height: 1.15; margin: 12px 0; letter-spacing: -0.03em; }
.hello p { color: var(--muted); font-size: 1.05rem; }
.hello .mark { display: block; }
.eyebrow { margin: 14px 0 0; font-weight: 700; color: var(--coral-deep); }
.panel h1 { margin-top: 0; }
.lead { margin-top: 0; color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 0.92rem; }
.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    overflow: hidden;
    color: #fff;
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
}
.avatar.lg { width: 84px; height: 84px; font-size: 1.45rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tone-0 { background: #ff6b57; }
.tone-1 { background: #ffb703; color: #3d2c00; }
.tone-2 { background: #1fbfa0; }
.tone-3 { background: #7b6cff; }
.tone-4 { background: #f077a0; }
.tone-5 { background: #5b8def; }
.item-link { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.item-sub { display: block; color: var(--muted); font-weight: 400; font-size: 0.82rem; }
.profile { display: flex; align-items: center; gap: 16px; }

@media (max-width: 1200px) {
    .shell { grid-template-columns: 220px 1fr; }
    main { padding: 24px 22px 40px; }
    h1 { font-size: 1.7rem; }
}

@media (max-width: 900px) {
    .shell { display: block; min-height: 100dvh; }
    .topbar {
        display: flex;
        align-items: center;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 50;
        padding: 10px 12px calc(10px + env(safe-area-inset-top));
        background: rgba(255, 248, 244, 0.92);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid rgba(240, 226, 216, 0.9);
    }
    .topbar .brand { margin: 0; font-size: 1.05rem; }
    .burger {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        min-height: 44px;
        padding: 0 12px;
        border-radius: 12px;
        background: #fff;
        color: var(--ink);
        font-weight: 600;
        box-shadow: var(--shadow);
        cursor: pointer;
    }
    .burger-lines, .burger-lines::before, .burger-lines::after {
        display: block;
        width: 16px;
        height: 2px;
        border-radius: 2px;
        background: var(--ink);
        position: relative;
    }
    .burger-lines::before, .burger-lines::after { content: ""; position: absolute; left: 0; }
    .burger-lines::before { top: -5px; }
    .burger-lines::after { top: 5px; }
    .backdrop {
        position: fixed;
        inset: 0;
        background: rgba(44, 36, 64, 0.38);
        z-index: 30;
    }
    .nav-toggle:checked ~ .backdrop { display: block; }
    body:has(.nav-toggle:checked) { overflow: hidden; }
    .side-brand { display: none; }
    aside {
        position: fixed;
        z-index: 40;
        top: 64px;
        left: 0;
        width: min(86vw, 320px);
        height: calc(100dvh - 64px);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        border-right: 0;
        box-shadow: var(--shadow);
        padding-top: 12px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    .nav-toggle:checked ~ aside { transform: none; }
    aside nav a { min-height: 44px; display: flex; align-items: center; }
    .logout { margin-top: auto; padding-bottom: 8px; }
    .logout button { min-height: 44px; }
    main { padding: 18px 14px calc(28px + env(safe-area-inset-bottom)); max-width: none; }
    h1 { font-size: 1.55rem; margin-bottom: 12px; }
    h2 { font-size: 1.05rem; }
    table.has-head {
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }
    table.has-head tr:first-child { display: none; }
    table.has-head tr {
        display: block;
        background: var(--card);
        border-radius: 16px;
        box-shadow: var(--shadow);
        margin: 0 0 12px;
        overflow: hidden;
    }
    table.has-head td {
        display: grid;
        grid-template-columns: minmax(6.5rem, 40%) minmax(0, 1fr);
        gap: 8px;
        align-items: start;
        border-bottom: 1px solid var(--line);
        padding: 10px 14px;
        overflow-wrap: anywhere;
    }
    table.has-head td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 600;
    }
    table.has-head td:last-child { border-bottom: 0; }
    table.has-head td[colspan] { grid-template-columns: 1fr; }
    table.has-head td[colspan]::before { content: none; }
    table.has-head td form, table.has-head td button { width: 100%; }
    .line { flex-direction: column; align-items: stretch; }
    .line select, .line input { width: 100%; min-width: 0; }
    .avail { white-space: normal; }
    .card button, form.card > button, .panel button[type="submit"] { min-height: 46px; width: 100%; }
    input, select, textarea { font-size: 16px; }
    .stage {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 8px;
        padding: 28px 16px calc(32px + env(safe-area-inset-bottom));
    }
    .hello h2 { font-size: 1.75rem; }
    .hello p { font-size: 1rem; }
    .profile { align-items: flex-start; }
}

@media (max-width: 380px) {
    .topbar .brand span:last-child { font-size: 0.95rem; }
    table.has-head td { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
    aside { transition: none; }
}
