/* === Base Reset & Typography (Mobile-First) === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #F5F5F5;
    color: #212121;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
input, button, select, textarea {
    font-family: inherit;
    font-size: 16px; /* prevents iOS zoom on focus */
}

/* === CSS Variables === */
:root {
    --primary: #1B5E20;
    --primary-light: #2E7D32;
    --primary-dark: #0D3B13;
    --accent: #FFC107;
    --accent-dark: #FFA000;
    --bg: #F5F5F5;
    --surface: #FFFFFF;
    --danger: #D32F2F;
    --danger-light: #FFEBEE;
    --text: #212121;
    --text-secondary: #757575;
    --border: #E0E0E0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 10px;
    --nav-height: 56px;
    --topbar-height: 48px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* === App Layout === */
#app {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

/* === Top Bar === */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--topbar-height) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    padding-left: 16px;
    padding-right: 16px;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.topbar-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.topbar .shop-name {
    font-weight: 600;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.sync-info {
    font-size: 0.65rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 1px;
}
.sync-info .sync-ok { color: #A5D6A7; }
.sync-info .sync-warn { color: #FFE082; }
.sync-info .sync-danger { color: #EF9A9A; }
.sync-info .sync-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}
.sync-info .dot-green { background: #81C784; }
.sync-info .dot-orange { background: #FFB74D; }
.sync-info .dot-red { background: #EF5350; }
.sync-info .dot-pulse { animation: pulse 1s infinite; }
.sync-info-tap {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    opacity: inherit;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    -webkit-tap-highlight-color: transparent;
}
.topbar-sync-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    padding: 8px;
    margin-left: 8px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s;
}
.topbar-sync-btn:active {
    background: rgba(255,255,255,0.15);
}
.topbar-sync-btn.syncing svg {
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.topbar-logout {
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    padding: 8px;
    margin-left: 8px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.topbar-logout:active {
    background: rgba(255,255,255,0.15);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* === Bottom Navigation === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    padding: 6px 0;
    min-height: 48px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.nav-item:active { opacity: 0.7; }
.nav-item.active { color: var(--primary); }
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 0.65rem; font-weight: 500; }

/* === Page Content === */
.page {
    padding: calc(var(--topbar-height) + var(--safe-top) + 8px) 12px 16px;
}
.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--primary-dark);
}

/* === Full-Screen Form Page (replaces modals for forms) === */
.fullpage {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(var(--nav-height) + var(--safe-bottom));
    background: var(--bg);
    z-index: 110;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.fullpage.active {
    transform: translateX(0);
}
.fullpage-header {
    height: calc(var(--topbar-height) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    padding-left: 8px;
    padding-right: 16px;
    flex-shrink: 0;
}
.fullpage-back {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
}
.fullpage-back svg { width: 24px; height: 24px; }
.fullpage-title {
    flex: 1;
    font-weight: 600;
    font-size: 1.05rem;
}
.fullpage-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
}
.fullpage-footer {
    padding: 12px 16px;
    background: var(--surface);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    flex-shrink: 0;
}
.fullpage-footer:empty {
    display: none;
}

/* === Auth Pages (no nav) === */
.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}
.auth-card {
    background: white;
    border-radius: 16px;
    padding: 28px 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}
.auth-logo h1 {
    font-size: 1.6rem;
    color: var(--primary);
}
.auth-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.auth-version {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(27,94,32,0.1);
    border-radius: 12px;
    letter-spacing: 0.5px;
}

/* === Utility === */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--primary); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* === No scrollbar on mobile === */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }
