/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1a1a2e;
    background: #f0f2f5;
    line-height: 1.5;
    overflow-x: hidden;
    max-width: 100vw;
}

/* ── App Shell ───────────────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,.06);
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header h1 { font-size: 1.25rem; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-right .user-pseudonym { font-size: .8rem; font-weight: 600; opacity: .9; }
.connection-status { font-size: .75rem; padding: 4px 8px; border-radius: 12px; }
.connection-status.online { background: rgba(255,255,255,.2); }
.connection-status.offline { background: rgba(255,50,50,.3); }

.app-main {
    flex: 1;
    padding: 16px;
    padding-bottom: 72px;
}

/* ── Bottom Nav ──────────────────────────────────── */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    justify-content: space-around;
    padding: 8px 0 12px;
    z-index: 100;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #6b7280;
    font-size: .7rem;
    gap: 2px;
    position: relative;
}
.nav-item.active { color: #667eea; }
.nav-icon { font-size: 1.25rem; }
.nav-label { font-size: .65rem; }
.badge {
    position: absolute;
    top: -4px;
    right: -8px;
    background: #ef4444;
    color: #fff;
    font-size: .6rem;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ── Cards & Grid ────────────────────────────────── */
.stream-grid, .product-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }

@media (min-width: 400px) {
    .stream-grid, .product-grid { grid-template-columns: 1fr 1fr; }
}

.stream-card, .product-card, .order-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: transform .1s, box-shadow .1s;
}
.stream-card:active, .product-card:active, .order-card:active {
    transform: scale(.98);
}
.stream-card h3, .product-card h3 { font-size: .95rem; margin-bottom: 4px; }
.stream-meta { display: flex; gap: 12px; font-size: .75rem; color: #9ca3af; margin-top: 8px; }
.product-sku { font-size: .7rem; color: #9ca3af; }
.product-price { font-size: 1.1rem; font-weight: 700; color: #667eea; margin-top: 6px; }
.product-card.inactive { opacity: .4; }

.order-card {
    margin-bottom: 8px;
    border-left: 4px solid #f59e0b;
}
.order-card.order-confirmed  { border-left-color: #3b82f6; }
.order-card.order-processing { border-left-color: #8b5cf6; }
.order-card.order-shipped    { border-left-color: #10b981; }
.order-card.order-delivered  { border-left-color: #059669; }
.order-card.order-cancelled  { border-left-color: #ef4444; opacity: .6; }

.order-header { display: flex; justify-content: space-between; align-items: center; }
.order-status { font-size: .7rem; padding: 2px 8px; border-radius: 8px; background: #f3f4f6; }
.order-meta { font-size: .75rem; color: #9ca3af; margin: 4px 0; display: flex; gap: 12px; }
.order-total { font-weight: 700; color: #1a1a2e; }
.order-items { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; font-size: .8rem; }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: .8rem; color: #6b7280; margin-bottom: 4px; }
.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: .9rem;
    outline: none;
    transition: border-color .2s;
}
.input:focus { border-color: #667eea; }
.input-qty { width: 60px; text-align: center; padding: 4px; border: 1px solid #d1d5db; border-radius: 6px; }

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s;
}
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { opacity: .85; }

.btn-secondary {
    padding: 8px 16px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: .85rem;
    cursor: pointer;
}
.btn-secondary:active { background: #e5e7eb; }

.btn-danger {
    padding: 10px 20px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .85rem;
    cursor: pointer;
}

.btn-text { background: none; border: none; color: #ef4444; cursor: pointer; padding: 2px 4px; }

/* ── Loading & Empty States ──────────────────────── */
.loading { padding: 20px; text-align: center; color: #9ca3af; }
.empty-state { padding: 20px; text-align: center; color: #9ca3af; font-style: italic; }

/* ── Stream Live ─────────────────────────────────── */
.stream-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.live-timer { font: .9rem monospace; color: #ef4444; font-weight: 700; }

.order-feed { max-height: 60vh; overflow-y: auto; }

.cart-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}
.item-price { font: .85rem monospace; margin-left: auto; }

.add-product-row { display: flex; gap: 8px; margin-top: 8px; }
.add-product-row .input { flex: 1; }

.quick-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* ── Login ───────────────────────────────────────── */
.page-login { display: flex; justify-content: center; padding-top: 40px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-subtitle { font-size: .85rem; color: #6b7280; margin: 4px 0 20px; }
.alert-error { background: #fef2f2; color: #dc2626; padding: 10px; border-radius: 8px; font-size: .85rem; margin-bottom: 12px; }

/* ── Utilities ───────────────────────────────────── */
.flex-grow { flex: 1; }
.input-row { display: flex; gap: 8px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px !important; font-size: .8rem !important; display: inline !important; width: auto !important; }
.customer-found { background: #f0fdf4; border: 1px solid #bbf7d0; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: .85rem; }
.order-actions { display: flex; gap: 8px; margin-top: 8px; }
.order-actions .btn-primary, .order-actions .btn-danger { display: inline; width: auto; padding: 6px 12px; font-size: .8rem; }
.badge-processing { font-size: .75rem; color: #6b7280; font-style: italic; }
.order-total-row { font-size: 1rem; padding: 12px 0; border-top: 2px solid #e5e7eb; margin-top: 8px; }
.redirect-to-login { text-align: center; padding: 40px 20px; }
.redirect-to-login p { color: #6b7280; margin-bottom: 16px; }

.not-found { padding: 40px; text-align: center; }

.section-header { display: flex; align-items: center; gap: 8px; }
.section-header h2 { flex: 1; }
.section { margin-bottom: 24px; }
.section h2 { font-size: 1.1rem; margin-bottom: 12px; color: #374151; }

.page-dashboard, .page-products, .page-orders, .page-stream { padding-bottom: 20px; }

.badge-inactive { font-size: .7rem; background: #fef2f2; color: #ef4444; padding: 2px 8px; border-radius: 6px; }

.stream-control { max-width: 360px; margin: 20px auto; }
