/**
 * MetaGrid Excel - Microsoft Excel 365 Theme & UI Styles
 * Fluent Design, Ribbon, Formula Bar, Virtual Grid, Modals, Status Bar.
 * MIT License
 */

:root {
    --excel-primary: #1473e6;
    --excel-primary-hover: #0d66d0;
    --excel-primary-dark: #0952a8;
    --excel-primary-light: #e0f2fe;
    --excel-border: #cbd5e1;
    --excel-border-light: #e2e8f0;
    --excel-bg-gray: #f8fafc;
    --excel-bg-hover: #f1f5f9;
    --excel-text: #0f172a;
    --excel-text-muted: #475569;
    --excel-selection-bg: rgba(20, 115, 230, 0.12);
    --excel-selection-border: #1473e6;
    --excel-font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Inter', Roboto, Helvetica, Arial, sans-serif;
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--excel-font);
    font-size: 12px;
    color: var(--excel-text);
    background-color: #ffffff;
    -webkit-font-smoothing: antialiased;
}

#app-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
}

/* 1. TITLE BAR & QUICK ACCESS TOOLBAR (UNIFIED WITH M.WORD) */
.title-bar {
    height: 38px;
    background: #f8fafc;
    color: #0f172a;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    flex-shrink: 0;
    z-index: 1250;
}

.qat-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qat-app-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.2px;
    color: #0f172a;
}

.qat-app-badge svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.qat-divider {
    width: 1px;
    height: 16px;
    background: #cbd5e1;
    margin: 0 4px;
}

.qat-btn {
    background: transparent;
    border: none;
    color: #334155;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.15s ease;
}

.qat-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.qat-btn:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

.qat-btn:active {
    background-color: #cbd5e1;
}

.qat-btn.active {
    background-color: #dff6dd !important;
    color: #107c41 !important;
    box-shadow: inset 0 0 0 1.5px #107c41;
}

.qat-btn.active svg {
    stroke: #107c41;
}

.workbook-title-input {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    font-weight: 500;
    font-size: 13px;
    font-family: inherit;
    padding: 2px 8px;
    border-radius: 5px;
    text-align: left;
    width: 220px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.workbook-title-input:hover {
    border-color: #94a3b8;
}

.workbook-title-input:focus {
    background-color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.search-bar-center {
    display: flex;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 12px;
    width: 340px;
    transition: all 0.18s ease;
}

.search-bar-center:focus-within {
    background-color: #ffffff;
    border-color: #1473e6;
    box-shadow: 0 0 0 2px rgba(20, 115, 230, 0.15);
}

.search-bar-center .search-icon {
    display: inline-flex;
    align-items: center;
    color: #64748b;
}

.search-bar-center:focus-within .search-icon {
    color: var(--excel-primary);
}

.search-bar-center input {
    background: none;
    border: none;
    color: #0f172a;
    outline: none;
    width: 100%;
    font-size: 12px;
    margin-left: 8px;
}

.search-bar-center:focus-within input {
    color: #0f172a;
}

.search-bar-center input::placeholder {
    color: #64748b;
}

.search-bar-center:focus-within input::placeholder {
    color: #8a8886;
}

/* 2. RIBBON (FLUENT MICROSOFT 365 STYLE) */
.ribbon-container {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dadce0;
    flex-shrink: 0;
    position: relative;
    z-index: 1200;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ribbon-tabs-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 10px 0 10px;
    background-color: #ffffff;
    border-bottom: 1px solid #e3e5e8;
}

.ribbon-tab-btn {
    background: transparent;
    border: none;
    padding: 6px 14px 7px 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: #3b3a39;
    cursor: pointer;
    position: relative;
    border-radius: 5px 5px 0 0;
    transition: color 0.15s ease, background-color 0.15s ease;
    letter-spacing: 0.1px;
}

.ribbon-tab-btn::after {
    content: '';
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 0;
    height: 2.5px;
    border-radius: 2px 2px 0 0;
    background-color: transparent;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.ribbon-tab-btn:hover:not(.file-tab-btn) {
    color: var(--excel-primary);
    background-color: #f3f6f4;
}

.ribbon-tab-btn:hover:not(.file-tab-btn)::after {
    background-color: rgba(16, 124, 65, 0.35);
}

.ribbon-tab-btn.active:not(.file-tab-btn) {
    font-weight: 600;
    color: var(--excel-primary);
    background-color: #f8f9fa;
}

.ribbon-tab-btn.active:not(.file-tab-btn)::after {
    background-color: var(--excel-primary);
}

.ribbon-tab-content {
    display: none;
    height: 96px;
    padding: 5px 10px 4px 10px;
    overflow: visible;
    align-items: stretch;
    gap: 2px;
    background: linear-gradient(180deg, #fbfcfd 0%, #f3f5f7 100%);
    position: relative;
    z-index: 1250;
}

.ribbon-tab-content.active {
    display: flex;
}

.ribbon-group {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid #e1e3e6;
    padding: 2px 8px 1px 8px;
    min-width: 54px;
    flex-shrink: 0;
}

.ribbon-group:last-child {
    border-right: none;
}

.ribbon-group-title {
    font-size: 10px;
    font-weight: 500;
    color: #6e6d6b;
    text-align: center;
    padding-top: 2px;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.ribbon-group-body {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

/* Large Vertical Ribbon Buttons */
.ribbon-btn-large,
.ribbon-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
    height: 66px;
    min-width: 48px;
    color: #252423;
    font-family: var(--excel-font);
    transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.1s ease;
}

.ribbon-btn-large:hover,
.ribbon-btn:hover,
.ribbon-btn-small:hover {
    background-color: #e8f2ec;
    border-color: #b7d9c4;
    color: #0d5c30;
}

.ribbon-btn-large:active,
.ribbon-btn:active,
.ribbon-btn-small:active {
    background-color: #d7eadf;
    border-color: #93c6a7;
    transform: translateY(0.5px);
}

.ribbon-btn-large .icon,
.ribbon-btn .btn-icon {
    font-size: 20px;
    line-height: 1;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    color: var(--excel-primary);
}

.ribbon-btn-large .icon svg,
.ribbon-btn .btn-icon svg {
    width: 22px;
    height: 22px;
}

.ribbon-btn-large span,
.ribbon-btn .btn-label {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    line-height: 1.15;
    color: inherit;
    white-space: nowrap;
}

/* Small Horizontal Ribbon Buttons */
.ribbon-btn-small {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 7px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 500;
    color: #252423;
    font-family: var(--excel-font);
    height: 24px;
    white-space: nowrap;
    transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

/* Compact Stacked Buttons inside .ribbon-column */
.ribbon-column,
.ribbon-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}

.ribbon-column .ribbon-btn {
    flex-direction: row;
    justify-content: flex-start;
    height: 26px;
    min-width: auto;
    padding: 2px 8px;
    gap: 6px;
}

.ribbon-column .ribbon-btn .btn-icon {
    font-size: 14px;
    height: 18px;
    margin-bottom: 0;
}

.ribbon-column .ribbon-btn .btn-label {
    font-size: 11.5px;
    text-align: left;
}

.ribbon-row {
    display: flex;
    align-items: center;
    gap: 3px;
}

select.ribbon-select {
    height: 24px;
    border: 1px solid #c8c6c4;
    border-radius: 4px;
    font-size: 11.5px;
    font-family: var(--excel-font);
    color: #201f1e;
    padding: 0 6px;
    outline: none;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select.ribbon-select:hover {
    border-color: var(--excel-primary);
}

select.ribbon-select:focus {
    border-color: var(--excel-primary);
    box-shadow: 0 0 0 2px rgba(16, 124, 65, 0.15);
}

/* 3. FORMULA BAR */
.formula-bar-container {
    height: 28px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--excel-border);
    display: flex;
    align-items: center;
    padding: 0 4px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.name-box {
    width: 80px;
    height: 22px;
    border: 1px solid var(--excel-border);
    border-radius: 2px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    outline: none;
}

.formula-buttons {
    display: flex;
    align-items: center;
    margin: 0 4px;
}

.formula-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--excel-text-muted);
}

.formula-btn:hover {
    background-color: var(--excel-bg-hover);
    color: var(--excel-primary);
}

.formula-input {
    flex: 1;
    height: 22px;
    border: 1px solid transparent;
    border-radius: 2px;
    padding: 0 6px;
    font-size: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    outline: none;
    user-select: text;
}

.formula-input:focus {
    border-color: var(--excel-primary);
}

/* 4. GRID VIEWPORT & CANVAS */
.grid-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #ffffff;
}

#grid-canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: cell;
}

/* IN-CELL EDITOR */
#in-cell-editor {
    position: absolute;
    display: none;
    border: 2px solid var(--excel-primary);
    outline: none;
    background: #ffffff;
    padding: 2px 4px;
    font-family: var(--excel-font);
    font-size: 11pt;
    z-index: 50;
    user-select: text;
}

/* 5. SHEET TABS BAR & HORIZONTAL SCROLLBAR */
.sheet-tabs-container {
    height: 32px;
    background-color: var(--excel-bg-gray);
    border-top: 1px solid var(--excel-border);
    display: flex;
    align-items: center;
    padding: 0 4px;
    flex-shrink: 0;
    user-select: none;
    box-sizing: border-box;
    overflow: hidden;
}

.sheet-tabs-left-section {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    max-width: 55%;
    min-width: 140px;
    overflow: hidden;
    gap: 2px;
}

.sheet-tabs-splitter {
    width: 8px;
    height: 22px;
    margin: 0 4px;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sheet-tabs-splitter::before {
    content: '';
    width: 2px;
    height: 14px;
    background: #c8c6c4;
    border-radius: 1px;
    transition: background 0.15s;
}

.sheet-tabs-splitter:hover::before,
.sheet-tabs-splitter.dragging::before {
    background: #107c41;
    width: 3px;
}

/* HORIZONTAL SCROLLBAR */
.excel-h-scrollbar {
    flex: 1;
    display: flex;
    align-items: center;
    height: 24px;
    min-width: 120px;
    padding: 0 2px;
    gap: 3px;
    box-sizing: border-box;
    transition: opacity 0.2s ease;
}

.excel-h-scrollbar.is-short {
    opacity: 0.55;
}

.excel-sb-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: #605e5c;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background-color 0.1s, color 0.1s;
}

.excel-sb-btn:hover {
    background-color: #e1dfdd;
    color: #201f1e;
}

.excel-sb-btn:active {
    background-color: #c8c6c4;
}

.excel-sb-track {
    flex: 1;
    height: 14px;
    background: #e1dfdd;
    border-radius: 7px;
    position: relative;
    cursor: pointer;
    user-select: none;
    overflow: hidden;
}

.excel-sb-thumb {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 0;
    min-width: 36px;
    background: #a19f9d;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.1s;
}

.excel-sb-thumb:hover {
    background: #797775;
}

.excel-sb-thumb.dragging,
.excel-sb-thumb:active {
    background: #484644;
}

.sheet-nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 2px;
}

