/* ==========================================================================
   ECO CutList Optimizer - Professional App UI (Replicated from CutListOptimizer.com)
   ========================================================================== */

:root {
    --cl-primary: #1a73e8;
    --cl-secondary: #44484c;
    /* Green for Calculate, matching reference */
    --cl-primary-hover: #218838;
    --cl-primary-active: #1e7e34;
    --cl-surface: #ffffff;
    /* White for main cards */
    --cl-bg: #f0f0f0;
    /* Muted grey background */
    --cl-text-main: #333333;
    --cl-text-muted: #ccc;
    --cl-border: #dddddd;
    /* Thin light-grey borders */
    --cl-radius: 0;
    /* No radius for technical look */
    --cl-shadow-sm: none;
    /* Minimal shadows */
    --cl-shadow-md: none;
    --cl-shadow-lg: none;
    --cl-transition: all 0.2s ease-in-out;
    --cl-font-base: system-ui, -apple-system, sans-serif;
    --cl-focus-ring: 0 0 0 2px rgba(40, 167, 69, 0.3);
    /* Green focus */
}

/* Base App Wrapper */
body {
    margin: 0;
    background-color: var(--cl-bg);
    font-family: var(--cl-font-base);
    color: var(--cl-text-main);
    line-height: 1.2;
    font-size: 13px;
    scroll-behavior: smooth;
}

/* body.admin-bar #main-container {
    margin-top: 32px;
} */

/* Make full page flex layout */
html,
body {
    height: 100%;
    margin: 0;
}

/* Page becomes vertical app shell */
body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Make WP wrapper fill viewport */
#main-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    min-height: 0;
}

/* ==========================================================================
   Navbar & Actions
   ========================================================================== */

.cl-navbar__brand {
    display: flex;
    align-items: center;
}

.cl-navbar__logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    gap: 12px;
}

.cl-navbar__logo {
    height: 32px;
    width: auto;
    display: block;
}

.cl-navbar__title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.cl-navbar__logo-link:hover .cl-navbar__title {
    opacity: 0.8;
}

.cl-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 56px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cl-navbar__brand #nav-toggle-project {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.5px;
    color: #1a73e8;
    background: #e8f0fe;
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: var(--cl-transition);
}

.cl-navbar__brand #nav-toggle-project:hover {
    background: #d2e3fc;
}

/* ==========================================================================
   Navbar Actions & Export Dropdown
   ========================================================================== */

.cl-navbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Base style for Navbar buttons (Secondary/Ghost style) */
.cl-navbar__actions .btn {
    height: 36px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: #5f6368;
    /* Muted grey for secondary actions */
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Hover effect for Save, Export, and Help */
.cl-navbar__actions .btn:not(#btn-calc):hover {
    background-color: #f1f3f4;
    color: #1a73e8;
    /* Text turns primary blue on hover */
}

/* ==========================================================================
   Primary Call to Action: Calculate
   ========================================================================== */
#btn-calc {
    background-color: #1a73e8 !important;
    /* Solid Primary Blue */
    color: #ffffff !important;
    border: none;
    box-shadow: 0 1px 2px rgba(26, 115, 232, 0.3);
    margin-right: 8px;
    /* Give it a slight separation from the secondary tools */
}

#btn-calc:hover {
    background-color: #1765cc !important;
    box-shadow: 0 4px 8px rgba(26, 115, 232, 0.4);
    transform: translateY(-1px);
    /* Slight lift effect */
}

#btn-calc:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(26, 115, 232, 0.3);
}

/* Disabled state for while calculating */
#btn-calc:disabled {
    background-color: #bdc1c6 !important;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Export Dropdown Specifics
   ========================================================================== */
.cl-navbar__dropdown {
    position: relative;
    /* Essential: Anchor for the dropdown */
    display: inline-block;
}

/* Position and animate the Export menu */
.cl-navbar__dropdown .cl-dropdown {
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    transform-origin: top right;
    animation: dropFade 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Subtle open animation for a premium feel */
@keyframes dropFade {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(-5px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ==========================================================================
   Card Header & Child Items (Toolbar Style)
   ========================================================================== */

.cl-card__header,
.right-sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    min-height: auto;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 3px 4px 0 #33333312;
    transition: transform 0.1s ease-in-out, padding 0.8s cubic-bezier(0.32, 0.72, 0, 1), justify-content 0.8s;
}

.cl-card__header {
    justify-content: space-between;
}

#right-sidebar.collapsed .cl-card__header {
    cursor: pointer;
}

#right-sidebar.collapsed .cl-card__header:hover {
    transform: translatex(-2px);
}

