/* WMS Storefront — administration panel */
:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #1c2430;
    --muted: #5d6877;
    --border: #dde2e8;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-text: #ffffff;
    --danger: #b42318;
    --ok-bg: #e7f6ec; --ok-fg: #17663a;
    --warn-bg: #fff4dc; --warn-fg: #8a5a00;
    --fail-bg: #fdecea; --fail-fg: #b42318;
    --info-bg: #e8f0fe; --info-fg: #1d4ed8;
    --radius: 10px;
    --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
    --topbar-h: 56px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1318; --surface: #161d25; --surface-2: #1b232d; --text: #e2e8ef; --muted: #98a4b3;
        --border: #2a3440; --primary: #6ea8fe; --primary-hover: #8cbaff; --primary-text: #0b1320; --danger: #ff7b72;
        --ok-bg: #12301f; --ok-fg: #7ee2a8; --warn-bg: #33270b; --warn-fg: #f5c451;
        --fail-bg: #3a1513; --fail-fg: #ff9b93; --info-bg: #142540; --info-fg: #9cc3ff;
        --shadow: 0 1px 2px rgb(0 0 0 / .4);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .75em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
pre { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; overflow: auto; max-width: 420px; white-space: pre-wrap; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; display: block; margin: 6px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
    font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-small { min-height: 30px; padding: 0 10px; font-size: .85rem; }
.btn-block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

/* Forms */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; margin: 0; min-width: 0; border: 0; padding: 0; }
.field > span, .field > legend { font-weight: 600; font-size: .9rem; }
.field small, .check small { color: var(--muted); font-size: .82rem; display: block; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=tel], input[type=number],
input[type=search], input[type=date], select, textarea {
    width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit; }
textarea { min-height: 70px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input[type=file] { font: inherit; max-width: 100%; }
.field-error { color: var(--danger); font-size: .85rem; margin: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 4px 0; }
.check input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--primary); }
.check.disabled { opacity: .55; cursor: not-allowed; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); padding: 12px 0; z-index: 5; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.narrow-field { max-width: 320px; }
.code-input { font-size: 1.3rem; letter-spacing: .2em; text-align: center; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* Alerts and pills */
.alert { border-radius: 8px; padding: 10px 14px; margin: 0 0 14px; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok-fg); }
.alert-warning { background: var(--warn-bg); color: var(--warn-fg); }
.alert-error { background: var(--fail-bg); color: var(--fail-fg); }
.alert-info { background: var(--info-bg); color: var(--info-fg); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill-fail { background: var(--fail-bg); color: var(--fail-fg); }
.pill-info { background: var(--info-bg); color: var(--info-fg); }
.tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px; font-size: .7rem; font-weight: 600;
    background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); vertical-align: middle; }

