:root {
    --primary: #3D2B1F;       /* Deep Coffee - Core brand color */
    --primary-hover: #2B1E15; /* Rich Roast */
    --success: #15803d;       /* Muted Emerald 700 */
    --success-hover: #166534; /* Muted Emerald 800 */
    --danger: #b91c1c;        /* Red 700 */
    --danger-hover: #991b1b;  /* Red 800 */
    --stone-50: #fafaf9;
    --stone-100: #f5f5f4;
    --stone-200: #e7e5e4;
    --stone-300: #d6d3d1;
    --stone-600: #57534e;
    --stone-700: #44403c;
    --stone-800: #292524;
    --stone-900: #1c1917;
    --brand-primary: var(--primary);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--stone-50);
    color: var(--stone-700);
    margin: 0;
}

/* --- General Layout --- */
.main-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    display: flex;
    justify-content: center;
    flex-grow: 1;
}

.dashboard-container,
.management-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* --- Login Page --- */
.login-page-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    padding: 20px;
}

.login-display-header {
    text-align: center;
    margin-bottom: 30px;
}

.main-logo {
    max-width: 250px;
    height: auto;
}

.login-card {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

/* --- Header --- */
.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    width: 100%;
    box-sizing: border-box;
}

.nav-left .app-logo {
    height: 40px;
    display: block;
}

.nav-center {
    display: flex;
    gap: 16px;
}

.nav-right {
    display: flex;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--stone-600);
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.nav-link:hover {
    background-color: var(--stone-100);
    color: var(--stone-900);
}

.nav-link.active {
    background-color: var(--primary);
    color: white;
}

.logout-button {
    text-decoration: none;
    background-color: var(--stone-100);
    color: var(--stone-600);
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.logout-button:hover {
    background-color: var(--stone-200);
    color: var(--stone-900);
}



/* --- Cards & Rows --- */
.dashboard-row,
.management-row {
    background-color: #ffffff;
    margin-top: 30px;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* --- Design Variants Page Layout --- */
.top-section-grid {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    /* Align items to the top */
    margin-top: 30px;
}

.design-details-panel {
    flex: 1.5;
    /* Takes more space */
    margin-top: 0;
}

.generation-status-panel {
    flex: 1;
    /* Takes less space */
    margin-top: 0;
}


/* --- Forms --- */
.form-row {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
    flex-grow: 1;
    min-width: 200px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: #374151;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 43, 31, 0.1);
}

.modern-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #ffffff;
    font-size: 16px;
    color: #374151;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modern-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 43, 31, 0.1);
}

/* --- Custom Searchable Select with Swatches --- */
.custom-select-wrapper {
    position: relative;
    width: 100%;
    user-select: none;
    z-index: 10;
    /* Base z-index */
}

.custom-select-wrapper.active {
    z-index: 10000;
    /* Higher than other cards when open */
}

/* Helper to ensure parent cards float when a dropdown is open */
.palette-card.has-active-dropdown {
    z-index: 2000 !important;
    overflow: visible !important;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 42px;
}

.custom-select-wrapper.active .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 43, 31, 0.1);
}

.custom-select-trigger:after {
    content: "";
    width: 15px;
    height: 15px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-size: contain;
    background-repeat: no-repeat;
    transition: transform 0.2s;
}

.custom-select-wrapper.active .custom-select-trigger:after {
    transform: rotate(180deg);
}

/* --- Full-Width Responsive Color Drawer for Palette Cards --- */
.palette-card-color-drawer {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    width: 100%;
    box-sizing: border-box;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
    z-index: 10000;
    display: none;
    padding: 14px 18px 18px 18px;
    max-height: min(520px, calc(100vh - 180px));
    overflow-y: auto;
    opacity: 1 !important;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
    box-sizing: border-box;
}

.drawer-title {
    font-size: 14px;
    color: #475569;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.drawer-title-prefix {
    color: #64748b;
    margin-right: 4px;
}

.drawer-active-slot-name {
    color: #0f172a;
    font-weight: 700;
    text-transform: uppercase;
}

.drawer-close-btn {
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.drawer-close-btn:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.drawer-search-wrapper {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.drawer-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #94a3b8;
    pointer-events: none;
    z-index: 2;
    flex-shrink: 0;
}

.palette-card-color-drawer .custom-select-search {
    width: 100%;
    height: 42px;
    padding: 0 36px 0 40px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    line-height: 42px;
    color: #0f172a;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
    margin: 0;
}

.palette-card-color-drawer .custom-select-search:focus {
    border-color: #0f172a;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.drawer-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    z-index: 2;
    flex-shrink: 0;
}

.drawer-search-clear:hover {
    color: #0f172a;
    background: #f1f5f9;
}

/* Grid & Swatches (Responsive by screen size) */
.palette-card-color-drawer .custom-options-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 14px;
}

@media (max-width: 900px) {
    .palette-card-color-drawer {
        padding: 12px 14px 14px 14px;
    }
    .palette-card-color-drawer .custom-options-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
    .custom-option .swatch {
        height: 80px !important;
    }
}

@media (max-width: 640px) {
    .palette-card-color-drawer {
        padding: 10px 12px 12px 12px;
    }
    .palette-card-color-drawer .custom-options-list {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
    }
    .drawer-title {
        font-size: 13px;
    }
}

.custom-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    border-radius: 10px;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    transition: all 0.18s ease;
    text-align: center;
    box-sizing: border-box;
}