.cl-card.is-collapsed .cl-card__header {
    border-radius: 12px;
}

#right-sidebar.collapsed .cl-card__header,
#right-sidebar.collapsed .right-sidebar-header {
    padding: 8px 10px;
}

h3.cl-sidebar__title {
    margin: 0;
}

#right-sidebar:not(.collapsed) .right-sidebar-header {
    border-radius: 12px;
}

.cl-card__header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5f6368;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cl-card__header h2 .count-badge {
    background: #e8eaed;
    color: #3c4043;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.cl_card__label {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start
}

.cl-card__header .cl-card__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cl-card__header .btn {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    background: white;
    border: 1px solid #dadce0;
    color: #1a73e8;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.cl-card__header .btn:hover {
    background-color: #f1f3f4;
    border-color: #1a73e8;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

#add-row-parts,
#add-row-stock {
    background-color: #fff;
    border-color: #1a73e8;
    color: #1a73e8;
}

#add-row-parts:hover,
#add-row-stock:hover {
    background-color: #e8f0fe;
}

.cl-card__header .btn-danger {
    color: #d93025;
}

.cl-card__header .btn-danger:hover {
    background-color: #fce8e6;
    border-color: #d93025;
}

.cl-card__header .cl-caret,
.cl-card__header .btn-icon {
    color: #5f6368;
    transition: all 0.2s ease;
    padding: 0 8px;
}

.cl-card__header .cl-caret:hover,
.cl-card__header .btn-icon:hover {
    cursor: pointer;
    color: #1a73e8;
}

.cl-caret svg {
    width: 10px;
    transition: transform 0.2s;
}

.is-collapsed .cl-caret svg {
    transform: rotate(-90deg);
}

.stats-navigator {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-evenly;
    align-items: center;
    margin: 0px -16px;
    margin-bottom: 10px;
}

.stats-navigator .btn-icon {
    color: #5f6368;
    transition: all 0.2s ease;
    padding: 0 8px;
}

.stats-navigator .btn-icon:hover {
    cursor: pointer;
    color: #1a73e8;
}

.cl-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 12px;
    color: var(--cl-text-muted);
}

/* ==========================================================================
   Professional Card Body & Data Entry
   ========================================================================== */

.cl-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: grid;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
    position: relative;
    z-index: 1;
}

/* Elevated state when dropdown is active */
.cl-card.is-open {
    z-index: 100;
}

.cl-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.cl-card__body {
    padding: 12px 16px;
    opacity: 1;
    z-index: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cl-card__body.no-padding {
    padding: 0;
}

.cl-card.is-collapsed .cl-card__body {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    opacity: 0;
    pointer-events: none;
}

.cl-card.is-scrollable .cl-card__body {
    overflow-y: auto;
}

/* ==========================================================================
   Modern Spreadsheet Table (SaaS Look)
   ========================================================================== */

.cl-excel-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 12px;
}

.cl-card__body.table-container {
    max-height: 500px;
    overflow: auto;
}

.cl-excel-table th {
    background: #f8f9fa;
    color: #5f6368;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 5px;
    border-bottom: 2px solid #edf2f7;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 10;
}

.cl-excel-table td {
    border: 1px solid #e0e0e0;
    position: relative;
}

.cl-excel-table td input,
.cl-excel-table td select {
    width: 100%;
    box-sizing: border-box;
    height: 26px;
    border: none;
    outline: none;
    background: transparent;
    padding: 0 5px;
    font-size: 13px;
    color: #3c4043;
    transition: all 0.15s ease;
}

.cl-excel-table tr:hover {
    background: rgba(26, 115, 232, 0.05) !important;
}

.cl-excel-table td:focus {
    outline: none;
    background: #fff;
    border-color: #1a73e8;
    box-shadow: inset 0 0 0 1px #1a73e8;
    z-index: 2;
}

input[type="number"]::placeholder,
input[type="text"]::placeholder {
    color: #d3d3d3;
}

#parts-table tr td:nth-child(2) input[type="number"] {
    text-align: right;
}

.cl-excel-table tr:nth-child(odd) {
    background: #1717170e;
}

/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox */
input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/** Delete Icon **/

.cl-excel-table .btn-delete {
    position: absolute;
    top: 0;
    right: 0;
    transform: translateY(-50%) scale(0.5);
    width: 20px;
    height: 20px;
    padding: 0;
    background-color: #e74c3c;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99;

    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cl-excel-table tr:hover .btn-delete {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) scale(1);
}