/* Cards and tables */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; min-width: 0; }
.card.narrow { max-width: 560px; }
.card-header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.empty { color: var(--muted); padding: 12px 0; margin: 0; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.list li:last-child { border-bottom: 0; }
.status-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.status-list li { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: start; }
.status-list .pill { text-align: center; }
.section-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 16px 0 6px; }
details summary { cursor: pointer; color: var(--primary); margin: 8px 0; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-header p { margin: 0; }
.breadcrumb { margin: 0 0 2px; font-size: .85rem; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--primary); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 12px; align-items: center; min-height: 40px; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 2px; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { font-size: 1.7rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-warn { border-color: var(--warn-fg); }
.grid-dashboard { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
.span-2 { grid-column: 1 / -1; }
.upcoming-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.upcoming { border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; display: grid; gap: 2px; }
.upcoming .tag { margin: 0 0 4px; justify-self: start; }
.notification-list li.unread a strong::before { content: "● "; color: var(--primary); }
.notification-list li.priority-high strong { color: var(--danger); }

/* Roles and theme */
.permission-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.permission-module { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.permission-module legend { font-weight: 700; padding: 0 6px; display: flex; gap: 10px; align-items: baseline; }
.permission-module .check code { font-size: .72rem; }
.role-group { margin-bottom: 8px; }
.palette-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 12px; }
.palette { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; display: grid; gap: 6px; }
.palette legend { font-weight: 700; padding: 0 6px; }
.color-field { display: grid; grid-template-columns: 40px 96px 1fr; gap: 8px; align-items: center; }
.color-field input[type=color] { width: 40px; height: 34px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; background: var(--surface); cursor: pointer; }
.color-field input[type=text] { min-height: 34px; padding: 4px 8px; }
.logo-preview { max-height: 64px; display: block; margin: 4px 0; background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 12px 12px; }
.favicon-preview { width: 32px; height: 32px; display: block; margin: 4px 0; }
.order-input { max-width: 90px; }
.reset-form { text-align: right; margin-bottom: 24px; }

/* Admin layout */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
    padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); min-width: 0; }
.topbar-brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-brand:hover { text-decoration: none; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { position: relative; display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 10px; border-radius: 8px;
    background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.menu-btn { display: none; font-size: 1.2rem; }
.badge-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: var(--primary-text);
    display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; flex: none; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 8px; font-size: .95rem; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 8px; color: var(--text); margin: 0; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .14); padding: 6px; display: grid; }
.user-menu .menu a, .user-menu .menu button { display: block; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text);
    background: none; border: 0; font: inherit; cursor: pointer; width: 100%; }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--surface-2); text-decoration: none; }

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px 24px; position: sticky; top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h)); overflow-y: auto; }
.sidebar ul { list-style: none; margin: 0 0 8px; padding: 0; }
.nav-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin: 14px 10px 4px; }
.nav-link { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 7px; color: var(--text); }
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--info-bg); color: var(--info-fg); font-weight: 600; }
.nav-link.disabled { color: var(--muted); cursor: default; }
.nav-link.disabled:hover { background: none; }
.sidebar-footer { margin: 18px 10px 0; }
.sidebar-backdrop { display: none; }
.main { padding: 24px; min-width: 0; max-width: 1280px; width: 100%; }

/* Sign-in and installer pages */
.auth-page { min-height: 100vh; display: grid; place-items: start center; padding: 6vh 16px 32px; }
.auth { width: 100%; max-width: 460px; }
.install { width: 100%; max-width: 760px; }
.auth-header, .install-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-header div { display: grid; }
.install-header h1 { margin: 0; font-size: 1.4rem; }
.install-header p { margin: 0; }
.auth h1 { font-size: 1.35rem; }
.steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 16px; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.steps li span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: .78rem; }
.steps li.current { color: var(--text); border-color: var(--primary); }
.steps li.current span { background: var(--primary); color: var(--primary-text); }
.steps li.done span { background: var(--ok-bg); color: var(--ok-fg); }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); align-items: start; }
.check-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 800; }
.check-ok .check-icon { background: var(--ok-bg); color: var(--ok-fg); }
.check-warn .check-icon { background: var(--warn-bg); color: var(--warn-fg); }
.check-fail .check-icon { background: var(--fail-bg); color: var(--fail-fg); }
.check-info .check-icon { background: var(--info-bg); color: var(--info-fg); }
.check-label em { font-style: normal; font-size: .72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.check-detail { color: var(--muted); font-size: .88rem; }
.setup-steps { padding-left: 20px; display: grid; gap: 10px; }
.secret-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.secret-box code { font-size: 1.05rem; letter-spacing: .08em; border: 0; background: none; padding: 0; word-break: break-all; }
.recovery-codes { list-style: none; padding: 14px; margin: 0 0 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-size: 1.05rem; }

/* Responsive */
@media (max-width: 960px) {
    .grid-dashboard { grid-template-columns: minmax(0, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .palette-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
    .menu-btn { display: inline-flex; }
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 270px; height: auto; z-index: 40;
        transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 30px rgb(0 0 0 / .2); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgb(0 0 0 / .35); z-index: 35; }
    .main { padding: 16px; }
    .hide-sm { display: none; }
}
@media (max-width: 600px) {
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .card { padding: 16px; }
    .checklist li { grid-template-columns: 26px minmax(0, 1fr); }
    .checklist .check-detail { grid-column: 2; }
    .recovery-codes { grid-template-columns: 1fr; }
    .topbar-actions .icon-btn[target] { display: none; }
    h1 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
    .topbar, .sidebar, .form-actions, .btn, form { display: none !important; }
    .auth-page { display: block; padding: 0; }
}