.custom-option:hover {
    border-color: #0f172a;
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.custom-option.selected {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.custom-option .swatch {
    width: 100%;
    height: 95px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    margin-bottom: 6px;
    transition: transform 0.15s ease;
}

.custom-option:hover .swatch {
    transform: scale(1.02);
}

.custom-option .swatch-name {
    color: #1e293b;
    font-weight: 600;
    font-size: 12px;
    line-height: 1.25;
    word-break: break-word;
    max-width: 100%;
}

.custom-option .swatch-hex {
    font-size: 10px;
    color: #64748b;
    font-family: monospace;
    margin-top: 2px;
}

.custom-select-trigger.active-slot {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25) !important;
    background: #eff6ff !important;
}

.trigger-selected-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trigger-selected-content .swatch {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 4px;
    background-color: var(--primary);
    color: white;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
}

.btn.btn-primary {
    width: auto;
    padding: 12px 24px;
}

.custom-file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 5px;
    background-color: #f9fafb;
}

.custom-file-button {
    flex-shrink: 0;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background-color: var(--primary);
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

.custom-file-button:hover {
    background-color: var(--primary-hover);
}

.file-name-display {
    flex-grow: 1;
    color: #6b7280;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Color Management Page --- */
.management-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.color-type-section,
.color-section {
    padding: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.item-list {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}

.item-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s;
}

.item-list li:last-child {
    border-bottom: none;
}

.item-list li:hover {
    background-color: #f9fafb;
}

.color-swatch {
    width: 70px;
    height: 30px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    display: inline-block;
    margin-right: 10px;
    vertical-align: middle;
}

.action-buttons button {
    background-color: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
    cursor: pointer;
    font-weight: 500;
    margin-left: 15px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 14px;
    transition: background-color 0.2s, color 0.2s;
}

.action-buttons button:hover {
    background-color: var(--danger-hover-bg);
    color: var(--danger-hover-text);
}

/* --- Image Grid --- */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.design-card {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s;
    position: relative;
    /* This is the critical fix for positioning context */
}

.design-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* --- Status Highlighting for Design Cards --- */
.design-card.status-in-progress {
    border-color: #92c30c;
    /* Amber border */
    box-shadow: 0 0 15px rgb(43 129 43 / 77%);
    /* Amber glow */

}

.design-card.status-pending {
    background-color: #ffffff;
    border-color: var(--stone-300);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
}

.design-card.status-failed {
    border-color: var(--danger);
    box-shadow: 0 0 15px rgba(185, 28, 28, 0.1);
}

.card-image-container {
    position: relative;
}

/* This new rule is the specific fix for the image spacing issue */
.card-image-container a {
    display: block;
    line-height: 0;
}

.delete-icon-form {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.design-card:hover .delete-icon-form {
    opacity: 1;
    visibility: visible;
}

.btn-icon-delete {
    background: #2D3748;
    /* Solid dark grey */
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    padding: 0;
    box-shadow: 0 0 44px rgba(255, 255, 255, 1);
    /* Red, EVEN LARGER outer glow */
}

.btn-icon-delete:hover {
    background: #E53E3E;
    /* Red on hover */
    box-shadow: 0 0 44px rgba(255, 0, 0, 0.9);
    /* Red, EVEN LARGER outer glow */
}

.btn-icon-delete svg {
    stroke: white;
    width: 16px;
    height: 16px;
}

.design-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: contain;
    background-color: #ffffff;
    display: block;
}

.design-info {
    padding: 12px 15px;
    position: relative;
    /* Positioning context for the progress bar */
    overflow: hidden;
    /* Keep the progress bar contained */
}

.design-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.design-title {
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-grow: 1;
}

.btn-edit-design-name {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.design-title-row:hover .btn-edit-design-name,
.design-info:hover .btn-edit-design-name,
.design-card:hover .btn-edit-design-name,
.design-title-with-edit:hover .btn-edit-design-name {
    opacity: 0.65;
    visibility: visible;
}

.btn-edit-design-name:hover {
    opacity: 1 !important;
    color: #0f172a;
    background: #e2e8f0;
}

.design-title-with-edit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.program-name {
    margin: 0;
    font-weight: 500;
}

.card-subtitle-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 2px;
}

.separator {
    font-weight: 500;
}


.matching-count-overlay {
    color: #fff;
    /* Dark text for visibility on light capsule */
    font-weight: 600;
    font-size: 12px;
    text-align: center;
    width: 100%;
    padding-bottom: 8px;
    padding-top: 8px;
    padding-left: 0px;
    padding-right: 0px;
    background-color: #1f2937;
    border-radius: 50px;
    /*    border-bottom: 1px solid rgba(0, 0, 0, 0.1); */
    display: flex;
    /* Add flex properties for alignment */
    justify-content: center;
    align-items: baseline;
}

.progress-count-current {
    font-size: 12px;
    font-weight: 700;
    padding-left: 6px;
}

.progress-count-total {
    font-size: 10px;
    color: #9ba0ac;
    /* Lighter grey for the total */
    padding-right: 6px;
}



.card-progress-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.2);
    overflow: hidden;
    /* Keep the bar inside */
}

.card-progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--success);
    transition: width 0.5s ease-in-out;
}

/* Thicker progress bar for dashboard */
.design-actions .progress {
    height: 12px;
    margin-bottom: 0;
    background-color: #e5e7eb;
}

/* --- Inline Flash Banners --- */
.flash-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    overflow: hidden;
    opacity: 0;
    transform: translateY(100%);
    animation: flashFadeIn 0.4s ease forwards;
}

@keyframes flashFadeIn {
    to { opacity: 1; transform: translateY(0); }
}

.flash-banner.flash-hiding {
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.35s ease, transform 0.35s ease;
    animation: none;
}

.flash-banner-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: #fff;
    letter-spacing: 0.2px;
}

.flash-banner-close {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.7);
    transition: color 0.15s;
}
.flash-banner-close:hover {
    color: #fff;
}