.cl-excel-table .btn-delete:hover {
    background-color: #c0392b;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.cl-icon-delete {
    width: 12px;
    height: 12px;
    stroke: #ffffff;
    stroke-width: 3;
    fill: none;
}

/** Swap Icon **/
.swap-icon-btn {
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    cursor: pointer;
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.swap-icon-btn:hover {
    background-color: #f0f0f0;
    transform: translateY(-50%);
    box-shadow: 0 0 3px #7e7d7d7e;
    border-color: #aaa;
}

.swap-icon-btn:hover svg {
    fill: var(--cl-primary);
}

.swap-icon-btn.hidden {
    display: none !important;
}

.swap-icon-btn svg {
    width: 14px;
    height: 14px;
    fill: #555;
}

/* ==========================================================================
   Sidebar Stats & Options
   ========================================================================== */

.cl-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #f1f3f4;
    font-size: 13px;
    color: #5f6368;
}

.cl-stat:last-child {
    border-bottom: none;
}

.cl-stat strong {
    color: #202124;
    font-weight: 600;
}

/* ==========================================================================
   Professional Section Dropdowns
   ========================================================================== */

.cl-dropdown {
    position: absolute;
    min-width: 200px;
    background-color: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 6px 0;
    margin-top: 4px;
}

.cl-dropdown__item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    color: #3c4043;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.cl-dropdown__item:hover {
    background-color: #f1f3f4;
    color: #1a73e8;
}

.cl-dropdown hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 6px 0;
}

.cl-dropdown__item.action-import-csv,
.cl-dropdown__item.action-load-list {
    color: #1e8e3e;
}

.cl-dropdown__item.action-import-csv:hover,
.cl-dropdown__item.action-load-list:hover {
    background-color: #e6f4ea;
}

.cl-dropdown__item.action-clear {
    color: #d93025;
    border-top: 1px solid #f1f3f4;
    margin-top: 4px;
    padding-top: 12px;
}

.cl-dropdown__item.action-clear:hover {
    background-color: #fce8e6;
    color: #a50e0e;
}

.cl-hidden {
    display: none !important;
}

/* ==========================================================================
   COMPLETE SETTINGS SECTION STYLES
   ========================================================================== */

.cl-opt-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    position: relative;
    border-bottom: 1px solid #eee;
    padding: 10px 0;
    gap: 12px;
}

.cl-opt-item:last-child {
    border-bottom: none;
}

.opt-label.checkbox {
    margin-bottom: 0;
    flex: 1;
}

.cl-opt-item.slider {
    flex-direction: column;
}

#opt-unit,
#input-kerf {
    height: 36px;
    padding: 0 12px;
    background-color: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font-size: 13px;
    color: #3c4043;
    transition: all 0.2s ease;
}

#opt-unit {
    width: 150px;
    cursor: pointer;
}

#input-kerf {
    width: 100px;
}

#opt-unit:hover,
#input-kerf:hover {
    border-color: #1a73e8;
}

#opt-unit:focus,
#input-kerf:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.toggle-checkbox {
    position: absolute;
    opacity: 0;
    z-index: -1;
}

.switch-container {
    width: 44px;
    height: 22px;
    background: #bdc1c6;
    border-radius: 20px;
    position: relative;
    box-shadow: inset 0 0 3px #00000011;
    transition: background-color 0.2s ease;
}

.switch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 10;
}

.toggle {
    position: absolute;
    width: 18px;
    height: 18px;
    top: 2px;
    left: 2px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.led {
    width: 4px;
    height: 4px;
    background: #dadce0;
    border-radius: 50%;
    transition: background 0.2s;
}

.switch-container:has(.toggle-checkbox:checked) {
    background: #1a73e8;
}

.toggle-checkbox:checked~.switch .toggle {
    transform: translateX(22px);
}

.toggle-checkbox:checked~.switch .led {
    background: #ffffff;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

.cl-opt-item.slider .opt-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.cl-range-value {
    font-size: 12px;
    font-weight: 700;
    color: #1a73e8;
    background: #e8f0fe;
    padding: 2px 8px;
    border-radius: 4px;
}

.cl-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    outline: none;
    margin: 10px 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cl-slider:hover {
    background-color: #c4c4c4;
}

.cl-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #ffffff;
    border: 2px solid #1a73e8;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease-in-out;
}

.cl-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #ffffff;
    border: 2px solid #1a73e8;
    border-radius: 50%;
    cursor: pointer;
}

/* ==========================================================================
   Project Settings & Action Buttons
   ========================================================================== */

.cl-card__body label[for="project-name"] {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #5f6368;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

#project-name {
    width: 90%;
    height: 38px;
    padding: 0 12px;
    margin-bottom: 20px;
    background-color: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font-size: 14px;
    color: #202124;
    transition: all 0.2s ease;
}

#project-name:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.cl-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cl-actions .btn {
    width: 100%;
    height: 36px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #dadce0;
    background-color: #ffffff;
    color: #3c4043;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-save-db {
    background-color: #1a73e8;
    color: #ffffff;
    border-color: #1a73e8;
}

#btn-save-db:hover {
    background-color: #1765cc;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#btn-load-db:hover {
    background-color: #f8f9fa;
    border-color: #bdc1c6;
    color: #1a73e8;
}

#btn-reset {
    margin-top: 8px;
    border: none;
    background-color: #fce8e6;
    color: #d93025;
}

#btn-reset:hover {
    background-color: #f9d7d3;
    color: #a50e0e;
}

/* ==========================================================================
   Canvas Workspace, Toolbar & Tabs
   ========================================================================== */

#canvas-card {
    display: flex;
    flex-direction: column;
    height: auto;
    background: #f8f9fa;
}

#cl-app.right-collapsed #canvas-card,
#cl-app #canvas-card.no-svg {
    height: 100%;
}

#canvas-card .cl-card__header {
    background: #ffffff;
    /* Toolbar stays crisp white */
    padding: 8px 16px;
    border-bottom: 1px solid #e0e0e0;
    min-height: auto;
}

/* --- 2. The Toolbar & Icons --- */
.cl-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    /* Tight grouping for tools */
    flex-wrap: wrap;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #5f6368;
    /* Default grey icon */
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon svg.cl-icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    /* Crisp lines */
    fill: none;
}

/* Specific fix for the pallet icon which uses fill */
#pallet svg.cl-icon path {
    fill: currentColor;
    stroke: none;
}

/* Hover State */
.btn-icon:hover,
.btn-icon.is-active {
    color: #1a73e8;
    border-color: rgba(26, 115, 232, 0.2);
}

/* =============================================
   LOCKED TOOLBAR - Dim all buttons except Lock
   ============================================= */
.cl-toolbar.is-locked .btn-icon:not(#btn-lock) {
    opacity: 0.5;
    filter: grayscale(25%);
    pointer-events: none;
    cursor: not-allowed;
}

/* Optional nice visual feedback on locked toolbar */
.cl-toolbar.is-locked {
    background-color: #f8f9fa;
}

/* --- 3. Sheet Tabs --- */
.cl-canvas__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding: 16px;
    align-items: center;
}

.cl-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.sheet-tab {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #5f6368;
    background: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.sheet-tab:hover {
    background: #f8f9fa;
    color: #202124;
    border-color: #bdc1c6;
}

.sheet-tab.active {
    background: #1a73e8;
    color: #ffffff;
    border-color: #1a73e8;
    box-shadow: 0 2px 4px rgba(26, 115, 232, 0.3);
}

/* --- 4. The Canvas Area --- */
.cl-canvas {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: auto;
    background: #ffffff;
    border-radius: 8px;
    border: 1px dashed #dadce0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    padding: 20px;
    box-sizing: border-box;
}

/* --- 5. All Sheets Scroll Container --- */
#all-sheets-grid {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding-right: 8px;
    /* Room for scrollbar */
}

/* Scrollbar styling for the canvas/grid to keep it clean */
.cl-canvas::-webkit-scrollbar,
#all-sheets-grid::-webkit-scrollbar,
.cl-card__body.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.cl-canvas::-webkit-scrollbar-track,
#all-sheets-grid::-webkit-scrollbar-track,
.cl-card__body.table-container::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 4px;
}

.cl-canvas::-webkit-scrollbar-thumb,
#all-sheets-grid::-webkit-scrollbar-thumb,
.cl-card__body.table-container::-webkit-scrollbar-thumb {
    background: #bdc1c6;
    border-radius: 4px;
}

.cl-canvas::-webkit-scrollbar-thumb:hover,
#all-sheets-grid::-webkit-scrollbar-thumb:hover,
.cl-card__body.table-container::-webkit-scrollbar-thumb:hover {
    background: #9aa0a6;
}


/* =============================================
   SINGLE / SCROLL MODE LOGIC (Master Grid)
   ============================================= */


/* SCROLL MODE - show all sheets as thumbnails */
#all-sheets-grid.scroll-mode .sheet-svg-wrapper {
    display: flex !important;
    width: 520px;
    margin: 0 auto 40px auto;
}

