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

:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-muted: #666;
    --border: #e0e0e0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --warning: #f59e0b;
    --success: #16a34a;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    text-decoration: none;
    padding: 0.75rem 0;
}

.nav-links {
    display: flex;
    gap: 0;
    overflow-x: auto;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.75rem 0.75rem;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    font-size: 0.9rem;
}

.nav-links a.active,
.nav-links a:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1rem; margin-bottom: 0.5rem; }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-number { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); }
.stat-warning .stat-number { color: var(--warning); }
.stat-danger .stat-number { color: var(--danger); }

.estimated-cost {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.5rem 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    line-height: 1.5;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d0d0d0; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

.table th, .table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.table .actions { white-space: nowrap; }
.table .actions .btn { margin-left: 0.25rem; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-ok { background: #dcfce7; color: #166534; }
.badge-low { background: #fef3c7; color: #92400e; }
.badge-out { background: #fecaca; color: #991b1b; }
.badge-unknown { background: #e5e7eb; color: #374151; }

/* Forms */
.form-group {
    margin-bottom: 1rem;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header h1 { margin-bottom: 0; }

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Filters */
.filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.filters select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Stock update */
.stock-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.stock-name { font-weight: 500; flex: 1; }

.stock-input {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stock-input input {
    width: 60px;
    text-align: center;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stock-unit { font-size: 0.85rem; color: var(--text-muted); min-width: 30px; }

.category-header {
    margin-top: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
    color: var(--primary);
}

.sticky-bottom {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding: 1rem;
    border-top: 1px solid var(--border);
    margin: 1rem -1rem -1rem;
}

/* Upload */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
}

.upload-icon { font-size: 3rem; margin-bottom: 0.5rem; }

/* Table inputs */
.table-input {
    width: 100%;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}

.table-input-sm {
    width: 70px;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Shopping */
.shopping-row.checked-off td {
    text-decoration: line-through;
    opacity: 0.5;
}

.shopping-summary {
    text-align: right;
    font-size: 1.2rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.dismissed-section { margin-top: 1.5rem; }
.dismissed-section h2 { color: var(--text-muted); }
.dismissed-row { opacity: 0.7; }

.estimated-badge {
    background: var(--primary);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    font-weight: 600;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 1rem auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 640px) {
    .form-row { flex-direction: column; gap: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .table { font-size: 0.8rem; }
    .table th, .table td { padding: 0.4rem; }
    .filters { flex-direction: column; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