/* Banner color variants */
.flash-success {
    background-color: #16a34a;
}

.flash-info {
    background-color: #2563eb;
}

.flash-warning {
    background-color: #ea580c;
}

.flash-danger {
    background-color: #dc2626;
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 20px 20px;
    background-color: #ffffff;
    border-top: 1px solid #e5e7eb;
    margin-top: auto;
}

.footer-link {
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
}

.footer-link:hover {
    color: #1f2937;
}

.footer-link img {
    height: 24px;
    width: auto;
}

/* --- Palette Management Page --- */
.palette-add-form {
    border: 1px solid #e5e7eb;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}

.palette-table-header-row,
.palette-table-body-row {
    display: flex;
    align-items: stretch;
    /* Make cells equal height */
}

.palette-table-header-row {
    background-color: #f9fafb;
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
    border-bottom: 1px solid #e5e7eb;
}

.header-cell,
.body-cell {
    padding: 12px 15px;
    flex-grow: 1;
    flex-basis: 0;
    /* Distribute space evenly */
    display: flex;
    align-items: center;
}

.header-cell:not(:last-child),
.body-cell:not(:last-child) {
    border-right: 1px solid #e5e7eb;
}

.palette-table-body-row {
    border-bottom: 1px solid #e5e7eb;
}

.palette-table-body-row:last-child {
    border-bottom: none;
}

.palette-table-body-row:hover {
    background-color: #f9fafb;
}

.palette-table-body {
    border: 1px solid #e5e7eb;
    border-radius: 0 0 8px 8px;
}

.actions-cell {
    justify-content: flex-end;
    /* Align buttons to the right */
    gap: 8px;
}



.not-set {
    color: #9ca3af;
    font-style: italic;
}

.no-palettes-cell {
    text-align: center;
    padding: 30px;
    color: #6b7280;
}

.palette-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #ffffff;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.palette-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(93, 67, 156, 0.1);
}

.palette-add-form .btn {
    padding: 10px 15px;
    /* Slightly smaller padding for in-table button */
    width: auto;
    font-size: 14px;
}

.actions-cell .delete-form {
    display: inline-block;
}

.btn-action {
    display: inline-block;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
    border: 1px solid transparent;
}

.btn-action:hover {
    transform: translateY(-1px);
}

.btn-action.edit {
    background-color: #e5e7eb;
    border-color: #d1d5db;
    color: #374151;
}

.btn-action.edit:hover {
    background-color: #d1d5db;
}

.btn-action.save {
    background-color: var(--success);
    border-color: var(--success-hover);
    color: white;
}

.btn-action.save:hover {
    background-color: var(--success-hover);
}

.btn-action.delete {
    background-color: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
    cursor: pointer;
}

.btn-action.delete:hover {
    background-color: #fca5a5;
    color: #7f1d1d;
}


/* --- Design Mapping Page Styles --- */
.design-mapping-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.design-mapping-header .design-thumbnail-container {
    flex-shrink: 0;
    /* Prevent thumbnail from shrinking */
}

.design-mapping-header .design-thumbnail {
    width: 150px;
    /* Smaller thumbnail for details view */
    height: 150px;
    object-fit: contain;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background-color: #f9fafb;
}

.design-mapping-header .design-details {
    flex-grow: 1;
}

.design-mapping-header .design-details p {
    margin: 5px 0;
    font-size: 16px;
    color: #374151;
}

.design-mapping-header.full-width-image .design-thumbnail-container {
    width: 100%;
}

.design-mapping-header.full-width-image .design-thumbnail {
    width: 100%;
    height: auto;
    /* Maintain aspect ratio */
    max-height: 700px;
    /* Optional: prevent excessively tall images */
}

.color-mapping-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.color-mapping-table th,
.color-mapping-table td {
    border: 1px solid #e5e7eb;
    padding: 12px 15px;
    text-align: left;
}

.color-mapping-table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #1f2937;
}

.color-mapping-table tbody tr:nth-child(even) {
    background-color: #fcfcfc;
}

.color-mapping-table .color-swatch {
    width: 100%;
    height: 100px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    align-self: center;
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
    transform: scale(0.95);
    animation: modal-appear 0.2s forwards ease-out;
}

.modal-content h3 {
    color: #1f2937;
    margin-top: 0;
    margin-bottom: 15px;
}

.modal-content p {
    color: #4b5563;
    margin-bottom: 25px;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-actions .btn {
    width: auto;
    padding: 10px 25px;
}

/* Animation for modal appearance */
@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Spinner --- */
.upload-section {
    position: relative;
}

.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    /* Match the parent card's radius */
    display: none;
    /* Hidden by default */
}

.spinner {
    border: 5px solid #e5e7eb;
    border-top: 5px solid var(--primary);
    border-right: 5px solid var(--primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 15px auto;
}

.spinner-overlay p {
    font-weight: 500;
    color: #374151;
    margin-top: 10px;
}

.progress-container {
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    height: 8px;
}

.progress-bar {
    background-color: var(--primary);
    height: 100%;
}

/* Mini Spinner for Badges */
.mini-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    margin-right: 6px;
}

.processing-psd-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    height: 100%;
}

.processing-psd-container span {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.95);
    white-space: nowrap;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.upload-form-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    /* Adjusted column widths */
    gap: 30px;
    align-items: start;
}

.drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 5px 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    transition: border-color 0.2s, background-color 0.2s;
    cursor: pointer;
    /* Make the whole area clickable */
}

.drop-zone.drag-over {
    border-color: var(--brand-primary);
    background-color: #f0f4ff;
}

.image-preview {
    max-width: 100%;
    max-height: 200px;
    /* Or match the min-height of drop-zone */
    object-fit: contain;
}