#all-sheets-grid.single-mode .sheet-svg-wrapper {
    display: none !important;
}

#all-sheets-grid.single-mode .sheet-svg-wrapper.active {
    display: flex !important;
    width: 520px;
    margin: 0 auto;
}

/* Grid View Layout */
#all-sheets-grid.grid-mode {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: flex-start;
    padding: 20px;
}

#all-sheets-grid.grid-mode .sheet-svg-wrapper {
    width: 100px !important;
    height: auto;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

#all-sheets-grid.grid-mode .sheet-svg-wrapper:hover {
    transform: scale(1.05);
    border-color: var(--cl-primary);
}

#all-sheets-grid.grid-mode .sheet-svg-wrapper svg {
    width: 100% !important;
    height: auto !important;
}

#all-sheets-grid.grid-mode+#sheet-tabs,
.grid-mode~#sheet-tabs {
    display: none !important;
}

/* Hide dimensions in grid mode */
#all-sheets-grid.grid-mode .sheet-dim-indicator,
#all-sheets-grid.grid-mode .part-hover-dim {
    display: none !important;
}

/* Disable hover effects in grid mode */
#all-sheets-grid.grid-mode .sheet-svg-wrapper .panel-group:hover {
    pointer-events: none;
}

.view-mode-drop-down .cl-dropdown {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.view-mode-drop-down .cl-dropdown__item {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #eeeeefc7;
}

.view-mode-drop-down .cl-dropdown__item:hover,
.view-mode-drop-down .cl-dropdown__item.active {
    background: #eeeeee;
    color: var(--cl-primary);
}
.view-mode-drop-down .cl-dropdown__item:last-child {
    border: none;
}

/* ==========================================================================
   Canvas Empty State
   ========================================================================== */
.empty-canvas-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    width: 100%;
    text-align: center;
    color: #5f6368;
}

.empty-canvas-state .empty-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    color: #dadce0;
    /* Subtle grey */
}

.empty-canvas-state h4 {
    font-size: 18px;
    font-weight: 500;
    margin: 0 0 10px 0;
}

.empty-canvas-state p {
    font-size: 14px;
    color: #9aa0a6;
    max-width: 300px;
    margin: 0;
}

/* Hide message when grid has items */
#all-sheets-grid.has-results .empty-canvas-state {
    display: none;
}


/* ==========================================================================
   RIGHT SIDEBAR - ARCHITECTURAL REFACTOR
   ========================================================================== */

#right-sidebar {
    inline-size: 100%;
    min-inline-size: 52px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

#right-sidebar.collapsed {
    background: #fff;
    border-radius: 12px;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.06);
    border-left: 1px solid #e5e7eb;
}

#right-sidebar.collapsed svg {
    width: 16px;
    height: 16px;
}

.cl-sidebar__title,
.cl-card__title,
.cl-caret,
.cl-card__body,
.cl-sta,
#right-sidebar #cuts-title .cl-card__title,
#right-sidebar #cuts-title #total-cutst {
    opacity: 1;
    max-width: 500px;
    white-space: nowrap;
    transition:
        opacity 0.4s ease,
        max-width 0.6s cubic-bezier(0.32, 0.72, 0, 1),
        visibility 0.4s;
    visibility: visible;
}

#right-sidebar.collapsed .cl-sidebar__title,
#right-sidebar.collapsed .cl-card__title,
#right-sidebar.collapsed .cl-caret,
#right-sidebar.collapsed .cl-card__body,
#right-sidebar.collapsed .cl-stat,
#right-sidebar.collapsed #cuts-title .cl-card__title,
#right-sidebar.collapsed #cuts-title #total-cuts {
    opacity: 0;
    max-width: 0;
    visibility: hidden;
    margin: 0;
    padding: 0;
}

#right-sidebar.collapsed .cl-card__header,
#right-sidebar.collapsed .cl-card {
    box-shadow: none;
    border: none;
    background: #fff;
}



/* Toggle button rotation */
#toggle-right-sidebar {
    transition: transform 0.6s cubic-bezier(0.32, 0.72, 0, 1);
}

#right-sidebar.collapsed #toggle-right-sidebar {
    transform: rotate(180deg);
    transition: transform 500ms ease;
    ;
}

#right-sidebar #toggle-right-sidebar {
    transition: transform 500ms ease;
    ;
}

.section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    inline-size: 24px;
    block-size: 24px;
    flex-shrink: 0;
    color: #5f6368;
}

.section-icon svg {
    inline-size: 20px;
    block-size: 20px;
}