.sheet-nav-btn:hover {
    background-color: var(--excel-bg-hover);
}

.sheet-tabs-list {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
    margin: 0 6px;
}

.sheet-tab {
    padding: 4px 14px;
    font-size: 11px;
    background-color: #ffffff;
    border: 1px solid var(--excel-border-light);
    border-bottom: none;
    border-radius: 3px 3px 0 0;
    cursor: pointer;
    position: relative;
}

.sheet-tab.active {
    font-weight: 600;
    color: var(--excel-primary);
    border-bottom: 2px solid var(--excel-primary);
    background-color: #ffffff;
}

.sheet-add-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sheet-add-btn:hover {
    background-color: var(--excel-bg-hover);
    color: var(--excel-primary);
}

/* 6. STATUS BAR */
.status-bar {
    height: 24px;
    background-color: var(--excel-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 11px;
    flex-shrink: 0;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zoom-slider-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.zoom-slider {
    width: 80px;
    accent-color: #ffffff;
}

/* Realtime Auto-Save Badges & Status (Unified with Word Save Status Pill) */
.autosave-badge,
.word-save-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #000000;
    background-color: rgba(34, 197, 94, 0.25);
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    user-select: none;
}
.autosave-badge.badge-saving,
.word-save-status-pill.saving {
    background-color: rgba(234, 179, 8, 0.3);
    color: #000000;
}
.autosave-badge.badge-saved,
.word-save-status-pill.saved {
    background-color: rgba(34, 197, 94, 0.25);
    color: #000000;
}
.autosave-badge.badge-error {
    background-color: rgba(34, 197, 94, 0.25);
    color: #000000;
}

.status-autosave {
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    opacity: 0.95;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    padding-left: 10px;
}
.status-autosave.status-saving {
    color: #fffa75;
}
.status-autosave.status-saved {
    color: #ffffff;
}
.status-autosave.status-error {
    color: #ffb3b3;
}

/* 7. MODALS & DIALOGS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog {
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    min-width: 480px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    height: 36px;
    background-color: var(--excel-bg-gray);
    border-bottom: 1px solid var(--excel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-weight: 600;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 2px;
}

.modal-close-btn:hover {
    background-color: #e81123;
    color: #ffffff;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    height: 48px;
    background-color: var(--excel-bg-gray);
    border-top: 1px solid var(--excel-border-light);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 16px;
}

.btn-primary {
    background-color: var(--excel-primary);
    color: #ffffff;
    border: 1px solid var(--excel-primary);
    padding: 5px 18px;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: var(--excel-primary-hover);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--excel-text);
    border: 1px solid var(--excel-border);
    padding: 5px 18px;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: var(--excel-bg-hover);
}

/* MODAL TABS (Format Cells) */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--excel-border);
    margin-bottom: 12px;
}

.modal-tab-btn {
    background: none;
    border: none;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.modal-tab-btn.active {
    font-weight: 600;
    color: var(--excel-primary);
    border-bottom-color: var(--excel-primary);
}

/* CONTEXT MENU */
.context-menu {
    position: fixed;
    display: none;
    background: #ffffff;
    border: 1px solid var(--excel-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    padding: 4px 0;
    min-width: 180px;
    z-index: 2000;
}

.context-menu-item {
    padding: 6px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    cursor: pointer;
}

.context-menu-item:hover {
    background-color: var(--excel-bg-hover);
    color: var(--excel-primary);
}

.context-menu-separator {
    height: 1px;
    background-color: var(--excel-border-light);
    margin: 4px 0;
}

/* ========================================================
 * AUTOFILL OPTIONS SMART TAG (OFFICE 365 PARITY)
 * ======================================================== */
.autofill-options-widget {
    position: absolute;
    z-index: 100;
    pointer-events: auto;
    user-select: none;
}

.autofill-options-btn {
    width: 22px;
    height: 22px;
    background: #ffffff;
    border: 1px solid #8a8886;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #107c41;
    transition: background-color 0.1s ease, border-color 0.1s ease;
}

.autofill-options-btn:hover {
    background: #f3f2f1;
    border-color: #107c41;
}

.autofill-options-btn svg {
    pointer-events: none;
}

.autofill-options-menu {
    position: absolute;
    top: 24px;
    left: 0;
    background: #ffffff;
    border: 1px solid #c8c6c4;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    border-radius: 3px;
    padding: 5px 0;
    min-width: 195px;
    z-index: 110;
}

.autofill-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 12px;
    color: #323130;
    cursor: pointer;
    margin: 0;
    user-select: none;
    transition: background-color 0.1s ease;
}

.autofill-menu-item:hover {
    background: #edebe9;
    color: #107c41;
}

.autofill-menu-item input[type="radio"] {
    margin: 0;
    cursor: pointer;
    accent-color: #107c41;
}

/* ========================================================
 * 7. BACKSTAGE VIEW (FILE TAB) & OFFICE 365 PARITY STYLES
 * ======================================================== */
.file-tab-btn {
    background: linear-gradient(135deg, #107c41 0%, #0d6836 100%) !important;
    background-color: #107c41 !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    padding: 5px 16px !important;
    border-radius: 5px !important;
    margin: 0 6px 3px 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    box-shadow: 0 1px 2px rgba(16, 124, 65, 0.25) !important;
    transition: all 0.15s ease !important;
}

.file-tab-btn::after {
    display: none !important;
}

.file-tab-btn:hover,
.file-tab-btn:focus,
.file-tab-btn:active {
    background: linear-gradient(135deg, #0b5a2f 0%, #084724 100%) !important;
    background-color: #0b5a2f !important;
    color: #ffffff !important;
    box-shadow: 0 2px 5px rgba(11, 90, 47, 0.35) !important;
}

.backstage-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #f3f2f1;
    z-index: 5000;
    display: none;
}

.backstage-nav {
    width: 255px;
    height: 100%;
    background: linear-gradient(180deg, #0e6f3a 0%, #0b572d 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 14px 0;
    flex-shrink: 0;
    user-select: none;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
}

.backstage-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
    width: 100%;
}

.backstage-nav-item:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.backstage-nav-item.active {
    background-color: rgba(0, 0, 0, 0.18);
    font-weight: 600;
}

.backstage-back-btn {
    margin-bottom: 8px;
    font-weight: 600;
}

.bs-icon {
    font-size: 16px;
    width: 20px;
    display: inline-flex;
    justify-content: center;
}

.bs-nav-separator {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.2);
    margin: 8px 16px;
}

.bs-nav-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.backstage-content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    background-color: #ffffff;
    padding: 36px 56px;
}