.drop-zone p {
    margin: 5px 0;
    color: #6b7280;
}

#drop-zone-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 15px;
    color: var(--brand-primary);
    /* Use brand color for icon */
}

.drop-zone.psd-selected {
    background-color: #f0f4ff;
    border-color: var(--brand-primary);
}

.drop-zone .icon {
    width: 60px;
    height: 60px;
    margin-bottom: 15px;
    color: var(--brand-primary);
}

.drop-zone .btn {
    width: auto;
    padding: 8px 20px;
    margin-top: 15px;
}

.drop-zone .file-name-display {
    margin-top: 10px;
    font-weight: 500;
    color: #374151;
}

.btn-action.view {
    background-color: var(--stone-700);
    border-color: var(--stone-800);
    color: white;
}

.btn-action.view:hover {
    background-color: var(--stone-900);
}

/* Progress Bar Styles */
.progress {
    height: 20px;
    background-color: #e9ecef;
    border-radius: 0.25rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background-color: var(--success);
    color: #fff;
    text-align: center;
    white-space: nowrap;
    transition: width 0.6s ease;
}

/* Variant Status Text */
.variant-status-text {
    font-size: 14px;
    font-weight: 500;
    margin-top: 5px;
}

.status-pending {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

.status-in_progress {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.status-complete {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.status-failed {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Design card for status display on variant page */
.variant-grid .design-card.status-pending,
.variant-grid .design-card.status-in_progress,
.variant-grid .design-card.status-failed {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    /* Match thumbnail height */
    text-align: center;
    border: 1px dashed #ccc;
    /* Indicate it's a job, not a final image */
}

/* --- Image Preview Modal --- */
.image-preview-container {
    text-align: center;
    margin-bottom: 1rem;
    background-color: #f3f4f6;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #e5e7eb;
}

#image-modal-preview-src {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 4px;
}

/* --- PSD Preview Modal --- */
.modal-content {
    text-align: left;
    max-width: 500px;
}

#modal-body-content h5 {
    font-size: 18px;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 10px;
    margin-top: 20px;
    margin-bottom: 15px;
}

#modal-body-content p {
    margin: 4px 0;
    font-size: 14px;
}

.channel-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.channel-list li {
    display: flex;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.color-swatch-small {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    margin-right: 12px;
    flex-shrink: 0;
}

.modal-content .form-group {
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    gap: 15px;
}

.modal-content .form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 14px;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    /* Changed from flex-end */
    align-items: center;
    /* Vertically align items */
    gap: 10px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.pixel-display-text {
    font-style: italic;
    color: #6b7280;
    /* A slightly muted color for secondary info */
    font-size: 13px;
}

.modal-footer .btn {
    width: auto;
    padding: 10px 20px;
}

.generation-options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.aspect-ratio-lock {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aspect-ratio-lock label {
    margin-bottom: 0;
    /* Override default form-group margin */
    font-size: 13px;
    color: #6b7280;
}

/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked+.slider:before {
    transform: translateX(16px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* --- Redesigned PSD Preview Modal --- */
.modal-content .modal-header {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 20px;
    text-align: center;
}

.channel-palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.channel-palette {
    display: flex;
    align-items: center;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
}

.channel-palette .color-swatch-small {
    width: 30px;
    height: 30px;
}

.channel-palette .channel-info {
    margin-left: 12px;
}

.channel-palette .channel-name {
    font-weight: 600;
    display: block;
}

.channel-palette .channel-meta {
    font-size: 12px;
    color: #6b7280;
}

.modal-content .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #f3f4f6;
    color: #6b7280;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 20px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.modal-content .close-button:hover {
    background-color: #fee2e2;
    color: #b91c1c;
}

/* --- Dashboard Progress Bar --- */
.dashboard-progress-container {
    width: 100%;
}

.progress-text {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 5px;
    text-align: center;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6b7280;
}

.progress-label {
    font-weight: 500;
    color: #374151;
}

.progress-total {
    font-style: italic;
}

.design-actions .progress {
    height: 8px;
    /* A shorter bar for the dashboard */
    margin-bottom: 0;
    background-color: #e5e7eb;
    /* Lighter background for the track */
}

.dashboard-status-text {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

/* --- Colors Page Redesign --- */
.colors-management-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    /* 1 part for types, 2 parts for colors */
    gap: 30px;
    align-items: flex-start;
}

.management-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.management-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--stone-100);
}

.management-list li:last-child {
    border-bottom: none;
}

.management-list li span {
    font-weight: 500;
}

.management-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Constrain width on the Matching Patterns page */
.matching-patterns-container .management-card {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.management-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.management-card .card-header h3 {
    margin: 0;
    font-size: 18px;
}

/* Card Header Title Group & Badges */
.color-header-left,
.card-header-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-count-pill {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
}

.color-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.color-action-item {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.btn-action-icon:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
}

.btn-action-icon.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.color-search-popover {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 42px;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    padding: 0 12px;
    gap: 8px;
    z-index: 100;
    width: 300px;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.color-search-popover:focus-within {
    border-color: #0f172a;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.15), 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.color-search-popover input,
.color-search-popover input[type="text"],
.color-search-popover input[type="text"]:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    font-size: 14px !important;
    color: #0f172a !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: normal !important;
}

.search-inner-icon {
    color: #64748b;
    flex-shrink: 0;
}

.btn-clear-search {
    border: none;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 4px;
    flex-shrink: 0;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s;
}

.btn-clear-search:hover {
    color: #0f172a;
    background-color: #f1f5f9;
}

.color-sort-menu {
    position: absolute;
    right: 0;
    top: 44px;
    width: 230px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
    padding: 6px;
    z-index: 150;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: popoverFadeIn 0.15s ease;
}

.color-sort-menu-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    padding: 6px 10px 4px;
}

.color-sort-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.12s, color 0.12s;
}

.color-sort-option:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.color-sort-option.active {
    font-weight: 600;
    color: #0f172a;
    background: #f8fafc;
}

.color-sort-option .check-icon {
    font-size: 13px;
    color: #3b82f6;
    font-weight: 700;
}

@keyframes popoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.management-card .card-body {
    padding: 20px;
}

.management-card+.management-card {
    margin-top: 30px;
}

.btn-primary-small,
.btn-success-small {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary-small {
    background-color: var(--primary);
    color: white;
}

.btn-primary-small:hover {
    background-color: var(--primary-hover);
}

.btn-success-small {
    background-color: var(--success);
    color: white;
}

.btn-success-small:hover {
    background-color: var(--success-hover);
}

.inline-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.inline-form input {
    flex-grow: 1;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

/* --- New Pattern Grid Styles --- */
.pattern-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Single column layout */
    gap: 12px;
}

.pattern-item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: box-shadow 0.2s, border-color 0.2s;
    gap: 20px;
    /* Add gap between columns */
}

.pattern-card-link-area {
    display: flex;
    flex-grow: 1;
    align-items: center;
    text-decoration: none;
    color: inherit;
    gap: 20px;
    /* Match the parent card's gap */
}

.pattern-column-main {
    flex: 2;
    /* Title column takes more space */
    min-width: 0;
    /* Prevents text overflow issues */
}

.pattern-column-preview {
    flex: 1;
    display: flex;
    justify-content: center;
}

.pattern-column-actions {
    flex-shrink: 0;
    /* Prevent actions from shrinking */
    display: flex;
    align-items: center;
    gap: 10px;
}

.pattern-item-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #d1d5db;
}

.mini-palette-preview {
    display: flex;
    margin-top: 12px;
}

.mini-swatch {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mini-swatch:not(:first-child) {
    margin-left: -8px;
    /* Create the overlap effect */
}

.pattern-item-card.pending-structure {
    border-color: #facc15;
    /* A yellow-ish warning color */
    background-color: #fefce8;
}

.status-pending-text {
    color: #ca8a04;
    font-weight: 600;
}

.empty-list-item {
    color: #9ca3af;
    padding: 10px 0;
}

.btn-icon-delete-small {
    background: #2D3748;
    /* Solid background to match edit button */
    border: none;
    cursor: pointer;
    color: white;
    /* White icon by default */
    padding: 6px;
    /* Match edit button padding */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s, transform 0.2s;
    /* Add transform to transition */
}

.btn-icon-delete-small svg {
    stroke: currentColor;
    width: 16px;
    height: 16px;
}

.btn-icon-delete-small:hover {
    color: var(--danger-text);
    background-color: var(--danger-bg);
    transform: scale(1.15);
    /* Increase size on hover */
}

/* Color Library Grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
}

.color-library-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: box-shadow 0.2s;
}

.color-library-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* This targets the delete button ONLY on the color cards to give it the dark style */
.color-library-card .btn-icon-delete-small {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #2D3748;
    width: 28px;
    height: 28px;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s, background-color 0.2s;
}

.color-library-card .btn-icon-delete-small svg {
    stroke: white;
    width: 14px;
    height: 14px;
}

.color-library-card:hover .btn-icon-delete-small {
    opacity: 1;
    visibility: visible;
}

.color-library-card .btn-icon-delete-small:hover {
    background: #E53E3E;
    /* Red on hover */
}

.color-library-card:hover .btn-icon-delete-small {
    opacity: 1;
    visibility: visible;
}

.color-card-swatch {
    height: 100px;
    width: 100%;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.swatch-edit-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.color-card-swatch:hover .swatch-edit-overlay {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.color-card-info {
    padding: 10px;
    background-color: #f9fafb;
}

.color-card-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.color-card-name {
    font-weight: 600;
    margin: 0;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-grow: 1;
}

.btn-edit-color-name {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.color-card-name-row:hover .btn-edit-color-name,
.color-card-info:hover .btn-edit-color-name,
.color-library-card:hover .btn-edit-color-name {
    opacity: 0.65;
    visibility: visible;
}

.btn-edit-color-name:hover {
    opacity: 1 !important;
    color: #0f172a;
    background: #e2e8f0;
}

.color-card-hex {
    font-family: monospace;
    font-size: 12px;
    color: #6b7280;
    margin: 2px 0 0 0;
}

/* Modal Adjustments */
#add-color-modal .modal-content {
    max-width: 450px;
}

.color-picker-wrapper {
    position: relative;
    width: 50px;
    height: 50px;
}

.color-picker-wrapper .color-picker-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #6b7280;
    pointer-events: none;
    /* So the click goes to the input underneath */
}

.color-picker-wrapper input[type="color"] {
    width: 50px;
    height: 50px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    /* Make the input transparent but still clickable */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: transparent;
    opacity: 0.05;
}

/* --- Matching Patterns Page List --- */
.list-item-main {
    display: flex;
    flex-direction: column;
}

.list-item-title {
    font-weight: 500;
    color: #1f2937;
}

.list-item-subtitle {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.list-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pattern-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    /* Make the link fill the grid area */
}

.btn-secondary-small {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--stone-200);
    background-color: var(--stone-50);
    color: var(--stone-700);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-secondary-small:hover {
    background-color: var(--stone-100);
    color: var(--stone-900);
}

/* --- Interactive Add/Edit Card Styles --- */

.interactive-card-content {
    display: flex;
    background-color: #ffffff;
}

.interactive-slot-column {
    flex: 1;
    /* Each column takes equal width */
    border-right: 1px solid #e5e7eb;
}

.interactive-slot-column:last-child {
    border-right: none;
}

.interactive-slot-column .palette-color-block {
    height: 65px;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s ease-in-out;
}

.interactive-input-wrapper {
    padding: 10px;
}

.add-palette-card,
.edit-palette-card {
    margin-bottom: 15px;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    background-color: #ffffff;
    position: relative;
    z-index: 100;
    /* overflow: hidden removed — it clips floating dropdowns */
}

.interactive-card-content {
    display: flex;
    background-color: #ffffff;
}

.interactive-slot-column {
    flex: 1;
    /* Each column takes equal width */
    border-right: 1px solid #e5e7eb;
}

.interactive-slot-column:last-child {
    border-right: none;
}

.interactive-slot-column .palette-color-block {
    height: 65px;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s ease-in-out;
}

.interactive-input-wrapper {
    padding: 10px;
}

.add-palette-save-row,
.edit-palette-save-row {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

/* --- Pattern Palettes Page --- */
.structure-form .form-footer {
    text-align: right;
    margin-top: 20px;
}

.structure-slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.palette-table-container {
    margin-top: 20px;
}

/* --- New Palette List Styles --- */
.palette-list-header {
    display: flex;
    padding: 12px 15px;
    margin-bottom: 15px;
    /* Increased space below */
    background-color: #f9fafb;
    /* Light grey background */
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Subtle floating shadow */
    border: 1px solid #e5e7eb;
}

.palette-header-name {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: #4b5563;
    /* Dark text */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.palette-list-container {
    display: grid;
    gap: 16px;
    /* The space between palette cards */
    position: relative;
    transition: opacity 0.3s ease;
}

.palette-list-container.picker-active {
    opacity: 0.35;
    pointer-events: none;
}

/* Always elevate the edit card wrapper above sibling palette rows */
.edit-palette-wrapper {
    position: relative;
    z-index: 9999;
}

.palette-management-content {
    width: 100%;
}

/* The main card for each palette */
.palette-card {
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    /* overflow: hidden; -- REMOVED to allow floating dropdowns */
    transition: box-shadow 0.25s ease, transform 0.25s ease;
    position: relative;
    /* Set as positioning context for actions */
    border: 1px solid #e8eaf0;
}

.palette-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10), 0 3px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

/* Container for the top color blocks */
.palette-card-colors {
    display: flex;
    height: 65px;
    /* The height of the main color preview bar */
    border-radius: 13px 13px 0 0;
    overflow: hidden;
}

.palette-color-block {
    flex: 1;
    /* Each color block expands to fill space equally */
    transition: filter 0.25s ease;
}

/* Subtle separator between color blocks */
.palette-card-colors .palette-color-block + .palette-color-block {
    border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.add-palette-card .palette-card-colors .palette-color-block:not(:first-child) {
    border-left: 2px dashed rgba(255, 255, 255, 0.75);
}

/* The white bar at the bottom holding names and actions */
.palette-card-info {
    display: flex;
    background-color: #fafbfc;
    padding: 10px 15px;
    border-top: 1px solid #e8eaf0;
    border-radius: 0 0 13px 13px;
}

/* Flex container for just the names */
.palette-color-names {
    display: flex;
    flex: 1;
}

.palette-color-name {
    flex: 1;
    /* Each name aligns under its color block */
    text-align: center;
    font-size: 13px;
    color: #4b5563;
    font-weight: 500;
}

/* Container for the Edit/Delete buttons */
.palette-card-actions {
    position: absolute;
    /* Position on top of the card */
    top: 10px;
    right: 15px;
    /* transform: translateY(-50%); -- Removed for top alignment */
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 5px;
    border-radius: 50px;
}

.palette-card:hover .palette-card-actions {
    opacity: 1;
    visibility: visible;
}

@keyframes paletteDuplicateGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.45);
        border-color: #6366f1;
    }
    40% {
        box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.25);
        border-color: #4f46e5;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
        border-color: inherit;
    }
}

.palette-card-row.palette-highlight-pulse .palette-card {
    animation: paletteDuplicateGlow 2.5s cubic-bezier(0.16, 1, 0.3, 1);
    border-color: #6366f1 !important;
}

.btn-icon-edit-small {
    background: #2D3748;
    /* Solid background to match delete button */
    border: none;
    cursor: pointer;
    color: white;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s, transform 0.2s;
    /* Add color and transform */
}

.btn-icon-edit-small:hover {
    background-color: #dcfce7;
    /* Light green background */
    color: #166534;
    /* Dark green icon */
    transform: scale(1.15);
    /* Add scale effect */
}

.btn-icon-edit-small svg {
    stroke: currentColor;
    width: 16px;
    height: 16px;
}

.btn-icon-duplicate-small {
    background: #2D3748;
    border: none;
    cursor: pointer;
    color: white;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s, transform 0.2s;
}

.btn-icon-duplicate-small:hover {
    background-color: #e0e7ff;
    color: #3730a3;
    transform: scale(1.15);
}

.btn-icon-duplicate-small svg {
    stroke: currentColor;
    width: 16px;
    height: 16px;
}

/* --- New Color Picker Modal Styles --- */
#color-preview-swatch {
    width: 100%;
    height: 150px;
    /* Large height as requested */
    border-radius: 8px;
    border: 1px solid #d1d5db;
    margin-bottom: 20px;
    transition: background-color 0.2s;
}

