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

/* Normalize form elements across browsers */
input, button, textarea, select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

button {
    -webkit-appearance: none;
    appearance: none;
}

/* Consistent focus styles */
input:focus, button:focus, textarea:focus, select:focus {
    outline: 2px solid #007bff;
    outline-offset: 1px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: #f4f4f4;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1 {
    color: #333;
    margin-bottom: 30px;
    text-align: center;
}

h2 {
    color: #555;
    margin-bottom: 20px;
}

.form-section {
    margin-bottom: 40px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 5px;
}

#partForm {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    flex-basis: 100%;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 5px;
}

#partForm input, #partForm select, #partForm textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-family: inherit;
    background-color: white;
}

#partForm select {
    padding-right: 32px;
}

#partForm textarea {
    resize: vertical;
}

#partForm button[type="submit"] {
    padding: 12px 24px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    align-self: flex-start;
}

#partForm button[type="submit"]:hover {
    background-color: #0056b3;
}

.parts-section {
    margin-top: 30px;
}

/* Table styles */
.table-container {
    overflow-x: auto;
}

#partsTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#partsTable thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
}

#partsTable tbody td {
    padding: 10px 8px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.part-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.part-row:hover {
    background-color: #f8f9fa;
}

.part-row.expanded {
    background-color: #e7f1ff;
}

.expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    color: #666;
}

.expand-btn:hover {
    color: #007bff;
}

.detail-row {
    background-color: #fafbfc;
}

.detail-row td {
    padding: 0 !important;
    border-bottom: 2px solid #dee2e6;
}

.detail-content {
    padding: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.detail-section {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
}

.detail-section h4 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.detail-fields p {
    margin: 6px 0;
    font-size: 13px;
    color: #555;
}

.detail-activity {
    grid-column: 1 / -1;
}

.col-stock {
    font-weight: 500;
}

.col-status {
    white-space: nowrap;
}

.activity-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.activity-label {
    font-size: 14px;
    color: #666;
    font-weight: bold;
}

.add-note-btn {
    padding: 3px 10px;
    font-size: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.add-note-btn:hover {
    background-color: #0056b3;
}

.activity-list {
    margin-bottom: 10px;
}

.no-notes {
    color: #999;
    font-size: 14px;
    margin: 0;
}

.activity-item {
    display: flex;
    gap: 10px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 6px;
}

.activity-item.status-change {
    background-color: #f0f7ff;
    border-color: #b3d4fc;
}

.activity-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.note-content {
    font-size: 14px;
    color: #333;
    margin: 0 0 4px 0;
    white-space: pre-wrap;
}

.status-change-text {
    font-size: 14px;
    color: #333;
    margin: 0 0 4px 0;
}

.status-change-note {
    font-size: 13px;
    color: #555;
    margin: 4px 0;
    padding: 4px 8px;
    background-color: #f8f8f8;
    border-left: 2px solid #007bff;
    font-style: italic;
}

.activity-meta {
    font-size: 12px;
    color: #888;
    font-style: italic;
}

.add-note-form {
    background-color: #fff;
    border: 1px solid #007bff;
    border-radius: 4px;
    padding: 10px;
}

.new-note-textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 8px;
    background-color: white;
    min-height: 60px;
}

.add-note-actions {
    display: flex;
    gap: 8px;
}

.save-new-note-btn, .cancel-new-note-btn {
    padding: 5px 12px;
    font-size: 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.save-new-note-btn {
    background-color: #28a745;
    color: white;
}

.save-new-note-btn:hover {
    background-color: #218838;
}

.cancel-new-note-btn {
    background-color: #6c757d;
    color: white;
}

.cancel-new-note-btn:hover {
    background-color: #5a6268;
}

.part-info h3 {
    color: #333;
    margin-bottom: 5px;
}

.part-info p {
    color: #666;
    margin: 3px 0;
    font-size: 14px;
}

.part-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-update-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.status-note-input {
    flex: 1;
    min-width: 150px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.status-select {
    padding: 5px 28px 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
}

/* Action required statuses - orange/red */
.status-d2, .status-d3, .status-d4, .status-d5, .status-d6 {
    color: #dc3545;
    font-weight: 500;
}

/* Complete statuses - green */
.status-d7, .status-d8, .status-d9, .status-d0, .status-d01, .status-d02 {
    color: #28a745;
    font-weight: 500;
}

/* Legacy statuses */
.status-returned {
    color: #dc3545;
}

.status-stored {
    color: #ffc107;
}

.status-sold {
    color: #28a745;
}

.part-meta {
    font-size: 12px;
    color: #888;
    margin-top: 8px;
}

.update-btn, .delete-btn {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
}

.update-btn {
    background-color: #28a745;
    color: white;
}

.update-btn:hover {
    background-color: #218838;
}

.delete-btn {
    background-color: #dc3545;
    color: white;
}

.delete-btn:hover {
    background-color: #c82333;
}

.loading {
    text-align: center;
    color: #666;
    padding: 20px;
}

.error {
    color: #dc3545;
    text-align: center;
    padding: 20px;
}