:root {
    --header-h: 64px;
    --accent: #6366f1;
    --accent-dark: #4f46e5;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 12px;
}

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

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

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: 16px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    min-height: calc(var(--header-h) + env(safe-area-inset-top));
}

header h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

header button {
    background: white;
    color: var(--accent);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

main {
    padding-top: calc(var(--header-h) + env(safe-area-inset-top) + 16px);
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    max-width: 600px;
    margin: 0 auto;
}

#loading {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 0;
}

#filters {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

#filters input,
#filters select {
    flex: 1;
    min-width: 140px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
}

#items-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

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

.item-product {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 2px;
}

.item-company {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.item-category {
    display: inline-block;
    background: #ede9fe;
    color: var(--accent-dark);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
    margin-bottom: 4px;
}

.item-notes {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: pre-wrap;
    margin-top: 4px;
}

.item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.item-actions button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-muted);
}

.item-actions .btn-delete {
    color: #ef4444;
    border-color: #fecaca;
}

#empty-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 0;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
}

.modal[hidden] { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.modal-content h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
}

form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 14px;
    color: var(--text);
}

form input,
form textarea,
form select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
}

form input:focus,
form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.btn-primary {
    flex: 1;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 1rem;
    cursor: pointer;
}