.form-group-inline {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 15px;
    /* Add standard spacing */
}

.form-group-inline .form-group {
    flex-grow: 1;
    margin-bottom: 0;
    /* Remove bottom margin for inline groups */
}

/* Make the native color picker just a small button */
#color_picker {
    width: 50px;
    height: 50px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    background-color: transparent;
}


/* --- Accordion Styles --- */
.accordion-header {
    cursor: pointer;
    user-select: none;
}

.accordion-icon {
    transition: transform 0.3s ease-in-out;
}

.accordion-icon.rotated {
    transform: rotate(-180deg);
}

.management-card>.card-body {
    transition: max-height 0.35s ease-out, padding 0.35s ease-out, border 0.35s ease-out;
    /* overflow: hidden; -- Removed from base to prevent clipping dropdowns */
    border-top: 1px solid #e5e7eb;
}

/* Only hide overflow when actually collapsed or designated as an accordion body */
.management-card>.card-body.collapsed,
.management-card>.card-body[id$="-card-body"] {
    overflow: visible;
    /* Default to visible */
}

.management-card>.card-body.collapsed {
    overflow: hidden;
    /* Hide when collapsed */
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top: none;
}

/* Custom styling for the note in the edit pattern modal */
#edit-warning-message p.form-text-muted {
    display: block;
    box-sizing: border-box;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    margin: 8px 0 0 0;
    background-color: #fbe9e7;
    color: #c94a4a;
    border-radius: 4px;
    font-size: 0.875em;
    border: 1px solid #f5c6cb;
}