.bs-page-container {
    max-width: 900px;
}

.bs-page-heading {
    font-size: 22px;
    font-weight: 600;
    color: #201f1e;
    margin-bottom: 24px;
}

/* Info Grid */
.bs-info-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 32px;
}

.bs-card {
    background: #ffffff;
    border: 1px solid #edebe9;
    border-radius: 4px;
    padding: 20px;
    box-shadow: 0 1.6px 3.6px 0 rgba(0,0,0,0.06);
    transition: box-shadow 0.2s ease;
}

.bs-card:hover {
    box-shadow: 0 3.2px 7.2px 0 rgba(0,0,0,0.1);
}

.bs-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
}

.bs-card-icon {
    width: 40px;
    height: 40px;
    background-color: #e8f4fc;
    color: var(--excel-primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.bs-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #323130;
    margin: 0 0 4px 0;
}

.bs-card-desc {
    font-size: 12px;
    color: #605e5c;
    margin: 0;
    line-height: 1.4;
}

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

.bs-btn-action {
    display: flex;
    flex-direction: column;
    text-align: left;
    padding: 10px 14px;
    background: #f3f2f1;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.bs-btn-action strong {
    font-size: 13px;
    color: #201f1e;
    margin-bottom: 2px;
}

.bs-btn-action span {
    font-size: 11px;
    color: #605e5c;
}

.bs-btn-action:hover {
    background: #edebe9;
    border-color: #c8c6c4;
}

/* Document Properties Side Card */
.bs-props-card {
    background: #faf9f8;
    border: 1px solid #edebe9;
    border-radius: 4px;
    padding: 16px;
}

.bs-props-title {
    font-size: 14px;
    font-weight: 600;
    color: #323130;
    margin: 0 0 14px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #edebe9;
}

.bs-prop-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 8px;
}

.bs-prop-label {
    color: #605e5c;
}

.bs-prop-val {
    font-weight: 500;
    color: #323130;
}

.bs-prop-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
}

.bs-prop-field label {
    font-size: 11px;
    font-weight: 600;
    color: #605e5c;
}

.bs-input, .bs-select, .bs-textarea {
    padding: 6px 10px;
    border: 1px solid #c8c6c4;
    border-radius: 3px;
    font-size: 12px;
    font-family: inherit;
    background: #ffffff;
}

.bs-input:focus, .bs-select:focus, .bs-textarea:focus {
    outline: none;
    border-color: var(--excel-primary);
}

.bs-primary-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background-color: var(--excel-primary);
    color: #ffffff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.bs-primary-action-btn:hover {
    background-color: var(--excel-primary-dark);
}

/* Templates Grid */
.bs-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.bs-template-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.bs-template-card:hover {
    transform: translateY(-2px);
}

.bs-template-preview {
    height: 130px;
    border: 1px solid #c8c6c4;
    border-radius: 4px;
    background: #ffffff;
    box-shadow: 0 1.6px 3.6px rgba(0,0,0,0.06);
    overflow: hidden;
    position: relative;
}

.bs-template-card:hover .bs-template-preview {
    border-color: var(--excel-primary);
    box-shadow: 0 4px 10px rgba(16, 124, 65, 0.2);
}

.bs-template-title {
    font-size: 12px;
    font-weight: 600;
    color: #323130;
    line-height: 1.3;
}

.tmpl-grid-lines {
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(to right, #edebe9 1px, transparent 1px),
        linear-gradient(to bottom, #edebe9 1px, transparent 1px);
    background-size: 18px 14px;
}

.tmpl-header-bar {
    height: 24px;
    width: 100%;
}

.tmpl-chart-mini, .tmpl-bars-mini, .tmpl-gantt-mini, .tmpl-invoice-mini {
    height: calc(100% - 24px);
    background-image: 
        linear-gradient(to right, #f3f2f1 1px, transparent 1px),
        linear-gradient(to bottom, #f3f2f1 1px, transparent 1px);
    background-size: 18px 14px;
}

/* Print Layout */
.bs-print-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 40px;
    align-items: flex-start;
}

.bs-print-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bs-print-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bs-print-preview-container {
    background: #e1dfdd;
    padding: 30px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.bs-print-paper-sheet {
    background: #ffffff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    border: 1px solid #c8c6c4;
    transition: all 0.2s ease;
}

.bs-print-paper-sheet.portrait {
    width: 380px;
    height: 537px;
}

.bs-print-paper-sheet.landscape {
    width: 537px;
    height: 380px;
}

/* Recents List */
.bs-recent-list {
    display: flex;
    flex-direction: column;
    border: 1px solid #edebe9;
    border-radius: 4px;
    background: #ffffff;
}

.bs-recent-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid #f3f2f1;
    cursor: pointer;
    transition: background 0.15s ease;
}

.bs-recent-item:last-child {
    border-bottom: none;
}

.bs-recent-item:hover {
    background-color: #f3f2f1;
}

.bs-recent-icon {
    font-size: 22px;
}

.bs-recent-info {
    display: flex;
    flex-direction: column;
}

.bs-recent-name {
    font-size: 13px;
    font-weight: 600;
    color: #323130;
}

.bs-recent-path {
    font-size: 11px;
    color: #8a8886;
}

/* Status Bar View Mode Toggles */
.status-view-modes {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 8px;
}

.status-btn {
    background: none;
    border: none;
    color: #ffffff;
    opacity: 0.8;
    width: 22px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.status-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.2);
}

.status-btn.active {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.25);
    font-weight: bold;
}

.zoom-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    border-radius: 2px;
}

.zoom-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.2);
}

.zoom-text {
    cursor: pointer;
    padding: 0 4px;
    border-radius: 2px;
}

.zoom-text:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* ========================================================
 * 8. RIBBON DROPDOWN MENUS & OFFICE 365 TOOLBAR STYLES
 * ======================================================== */
.ribbon-dropdown-wrap {
    position: relative;
    display: inline-flex;
}

