:root {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f8fafc;
    --muted: #94a3b8;
    --accent: #22c55e;
    --danger: #f87171;
    --touch-min: 48px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
}

.app-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.card {
    background: var(--card);
    border-radius: 16px;
    padding: 1.25rem;
    width: min(100%, 420px);
}

.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }

.muted { color: var(--muted); font-size: 0.9rem; }
.center { text-align: center; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 1rem; }
.error { color: var(--danger); }

label {
    display: block;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}

input {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid #334155;
    background: #0f172a;
    color: var(--text);
    font-size: 1rem;
    min-height: var(--touch-min);
}

.btn {
    display: block;
    width: 100%;
    min-height: var(--touch-min);
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    line-height: var(--touch-min);
}

.btn.primary { background: var(--accent); color: #052e16; }

.legal-block { margin: 1.25rem 0; padding-top: 1rem; border-top: 1px solid var(--border, #e2e8f0); }
.legal-content .legal-text { line-height: 1.55; }
.auth-platform-legal { margin-top: 1rem; font-size: 0.85rem; text-align: center; }

.pos-shell { align-items: stretch; max-width: 480px; margin: 0 auto; width: 100%; }

.pos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.pos-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.badge {
    font-size: 0.7rem;
    background: #334155;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    margin-left: 0.35rem;
    text-transform: uppercase;
}

.link { color: var(--accent); text-decoration: none; font-size: 0.9rem; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin: 1rem 0 5rem;
}

.product-tile {
    min-height: 88px;
    border: none;
    border-radius: 14px;
    background: var(--card);
    color: var(--text);
    padding: 0.75rem;
    text-align: left;
    cursor: pointer;
}

.product-name { display: block; font-weight: 600; font-size: 0.95rem; }
.product-price { color: var(--accent); font-size: 1.1rem; }

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: #1e293b;
    padding: 0.75rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    border-top: 1px solid #334155;
    font-size: 0.85rem;
}

.bottom-nav .active { color: var(--accent); font-weight: 600; }
.bottom-nav .disabled { color: var(--muted); }

.bottom-nav-links a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
}

.bottom-nav-links a.active {
    color: var(--accent);
    font-weight: 600;
}

.stock-list {
    list-style: none;
    margin: 0 0 5rem;
    padding: 0;
}

.stock-row {
    display: grid;
    grid-template-columns: 1fr auto minmax(6rem, auto);
    gap: 0.5rem;
    align-items: center;
    padding: 0.65rem 0;
    border-bottom: 1px solid #334155;
}

.online-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.online-toggle input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent);
}

.shop-order-list .shop-order-row {
    padding: 0.85rem 0;
    border-bottom: 1px solid #334155;
    list-style: none;
}

.shop-order-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.35rem;
}

.shop-order-email { display: block; font-size: 0.8rem; }

.shop-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.shop-logo {
    max-height: 40px;
    max-width: 120px;
    object-fit: contain;
}

.shop-tagline {
    display: block;
    font-size: 0.8rem;
}

.shop-footer {
    margin-top: 1.5rem;
    padding: 1rem 0 2rem;
    text-align: center;
    font-size: 0.85rem;
}

.shop-legal {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.product-thumb {
    display: block;
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.35rem;
}

.shop-order-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.5rem 0 0.75rem;
}

.filter-tab {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid #334155;
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
}

.filter-tab-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0f172a;
    font-weight: 600;
}

.stock-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.product-shop-meta {
    flex: 1 0 100%;
    margin-top: 0.5rem;
    padding: 0.65rem 0 0.25rem;
    border-top: 1px dashed #334155;
}

.product-shop-meta.hidden { display: none; }

.meta-field {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.meta-field textarea,
.meta-field input {
    width: 100%;
    margin-top: 0.25rem;
}

.admin-advanced {
    margin-top: 1.25rem;
    padding: 0.75rem 0;
    border-top: 1px solid #334155;
}
.admin-advanced summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.9rem;
    list-style-position: inside;
}
.admin-advanced[open] summary { color: var(--accent); margin-bottom: 0.75rem; }
.admin-advanced h4 { font-size: 0.95rem; margin: 1rem 0 0.5rem; }