/* --- Color Type Table Styles (Appended) --- */
#color-type-list-container .type-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

#color-type-list-container .type-list-item:hover {
    background-color: #f8fafc;
}

#color-type-list-container .type-list-item:last-child {
    border-bottom: none;
}

#color-type-list-container .actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

#color-type-list-container .btn-type-edit,
#color-type-list-container .btn-type-delete {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}

#color-type-list-container .btn-type-edit svg,
#color-type-list-container .btn-type-delete svg {
    stroke: currentColor;
    width: 16px;
    height: 16px;
}

#color-type-list-container .type-list-item:hover .btn-type-edit,
#color-type-list-container .type-list-item:hover .btn-type-delete {
    color: #334155;
}

#color-type-list-container .btn-type-edit:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
}

#color-type-list-container .btn-type-delete:hover {
    background-color: #fef2f2 !important;
    color: #dc2626 !important;
    border-color: #fecaca !important;
}

/* --- User Management Table and Forms (Appended) --- */
.styled-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.styled-table thead tr {
    background-color: #f9fafb;
    color: #374151;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.styled-table th,
.styled-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e5e7eb;
}

.styled-table tbody tr:hover {
    background-color: #f9fafb;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-badge.status-admin {
    background-color: #fee2e2;
    color: #b91c1c;
}

