/* SheetWorks v1.1 — Microsoft Excel-style interface: green title bar, Office ribbon, bottom sheet tabs. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: #fff; color: #262626; display: flex; flex-direction: column; height: 100dvh; overflow: hidden; -webkit-font-smoothing: antialiased; }

/* ---- green title bar ---- */
.titlebar { flex: none; display: flex; align-items: center; gap: 8px; padding: 5px 10px; background: #107c41; color: #fff; }
.glyph { width: 26px; height: 26px; flex: none; }
.wbtitle { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 15px; font-weight: 600; color: #fff; border: 1px solid transparent; border-radius: 4px; padding: 4px 8px; background: transparent; text-align: center; }
.wbtitle:hover { border-color: rgba(255,255,255,.5); }
.wbtitle:focus { border-color: #fff; outline: none; background: rgba(255,255,255,.12); }
.iconbtn { flex: none; width: 32px; height: 32px; border: 0; border-radius: 4px; background: transparent; font-size: 17px; color: #fff; cursor: pointer; }
.iconbtn:hover { background: rgba(255,255,255,.18); }
.iconbtn.starred { color: #ffd966; }
.qatbtn { flex: none; font: inherit; font-size: 13px; font-weight: 600; color: #fff; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.45); border-radius: 4px; padding: 6px 10px; cursor: pointer; min-height: 32px; white-space: nowrap; }
.qatbtn:hover { background: rgba(255,255,255,.26); }
.savestate { flex: none; font-size: 12px; color: rgba(255,255,255,.85); white-space: nowrap; }
@media (max-width: 620px) { .savestate { display: none; } .wbtitle { text-align: left; } }

/* ---- ribbon ---- */
.ribbon { flex: none; background: #fff; border-bottom: 1px solid #d2d0ce; position: relative; z-index: 30; }
.ribbontabs { display: flex; align-items: center; gap: 2px; padding: 2px 8px 0; }
.menuwrap { position: relative; }
.filebtn { font: inherit; font-size: 13.5px; font-weight: 600; color: #fff; background: #107c41; border: 0; border-radius: 4px 4px 0 0; padding: 6px 16px; cursor: pointer; min-height: 32px; }
.filebtn:hover { background: #0c6634; }
.ribtab { font: inherit; font-size: 13.5px; color: #262626; background: transparent; border: 0; border-bottom: 3px solid transparent; padding: 6px 12px 4px; cursor: pointer; min-height: 32px; }
.ribtab:hover { color: #107c41; }
.ribtab.active { font-weight: 700; color: #107c41; border-bottom-color: #107c41; }
.menupanel { position: absolute; top: calc(100% + 4px); left: 0; min-width: 272px; max-width: 88vw; background: #fff; border: 1px solid #d2d0ce; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.22); padding: 6px 0; z-index: 50; }
.menupanel[hidden] { display: none; }
.menuitem { display: block; width: 100%; text-align: left; font: inherit; font-size: 13.5px; color: #262626; background: transparent; border: 0; padding: 8px 16px; cursor: pointer; min-height: 38px; }
.menuitem:hover { background: #e6f4ec; }
.menusep { height: 1px; background: #edebe9; margin: 6px 0; }
.ribbonbody { background: #faf9f8; border-top: 1px solid #edebe9; }
.ribbonpanel { display: flex; align-items: stretch; gap: 0; padding: 6px 8px 4px; overflow-x: auto; scrollbar-width: none; }
.ribbonpanel::-webkit-scrollbar { display: none; }
.ribbonpanel[hidden] { display: none; }
.rgroup { flex: none; display: flex; flex-direction: column; align-items: center; padding: 0 10px; border-right: 1px solid #e1dfdd; }
.rgroup:last-child { border-right: 0; }
.rrow { display: flex; align-items: center; gap: 2px; flex: 1; }
.rlabel { font-size: 11px; color: #605e5c; padding: 3px 0 1px; white-space: nowrap; }
.rbtn { position: relative; min-width: 32px; height: 32px; padding: 0 7px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #262626; font: inherit; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.rbtn:hover { background: #e6f4ec; }
.rbtn.on { background: #cfe8d8; border-color: #107c41; }
.rbtn.bold { font-weight: 700; }
.rbtn.italic { font-style: italic; font-family: Georgia, serif; }
.rbtn.small { font-size: 12.5px; color: #444; }
.rbtn.big { height: 38px; padding: 0 12px; font-size: 13.5px; white-space: nowrap; }
.rbtn.big i { font-family: Georgia, serif; color: #107c41; margin-right: 4px; }
.colorbtn { flex-direction: column; line-height: 1; padding-top: 4px; }
.colorbar { display: block; width: 18px; height: 4px; border-radius: 2px; margin-top: 2px; border: 1px solid rgba(0,0,0,.15); }
.colorinput { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.fmtselect { font: inherit; font-size: 13px; color: #262626; background: #fff; border: 1px solid #d2d0ce; border-radius: 4px; padding: 5px 3px; max-width: 112px; cursor: pointer; }
.alicon { width: 18px; height: 18px; }
.zoomlabel { font-size: 13px; color: #444; min-width: 44px; text-align: center; }

/* ---- formula bar ---- */
.formulabar { flex: none; display: flex; align-items: center; background: #fff; border-bottom: 1px solid #d2d0ce; min-height: 32px; }
.namebox { flex: 0 0 74px; width: 74px; font: inherit; font-size: 13px; text-align: center; color: #262626; border: 0; border-right: 1px solid #edebe9; padding: 6px 2px; background: transparent; }
.namebox:focus { outline: none; background: #e6f4ec; }
.fx { flex: none; font-family: Georgia, serif; font-size: 14px; color: #605e5c; padding: 0 10px; border-right: 1px solid #edebe9; align-self: stretch; display: flex; align-items: center; }
.formulainput { flex: 1; min-width: 0; font: inherit; font-size: 13.5px; color: #262626; border: 0; padding: 6px 10px; background: transparent; }
.formulainput:focus { outline: none; background: #fafafa; }

/* ---- main column ---- */
main { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.honest { flex: none; background: #fff4ce; border-bottom: 1px solid #f9ab00; color: #7a5c00; padding: 8px 12px; font-size: 13px; line-height: 1.4; }
.note { flex: none; background: #e6f4ec; border-bottom: 1px solid #107c41; color: #0b5c2e; padding: 8px 12px; font-size: 13px; margin: 0; }

/* ---- grid ---- */
.gridwrap { flex: 1 1 auto; overflow: auto; background: #fff; min-height: 120px; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: collapse; font-size: calc(13.5px * var(--zoom, 1)); color: #262626; }
table.grid th, table.grid td { border: 1px solid #d9d9d9; padding: 0 7px; height: calc(24px * var(--zoom, 1)); min-width: calc(88px * var(--zoom, 1)); max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #fff; font-weight: 400; }
table.grid thead th { position: sticky; top: 0; z-index: 3; background: #fff; color: #444; text-align: center; font-size: calc(12.5px * var(--zoom, 1)); border-bottom: 1.5px solid #b6b6b6; }
table.grid th.rowhead { position: sticky; left: 0; z-index: 2; background: #fff; color: #444; min-width: 42px; width: 42px; text-align: center; font-size: calc(12.5px * var(--zoom, 1)); border-right: 1.5px solid #b6b6b6; }
table.grid th.corner { position: sticky; left: 0; top: 0; z-index: 4; background: #fff; min-width: 42px; width: 42px; cursor: pointer; }
.cornertri { position: absolute; right: 3px; bottom: 3px; width: 0; height: 0; border-left: 7px solid transparent; border-bottom: 7px solid #a6a6a6; }
table.grid th.selhead { background: #d9ead3; color: #0b5c2e; font-weight: 700; box-shadow: inset 0 -2.5px 0 #107c41; }
table.grid th.rowhead.selhead { box-shadow: inset -2.5px 0 0 #107c41; }
td.cell { cursor: cell; }
td.cell.err { color: #b3261e; font-weight: 700; }
td.cell.selected { outline: 2.5px solid #107c41; outline-offset: -2.5px; }
.celledit { width: 100%; height: 100%; font: inherit; font-size: 13.5px; border: 0; outline: none; padding: 0 2px; background: #fff; color: #262626; }
body.nogrid table.grid td, body.nogrid table.grid th { border-color: transparent; }
body.nogrid table.grid thead th { border-bottom-color: #d9d9d9; }
body.noheads table.grid thead th, body.noheads table.grid th.rowhead { visibility: hidden; }

/* ---- sheet tabs (bottom, Excel style) ---- */
.tabstrip { flex: none; display: flex; align-items: center; gap: 4px; background: #f3f2f1; border-top: 1px solid #d2d0ce; padding: 2px 8px; min-height: 36px; overflow-x: auto; scrollbar-width: none; }
.tabstrip::-webkit-scrollbar { display: none; }
.addtab { flex: none; width: 26px; height: 26px; border: 1.5px solid #8a8886; border-radius: 50%; background: transparent; color: #444; font-size: 16px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.addtab:hover { background: #e6f4ec; border-color: #107c41; color: #107c41; }
.sheettabs { display: flex; align-items: stretch; gap: 2px; }
.sheettab { font: inherit; font-size: 13px; color: #444; background: transparent; border: 0; border-bottom: 3px solid transparent; padding: 6px 14px; cursor: pointer; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheettab:hover { background: #edebe9; }
.sheettab.active { color: #107c41; font-weight: 700; background: #fff; border-bottom-color: #107c41; }

/* ---- footer ---- */
footer { flex: none; padding: 5px 12px 7px; background: #f3f2f1; border-top: 1px solid #edebe9; }
.fine { font-size: 11.5px; color: #605e5c; line-height: 1.4; margin: 0; }
.version { font-size: 11px; color: #8a8886; margin: 2px 0 0; }

/* ---- v1.1 ribbon completion: clipboard, font controls, data + view ---- */
.menuhint { display: block; font-size: 11.5px; color: #605e5c; margin-top: 1px; }
.clipboardlayout { display: flex; align-items: stretch; gap: 3px; flex: 1; }
.pastebtn { min-width: 58px; min-height: 58px; font-weight: 700; color: #0b5c2e; background: #e6f4ec; border-color: #b7d8c4; }
.clipstack { display: flex; flex-direction: column; gap: 2px; justify-content: center; }
.clipstack .rbtn { height: 27px; justify-content: flex-start; }
.fontgroup { min-width: 252px; }
.fontrow { gap: 4px; }
.fontselect, .sizeselect { font: inherit; font-size: 13px; color: #262626; background: #fff; border: 1px solid #d2d0ce; border-radius: 4px; padding: 5px 3px; cursor: pointer; }
.fontselect { width: 132px; }
.sizeselect { width: 62px; }
.rbtn.underline { text-decoration: underline; text-underline-offset: 3px; }
.rbtn.strike { text-decoration: line-through; }
.decimalrow, .cellactions { justify-content: center; }
.formulabar[hidden], .tabstrip[hidden] { display: none !important; }
table.grid td.cell { vertical-align: top; }
@media (max-width: 620px) {
  .ribbonpanel { padding-left: 4px; padding-right: 4px; }
  .rgroup { padding: 0 7px; }
  .qatbtn { padding: 6px 8px; }
}
