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

:root {
    --bg: #f5f5f7;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #059669;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

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

.topbar {
    background: #1f2937;
    color: white;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.brand { color: white; text-decoration: none; font-weight: 600; font-size: 18px; }
.topbar nav { display: flex; gap: 10px; align-items: center; }
.topbar nav a { color: white; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.topbar nav a:hover { background: rgba(255,255,255,0.1); }

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

h1 { font-size: 24px; margin-bottom: 16px; }
h2 { font-size: 18px; margin-bottom: 12px; color: var(--text); }
h3 { font-size: 16px; margin-bottom: 8px; }

.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}
.search-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: white;
}
.search-form button {
    padding: 10px 18px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

.box-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 16px;
}
.box-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: var(--shadow);
}
.box-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.thumb {
    height: 140px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { font-size: 48px; }
.box-info { padding: 12px; }
.box-info h3 { margin-bottom: 4px; }
.location { color: var(--text-muted); font-size: 13px; margin-bottom: 4px; }
.count { color: var(--text-muted); font-size: 13px; }

.box-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.box-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notes { color: var(--text-muted); margin-top: 6px; }

.section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; }
.form input, .form textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: white;
}
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }

.card { background: #fef9c3; border: 1px solid #fde047; padding: 16px; border-radius: 12px; margin-bottom: 16px; }

.btn-primary, .btn-secondary, .btn-danger {
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger { background: var(--danger); color: white; margin-top: 10px; }
.btn-icon-danger {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 6px;
}
.btn-icon-danger:hover { background: #fee2e2; }

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.photo-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
}
.photo-card img { width: 100%; height: 100%; object-fit: cover; }
.photo-card form {
    position: absolute;
    top: 6px;
    right: 6px;
}
.photo-card .btn-icon-danger {
    background: rgba(255,255,255,0.95);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.upload-form { margin-top: 10px; }
.file-input-label {
    display: inline-block;
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}
.file-input-label:hover { background: var(--primary-hover); }
.file-input-label input { display: none; }

.add-item-form {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.add-item-form input[type="text"] {
    flex: 1;
    min-width: 150px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
}
.add-item-form input.qty {
    width: 70px;
    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
}

.item-list { list-style: none; }
.item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: none; }
.item-inline {
    flex: 1;
    display: flex;
    gap: 8px;
    align-items: center;
}
.item-inline input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    font-size: 15px;
}
.item-inline input[type="text"]:focus { border-color: var(--border); background: white; outline: none; }
.item-inline input.qty {
    width: 60px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.qr-display {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.qr-display img {
    width: 200px;
    height: 200px;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.qr-display > div { display: flex; flex-direction: column; gap: 10px; }

.empty {
    text-align: center;
    padding: 40px 20px;
    background: var(--card);
    border-radius: 12px;
    border: 1px dashed var(--border);
}

.muted { color: var(--text-muted); font-size: 14px; }
.hidden { display: none; }

.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .container { padding: 12px; }
    .box-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .thumb { height: 110px; }
    h1 { font-size: 20px; }
    .topbar { padding: 12px 14px; }
    .topbar nav a { padding: 6px 8px; font-size: 14px; }
    .qr-display img { width: 160px; height: 160px; }
}