.status-badge.status-user {
    background-color: var(--stone-100);
    color: var(--stone-700);
    border: 1px solid var(--stone-200);
}

.status-badge.status-active {
    background-color: #dcfce7;
    color: #15803d;
}

.status-badge.status-inactive {
    background-color: var(--stone-50);
    color: var(--stone-500);
    border: 1px solid var(--stone-200);
}

.form-grid {
    display: grid;
}

.form-group-submit {
    text-align: right;
    align-self: flex-end;
}

.form-divider {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #e5e7eb;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-checkbox {
    height: 16px;
    width: 16px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    cursor: pointer;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 20px;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

.username-highlight {
    font-family: monospace;
    color: var(--primary);
}

.btn-secondary {
    background-image: none;
    background-color: #e5e7eb;
    color: #374151;
    border: 1px solid #d1d5db;
    box-shadow: none;
}

.btn-secondary:hover {
    background-color: #d1d5db;
    transform: none;
    box-shadow: none;
}

/* --- Password Visibility Toggle --- */
.password-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    width: 100%;
    padding-right: 42px !important;
    box-sizing: border-box;
}

.password-toggle-icon {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    cursor: pointer;
    color: #9ca3af;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    transition: color 0.15s ease, background-color 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.password-toggle-icon:hover {
    color: var(--primary, #3D2B1F);
    background-color: rgba(61, 43, 31, 0.07);
}

.password-toggle-icon svg {
    display: block;
    width: 20px;
    height: 20px;
}


/* --- Dashboard Card Action Icons --- */
.card-action-icons {
    position: absolute;
    bottom: 6px;
    /* Increased spacing */
    right: 6px;
    /* Increased spacing */
    display: flex;

    flex-direction: column;
    /* Stack buttons vertically */
    gap: 5px;
    z-index: 10;
    /* Ensure icons float on top */

    /* Frosted glass capsule effect */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 1px;
    border-radius: 50px;
    /* Pill shape */
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateY(100%);
    /* Add a smooth transition for the opacity and transform properties */
    transition: opacity 0.5s ease-in-out, transform 0.3s ease-in-out;
}


.design-card:hover .card-action-icons {
    opacity: 1;
    transform: translateY(0);
}

.card-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: #2D3748;
    /* Dark grey */
    color: white;
    border-radius: 50%;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.2s;
}

.card-icon-btn:hover {
    background-color: #1A202C;
    /* Even darker grey */
    transform: scale(1.1);
}

.card-icon-btn svg {
    width: 16px;
    height: 16px;
}

.card-button-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* --- Loading Dots Animation --- */
@keyframes dot-fade {

    0%,
    80%,
    100% {
        opacity: 0.2;
    }

    40% {
        opacity: 1;
    }
}

.loading-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    color: #d4d7df;
    padding: 0 8px;
}

.loading-dots div {
    width: 6px;
    height: 6px;
    background-color: #f8f9fc;
    border-radius: 50%;
    animation: dot-fade 1.4s infinite ease-in-out both;
    color: #d4d7df;
}

.loading-dots div:not(:last-child) {
    margin-right: 6px;

}

.loading-dots div:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots div:nth-child(2) {
    animation-delay: -0.16s;
}


