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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    line-height: 1.4;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
}

header {
    background: #1a1a1a;
    color: white;
    padding: 12px 0;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header .container > a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
}

header .container > a img {
    height: 40px;
    margin-right: 15px;
}

header .container > a h1 {
    margin: 0;
}

header h1 {
    font-size: 1.5em;
}

nav a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.95em;
}

/* Compact, information-dense grid */
.remnants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

/* Compact card design */
.remnant-card {
    background: white;
    border-radius: 4px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: box-shadow 0.2s;
}

.remnant-card:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Image wrapper - clickable, no crop */
.card-image-wrapper {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    border-radius: 3px;
    margin-bottom: 8px;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

.card-image-wrapper:hover {
    background: #f0f0f0;
}

.card-image-wrapper .card-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.card-image-wrapper .no-image {
    width: 100%;
    height: 100%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.85em;
}

/* Compact card content */
.card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.card-title-section {
    display: flex;
    flex-direction: column;
    margin: 0 0 2px 0;
    line-height: 1.2;
}

.card-color {
    font-size: 0.9em;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.card-material-brand {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 0.7em;
    margin: 0 0 4px 0;
}

.card-material {
    color: #666;
    font-weight: 400;
}

.card-separator {
    color: #999;
    font-weight: 300;
}

.card-brand {
    color: #888;
    font-weight: 400;
}

.card-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75em;
    margin: 0 0 4px 0;
    gap: 6px;
}

.card-size {
    color: #333;
    font-weight: 500;
}

.card-slab-id {
    font-size: 0.7em;
    color: #999;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    gap: 6px;
}

.card-price {
    font-size: 0.9em;
    font-weight: bold;
    color: #2d5016;
}

.card-button {
    padding: 4px 10px;
    background: #6b9c66;
    border: 1.5px solid #6b9c66;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75em;
    color: #fff;
    white-space: nowrap;
    transition: all 0.2s;
    font-weight: 500;
}

.card-button:hover {
    background: #5a8556;
    border-color: #5a8556;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(107, 156, 102, 0.4);
}

.page-title {
    margin: 10px 0;
    padding: 0;
}

.page-title h1 {
    font-size: 1.5em;
    color: #1a1a1a;
    margin: 0;
}

.filters {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 15px 0;
    flex-wrap: wrap;
    padding: 15px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.search-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 250px;
}

.search-group input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.9em;
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filters label {
    font-size: 0.9em;
    color: #666;
    white-space: nowrap;
}

.filters select, .filters button {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.9em;
    background: white;
}

.filters button {
    background: #a8d5a3;
    border: none;
    cursor: pointer;
    color: #000;
    white-space: nowrap;
}

.filters button:hover {
    background: #8bc584;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    overflow: auto;
    cursor: pointer;
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 30px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    transition: background 0.3s;
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
    color: white;
}

.lightbox-image {
    display: block;
    margin: 0 auto;
    padding: 60px 20px 20px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    cursor: default;
    pointer-events: none; /* Prevent image click from closing lightbox */
}

/* Admin styles */
table {
    width: 100%;
    background: white;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.9em;
}

table th, table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table th {
    background: #333;
    color: white;
    font-weight: 600;
}

table tr:hover {
    background: #f9f9f9;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    margin: 50px auto;
}

.close {
    float: right;
    font-size: 28px;
    cursor: pointer;
}

form label {
    display: block;
    margin: 15px 0;
}

form input, form textarea, form select {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    background: white;
    margin: 10px 0;
    border-radius: 4px;
}

.cart-item button {
    background: #f5a5a5;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
}

.cart-item button:hover {
    background: #e89494;
}

#imagePreview img {
    max-width: 200px;
    margin-top: 10px;
    border-radius: 4px;
}

/* Dimension search section - integrated at top of filters */
.dimension-search-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    padding-bottom: 12px;
    border-bottom: 1px solid #e8e8e8;
    margin-bottom: 0px;
}

.dimension-search-section .section-label {
    font-weight: 600;
    font-size: 0.95em;
    color: #333;
    margin: 0;
    white-space: nowrap;
}

.dimension-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
}

.dimension-input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.dimension-input-group label {
    font-size: 0.9em;
    margin: 0;
    color: #666;
    white-space: nowrap;
}

.dimension-input-group input[type="number"] {
    width: 95px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.9em;
}

.dimension-input-group input[type="number"]:focus {
    outline: none;
    border-color: #6b9c66;
}

.dimension-search-btn,
.dimension-clear-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    white-space: nowrap;
}

.dimension-search-btn {
    background: #6b9c66;
    color: white;
}

.dimension-search-btn:hover {
    background: #5a8a55;
}

.dimension-clear-btn {
    background: #999;
    color: white;
}

.dimension-clear-btn:hover {
    background: #777;
}

.filter-divider {
    width: 100%;
    height: 0;
    margin: 0;
    padding: 0;
}