/* ==========================================================================
   APPLICATION SHELL - GRID ENGINE
   ========================================================================== */

#cl-app {
    flex: 1;
    inline-size: 100%;
    display: grid;
    grid-template-columns: 350px 1fr 300px;
    gap: 8px;
    padding: 8px;
    max-inline-size: 100%;
    min-block-size: 0;
    margin: 0 auto;
    overflow: hidden;
    box-sizing: border-box;
    transition: grid-template-columns 1s cubic-bezier(0.32, 0.72, 0, 1);
}

#cl-app.right-collapsed {
    grid-template-columns: 350px 1fr 52px;
}

/* Scrollbar and Typography consistency */
#left-sidebar,
#main-content,
#right-sidebar {
    block-size: auto;
    min-block-size: 0;
    overflow-y: auto !important;
    overflow-x: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#left-sidebar::-webkit-scrollbar,
#main-content::-webkit-scrollbar,
#right-sidebar::-webkit-scrollbar {
    inline-size: 6px;
}

#left-sidebar::-webkit-scrollbar-thumb,
#main-content::-webkit-scrollbar-thumb,
#right-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

#cl-app h2 {
    font-size: clamp(0.8rem, 2vw, 14px);
    font-weight: 500;
}

#cl-app h3 {
    font-size: clamp(0.75rem, 1.5vw, 13px);
    font-weight: 500;
}




/* ================================
   Cuts Section – Internal Content
================================ */

/* Make table wrapper fill available width */
#cuts-section .cl-table-wrap {
    width: 100%;
    overflow-x: auto;
}

/* Table base */
#cuts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}

/* Header */
#cuts-table thead {
    background: #f3f4f6;
}

#cuts-table th {
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

/* Cells */
#cuts-table td {
    padding: 5px 2px;
    border-bottom: 1px solid #f1f1f1;
    vertical-align: middle;
}

/* Zebra rows */
#cuts-table tbody tr:nth-child(even):not(.cut-separator) {
    background: #fafafa;
}

/* Hover state */
#cuts-table tbody tr:not(.cut-separator):hover {
    background: #eef2ff;
}

/* Sheet separator row */
#cuts-table .cut-separator td {
    padding: 6px 10px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: #e9ecef;
    border-bottom: 1px solid #dcdcdc;
}

/* First column (#) compact */
#cuts-table th:first-child,
#cuts-table td:first-child {
    width: 10px;
    text-align: center;
}

/* Result column slightly emphasized */
#cuts-table td:last-child {
    font-weight: 500;
}

/* ==========================================================================
   Section Dropdown Menus (Kebab)
   ========================================================================== */
.btn-kebab {
    border: none;
    background: transparent;
    padding: 0 4px;
    margin-left: 2px;
    display: flex;
    align-items: center;
}

.btn-kebab:hover {
    background: transparent;
    color: var(--cl-primary);
}

.btn-kebab svg {
    width: 14px;
    height: 14px;
    fill: #666;
    transition: fill 0.2s ease;
}

.btn-kebab:hover svg {
    fill: var(--cl-primary);
}

.section-dropdown {
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 170px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    z-index: 100;
}

/* Loading Overlay */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
}

.loading-overlay.is-active {
    display: flex !important;
    z-index: 9999 !important;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: #fff;
}

#time-left {
    font-size: 1.2rem;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Container for the buttons */
.loading-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 15px;
}

/* Base button styling */
.loading-buttons .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    outline: none;
    text-decoration: none;
}

/* Primary "Stop & Show" Button */
.btn-primary {
    background-color: var(--cl-primary, #1a73e8);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    filter: brightness(1.1);
}

/* Cancel Button - Optimized for Overlay */
.btn-danger-outline {
    background-color: rgba(255, 255, 255, 0.9);
    color: #b91c1c;
    border-color: #fca5a5;
}

.btn-danger-outline:hover {
    background-color: #ffffff;
    border-color: #dc2626;
    color: #dc2626;
}

#progress-percent {
    font-size: 2.4rem;
    font-weight: 700;
    margin-top: 20px;
    text-shadow: 0 3px 15px rgba(0, 0, 0, 0.6);
}

.pl {
    width: 6em;
    height: 6em;
}

.pl__ring {
    animation: ringA 2s linear infinite;
}

.pl__ring--a {
    stroke: #f42f25;
}

.pl__ring--b {
    animation-name: ringB;
    stroke: #f49725;
}

.pl__ring--c {
    animation-name: ringC;
    stroke: #255ff4;
}

.pl__ring--d {
    animation-name: ringD;
    stroke: #f42582;
}