.admin-details {
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

.admin-details summary { cursor: pointer; color: var(--accent); }

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.stock-row.stock-low .stock-qty {
    color: var(--danger);
    font-weight: 700;
}

.stock-meta strong { display: block; font-size: 0.95rem; }
.stock-qty {
    min-width: 2.5rem;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
}

.stock-actions {
    display: flex;
    gap: 0.35rem;
}

.qty-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
}

.warehouse-select {
    display: block;
    margin: 0.5rem 0;
    font-size: 0.85rem;
}

.warehouse-select select {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.6rem;
    border-radius: 10px;
    border: 1px solid #334155;
    background: #0f172a;
    color: var(--text);
}

.admin-card {
    width: min(100%, 480px);
    margin: 0 auto 5rem;
}

.admin-card h2 { margin-top: 0; }
.admin-card h3 { margin-bottom: 0.35rem; }

.admin-form label { margin-top: 0.5rem; }

.success-msg { color: var(--accent); font-size: 0.9rem; }
.status-ok { color: var(--accent); }
.status-warn { color: #fde68a; }

.webhook-stats {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 1rem;
    font-size: 0.9rem;
}

.webhook-stats li { margin-bottom: 0.35rem; }

.failed-list {
    font-size: 0.8rem;
    color: var(--muted);
    padding-left: 1.1rem;
}

.admin-card h4 { margin: 0.75rem 0 0.35rem; }

.invoice-list {
    list-style: none;
    margin: 0 0 5rem;
    padding: 0;
}

.invoice-link {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.2rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #334155;
    color: inherit;
    text-decoration: none;
}

.invoice-no { font-weight: 600; }
.invoice-sum { color: var(--accent); font-weight: 600; }

.invoice-pick {
    display: block;
    cursor: pointer;
}

.invoice-pick input[type="checkbox"] {
    margin-bottom: 0.35rem;
}

.invoice-pick .inv-qty {
    width: 100%;
    margin-top: 0.35rem;
}

.invoice-product-grid {
    margin-bottom: 1rem;
}

.shop-header { margin-bottom: 0.5rem; }
.shop-desc { display: block; font-size: 0.75rem; margin: 0.25rem 0; }

.offline-banner {
    background: #422006;
    color: #fde68a;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    text-align: center;
    margin: 0.5rem 0 0;
}

.pending-hint { min-height: 1.2rem; margin-top: 0.25rem; }

.cart-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 3.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: #14532d;
    color: #ecfdf5;
    max-width: 480px;
    margin: 0 auto;
    border-top: 1px solid #166534;
}

.cart-bar-btn {
    flex: 1;
    min-height: var(--touch-min);
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #052e16;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}

.cart-bar-total {
    font-weight: 700;
    font-size: 1.05rem;
    min-width: 5.5rem;
    text-align: right;
}

.cart-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 480px;
    margin: 0 auto;
    background: var(--card);
    border-radius: 16px 16px 0 0;
    padding: 1rem 1rem 6rem;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    z-index: 20;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}

.cart-panel.open { transform: translateY(0); }

.cart-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.9rem;
    cursor: pointer;
    min-height: var(--touch-min);
}

.cart-lines {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    max-height: 40vh;
    overflow-y: auto;
}

.cart-line {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.35rem;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #334155;
    font-size: 0.9rem;
}

.cart-line-name { font-weight: 500; }
.cart-line-sum { color: var(--accent); font-weight: 600; }

.cart-line-remove {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #334155;
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
}

.btn.stripe-btn {
    margin-top: 0.5rem;
    background: #635bff;
    color: #fff;
    min-height: var(--touch-min);
}

.scanner-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 40;
    padding: 1rem;
}

.scanner-modal[hidden] {
    display: none !important;
}

.scanner-dialog {
    width: min(100%, 480px);
    background: var(--card);
    border-radius: 16px 16px 0 0;
    padding: 1rem;
}

.scanner-video {
    width: 100%;
    border-radius: 12px;
    background: #000;
    max-height: 40vh;
    object-fit: cover;
}

.scanner-manual {
    display: block;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}