.ribbon-menu-dropdown {
    position: fixed;
    top: calc(100% + 2px);
    left: 0;
    min-width: 200px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22), 0 2px 6px rgba(15, 23, 42, 0.08);
    border-radius: 6px;
    padding: 4px 0;
    z-index: 99999;
    display: none;
}

.ribbon-menu-dropdown.show {
    display: block !important;
}

.ribbon-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    font-size: 12px;
    color: #323130;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.ribbon-menu-item:hover {
    background-color: #f3f2f1;
    color: var(--excel-primary);
}

.ribbon-menu-item .menu-icon {
    margin-right: 8px;
    font-size: 14px;
    width: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ribbon-menu-item .menu-shortcut {
    color: #8a8886;
    font-size: 11px;
    margin-left: 14px;
}

.ribbon-menu-sep {
    height: 1px;
    background: #edebe9;
    margin: 4px 0;
}

/* Style Galleries (Table & Cell Styles) */
.ribbon-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px 12px;
    max-height: 260px;
    overflow-y: auto;
}

.ribbon-gallery-item {
    padding: 6px 10px;
    border: 1px solid #c8c6c4;
    border-radius: 2px;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ribbon-gallery-item:hover {
    border-color: var(--excel-primary);
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Ribbon Split Buttons (Fill Color, Font Color, Paste...) */
.ribbon-split-btn {
    display: inline-flex;
    align-items: center;
    position: relative;
    border-radius: 3px;
    border: 1px solid transparent;
    height: 24px;
}

.ribbon-split-btn:hover {
    background-color: var(--excel-bg-hover);
    border-color: var(--excel-border);
}

.ribbon-btn-split-main {
    background: none;
    border: none;
    height: 22px;
    padding: 0 4px;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 2px 0 0 2px;
    position: relative;
    color: var(--excel-text);
}

.ribbon-btn-split-drop {
    background: none;
    border: none;
    border-left: 1px solid transparent;
    height: 22px;
    padding: 0 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 2px 2px 0;
    color: #605e5c;
    font-size: 9px;
}

.ribbon-split-btn:hover .ribbon-btn-split-drop {
    border-left-color: var(--excel-border-light);
}

.ribbon-btn-split-drop:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

.color-bar-indicator {
    display: block;
    width: 14px;
    height: 3px;
    border-radius: 1px;
    margin-top: 1px;
}

/* Custom Office 365 Color Palette Popover */
.color-palette-popover {
    width: 206px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #c8c6c4;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    user-select: none;
    z-index: 5500;
}

.color-palette-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 11px;
    color: #323130;
    margin-bottom: 6px;
}

.color-palette-header:hover {
    background-color: #f3f2f1;
    color: var(--excel-primary);
}

.color-palette-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #605e5c;
    margin: 6px 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.color-palette-matrix {
    display: grid;
    grid-template-columns: repeat(10, 16px);
    gap: 3px;
    margin-bottom: 4px;
}

.color-swatch-cell {
    width: 16px;
    height: 16px;
    border-radius: 1px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    cursor: pointer;
    box-sizing: border-box;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.color-swatch-cell:hover {
    outline: 2px solid #107c41;
    outline-offset: 1px;
    transform: scale(1.15);
    z-index: 2;
    position: relative;
}

.color-palette-footer {
    border-top: 1px solid #edebe9;
    margin-top: 6px;
    padding-top: 4px;
}

.color-palette-more-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 11px;
    color: #323130;
}

.color-palette-more-btn:hover {
    background-color: #f3f2f1;
    color: var(--excel-primary);
}

/* Ribbon Inline SVG Icons */
.ribbon-svg {
    display: inline-block;
    vertical-align: middle;
    fill: currentColor;
    flex-shrink: 0;
}

.ribbon-btn-large .ribbon-svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    color: var(--excel-primary);
}

.ribbon-btn-small .ribbon-svg,
.ribbon-btn .ribbon-svg {
    width: 14px;
    height: 14px;
    color: #323130;
    margin-right: 4px;
}

.ribbon-btn-small .ribbon-svg:only-child,
.ribbon-btn-split-main .ribbon-svg {
    margin-right: 0;
}

.ribbon-btn-small:hover .ribbon-svg,
.ribbon-btn:hover .ribbon-svg {
    color: var(--excel-primary);
}

/* Floating Objects Layer (Charts, Shapes, Pictures, Slicers, WordArt, TextBoxes) */
.floating-object,
.floating-obj-container {
    transition: box-shadow 0.12s ease;
}

.floating-object:hover,
.floating-obj-container:hover {
    outline: 1px dashed rgba(16, 124, 65, 0.55);
}

.floating-object.floating-obj-selected,
.floating-obj-container.floating-obj-selected {
    outline: 2px solid #107c41 !important;
    box-shadow: 0 8px 24px rgba(16, 124, 65, 0.22) !important;
}

.floating-resize-handle:hover {
    transform: scale(1.25);
    background: #107c41 !important;
}

.slicer-item-btn:hover {
    filter: brightness(0.95);
    border-color: #107c41 !important;
}

/* ==========================================================================
   Excel 365 Right-Hand Format Chart / Object Task Pane (#format-task-pane)
   ========================================================================== */
.format-task-pane {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 325px;
    background: #ffffff;
    border-left: 1px solid #d2d0ce;
    box-shadow: -4px 0 18px rgba(0, 0, 0, 0.10);
    z-index: 65;
    display: flex;
    flex-direction: column;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    color: #201f1e;
    user-select: none;
    animation: fpSlideIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fpSlideIn {
    from {
        transform: translateX(24px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.fp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e1dfdd;
}

.fp-header-title {
    display: flex;
    align-items: center;
    gap: 9px;
}

.fp-header-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #e6f4ea;
    color: #107c41;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    border: 1px solid #b7e1cd;
}

.fp-title-main {
    font-size: 13px;
    font-weight: 700;
    color: #201f1e;
    line-height: 1.2;
}

.fp-title-sub {
    font-size: 10.5px;
    color: #107c41;
    font-weight: 600;
    margin-top: 1px;
}

.fp-close-btn {
    border: none;
    background: transparent;
    color: #605e5c;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
}

.fp-close-btn:hover {
    background: #fde7e9;
    color: #a4262c;
}

.fp-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: #f3f2f1;
    border-bottom: 1px solid #e1dfdd;
    padding: 4px 6px 0;
    gap: 3px;
    pointer-events: auto;
    position: relative;
    z-index: 2;
}

.fp-tab-btn {
    border: none;
    background: transparent;
    padding: 7px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #605e5c;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    border-bottom: 2.5px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.12s;
    user-select: none;
    pointer-events: auto;
}

.fp-tab-btn span {
    pointer-events: none;
}

.fp-tab-btn:hover {
    color: #201f1e;
    background: rgba(255, 255, 255, 0.6);
}

.fp-tab-btn.active {
    background: #ffffff;
    color: #107c41;
    border-bottom-color: #107c41;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.04);
}

.fp-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fp-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fp-section {
    background: #faf9f8;
    border: 1px solid #edebe9;
    border-radius: 6px;
    padding: 10px 11px;
}

.fp-section-title {
    font-size: 11.5px;
    font-weight: 700;
    color: #323130;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.fp-field-label {
    display: block;
    font-size: 11px;
    color: #605e5c;
    margin-bottom: 4px;
    font-weight: 500;
}

.fp-input-row {
    display: flex;
    gap: 6px;
}

.fp-input,
.fp-select {
    width: 100%;
    box-sizing: border-box;
    padding: 5px 8px;
    font-size: 12px;
    border: 1px solid #c8c6c4;
    border-radius: 4px;
    background: #ffffff;
    color: #201f1e;
    outline: none;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.fp-input:focus,
.fp-select:focus {
    border-color: #107c41;
    box-shadow: 0 0 0 2px rgba(16, 124, 65, 0.15);
}

.fp-input-mono {
    font-family: Consolas, "Courier New", monospace;
    font-weight: 700;
    color: #107c41;
    letter-spacing: 0.3px;
}

.fp-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.fp-btn {
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.12s;
    white-space: nowrap;
}

.fp-btn-primary {
    background: #107c41;
    color: #ffffff;
}

.fp-btn-primary:hover {
    background: #0b5a2f;
}

.fp-btn-outline {
    background: #ffffff;
    border-color: #c8c6c4;
    color: #323130;
}

.fp-btn-outline:hover {
    border-color: #107c41;
    color: #107c41;
    background: #f0fdf4;
}

.fp-btn-active-pick {
    background: #dcfce7;
    border-color: #16a34a;
    color: #15803d;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.fp-btn-active-toggle {
    background: #e6f4ea;
    border-color: #107c41;
    color: #107c41;
}

.fp-btn-ghost {
    background: #f3f2f1;
    color: #323130;
    border-color: #e1dfdd;
}

.fp-btn-ghost:hover {
    background: #e6f4ea;
    color: #107c41;
    border-color: #b7e1cd;
}

.fp-btn-danger {
    background: #fff5f5;
    border-color: #fecaca;
    color: #dc2626;
}

.fp-btn-danger:hover {
    background: #fee2e2;
    border-color: #f87171;
}

.fp-series-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 135px;
    overflow-y: auto;
}

.fp-series-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 8px;
    background: #ffffff;
    border: 1px solid #e1dfdd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11.5px;
}

