* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2d5a27;
    --primary-light: #4a8c3f;
    --secondary: #f5f5f5;
    --accent: #ff9800;
    --danger: #e53935;
    --text: #333;
    --text-light: #666;
    --border: #ddd;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--secondary);
    color: var(--text);
    min-height: 100vh;
}

/* Navigation */
nav {
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand {
    font-size: 1.3rem;
    font-weight: bold;
    padding: 0.8rem 1rem;
}

.nav-tabs {
    display: flex;
    background: rgba(0,0,0,0.1);
}

.tab {
    flex: 1;
    text-align: center;
    padding: 0.8rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.tab.active {
    color: white;
    border-bottom-color: white;
    background: rgba(255,255,255,0.1);
}

/* Main content */
main {
    padding-bottom: 2rem;
}

.tab-content {
    display: none;
    padding: 1rem;
}

.tab-content.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.3rem;
    color: var(--primary);
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* Category groups */
.category-group {
    margin-bottom: 1.5rem;
}

.category-title {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

/* Item grid */
.item-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item-card {
    background: white;
    border-radius: 8px;
    padding: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-name {
    display: block;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-barcode {
    font-size: 0.75rem;
    color: var(--text-light);
    font-family: monospace;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.item-qty {
    background: var(--primary-light);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.9rem;
    min-width: 2rem;
    text-align: center;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.btn-icon:hover {
    opacity: 1;
}

/* Shopping list */
.add-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: white;
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.add-form input {
    flex: 1;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}

.add-form select {
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    max-width: 120px;
}

.btn-add {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    width: 44px;
    font-size: 1.5rem;
    cursor: pointer;
}

.shopping-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shopping-item {
    background: white;
    border-radius: 8px;
    padding: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    box-shadow: var(--shadow);
}

.shopping-item.checked {
    opacity: 0.5;
    background: #f0f0f0;
}

.shopping-item.checked .item-name {
    text-decoration: line-through;
}

.check-btn {
    width: 32px;
    height: 32px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    background: white;
    color: var(--primary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shopping-item.checked .check-btn {
    background: var(--primary);
    color: white;
}

.item-category {
    font-size: 0.75rem;
    color: var(--text-light);
    display: block;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    opacity: 0.5;
}

.btn-delete:hover {
    opacity: 1;
}

/* Checked section */
.checked-section {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.checked-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.checked-header h3 {
    font-size: 0.9rem;
    color: var(--text-light);
}

.btn-clear {
    background: none;
    border: 1px solid var(--border);
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.8rem;
}

.checked-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.checked-list .shopping-item {
    padding: 0.5rem 0.8rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state p {
    margin-bottom: 0.5rem;
}

.hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Utilities */
.inline-form {
    display: inline;
}

/* Mobile optimizations */
@media (max-width: 400px) {
    .add-form select {
        display: none;
    }
}

/* PWA install banner */
@media (display-mode: standalone) {
    nav {
        padding-top: env(safe-area-inset-top);
    }
}

/* Live indicator */
.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
    margin-left: 0.5rem;
    vertical-align: middle;
    transition: background 0.3s;
}

.live-dot.connected {
    background: #4caf50;
    box-shadow: 0 0 8px #4caf50;
}

.live-dot.flash {
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); background: #ff9800; }
    100% { transform: scale(1); }
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