/* Animations */
@keyframes ringA {

    from,
    4% {
        stroke-dasharray: 0 660;
        stroke-width: 20;
        stroke-dashoffset: -330;
    }

    12% {
        stroke-dasharray: 60 600;
        stroke-width: 30;
        stroke-dashoffset: -335;
    }

    32% {
        stroke-dasharray: 60 600;
        stroke-width: 30;
        stroke-dashoffset: -595;
    }

    40%,
    54% {
        stroke-dasharray: 0 660;
        stroke-width: 20;
        stroke-dashoffset: -660;
    }

    62% {
        stroke-dasharray: 60 600;
        stroke-width: 30;
        stroke-dashoffset: -665;
    }

    82% {
        stroke-dasharray: 60 600;
        stroke-width: 30;
        stroke-dashoffset: -925;
    }

    90%,
    to {
        stroke-dasharray: 0 660;
        stroke-width: 20;
        stroke-dashoffset: -990;
    }
}

@keyframes ringB {

    from,
    12% {
        stroke-dasharray: 0 220;
        stroke-width: 20;
        stroke-dashoffset: -110;
    }

    20% {
        stroke-dasharray: 20 200;
        stroke-width: 30;
        stroke-dashoffset: -115;
    }

    40% {
        stroke-dasharray: 20 200;
        stroke-width: 30;
        stroke-dashoffset: -195;
    }

    48%,
    62% {
        stroke-dasharray: 0 220;
        stroke-width: 20;
        stroke-dashoffset: -220;
    }

    70% {
        stroke-dasharray: 20 200;
        stroke-width: 30;
        stroke-dashoffset: -225;
    }

    90% {
        stroke-dasharray: 20 200;
        stroke-width: 30;
        stroke-dashoffset: -305;
    }

    98%,
    to {
        stroke-dasharray: 0 220;
        stroke-width: 20;
        stroke-dashoffset: -330;
    }
}

@keyframes ringC {
    from {
        stroke-dasharray: 0 440;
        stroke-width: 20;
        stroke-dashoffset: 0;
    }

    8% {
        stroke-dasharray: 40 400;
        stroke-width: 30;
        stroke-dashoffset: -5;
    }

    28% {
        stroke-dasharray: 40 400;
        stroke-width: 30;
        stroke-dashoffset: -175;
    }

    36%,
    58% {
        stroke-dasharray: 0 440;
        stroke-width: 20;
        stroke-dashoffset: -220;
    }

    66% {
        stroke-dasharray: 40 400;
        stroke-width: 30;
        stroke-dashoffset: -225;
    }

    86% {
        stroke-dasharray: 40 400;
        stroke-width: 30;
        stroke-dashoffset: -395;
    }

    94%,
    to {
        stroke-dasharray: 0 440;
        stroke-width: 20;
        stroke-dashoffset: -440;
    }
}

@keyframes ringD {

    from,
    8% {
        stroke-dasharray: 0 440;
        stroke-width: 20;
        stroke-dashoffset: 0;
    }

    16% {
        stroke-dasharray: 40 400;
        stroke-width: 30;
        stroke-dashoffset: -5;
    }

    36% {
        stroke-dasharray: 40 400;
        stroke-width: 30;
        stroke-dashoffset: -175;
    }

    44%,
    50% {
        stroke-dasharray: 0 440;
        stroke-width: 20;
        stroke-dashoffset: -220;
    }

    58% {
        stroke-dasharray: 40 400;
        stroke-width: 30;
        stroke-dashoffset: -225;
    }

    78% {
        stroke-dasharray: 40 400;
        stroke-width: 30;
        stroke-dashoffset: -395;
    }

    86%,
    to {
        stroke-dasharray: 0 440;
        stroke-width: 20;
        stroke-dashoffset: -440;
    }
}

/* SVG Panel Hover & Dimension Indicators */
.panel-group {
    transition: filter 0.2s ease, opacity 0.2s ease;
    cursor: pointer;
}

.dim-indicator,
.sheet-dim-indicator {
    transition: opacity 0.2s ease;
    pointer-events: none;
}

svg {
    overflow: visible !important;
    /* Ensure outside dims show */
}

/* Show dimensions on hover over the panel */
.panel-group:hover .dim-indicator {
    opacity: 1 !important;
}

/* Optimization Results Visual Styles: Handles part/sheet highlighting, dimensions, and auto-fading */

/* 1. Dimensions Visibility Logic */
svg:has(.panel-group:hover) .sheet-dim-indicator,
svg:has(.panel-group.is-highlighted) .sheet-dim-indicator {
    opacity: 0 !important;
}