.fp-series-item:hover {
    border-color: #107c41;
    background: #f8fafc;
}

.fp-series-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.fp-series-name {
    flex: 1;
    font-weight: 600;
    color: #201f1e;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fp-series-col {
    font-size: 10px;
    color: #605e5c;
    background: #f3f2f1;
    padding: 1px 5px;
    border-radius: 3px;
}

.fp-empty-hint {
    font-size: 11px;
    color: #8a8886;
    font-style: italic;
    padding: 4px 2px;
}

.fp-chart-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.fp-type-card {
    background: #ffffff;
    border: 1px solid #e1dfdd;
    border-radius: 5px;
    padding: 6px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: all 0.12s;
}

.fp-type-card:hover {
    border-color: #107c41;
    background: #f0fdf4;
}

.fp-type-card.active {
    border-color: #107c41;
    background: #e6f4ea;
    box-shadow: inset 0 0 0 1px #107c41;
}

.fp-type-icon {
    font-size: 15px;
    line-height: 1;
}

.fp-type-label {
    font-size: 10px;
    font-weight: 600;
    color: #323130;
    text-align: center;
}

.fp-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.fp-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.fp-color-input {
    width: 100%;
    height: 30px;
    padding: 1px 2px;
    border: 1px solid #c8c6c4;
    border-radius: 4px;
    background: #ffffff;
    cursor: pointer;
}

.fp-switch-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #107c41;
    font-weight: 600;
    cursor: pointer;
}

.fp-check-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    background: #ffffff;
    border: 1px solid #e1dfdd;
    border-radius: 4px;
    cursor: pointer;
}

.fp-check-row:hover {
    border-color: #107c41;
}

.fp-check-title {
    font-size: 11.5px;
    font-weight: 600;
    color: #201f1e;
}

.fp-check-desc {
    font-size: 10px;
    color: #605e5c;
    margin-top: 1px;
}

.fp-palette-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.fp-palette-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 9px;
    background: #ffffff;
    border: 1px solid #e1dfdd;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.12s;
}

.fp-palette-card:hover {
    border-color: #107c41;
    background: #f8fafc;
}

.fp-palette-card.active {
    border-color: #107c41;
    background: #e6f4ea;
    box-shadow: inset 0 0 0 1px #107c41;
}

.fp-palette-name {
    font-size: 11.5px;
    font-weight: 600;
    color: #201f1e;
}

.fp-palette-swatches {
    display: flex;
    gap: 3px;
}

.fp-palette-swatches i {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.fp-bg-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.fp-bg-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #d2d0ce;
    background: #ffffff;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
}

.fp-bg-chip.active {
    border-color: #107c41;
    background: #e6f4ea;
    color: #107c41;
    font-weight: 700;
}

.fp-bg-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* ========================================================
 * 10. FORMULA INTELLISENSE & ENGLISH USAGE GUIDE POPUP
 * ======================================================== */
.formula-helper-popup {
    position: absolute;
    z-index: 3200;
    display: none;
    align-items: stretch;
    background: #ffffff;
    border: 1px solid #c8c6c4;
    border-radius: 6px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.08);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    color: #201f1e;
    overflow: hidden;
    pointer-events: auto;
    user-select: none;
    max-width: 520px;
}

.fh-autocomplete-list {
    width: 175px;
    border-right: 1px solid #e1dfdd;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.fh-list-header {
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 700;
    color: #605e5c;
    letter-spacing: 0.4px;
    border-bottom: 1px solid #e1dfdd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f1f5f9;
}

.fh-key-hint {
    font-family: Consolas, monospace;
    font-size: 9.5px;
    background: #ffffff;
    border: 1px solid #d2d0ce;
    border-radius: 3px;
    padding: 0 4px;
    color: #107c41;
}

.fh-list-scroll {
    max-height: 245px;
    overflow-y: auto;
    padding: 3px;
}

.fh-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11.5px;
    transition: background 0.1s;
}

.fh-list-item:hover {
    background: #e2e8f0;
}

.fh-list-item.active {
    background: #107c41;
    color: #ffffff;
}

.fh-item-icon {
    font-style: italic;
    font-weight: 700;
    font-size: 10px;
    width: 18px;
    height: 16px;
    border-radius: 3px;
    background: #e6f4ea;
    color: #107c41;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fh-list-item.active .fh-item-icon {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.fh-item-name {
    font-family: Consolas, "Courier New", monospace;
    font-weight: 700;
    flex: 1;
    letter-spacing: 0.2px;
}

.fh-item-cat {
    font-size: 9.5px;
    opacity: 0.75;
}

.fh-side-guide {
    width: 325px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #ffffff;
}

.fh-side-guide.fh-single-card {
    width: 345px;
}

.fh-card {
    padding: 10px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.fh-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.fh-card-title-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fh-fx-badge {
    background: #107c41;
    color: #ffffff;
    font-style: italic;
    font-weight: 700;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
}

.fh-card-fn {
    font-size: 13.5px;
    font-weight: 700;
    color: #107c41;
    letter-spacing: 0.2px;
}

.fh-cat-badge {
    font-size: 10px;
    font-weight: 600;
    color: #0f5132;
    background: #e6f4ea;
    border: 1px solid #b7e1cd;
    padding: 1px 6px;
    border-radius: 10px;
}

.fh-syntax-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #107c41;
    border-radius: 4px;
    padding: 5px 8px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 11.5px;
    color: #334155;
    line-height: 1.45;
    word-break: break-word;
}

.fh-fn-name {
    font-weight: 700;
    color: #0b5a2f;
}

.fh-syn-arg {
    padding: 1px 3px;
    border-radius: 3px;
    transition: all 0.12s;
}

.fh-syn-arg.active {
    background: #107c41;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(16, 124, 65, 0.25);
}

.fh-summary {
    font-size: 11.5px;
    color: #323130;
    line-height: 1.38;
}

.fh-active-arg-box {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 5px;
    padding: 6px 8px;
}

.fh-active-arg-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #14532d;
    margin-bottom: 2px;
}

.fh-req-pill {
    font-size: 9.5px;
    font-weight: 700;
    padding: 0 5px;
    border-radius: 3px;
    text-transform: uppercase;
}

.fh-req-pill.req {
    background: #dcfce7;
    color: #15803d;
}

.fh-req-pill.opt {
    background: #f1f5f9;
    color: #64748b;
}

.fh-active-arg-desc {
    font-size: 11px;
    color: #166534;
    line-height: 1.35;
}

