:root{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Tahoma,sans-serif;color:#e5e7eb;background:#08111f;color-scheme:dark}*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:#08111f}body{min-height:100vh}.hidden{display:none!important}.app-shell{width:100%;min-height:100vh;padding:12px}.topbar{max-width:1800px;margin:0 auto 10px;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 16px;border:1px solid #243247;background:#0f172a;border-radius:16px}.brand{font-size:11px;letter-spacing:2.5px;color:#93c5fd;font-weight:900}.topbar h1{font-size:21px;margin:2px 0}.fidelity-note{font-size:11px;color:#94a3b8}.status-pill{font-size:12px;padding:8px 12px;border-radius:999px;background:#334155;color:#e2e8f0;white-space:nowrap}.status-pill.ok{background:#14532d;color:#bbf7d0}.status-pill.saving{background:#1e3a8a;color:#bfdbfe}.status-pill.warn{background:#78350f;color:#fde68a}.status-pill.bad{background:#7f1d1d;color:#fecaca}.card{max-width:520px;margin:50px auto;background:#111827;border:1px solid #2b3950;border-radius:20px;padding:24px}.card h2{margin:0 0 8px}.card p{color:#9caec4;line-height:1.8}.card label{display:block;margin:10px 0 7px}.card input{width:100%;padding:14px;border-radius:12px;border:1px solid #3b4a61;background:#0b1324;color:#fff;font-size:16px}.wide{width:100%;margin-top:14px}button{border:1px solid #3a4961;background:#1e293b;color:#fff;border-radius:10px;padding:10px 12px;font-weight:750;cursor:pointer;font-size:13px}.primary{background:#2563eb;border-color:#3b82f6}.danger{background:#991b1b;border-color:#b91c1c}.message{min-height:25px;margin-top:10px;color:#bfdbfe;line-height:1.6}.message.error{color:#fca5a5}.editor-card{max-width:1800px;margin:0 auto;background:#0f172a;border:1px solid #243247;border-radius:16px;overflow:hidden}.editor-toolbar{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 11px;background:#111827;border-bottom:1px solid #26354b}.meta-group,.actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.meta-group{color:#9fb0c7;font-size:12px}.style-badge,.number-badge{padding:4px 8px;border-radius:999px;border:1px solid #246a50;background:#153d31;color:#bbf7d0}.number-badge{background:#3b2d14;border-color:#6d5222;color:#fde68a}.small{padding:7px 9px;font-size:12px}.compact{margin:0;padding:6px 11px;min-height:32px;background:#0b1324;border-bottom:1px solid #1d2a3d;font-size:12px}.conflict{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 11px;background:#4a1d12;color:#fed7aa;border-bottom:1px solid #7c2d12;font-size:12px}.conflict-actions{display:flex;gap:7px}.sheet-tabs{display:flex;gap:2px;overflow-x:auto;background:#e5e7eb;border-bottom:1px solid #9ca3af;padding:4px 6px 0}.sheet-tab{color:#1f2937;background:#d1d5db;border:1px solid #9ca3af;border-bottom:0;border-radius:5px 5px 0 0;padding:6px 13px;font-size:12px;white-space:nowrap}.sheet-tab.active{background:#fff;color:#111827;font-weight:800}.sheet-viewport{height:calc(100vh - 205px);min-height:520px;overflow:auto;background:#fff;color:#111;direction:ltr;position:relative}.excel-table{border-collapse:separate;border-spacing:0;table-layout:fixed;background:#fff;color:#111;font-family:Calibri,Arial,sans-serif;min-width:max-content}.excel-table col.row-header-col{width:48px}.excel-table th.col-header,.excel-table th.row-header,.excel-table th.corner{position:sticky;background:#f3f4f6;color:#374151;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;font-size:11px;font-weight:600;text-align:center;border-right:1px solid #d1d5db;border-bottom:1px solid #d1d5db;z-index:5;user-select:none}.excel-table th.col-header{top:0;height:24px}.excel-table th.row-header{left:0;min-width:48px;width:48px;z-index:6}.excel-table th.corner{left:0;top:0;z-index:7;width:48px}.excel-cell{padding:2px 4px;overflow:hidden;min-width:20px;min-height:20px;outline:none;white-space:pre;line-height:1.2;background:#fff;color:#000;vertical-align:middle;border-right:1px solid #e5e7eb;border-bottom:1px solid #e5e7eb;unicode-bidi:plaintext}.excel-cell.wrap{white-space:pre-wrap;overflow-wrap:anywhere}.excel-cell:focus{box-shadow:inset 0 0 0 2px #2563eb;position:relative;z-index:4}.excel-cell.numeric-id{direction:ltr;text-align:left;font-variant-numeric:tabular-nums}.excel-cell.formula-cell::after{content:"ƒ";font-size:8px;opacity:.35;float:right;margin-left:3px}.empty-sheet{padding:40px;color:#4b5563;background:#fff}.message.compact{direction:rtl}.sheet-tabs{direction:ltr}@media(max-width:760px){.app-shell{padding:5px}.topbar{padding:9px 10px;border-radius:11px}.topbar h1{font-size:16px}.fidelity-note{font-size:9px}.editor-toolbar{flex-direction:column;align-items:flex-start}.actions{width:100%}.actions button{flex:1}.sheet-viewport{height:calc(100vh - 250px);min-height:420px}.excel-table th.row-header,.excel-table th.corner{min-width:38px;width:38px}.excel-table col.row-header-col{width:38px}.excel-cell{padding:2px 3px}}

.excel-ribbon{background:#f8fafc;color:#111827;border-bottom:1px solid #cbd5e1;padding:6px 8px;display:flex;flex-direction:column;gap:6px;position:relative;z-index:20}
.ribbon-row{display:flex;align-items:center;gap:6px;overflow-x:auto}.ribbon-tools{padding-bottom:2px}.tool-group{display:flex;align-items:center;gap:4px;padding-right:7px;margin-right:2px;border-right:1px solid #d1d5db;white-space:nowrap}.tool-group:first-child{border-right:0}.excel-ribbon button{background:#fff;color:#111827;border:1px solid #cbd5e1;border-radius:5px;padding:5px 7px;font-size:11px}.excel-ribbon button:hover{background:#e2e8f0}.excel-ribbon button.active{background:#dbeafe;border-color:#60a5fa}.name-box{width:72px;border:1px solid #cbd5e1;border-radius:4px;padding:5px 7px;font:12px Consolas,monospace}.formula-bar{min-width:260px;flex:1;border:1px solid #cbd5e1;border-radius:4px;padding:5px 8px;font:12px Consolas,monospace}.fx-mark{font-weight:800;font-style:italic;color:#475569}.color-tool{display:flex;align-items:center;gap:4px;background:#fff;border:1px solid #cbd5e1;border-radius:5px;padding:2px 5px;font-size:10px}.color-tool input{width:22px;height:22px;border:0;padding:0;background:transparent}.excel-cell.selected{box-shadow:inset 0 0 0 2px #2563eb!important;position:relative;z-index:9}.excel-cell.selected-range{background-image:linear-gradient(rgba(37,99,235,.08),rgba(37,99,235,.08));}.excel-cell.active-cell{box-shadow:inset 0 0 0 3px #1d4ed8!important;z-index:10}.excel-cell.frozen-row{position:sticky;z-index:8}.excel-cell.frozen-col{position:sticky;z-index:8}.excel-cell.frozen-row.frozen-col{z-index:9}.sheet-tab .sheet-color-dot{display:inline-block;width:7px;height:7px;border-radius:50%;margin-right:5px;vertical-align:middle}.sheet-viewport{height:calc(100vh - 300px)}
@media(max-width:760px){.excel-ribbon{padding:4px}.formula-bar{min-width:180px}.excel-ribbon button{padding:5px 6px}.sheet-viewport{height:calc(100vh - 365px);min-height:380px}}


/* V6 Excel-like selection + context menu */
.excel-cell{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;touch-action:pan-x pan-y;cursor:cell}
.excel-cell.editing{user-select:text;-webkit-user-select:text;cursor:text;background-image:none!important;box-shadow:inset 0 0 0 2px #2563eb!important}
.row-header,.col-header,.corner{cursor:default;touch-action:none;-webkit-touch-callout:none}
.row-header.selected-header,.col-header.selected-header,.corner.selected-header{background:#cfe3ff!important;color:#123b78!important;font-weight:800!important}
.excel-context-menu{position:fixed;z-index:9999;width:240px;max-height:72vh;overflow:auto;padding:6px;background:#fff;color:#111827;border:1px solid #cbd5e1;border-radius:8px;box-shadow:0 16px 45px rgba(15,23,42,.25);direction:rtl}
.excel-context-menu button{display:block;width:100%;text-align:right;background:#fff;color:#111827;border:0;border-radius:5px;padding:8px 10px;font-size:12px;font-weight:600}
.excel-context-menu button:hover,.excel-context-menu button:active{background:#eaf2ff}
.ctx-sep{height:1px;background:#e5e7eb;margin:4px 2px}
@media(max-width:760px){.excel-context-menu{width:225px}.excel-context-menu button{padding:11px 10px;font-size:13px}}