/* --- Admin View Bar --- */
.admin-view-bar {
    background-color: #ffffff;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.admin-view-form {
    display: flex;
    align-items: center;
    gap: 15px;
}

.admin-view-form label {
    margin-bottom: 0;
    /* Override default margin */
    font-weight: 600;
    color: #374151;
}

.admin-view-form .modern-select {
    flex-grow: 1;
    max-width: 300px;
    padding: 8px 12px;
    /* Smaller padding */
    font-size: 14px;
}

.admin-view-form .btn {
    width: auto;
    padding: 8px 20px;
    /* Smaller padding */
    font-size: 14px;
}

/* --- Variant Page Status Header --- */
.status-header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f9fafb;
    /* Subtle light grey background */
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    /* The parent .management-row has border-radius: 8px. We match the top corners. */
    border-radius: 8px 8px 0 0;
    margin: -20px -20px 1.5rem -20px;
    /* Pull to edges of the card and add margin below */
}

.status-header-text h4 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #9ca3af;
    /* Lighter grey */
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-header-text .pattern-display {
    margin: 0.25rem 0 0 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-header-text .pattern-display strong {
    display: none;
    /* Hide the "Pattern:" label as it's redundant now */
}

/* Style for the edit icon in this specific header */
.status-header-text .btn-icon-edit-small {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
}

.status-header-text .btn-icon-edit-small:hover {
    background-color: #e5e7eb;
    color: #1f2937;
    transform: scale(1.1);
}



/* --- Canvas Pan & Zoom Controls --- */
.canvas-wrapper {
    position: relative;
    width: 100%;
    height: auto;
    background-color: #f3f4f6;
    border-radius: 8px;
}

#live-preview-canvas {
    cursor: grab;
}

#live-preview-canvas:active {
    cursor: grabbing;
}

.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
}

.zoom-controls button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #d1d5db;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #374151;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background-color 0.2s, transform 0.1s;
}

.zoom-controls button:hover {
    background-color: #ffffff;
    transform: scale(1.05);
}

.zoom-controls button:active {
    transform: scale(0.95);
}

/* --- Spinner Icon --- */
.spinner-icon {
    animation: rotate 2s linear infinite;
    width: 20px;
    height: 20px;
}

.spinner-icon .path {
    stroke: var(--primary);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }

    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }

    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* Dashboard Accordion Styles */
.month-accordion-item {
    margin-bottom: 20px;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.accordion-header {
    width: 100%;
    padding: 15px 20px;
    background: var(--stone-100);
    border: none;
    text-align: left;
    outline: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--stone-800);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background-color: var(--stone-200);
}

.accordion-header.active {
    background-color: var(--stone-100);
    border-bottom: 1px solid var(--stone-200);
}

.accordion-header .count-badge {
    background: #e2e6ea;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: #555;
    margin-left: 10px;
    margin-right: auto;
}

.accordion-header .activity-indicator {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    color: #666;
}

.accordion-header.active .activity-indicator {
    transform: rotate(180deg);
}

.accordion-content {
    padding: 0;
    overflow: hidden;
    /* Default display handled by inline styles for JS logic */
}

.accordion-content .image-grid {
    padding: 20px;
}

/* ==========================================================================
   Modern Dialog Card Modal (Pattern Duplication & High-End Dialogs)
   ========================================================================== */

.modern-modal-backdrop {
    background-color: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1100 !important;
    padding: 16px;
    animation: modernFadeInBackdrop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modernFadeInBackdrop {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modern-dialog-card {
    position: relative;
    background: #ffffff;
    width: 100%;
    max-width: 460px;
    border-radius: 16px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.12),
        0 10px 10px -5px rgba(0, 0, 0, 0.04),
        0 0 0 1px rgba(0, 0, 0, 0.08);
    padding: 24px 28px;
    text-align: left;
    box-sizing: border-box;
    animation: modernDialogScaleUp 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modernDialogScaleUp {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modern-dialog-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: transparent;
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.modern-dialog-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.modern-dialog-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 22px;
    padding-right: 32px; /* space for close button */
}

.modern-dialog-icon-badge {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(61, 43, 31, 0.08);
    color: var(--primary, #3D2B1F);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modern-dialog-title {
    margin: 0 0 4px 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.01em;
}

.modern-dialog-desc {
    margin: 0;
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.45;
}

.modern-dialog-body {
    margin-bottom: 22px;
}

.modern-field-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.modern-field-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
}

.modern-input-wrapper {
    position: relative;
    width: 100%;
}

.modern-dialog-input {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    color: #0f172a;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.modern-dialog-input:focus {
    border-color: var(--primary, #3D2B1F);
    box-shadow: 0 0 0 3.5px rgba(61, 43, 31, 0.14);
}

.modern-field-help {
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.4;
    margin-top: 2px;
}

.modern-dialog-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid #f1f5f9;
}

.modern-btn-cancel {
    padding: 9px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.modern-btn-cancel:hover {
    background: #f8fafc;
    color: #1e293b;
    border-color: #94a3b8;
}

.modern-btn-confirm {
    padding: 9px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--primary, #3D2B1F);
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 2px 4px rgba(61, 43, 31, 0.18);
    transition: all 0.15s ease;
    font-family: inherit;
}

.modern-btn-confirm:hover {
    background: var(--primary-hover, #2B1E15);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(61, 43, 31, 0.28);
}

.modern-btn-confirm:active {
    transform: translateY(0);
}

@media (max-width: 480px) {
    .modern-dialog-card {
        padding: 20px 18px;
    }
    .modern-dialog-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }
    .modern-btn-cancel,
    .modern-btn-confirm {
        width: 100%;
        justify-content: center;
    }
}