.fh-args-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fh-sec-label {
    font-size: 9.5px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.5px;
}

.fh-args-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.fh-arg-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 11px;
    line-height: 1.35;
    padding: 2px 4px;
    border-radius: 3px;
}

.fh-arg-row.current {
    background: #ecfdf5;
    border-left: 2px solid #107c41;
}

.fh-arg-code {
    font-family: Consolas, "Courier New", monospace;
    font-weight: 700;
    font-size: 10.5px;
    color: #0f5132;
    background: #f1f5f9;
    padding: 0 4px;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.fh-arg-text {
    color: #475569;
    flex: 1;
}

.fh-example-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 4px;
    padding: 5px 8px;
}

.fh-example-code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 11.5px;
    font-weight: 700;
    color: #0b5a2f;
    margin-top: 1px;
}

.fh-example-note {
    font-size: 10.5px;
    color: #64748b;
    margin-top: 1px;
}

.fh-starter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.fh-starter-chip {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 3px 7px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 11px;
    color: #0f5132;
    cursor: pointer;
    transition: all 0.12s;
}

.fh-starter-chip:hover {
    background: #107c41;
    border-color: #107c41;
    color: #ffffff;
}

.fh-footer-tip {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 5px 10px;
    font-size: 10.5px;
    color: #64748b;
}

.fh-open-builder-btn {
    background: #107c41;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}

.fh-open-builder-btn:hover {
    background: #0b5a2f;
}

/* ==========================================================================
   FORMULA BUILDER & ARGUMENTS SIDEBAR (#formula-builder-pane)
   ========================================================================== */

.formula-builder-pane {
    width: 345px;
    z-index: 460;
}

.fb-body {
    padding: 10px 12px 14px 12px;
    gap: 10px;
}

.fb-cat-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}

.fb-cat-pill {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 10.5px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.12s;
}

.fb-cat-pill:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.fb-cat-pill.active {
    background: #107c41;
    border-color: #107c41;
    color: #ffffff;
}

.fb-sec-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
}

.fb-badge-green {
    background: #dcfce7;
    color: #15803d;
    font-size: 9.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.fb-step-hint {
    font-size: 10px;
    color: #0f5132;
    font-weight: 600;
}

.fb-helper-note {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 6px;
    line-height: 1.35;
}

.fb-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fb-mono-input {
    font-family: Consolas, "Courier New", monospace;
    font-weight: 600;
    font-size: 12px;
    color: #0f172a;
    flex: 1;
}

.fb-pick-btn {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.12s;
}

.fb-pick-btn:hover {
    background: #ecfdf5;
    border-color: #107c41;
    color: #0f5132;
}

.fb-pick-btn.active {
    background: #107c41;
    border-color: #107c41;
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(16, 124, 65, 0.2);
}

.fb-lock-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px 7px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 11.5px;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    transition: all 0.12s;
}

.fb-lock-btn:hover {
    background: #e2e8f0;
    color: #0f5132;
    border-color: #94a3b8;
}

.fb-args-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fb-arg-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 7px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.fb-picking-card {
    background: #f0fdf4 !important;
    border-color: #22c55e !important;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.fb-arg-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.fb-arg-title-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.fb-arg-eval-badge {
    font-family: Consolas, "Courier New", monospace;
    font-size: 10px;
    color: #475569;
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 3px;
    max-width: 125px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-arg-desc {
    font-size: 11px;
    color: #475569;
    line-height: 1.3;
}

.fb-criteria-chips {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 2px;
}

.fb-chip-label {
    font-size: 10px;
    color: #64748b;
    margin-right: 2px;
}

.fb-op-chip {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    padding: 1px 5px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 10.5px;
    font-weight: 700;
    color: #0f5132;
    cursor: pointer;
}

.fb-op-chip:hover {
    background: #107c41;
    border-color: #107c41;
    color: #ffffff;
}

.fb-add-arg-btn {
    width: 100%;
    margin-top: 6px;
    font-weight: 600;
}

.fb-empty-args {
    font-size: 11.5px;
    color: #475569;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 4px;
    padding: 8px;
    line-height: 1.4;
}

.fb-setting-row {
    margin-bottom: 6px;
}

.fb-quick-locks {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.fb-mini-btn {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 10.5px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.12s;
}

.fb-mini-btn:hover {
    background: #ecfdf5;
    border-color: #107c41;
    color: #0f5132;
}

.fb-fill-chips {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fb-fill-chip {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #64748b;
    padding: 0;
}

.fb-fill-chip.active {
    border: 2px solid #107c41;
    box-shadow: 0 0 0 1px #107c41;
}

.fb-footer {
    background: #f8fafc;
    border-top: 1px solid #cbd5e1;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fb-live-preview-box {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 6px 8px;
}

.fb-live-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fb-live-label {
    font-size: 9.5px;
    font-weight: 800;
    color: #64748b;
    width: 54px;
    flex-shrink: 0;
    letter-spacing: 0.4px;
}

.fb-live-formula-code {
    flex: 1;
    min-width: 0;
    width: 100%;
    font-family: Consolas, "Courier New", monospace;
    font-size: 11.5px;
    font-weight: 700;
    color: #0f5132;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 3px 6px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.fb-live-formula-code:focus {
    border-color: #107c41;
    box-shadow: 0 0 0 2px rgba(16, 124, 65, 0.15);
}

.fb-live-result-val {
    font-size: 12px;
    font-weight: 700;
}

.fb-live-result-val.ok {
    color: #15803d;
}

.fb-live-result-val.pending {
    color: #64748b;
    font-weight: 500;
    font-style: italic;
}

.fb-live-result-val.err {
    color: #dc2626;
    font-size: 11px;
}

.fb-footer-actions {
    display: flex;
    gap: 6px;
}

.fb-btn-apply {
    flex: 1;
    background: #107c41;
    color: #ffffff;
    border: 1px solid #0b5a2f;
    border-radius: 4px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.fb-btn-apply:hover {
    background: #0b5a2f;
}

/* =========================================================================
   OFFICE 365 VISUAL SHAPES GALLERY DROPDOWN (#menu-shapes)
   ========================================================================= */
.shapes-gallery-dropdown {
    width: 308px !important;
    max-height: 440px;
    overflow-y: auto;
    padding: 8px 10px 12px !important;
}

.shape-gallery-cat {
    font-size: 10.5px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 6px 2px 4px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 5px;
}

.shape-gallery-cat:not(:first-child) {
    margin-top: 8px;
}

.shape-gallery-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.shape-gallery-btn {
    width: 32px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    cursor: pointer;
    transition: all 0.12s ease;
}

.shape-gallery-btn svg {
    width: 20px;
    height: 20px;
    fill: rgba(0, 120, 212, 0.14);
    stroke: #005a9e;
    stroke-width: 1.75;
    stroke-linejoin: round;
    stroke-linecap: round;
    transition: all 0.12s ease;
}

.shape-gallery-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 120, 212, 0.15);
}

.shape-gallery-btn:hover svg {
    fill: rgba(16, 124, 65, 0.22);
    stroke: #107c41;
}

/* =========================================================================
   FORMAT SHAPE TASK PANE CONTROLS
   ========================================================================= */
.fp-shape-preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.fp-shape-preset-btn {
    height: 32px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s, box-shadow 0.12s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.fp-shape-preset-btn:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.fp-seg-group {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
}

.fp-seg-btn {
    flex: 1;
    border: 1px solid transparent;
    background: transparent;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.12s;
    text-align: center;
}

.fp-seg-btn:hover {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.6);
}

.fp-seg-btn.active {
    background: #ffffff;
    color: #107c41;
    border-color: #cbd5e1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.fp-color-swatch-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.fp-mini-swatch {
    width: 21px;
    height: 21px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s, box-shadow 0.1s;
}

.fp-mini-swatch:hover {
    transform: scale(1.14);
    box-shadow: 0 0 0 2px #107c41;
}

.shape-inline-editor:focus {
    cursor: text !important;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

/* ============================================================================
   UNIVERSAL OFFICE 365 COLOR PICKER POPOVER & CUSTOM COLOR CONTROLS
   (Replaces all native Windows/OS <input type="color"> pickers)
   ============================================================================ */

input[type="color"],
.fp-color-input {
    -webkit-appearance: none;
    appearance: none;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 2px;
    background: #ffffff;
    cursor: pointer !important;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

input[type="color"]:hover,
.fp-color-input:hover {
    border-color: #107c41;
    box-shadow: 0 0 0 2px rgba(16, 124, 65, 0.18);
    transform: translateY(-1px);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 3px;
}

input[type="color"]::-moz-color-swatch {
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 3px;
}

.mg-color-popover {
    position: fixed;
    z-index: 99999;
    width: 268px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.22), 0 4px 12px rgba(15, 23, 42, 0.1);
    padding: 10px 12px 12px 12px;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #1e293b;
    user-select: none;
    animation: mgPopoverFadeIn 0.12s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mgPopoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.mg-cp-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 7px;
    margin-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
}

.mg-cp-title-wrap {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
}

.mg-cp-live-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.22);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

.mg-cp-close {
    border: none;
    background: transparent;
    color: #64748b;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
}

.mg-cp-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.mg-cp-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.45px;
    color: #64748b;
    margin: 6px 0 4px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mg-cp-modal-link {
    border: none;
    background: transparent;
    color: #107c41;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.mg-cp-modal-link:hover {
    text-decoration: underline;
}

.mg-cp-matrix {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 3px;
}

.mg-cp-tints {
    margin-top: 4px;
    row-gap: 2px;
}

.mg-cp-swatch {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.16);
    cursor: pointer;
    padding: 0;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.mg-cp-swatch:hover {
    transform: scale(1.22);
    z-index: 3;
    border-color: #ffffff;
    box-shadow: 0 0 0 1.5px #107c41, 0 2px 5px rgba(0, 0, 0, 0.25);
}

.mg-cp-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 8px 0 6px 0;
}

.mg-cp-spectrum-wrap {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.mg-cp-sv-box {
    position: relative;
    width: 242px;
    height: 116px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    cursor: crosshair;
    margin: 0 auto;
}

.mg-cp-sv-box canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.mg-cp-sv-cursor {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.65), 0 2px 4px rgba(0, 0, 0, 0.35);
    transform: translate(-50%, -50%);
    pointer-events: none;
    top: 20%;
    left: 80%;
}

.mg-cp-hue-row {
    display: flex;
    align-items: center;
    padding: 0 1px;
}

.mg-cp-hue-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 11px;
    border-radius: 999px;
    background: linear-gradient(to right,
        #ff0000 0%,
        #ffff00 17%,
        #00ff00 33%,
        #00ffff 50%,
        #0000ff 67%,
        #ff00ff 83%,
        #ff0000 100%);
    outline: none;
    border: 1px solid rgba(0, 0, 0, 0.18);
    cursor: pointer;
}

.mg-cp-hue-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    cursor: grab;
}

