:root {
    --bg: #f6f6f5;
    --card: #fff;
    --ink: #1c1c1a;
    --muted: #6b6b66;
    --line: #e3e3df;
    --accent: #1c1c1a;
    --danger: #b42318;
    --ok: #067647;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 15px;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.45;
}
a { color: inherit; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    height: 52px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.brand { font-weight: 700; text-decoration: none; flex: 1; }
.menu-btn { padding: 6px 8px; line-height: 0; border-radius: 8px; }
.menu-btn:hover { background: var(--bg); }

.user-menu { position: relative; }
.avatar {
    width: 34px; height: 34px; padding: 0;
    border-radius: 50%;
    background: var(--accent); color: #fff; border-color: var(--accent);
    font-size: 0.8rem; font-weight: 700; letter-spacing: 0.02em;
    display: inline-flex; align-items: center; justify-content: center;
}
.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 200px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    padding: 6px;
    z-index: 60;
}
.user-dropdown[hidden] { display: none; }
.user-dropdown-email { font-size: 0.78rem; padding: 6px 8px; word-break: break-all; }
.user-dropdown form { margin: 0; }
.logout-btn { width: 100%; text-align: left; border: 0; background: none; padding: 8px; border-radius: 6px; }
.logout-btn:hover { background: var(--bg); }

.sidebar {
    position: fixed;
    top: 52px; bottom: 0; left: 0;
    width: 220px;
    background: var(--card);
    border-right: 1px solid var(--line);
    padding: 12px 8px;
    overflow-y: auto;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .18s ease, visibility .18s;
    visibility: hidden;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { text-decoration: none; color: var(--muted); padding: 9px 12px; border-radius: 6px; }
.nav a:hover { color: var(--ink); background: var(--bg); }
.nav a.active { color: var(--ink); background: var(--bg); font-weight: 600; }
.sidebar-backdrop { position: fixed; inset: 52px 0 0 0; background: rgba(0, 0, 0, .35); z-index: 20; }
.sidebar-backdrop[hidden] { display: none; }

.nav-open .sidebar, .nav-hover .sidebar, .nav-pinned .sidebar { transform: none; visibility: visible; }
.nav-hover:not(.nav-pinned) .sidebar { box-shadow: 4px 0 16px rgba(0, 0, 0, .1); }
@media (min-width: 900px) {
    .nav-pinned body { padding-left: 220px; }
    .sidebar-backdrop { display: none; }
}

/* Reusable tooltip: <el data-tip="text"> (add data-tip-pos="left" near the right edge). */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    padding: 4px 8px;
    border-radius: 5px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .12s ease;
    z-index: 70;
}
[data-tip][data-tip-pos="left"]::after { left: auto; right: 0; transform: none; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; visibility: visible; }

/* Compact icon buttons used for row actions. */
.icon-btn, .btn.icon-btn, button.icon-btn {
    width: 32px; height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted);
}
.icon-btn:hover, .btn.icon-btn:hover { color: var(--ink); background: var(--bg); }
.icon-btn.danger { color: var(--danger); }
.icon-btn[disabled], .icon-btn.disabled { opacity: .4; cursor: not-allowed; }
.icon-btn svg { width: 16px; height: 16px; display: block; }

.wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 80px; }
.wrap.narrow { max-width: 420px; padding-top: 72px; }
h1 { font-size: 1.4rem; margin: 0 0 6px; }
h2 { font-size: 1rem; margin: 0 0 12px; }
.lede, .muted { color: var(--muted); }
.lede { margin: 0 0 22px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.stat .num { font-size: 1.6rem; font-weight: 700; }

.flash, .errors {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 18px;
}
.flash { background: #ecfdf3; border: 1px solid #abefc6; color: var(--ok); }
.flash a { color: var(--ok); font-weight: 600; }
.errors { background: #fef3f2; border: 1px solid #fecdca; color: var(--danger); }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    background: #fff;
}
.field { margin-bottom: 14px; }
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.inline { display: inline; margin: 0; }

button, .btn {
    appearance: none;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 6px;
    padding: 7px 12px;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
button.primary, .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--muted); }
button.link:hover { color: var(--ink); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.tag { font-size: 0.75rem; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--muted); }
.tag.ok { color: var(--ok); border-color: #abefc6; }
.tag.warn { color: var(--danger); border-color: #fecdca; }
.tag.hidden-tag { color: #fff; background: var(--danger); border-color: var(--danger); font-weight: 600; }

.codes { font-family: ui-monospace, Consolas, monospace; columns: 2; padding: 12px 16px; background: var(--bg); border-radius: 6px; list-style: none; margin: 10px 0; }
.qr svg { display: block; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 6px; }
.scroll-x { overflow-x: auto; }



/* Shared list pages: page header, toolbar, table, bulk bar, pager. */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.page-head .actions { margin: 0; }

.toolbar { display: flex; flex-direction: column; gap: 10px; margin: 0 0 16px; }
.toolbar .row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.toolbar .field { display: flex; flex-direction: column; gap: 3px; min-width: 130px; margin: 0; }
.toolbar .field.grow { flex: 1; min-width: 220px; }
.toolbar label { margin: 0; font-size: 0.8rem; }
.toolbar .check { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 0.9rem; font-weight: 400; white-space: nowrap; padding-bottom: 8px; }
.check input, td input[type=checkbox], th input[type=checkbox] { width: auto; }

.list-card { padding: 8px 12px; }
.empty-state { padding: 8px; margin: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.c-check, th.c-check { width: 36px; }
.thumb { width: 44px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--bg); display: block; }
.thumb.wide { width: 64px; height: 44px; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; align-items: center; }
.row-actions > :last-child[data-tip]::after,
.row-actions > :last-child [data-tip]::after { left: auto; right: 0; transform: none; }
.tag.hidden-tag { margin-left: 4px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.tabs a { text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; background: #fff; color: var(--muted); }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
tr.is-off { opacity: .65; }

.bulk-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.bulk-bar select { width: auto; min-width: 180px; }
.bulk-bar select[hidden] { display: none; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-top: 14px; }

/* Coupons */
.coupon-code { font-family: ui-monospace, Consolas, monospace; font-weight: 600; letter-spacing: .03em; text-decoration: none; }
a.coupon-code:hover { text-decoration: underline; }
.choice-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.choice { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 400; background: #fff; }
.choice input { width: auto; margin-top: 3px; }
.choice strong { display: block; font-size: 0.9rem; }
.choice span { display: block; font-size: 0.78rem; color: var(--muted); }
.choice:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.form-row { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .form-row.cols-2 { grid-template-columns: 1fr 1fr; } }
.pick-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.pick-list .check { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 0; border-radius: 4px; font-weight: 400; font-size: 0.9rem; cursor: pointer; }
.pick-list .check:hover { background: var(--bg); }
.pick-list .check input { width: auto; }
.pick-list .sku { margin-left: auto; color: var(--muted); font-size: 0.78rem; }
.pick-thumb { width: 28px; height: 36px; object-fit: cover; border-radius: 3px; background: var(--bg); flex: none; }
.with-unit { display: flex; align-items: stretch; }
.with-unit .unit { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 0.85rem; }
.with-unit .unit:first-child { border-right: 0; border-radius: 6px 0 0 6px; }
.with-unit .unit:last-child { border-left: 0; border-radius: 0 6px 6px 0; }
.with-unit input { border-radius: 0; }
.with-unit input:first-child { border-radius: 6px 0 0 6px; }
.with-unit input:last-child { border-radius: 0 6px 6px 0; }
.saving { color: var(--ok); font-size: 0.8rem; }
/* Last-row tooltips open upward so they don't overflow (and scroll) the list card. */
.list-card tbody tr:last-child [data-tip]::after { top: auto; bottom: calc(100% + 6px); }