.panel-group:hover .part-hover-dim,
.panel-group.is-highlighted .part-hover-dim {
    opacity: 1 !important;
}

/* 2. FADE LOGIC: When a sheet or part is active, fade out the siblings */
/* Fade other sheets in the grid when one is highlighted */
#all-sheets-grid:has(.sheet-svg-wrapper.is-highlighted)~#all-sheets-grid .sheet-svg-wrapper:not(.is-highlighted),
svg:has(.panel-group.is-highlighted) .panel-group:not(.is-highlighted) {
    filter: grayscale(100%) brightness(0.8);
    transition: filter 0.2s ease;
}

/* 3. Highlight the specific PART (The Rectangle) */
.panel-group.is-highlighted rect {
    stroke: #000000 !important;
    vector-effect: non-scaling-stroke !important;
    stroke-width: 2px !important;
    transform-origin: center;
    paint-order: fill markers stroke;
    transition: all 0.2s ease;
}

/* 4. Highlight the SHEET boundary (The background rect) */
.sheet-svg-wrapper.is-highlighted .sheet-base-bg {
    stroke: #204be7 !important;
    vector-effect: non-scaling-stroke !important;
    stroke-width: 2px !important;
    filter: drop-shadow(0 0 20px rgba(32, 75, 231, 0.6)) !important;
    transition: all 0.2s ease;
}

/* 5. Reset the outer HTML wrapper boundaries */
.sheet-svg-wrapper {
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.sheet-svg-wrapper.is-highlighted {
    box-shadow: none !important;
    outline: none !important;
    border-color: transparent !important;
    background: transparent !important;
    z-index: 10;
    /* Ensures the glow of the sheet is above neighbors */
}

.panel-group {
    cursor: pointer;
    transition: opacity 0.3s ease;
}

/* container-level containment reduces layout scope */
#all-sheets-grid {
    contain: layout paint;
}

/* hint to GPU/compositor for smoother transforms */
.sheet-svg-wrapper svg {
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* panels are usually static — promote to its own layer */
.panel-group {
    will-change: transform, opacity;
    transform: translateZ(0);
}

.sheet-placeholder {
    content-visibility: auto;
    contain-intrinsic-size: 800px;
}

:root {
    --modal-bg: #ffffff;
    --modal-overlay: rgba(32, 33, 36, 0.6);
    --primary-text: #202124;
    --secondary-text: #5f6368;
    --radius: 8px;
    --shadow: 0 12px 15px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
}

/* Overlay / Container */
.cl-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    z-index: 1000;
    display: none;
    /* Controlled by .is-open or JS */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    transition: opacity 0.2s ease;
}

.cl-modal.is-open {
    display: flex;
    opacity: 1;
}

.cl-hidden {
    display: none !important;
}

/* Modal Box */
.cl-modal__content {
    background: var(--modal-bg);
    width: 100%;
    max-width: 448px;
    /* Standard Google Dialog width */
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cl-modal.is-open .cl-modal__content {
    transform: translateY(0);
}

/* Header */
.cl-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.cl-modal__header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 500;
    color: var(--primary-text);
}

/* Close button (the 'X') */
.cl-modal__header .btn[data-action*="close-modal"] {
    background: transparent;
    border: none;
    color: var(--secondary-text);
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    border-radius: 50%;
    line-height: 1;
    justify-content: center;
    align-items: center;
}

.cl-modal__header .btn:hover {
    background-color: rgba(60, 64, 67, 0.08);
}

/* Body */
.cl-modal__body {
    font-size: 14px;
    line-height: 1.5;
    color: var(--secondary-text);
    margin-bottom: 24px;
}

/* Modal Footer Layout */
.cl-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
}

/* Base Button Styles */
.cl-modal__footer .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-family: inherit;
}

/* Icon Spacing & Alignment */
.cl-modal__footer .cl-btn-icon {
    margin-right: 8px;
    flex-shrink: 0;
    /* Ensures SVG color matches text color */
    stroke: currentColor;
}

/* Primary Button (Login / Clear List) */
.btn--primary {
    background-color: #2563eb;
    color: #ffffff;
}

.btn--primary:hover {
    background-color: #1d4ed8;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn--primary:active {
    transform: translateY(1px);
}

.btn--secondary {
    background-color: #e5e7e9;
    color: #475569;
    border-color: #6e7683;
}

.btn--secondary:hover,
.btn--secondary:active {
    background-color: #cbcccd;
    color: #1e293b;
}