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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 16px; }

header {
    background: #1e40af;
    color: white;
    padding: 14px 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

header h1 { font-size: 1.4rem; }
header a { color: white; text-decoration: none; }

/* Search */
.search-box {
    display: flex;
    gap: 8px;
    margin: 20px 0;
}

.search-box input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #d1d5db;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input[type="text"]:focus {
    border-color: #1e40af;
}

.search-box button {
    padding: 12px 24px;
    background: #1e40af;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.search-box button:hover { background: #1e3a8a; }

/* Cabinet cards */
.cabinet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.cabinet-card {
    background: white;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 1px solid #e5e7eb;
}

.cabinet-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    border-color: #93c5fd;
}

.cabinet-card h2 { font-size: 1.25rem; margin-bottom: 2px; }

.cabinet-card .dims { color: #6b7280; font-size: 0.85rem; }

/* Drawer grid */
.drawer-grid {
    display: grid;
    gap: 6px;
    margin: 16px 0;
}

.drawer-cell {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 6px;
    text-align: center;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s, border-color 0.15s;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.drawer-cell:hover {
    background: #eff6ff;
    border-color: #1e40af;
}

.drawer-cell.has-items {
    border-color: #1e40af;
    background: #eff6ff;
}

.drawer-cell .coord { font-weight: 700; font-size: 0.8rem; }
.drawer-cell .count { font-size: 0.65rem; color: #1e40af; margin-top: 2px; }

/* Forms */
.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 1rem;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: #1e40af;
}

.btn {
    display: inline-block;
    padding: 10px 22px;
    background: #1e40af;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn:hover { background: #1e3a8a; }

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }

.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

.btn-outline {
    background: transparent;
    color: #1e40af;
    border: 2px solid #1e40af;
}

.btn-outline:hover { background: #eff6ff; }

/* Component list */
.comp-list { list-style: none; }

.comp-item {
    background: white;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #e5e7eb;
    gap: 12px;
}

.comp-item .info { flex: 1; }

.comp-item .actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.comp-item .qty-form {
    display: flex;
    gap: 4px;
    align-items: center;
}

.qty-form input[type="number"] {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-align: center;
    font-size: 0.85rem;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    color: #1e40af;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

/* Autocomplete */
.autocomplete { position: relative; }

.autocomplete-items {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.autocomplete-items div {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.9rem;
}

.autocomplete-items div:hover { background: #eff6ff; }
.autocomplete-items div:last-child { border-bottom: none; }

/* Breadcrumb */
.breadcrumb {
    margin: 16px 0;
    font-size: 0.9rem;
    color: #6b7280;
}

.breadcrumb a { color: #1e40af; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 6px; color: #9ca3af; }

/* Section titles */
h2 { font-size: 1.3rem; margin-bottom: 8px; }
h3 { font-size: 1.1rem; margin: 20px 0 10px; color: #374151; }

/* inline forms */
.inline-form { display: inline-flex; gap: 4px; align-items: center; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 14px;
    padding: 24px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 { margin-top: 0; }

/* Summary badges */
.badge {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}

/* Responsive */
@media (max-width: 768px) {
    .cabinet-grid { grid-template-columns: repeat(2, 1fr); }
    .drawer-cell { min-height: 44px; padding: 6px 4px; font-size: 0.7rem; }
}

@media (max-width: 480px) {
    .cabinet-grid { grid-template-columns: 1fr; }
    .drawer-grid { grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)) !important; }
    .drawer-cell { min-height: 38px; padding: 4px 2px; font-size: 0.65rem; border-radius: 4px; gap: 4px; }
    .drawer-cell .coord { font-size: 0.65rem; }
    .drawer-cell .count { font-size: 0.55rem; }
    .search-box { flex-direction: column; }
    .search-box button { width: 100%; }
    .comp-item { flex-direction: column; align-items: stretch; }
    .comp-item .actions { justify-content: flex-end; }
    .container { padding: 10px; }
    header h1 { font-size: 1.1rem; }
}
