#viewport {
    background-image:
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.swatch {
    aspect-ratio: 1;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.swatch:hover {
    transform: translateY(-1px);
    border-color: #fff;
}

.swatch.active {
    border-color: #0f172a;
    box-shadow: inset 0 0 0 1px #0f172a;
}

.tool-rail {
    border: 1px solid #cbd5e1;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.tool-rail-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #ffffff;
    color: #334155;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s ease;
}

.tool-rail-btn:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.tool-rail-btn.active {
    border-color: #38bdf8;
    background: #38bdf8;
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.top-tools {
    border: 1px solid #cbd5e1;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
}

.top-tool-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #ffffff;
    color: #334155;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s ease;
}

.top-tool-btn:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.top-tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.top-tools-sep {
    width: 1px;
    align-self: stretch;
    background: linear-gradient(to bottom, transparent, #cbd5e1, transparent);
    margin: 0 2px;
}

#bomTable td {
    border: 1px solid #e2e8f0;
    padding: 8px;
}

.color-preview {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: middle;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
}

.total-row {
    background: #eef2ff;
    font-weight: 700;
}

.topbar {
    border-bottom: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
}

.theme-btn {
    width: 34px;
    height: 34px;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    background: #fff;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s ease;
}

.theme-btn:hover {
    background: #f1f5f9;
}

.theme-btn.active {
    border-color: #0f766e;
    color: #0f766e;
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.3);
}

.avatar-chip {
    width: 34px;
    height: 34px;
    border-radius: 9999px;
    border: 1px solid #cbd5e1;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: #ecfeff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.lang-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.lang-icon {
    position: absolute;
    left: 8px;
    width: 16px;
    height: 16px;
    color: #64748b;
    pointer-events: none;
}

.lang-select {
    padding-left: 28px !important;
}

body[data-theme="dark"] {
    background: #020617;
    color: #e2e8f0;
}

body[data-theme="dark"] .topbar {
    border-color: #1f2937;
    background: rgba(2, 6, 23, 0.9);
}

body[data-theme="dark"] aside {
    background: #0b1220 !important;
    border-color: #1f2937 !important;
}

body[data-theme="dark"] main {
    background: #0f172a !important;
}

body[data-theme="dark"] .rounded-xl {
    background: #111827 !important;
    border-color: #1f2937 !important;
}

body[data-theme="dark"] .tool-rail,
body[data-theme="dark"] .top-tools {
    background: rgba(17, 24, 39, 0.92);
    border-color: #334155;
}

body[data-theme="dark"] .top-tool-btn,
body[data-theme="dark"] .tool-rail-btn,
body[data-theme="dark"] .theme-btn {
    background: #1f2937;
    border-color: #334155;
    color: #e2e8f0;
}

body[data-theme="dark"] #viewport {
    background-image:
        linear-gradient(45deg, #1e293b 25%, transparent 25%),
        linear-gradient(-45deg, #1e293b 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1e293b 75%),
        linear-gradient(-45deg, transparent 75%, #1e293b 75%);
}