.mg-cp-inputs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.mg-cp-hex-group {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 2px 6px;
    gap: 4px;
    flex: 1;
}

.mg-cp-hex-group span {
    font-size: 9.5px;
    font-weight: 700;
    color: #64748b;
}

.mg-cp-hex-group input {
    border: none;
    background: transparent;
    font-family: 'Consolas', monospace;
    font-size: 11.5px;
    font-weight: 700;
    color: #0f172a;
    width: 64px;
    outline: none;
    text-transform: uppercase;
}

.mg-cp-rgb-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.mg-cp-rgb-group input {
    width: 38px;
    padding: 3px 2px;
    font-size: 11px;
    font-family: 'Consolas', monospace;
    text-align: center;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #f8fafc;
    color: #0f172a;
    outline: none;
}

.mg-cp-rgb-group input:focus,
.mg-cp-hex-group:focus-within {
    border-color: #107c41;
    background: #ffffff;
}

.mg-cp-apply-btn {
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-radius: 5px;
    background: #107c41;
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.mg-cp-apply-btn:hover {
    background: #0c5e31;
}

/* =========================================================================
   ENTERPRISE EXCEL TEMPLATE LIBRARY MODAL (.mg-tpl-*)
   ========================================================================= */
.mg-tpl-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

.mg-tpl-modal-dialog {
    width: min(1360px, 96vw);
    height: min(860px, 92vh);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mg-tpl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #0b5a2f 0%, #107c41 60%, #0f766e 100%);
    color: #ffffff;
    flex-shrink: 0;
}

.mg-tpl-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mg-tpl-header-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mg-tpl-header-brand h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.mg-tpl-header-brand p {
    margin: 2px 0 0 0;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.85);
}

.mg-tpl-search-bar {
    position: relative;
    flex: 1;
    max-width: 520px;
    display: flex;
    align-items: center;
}

.mg-tpl-search-icon {
    position: absolute;
    left: 12px;
    color: #64748b;
    pointer-events: none;
}

#mg-tpl-search-input {
    width: 100%;
    padding: 9px 34px 9px 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: #ffffff;
    color: #0f172a;
    font-size: 13px;
    outline: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

#mg-tpl-search-input:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.mg-tpl-search-clear {
    position: absolute;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    font-size: 11px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.mg-tpl-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.mg-tpl-close-btn:hover {
    background: rgba(255, 255, 255, 0.26);
}

/* Blueprint Filter Strip */
.mg-tpl-blueprint-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
    flex-shrink: 0;
}

.mg-tpl-bp-pill {
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s;
}

.mg-tpl-bp-pill:hover {
    border-color: #107c41;
    color: #107c41;
    background: #f0fdf4;
}

.mg-tpl-bp-pill.active {
    background: #107c41;
    border-color: #107c41;
    color: #ffffff;
}

/* Main 3-Column Master-Detail Body: Categories | Template List | Live Preview */
.mg-tpl-body {
    flex: 1;
    display: grid;
    grid-template-columns: 205px 390px 1fr;
    min-height: 0;
    background: #f1f5f9;
}

/* 1. Left Category Sidebar */
.mg-tpl-sidebar {
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.mg-tpl-sidebar-title {
    padding: 10px 14px 6px;
    font-size: 10.5px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.05em;
}

.mg-tpl-cat-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mg-tpl-cat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #334155;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}

.mg-tpl-cat-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.mg-tpl-cat-item.active {
    background: #ecfdf5;
    color: #0b5a2f;
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--cat-accent, #107c41);
}

.mg-tpl-cat-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.mg-tpl-cat-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mg-tpl-cat-count {
    font-size: 10px;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 10px;
}

/* 2. Middle Column: Clean Scannable Template List */
.mg-tpl-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: #f8fafc;
    border-right: 1px solid #cbd5e1;
}

.mg-tpl-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.mg-tpl-result-stat {
    font-size: 11.5px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mg-tpl-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.mg-tpl-page-btn {
    padding: 3px 7px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #ffffff;
    color: #1e293b;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.mg-tpl-page-btn:hover:not(:disabled) {
    border-color: #107c41;
    color: #107c41;
    background: #f0fdf4;
}

.mg-tpl-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.mg-tpl-page-indicator {
    font-size: 11px;
    color: #475569;
    padding: 0 3px;
    white-space: nowrap;
}

/* Vertical List of Templates */
.mg-tpl-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: opacity 0.15s;
}

.mg-tpl-list-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 11px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-left: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.1s;
}

.mg-tpl-list-item:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    border-left-color: var(--tpl-accent, #107c41);
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.06);
}

.mg-tpl-list-item.selected {
    background: #f0fdf4;
    border-color: var(--tpl-accent, #107c41);
    border-left: 4px solid var(--tpl-accent, #107c41);
    box-shadow: 0 4px 14px rgba(16, 124, 65, 0.12);
}

.mg-tpl-li-icon {
    width: 44px;
    min-height: 46px;
    border-radius: 7px;
    border: 1px solid rgba(16, 124, 65, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 4px 2px 3px;
    flex-shrink: 0;
}

.mg-tpl-li-emoji {
    font-size: 16px;
    line-height: 1;
}

.mg-tpl-li-num {
    font-size: 8.5px;
    font-weight: 700;
    color: #ffffff;
    padding: 1px 4px;
    border-radius: 3px;
    letter-spacing: 0.02em;
}

.mg-tpl-li-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mg-tpl-li-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.mg-tpl-li-title {
    font-size: 12.5px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mg-tpl-list-item.selected .mg-tpl-li-title {
    color: #0b5a2f;
}

.mg-tpl-li-code {
    font-family: Consolas, monospace;
    font-size: 9.5px;
    font-weight: 700;
    color: #64748b;
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 4px;
    flex-shrink: 0;
}

.mg-tpl-li-desc {
    font-size: 11px;
    color: #64748b;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mg-tpl-li-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.mg-tpl-li-cat {
    font-size: 9.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.mg-tpl-badge-fx {
    font-family: Consolas, monospace;
    font-size: 9.5px;
    font-weight: 600;
    color: #0f5132;
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    padding: 1px 5px;
    border-radius: 4px;
    max-width: 155px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mg-tpl-badge-chart {
    font-size: 9.5px;
    font-weight: 600;
    color: #334155;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
}

.mg-tpl-li-arrow {
    align-self: center;
    color: #94a3b8;
    flex-shrink: 0;
    transition: transform 0.12s, color 0.12s;
}

.mg-tpl-list-item:hover .mg-tpl-li-arrow,
.mg-tpl-list-item.selected .mg-tpl-li-arrow {
    color: var(--tpl-accent, #107c41);
    transform: translateX(2px);
}

/* 3. Right Column: Wide Interactive Workbook Preview Panel */
.mg-tpl-inspector {
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.mg-tpl-inspector-empty {
    margin: auto;
    padding: 32px;
    text-align: center;
}

.mg-tpl-preview-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.mg-tpl-prev-header {
    background: #ffffff;
    padding: 12px 18px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.mg-tpl-prev-header-info {
    flex: 1;
    min-width: 0;
}

.mg-tpl-prev-badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 5px;
}

.mg-tpl-prev-code {
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
}

.mg-tpl-prev-cat,
.mg-tpl-prev-lang,
.mg-tpl-prev-fx,
.mg-tpl-prev-charts {
    font-size: 10px;
    font-weight: 600;
    color: #334155;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 2px 7px;
    border-radius: 6px;
}

.mg-tpl-prev-fx {
    font-family: Consolas, monospace;
    color: #0f5132;
    background: #ecfdf5;
    border-color: #bbf7d0;
}

.mg-tpl-prev-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
}

.mg-tpl-prev-desc {
    margin: 3px 0 0 0;
    font-size: 11.5px;
    color: #475569;
    line-height: 1.35;
}

.mg-tpl-prev-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    min-width: 185px;
}

.mg-tpl-btn-primary {
    width: 100%;
    padding: 9px 14px;
    border: none;
    border-radius: 7px;
    background: #107c41;
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 3px 8px rgba(16, 124, 65, 0.25);
    transition: filter 0.15s, transform 0.1s;
}

.mg-tpl-btn-primary:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.mg-tpl-btn-primary:disabled {
    opacity: 0.7;
    cursor: wait;
}

.mg-tpl-btn-secondary {
    width: 100%;
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #1e293b;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.mg-tpl-btn-secondary:hover:not(:disabled) {
    background: #f0fdf4;
    border-color: #107c41;
    color: #0b5a2f;
}

/* Interactive Preview Toolbar (Sheet Tabs + Values/Formulas Toggle) */
.mg-tpl-prev-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 36px;
    background: #f8fafc;
    border-bottom: 1px solid #dbe2ea;
    flex-shrink: 0;
}

.mg-tpl-prev-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}

.mg-tpl-prev-toolbar-label {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.04em;
    margin-right: 4px;
}

.mg-tpl-prev-tab {
    height: 100%;
    padding: 0 12px;
    border: none;
    border-bottom: 2.5px solid transparent;
    background: transparent;
    color: #475569;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.12s, background 0.12s;
}

.mg-tpl-prev-tab:hover {
    background: rgba(15, 23, 42, 0.04);
    color: #0f172a;
}

.mg-tpl-prev-tab.active {
    background: #ffffff;
    font-weight: 700;
}

.mg-tpl-tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.mg-tpl-prev-toggles {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mg-tpl-toggle-btn {
    padding: 3px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #ffffff;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s;
}

.mg-tpl-toggle-btn.active {
    background: #107c41;
    border-color: #107c41;
    color: #ffffff;
}

/* Scrollable Preview Content Area */
.mg-tpl-prev-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 4 Executive KPI Cards Strip in Preview */
.mg-tpl-kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.mg-tpl-kpi-card {
    background: #ffffff;
    border: 1px solid #dbe2ea;
    border-radius: 7px;
    padding: 8px 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.mg-tpl-kpi-label {
    font-size: 9.5px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mg-tpl-kpi-val {
    font-size: 15px;
    font-weight: 800;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.mg-tpl-kpi-fx {
    margin-top: 2px;
}

.mg-tpl-kpi-fx code {
    font-family: Consolas, monospace;
    font-size: 9.5px;
    color: #0f5132;
    background: #ecfdf5;
    padding: 0 4px;
    border-radius: 3px;
}

/* Dual Analytical Charts Row in Preview */
.mg-tpl-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mg-tpl-chart-box {
    background: #ffffff;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    padding: 9px 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
}

.mg-tpl-chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
}

.mg-tpl-chart-title {
    font-size: 11px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mg-tpl-chart-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.mg-tpl-chart-svg-wrap {
    width: 100%;
    height: 118px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mg-tpl-chart-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 4px;
    font-size: 10px;
    color: #475569;
}

.mg-tpl-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mg-tpl-chart-legend i {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
}

/* Live Spreadsheet Grid Preview Table */
.mg-tpl-prev-sheet-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.mg-tpl-prev-sheet-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 11px;
    color: #334155;
}

.mg-tpl-prev-table-wrap {
    overflow-x: auto;
}

.mg-tpl-grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.mg-tpl-grid-corner,
.mg-tpl-grid-colhdr {
    background: #f1f5f9;
    color: #475569;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    padding: 3px 6px;
    border: 1px solid #cbd5e1;
    user-select: none;
}

.mg-tpl-grid-rowhdr {
    background: #f1f5f9;
    color: #64748b;
    font-size: 9.5px;
    font-weight: 600;
    text-align: center;
    width: 24px;
    padding: 2px 4px;
    border: 1px solid #cbd5e1;
    user-select: none;
}

.mg-tpl-grid-spacer td {
    height: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.mg-tpl-grid-cell {
    position: relative;
    padding: 4px 7px;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mg-tpl-grid-cell:hover {
    outline: 1.5px solid #107c41;
    z-index: 2;
}

.mg-tpl-grid-cell.has-fx .mg-tpl-cell-text {
    position: relative;
    z-index: 1;
}

.mg-tpl-cell-databar {
    position: absolute;
    left: 2px;
    top: 2px;
    bottom: 2px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 0;
}

.mg-tpl-preview-loading {
    margin: auto;
    padding: 40px 24px;
    text-align: center;
    color: #475569;
    font-size: 12.5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mg-tpl-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #107c41;
    border-radius: 50%;
    animation: mgTplSpin 0.7s linear infinite;
}

@keyframes mgTplSpin {
    to { transform: rotate(360deg); }
}

.mg-tpl-empty-state {
    padding: 48px 20px;
    text-align: center;
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
}



