/* Carlito: Calibri's metric-compatible open twin, used when Calibri isn't installed (so
   columns, wrapping and printed pages measure as in Excel). */
@font-face { font-family: Carlito; src: url(fonts/Carlito-Regular.ttf); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Carlito; src: url(fonts/Carlito-Bold.ttf); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: Carlito; src: url(fonts/Carlito-Italic.ttf); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Carlito; src: url(fonts/Carlito-BoldItalic.ttf); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: "Noto Sans Devanagari"; src: url(fonts/NotoSansDevanagari-Regular.ttf); font-display: swap; }

/* Kraftoz Ganit: the Kraftoz look (dark title bar, light panels) with Excel's layout. */
:root {
  --bg: #e6e8ec;
  --panel: #f5f6f8;
  --panel-2: #ffffff;
  --border: #c9cdd4;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #1d7a4c;
  --accent-2: #15803d;
  --accent-soft: #dcfce7;
  --hover: #e3e8f0;
  --titlebar: #2b2f36;
  --titlebar-text: #e5e7eb;
  --sel: rgba(29, 122, 76, .12);
  --bad: #b91c1c;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 12px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  user-select: none;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; }

#app { display: grid; height: 100vh; grid-template-rows: 32px 28px auto 30px auto minmax(0, 1fr) 28px 24px; }

/* ---------- title bar ---------- */
#titlebar { display: flex; align-items: center; gap: 2px; background: var(--titlebar); color: var(--titlebar-text); padding: 0 8px; }
.brand { display: flex; align-items: center; gap: 7px; font-weight: 700; letter-spacing: .3px; margin-right: 10px; white-space: nowrap; }
.logo { width: 18px; height: 18px; background: url(logo-small.svg) center / contain no-repeat; }
.qa { background: none; border: 0; height: 26px; min-width: 28px; border-radius: 4px; font-size: 14px; cursor: default; }
.qa:hover:not(:disabled) { background: #3d434d; }
.qa:disabled { opacity: .35; }
.doc-title { margin-left: 16px; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-title .edited { color: #94a3b8; font-style: italic; margin-left: 6px; }
.spacer { flex: 1; }

/* ---------- ribbon ---------- */
#tabs { display: flex; align-items: flex-end; gap: 2px; background: var(--panel); padding: 0 6px; border-bottom: 1px solid var(--border); }
#tabs button {
  border: 0; background: none; padding: 5px 12px 6px; cursor: default; border-radius: 4px 4px 0 0; position: relative; top: 1px;
  border: 1px solid transparent; border-bottom: 0;
}
#tabs button:hover { background: var(--hover); }
#tabs button.active { background: var(--panel-2); border-color: var(--border); color: var(--accent); font-weight: 600; }
#tabs button.context { color: var(--accent); background: #ecfdf5; }
#tabs button.context.active { background: var(--panel-2); }
#tabs button.file { background: var(--accent); color: #fff; border-radius: 4px; top: -2px; padding: 4px 14px; }
#tabs button.file:hover { background: var(--accent-2); }

#ribbon { background: var(--panel-2); border-bottom: 1px solid var(--border); display: flex; align-items: stretch; padding: 4px 4px 0; min-height: 94px; overflow-x: auto; overflow-y: hidden; }
.rgroup { display: flex; flex-direction: column; padding: 0 6px; border-right: 1px solid #e5e7eb; flex: none; }
.rgroup .rbody { flex: 1; display: flex; align-items: flex-start; gap: 2px; }
.rgroup .rlabel { text-align: center; color: var(--muted); font-size: 11px; padding: 2px 0 3px; white-space: nowrap; }
.rcol { display: flex; flex-direction: column; gap: 2px; }
.rrow { display: flex; gap: 2px; align-items: center; }
/* a column whose rows end at the same edge (the Font group's name box fills its row) */
.rcol.stretch { align-items: stretch; }
.rcol.stretch > .rrow { justify-content: space-between; }
.rsel.grow { flex: 1 1 auto; min-width: 0; }
.rsep { width: 1px; align-self: stretch; background: #e5e7eb; margin: 2px 6px; }
.rbtn {
  border: 1px solid transparent; background: none; border-radius: 4px; cursor: default; padding: 2px 4px; min-height: 24px;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--text); font-size: 12px;
}
.rbtn:hover:not(:disabled) { background: var(--hover); border-color: #d6dbe3; }
.rbtn.on { background: var(--accent-soft); border-color: #86efac; }
.rbtn:disabled { opacity: .4; }
/* Icons: 16 px on small buttons, 32 px on big ones (as Excel's), outlines the same thickness at both. */
.rbtn .ico { position: relative; width: 16px; height: 16px; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; }
.rbtn .ico svg { width: 16px; height: 16px; display: block; }
.rbtn .ico svg * { vector-effect: non-scaling-stroke; }
.rbtn .lbl { display: inline-flex; align-items: center; gap: 4px; }
/* The chevron of a button that opens a menu. */
.rbtn .chev { width: 9px; height: 6px; flex: none; color: #4b5563; display: inline-block; vertical-align: middle; }
.rbtn.big { flex-direction: column; justify-content: flex-start; min-width: 52px; max-width: 84px; height: 70px; padding: 4px 5px 3px; gap: 3px; font-size: 11.5px; }
.rbtn.big .ico { width: 32px; height: 32px; font-size: 24px; }
.rbtn.big .ico svg { width: 32px; height: 32px; }
.rbtn.big .lbl { display: block; white-space: normal; text-align: center; line-height: 13px; max-height: 26px; overflow: hidden; }
.rbtn.big .lbl .chev { margin-left: 3px; }
.rbtn.big > .chev { margin-top: auto; }
/* A split button's menu half. */
.rbtn.split { padding: 2px 3px; min-width: 0; gap: 0; }
.bigsplit { flex-direction: column; }
.bigsplit > .rbtn.big { height: 39px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.bigsplit > .rbtn.split.big { height: 31px; padding: 0 4px; justify-content: flex-start; border-top-left-radius: 0; border-top-right-radius: 0; }
.rbtn.sq { width: 26px; justify-content: center; padding: 2px; }
.rsel { height: 24px; border: 1px solid var(--border); border-radius: 3px; background: #fff; font: inherit; padding: 0 4px; }
.colorbtn { position: relative; }
.colorbtn .bar { position: absolute; left: 0; right: 0; bottom: -2px; height: 3.5px; border-radius: 1px; }
.ico-b { font-weight: 800; font-family: Georgia, serif; }
.ico-i { font-style: italic; font-family: Georgia, serif; font-weight: 600; }
.ico-u { text-decoration: underline; font-family: Georgia, serif; font-weight: 600; }
.ico-s { text-decoration: line-through; font-family: Georgia, serif; }
.check { display: flex; align-items: center; gap: 5px; padding: 3px 4px; }

/* ---------- formula bar ---------- */
#formulabar { display: flex; align-items: center; gap: 6px; background: var(--panel); padding: 3px 6px; border-bottom: 1px solid var(--border); }
#namebox-wrap { display: inline-flex; align-items: stretch; }
#namebox-dd { width: 18px; height: 23px; margin-left: -1px; border: 1px solid var(--border); border-radius: 0 3px 3px 0; background: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--muted); }
#namebox-dd:hover { background: var(--hover); }
#namebox-dd .chev { width: 9px; height: 6px; }
#namebox { border-radius: 3px 0 0 3px !important; }
#namebox { width: 110px; height: 23px; border: 1px solid var(--border); border-radius: 3px; padding: 0 6px; font: inherit; user-select: text; }
.fx-buttons { display: flex; gap: 2px; padding: 0 4px; border-right: 1px solid var(--border); border-left: 1px solid var(--border); }
.fx-buttons button { width: 24px; height: 23px; border: 0; background: none; border-radius: 3px; cursor: default; color: var(--muted); }
.fx-buttons button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.fx-buttons button:disabled { opacity: .35; }
.fx-buttons i { font-family: Georgia, serif; font-weight: 600; }
#formula { flex: 1; height: 23px; border: 1px solid var(--border); border-radius: 3px; padding: 0 6px; font: 13px/1.2 ui-monospace, Menlo, Consolas, monospace; user-select: text; }
#formula.ghost { color: #9ca3af; }
#formula:focus, #namebox:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- grid ---------- */
#grid-wrap { position: relative; overflow: hidden; background: #fff; }
#grid { position: absolute; inset: 0; width: 100%; height: 100%; }
#scroller { position: absolute; inset: 0; overflow: scroll; }
#spacer { width: 1px; height: 1px; }
#editor {
  position: absolute; left: -9999px; top: 0; width: 40px; height: 20px; z-index: 5; resize: none; overflow: hidden;
  border: 2px solid var(--accent); margin: 0; padding: 1px 3px; outline: none; background: #fff; white-space: pre;
  font: 15px/1.2 Calibri, Carlito, "Segoe UI", system-ui, sans-serif; color: #000; user-select: text;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
#editor.idle { opacity: 0; pointer-events: none; width: 2px; height: 2px; border: 0; box-shadow: none; }
#autocomplete {
  position: absolute; z-index: 20; background: #fff; border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(0,0,0,.18);
  min-width: 220px; max-height: 240px; overflow-y: auto; border-radius: 4px; padding: 2px 0;
}
#autocomplete .ac { padding: 3px 8px; display: flex; gap: 8px; cursor: default; }
#autocomplete .ac b { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; }
#autocomplete .ac span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
#autocomplete .ac.on { background: var(--accent); color: #fff; }
#autocomplete .ac.on span { color: #dcfce7; }
#argtip {
  position: absolute; z-index: 19; background: #fffef0; border: 1px solid #d6d3a8; padding: 3px 7px; border-radius: 3px; white-space: nowrap;
  font-size: 11px; box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
#argtip b { font-weight: 700; }

/* ---------- sheet tabs ---------- */
#sheetbar { display: flex; align-items: stretch; background: var(--panel); border-top: 1px solid var(--border); padding: 0 4px; gap: 2px; }
#sheetbar .nav, #sheet-add { border: 0; background: none; width: 24px; cursor: default; color: var(--muted); font-size: 11px; }
#sheet-add { font-size: 15px; color: var(--accent); }
#sheetbar .nav:hover, #sheet-add:hover { background: var(--hover); }
#sheet-tabs { display: flex; overflow-x: auto; scrollbar-width: none; min-width: 0; }
#sheet-tabs::-webkit-scrollbar { display: none; }
.stab {
  padding: 4px 16px; cursor: default; white-space: nowrap; border-right: 1px solid #dde1e7; display: flex; align-items: center; color: #374151;
}
.stab:hover { background: var(--hover); }
.stab.active { background: #fff; color: var(--accent); font-weight: 600; box-shadow: inset 0 -3px 0 var(--accent); }
.stab input { font: inherit; width: 110px; border: 1px solid var(--accent); padding: 1px 3px; user-select: text; }
.stab.drop-before { box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- status bar ---------- */
#statusbar { display: flex; align-items: center; gap: 8px; background: var(--accent); color: #f0fdf4; padding: 0 10px; font-size: 11.5px; }
#statusbar #status-msg { color: #fef08a; }
#sel-stats { margin-right: 12px; white-space: nowrap; }
.zoom-btn, #zoom-pct { border: 0; background: none; color: inherit; cursor: default; padding: 0 4px; }
.zoom-btn:hover, #zoom-pct:hover { background: rgba(255,255,255,.15); }
#zoom-slider { width: 100px; accent-color: #fff; }

/* ---------- menus and dialogs ---------- */
#menu-layer { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
.menu {
  position: fixed; pointer-events: auto; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 4px 0;
  box-shadow: 0 10px 28px rgba(0,0,0,.2); min-width: 200px; max-height: 80vh; overflow-y: auto;
}
.menu .mi { display: flex; align-items: center; gap: 10px; padding: 5px 14px; cursor: default; white-space: nowrap; }
.menu .mi .mtx { flex: 1; }
.menu .mi .key { margin-left: 14px; }
/* A menu with icons: a 16 px column for them (blank where an item has none), as Excel's. */
.menu.icons .mi { padding-left: 8px; }
.menu.icons .mhead { padding-left: 34px; }
.menu .mic { width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 3px; }
.menu .mic svg { width: 16px; height: 16px; display: block; }
.menu .mic svg * { vector-effect: non-scaling-stroke; }
.menu .mi.checked .mic { background: var(--accent-soft); box-shadow: inset 0 0 0 1px #86efac; }
.menu .mi:hover:not(.disabled) .mic { background: #fff; }
.menu .mi.disabled .mic { opacity: .45; }
.menu .chev-r { width: 6px; height: 10px; flex: none; margin-left: 10px; color: #6b7280; }
.menu .mi:hover:not(.disabled) .chev-r { color: #fff; }
.menu .mi:hover:not(.disabled) { background: var(--accent); color: #fff; }
.menu .mi .key { color: var(--muted); }
.menu .mi:hover .key { color: #dcfce7; }
.menu .mi.disabled { color: #9ca3af; }
.menu .msep { height: 1px; background: var(--border); margin: 4px 0; }
.menu .mhead { padding: 5px 14px 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.menu .swatches { display: grid; grid-template-columns: repeat(10, 18px); gap: 3px; padding: 6px 10px; }
.menu .swatches i { width: 18px; height: 18px; border: 1px solid rgba(0,0,0,.15); cursor: default; display: block; }
.menu .swatches i:hover { outline: 2px solid var(--accent); outline-offset: 1px; }

.backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .28); pointer-events: auto; display: flex; align-items: center; justify-content: center; }
.dialog {
  background: #fff; border-radius: 8px; box-shadow: 0 20px 50px rgba(0,0,0,.3); min-width: 340px; max-width: min(720px, 94vw);
  max-height: 90vh; display: flex; flex-direction: column; user-select: text;
}
.dialog .dhead { padding: 12px 16px 6px; font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.dialog .dbody { padding: 8px 16px; overflow-y: auto; }
.dialog .dfoot { padding: 10px 16px 14px; display: flex; justify-content: flex-end; gap: 8px; }
.dialog button.btn { min-width: 76px; height: 28px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: default; padding: 0 12px; }
.dialog button.btn:hover { background: var(--hover); }
.dialog button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.dialog button.btn.primary:hover { background: var(--accent-2); }
.dialog label { display: block; margin: 6px 0 3px; color: #374151; }
.dialog input[type=text], .dialog input[type=number], .dialog select, .dialog textarea {
  font: inherit; border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; width: 100%;
}
.dialog .row { display: flex; gap: 10px; align-items: center; }
.dialog .row > * { flex: 1; }
.dialog .tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.dialog .tabs button { border: 0; background: none; padding: 6px 12px; cursor: default; border-bottom: 2px solid transparent; }
.dialog .tabs button.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.dialog .list { border: 1px solid var(--border); border-radius: 4px; height: 190px; overflow-y: auto; }
.dialog .list div { padding: 3px 8px; cursor: default; }
.dialog .list div.on { background: var(--accent); color: #fff; }
.dialog .list div:hover:not(.on) { background: var(--hover); }
.dialog .preview { border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; min-height: 30px; background: #fafafa; font-size: 13px; }
.dialog .help { color: var(--muted); margin: 6px 0; line-height: 1.45; }
.dialog .syntax { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; margin-top: 8px; }
.dialog .opts label { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
.dialog .opts input { width: auto; }
.dialog .warn { color: var(--bad); font-weight: 600; }
.dialog .swatches { display: grid; grid-template-columns: repeat(10, 20px); gap: 4px; margin: 6px 0; }
.dialog .swatches i { width: 20px; height: 20px; border: 1px solid rgba(0,0,0,.15); cursor: default; display: block; }
.dialog .swatches i.on { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Start-up splash (laid out as Alekh's) */
#splash { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: var(--bg); transition: opacity .4s ease; }
#splash.done { opacity: 0; pointer-events: none; }
#splash.ready { cursor: pointer; }
#splash.ready #splash-status { color: #e2e8f0; }
.splash-card { position: relative; width: min(760px, 100%); aspect-ratio: 5 / 3; border-radius: 14px; overflow: hidden; background: #03140c; box-shadow: 0 24px 60px rgba(15, 23, 42, .35), 0 2px 8px rgba(15, 23, 42, .2); animation: splash-in .5s ease both; }
.splash-card img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.splash-head { position: absolute; left: 6%; top: 8%; color: #fff; text-shadow: 0 2px 12px rgba(2, 6, 23, .6); }
.splash-title { display: flex; align-items: center; gap: 12px; font: 700 clamp(28px, 6vw, 46px)/1.1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: -.02em; white-space: nowrap; }
.splash-logo { display: inline-block; background: url(logo.svg) center / contain no-repeat; width: clamp(30px, 5.5vw, 46px); height: clamp(30px, 5.5vw, 46px); filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .35)); }
.splash-deva { font-weight: 600; font-size: .62em; color: #bbf7d0; letter-spacing: 0; }
.splash-tag { margin-top: 8px; font: 400 clamp(12px, 2vw, 15px)/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: #cbd5e1; max-width: 26ch; }
.splash-card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 26%; background: linear-gradient(to top, rgba(2, 10, 6, .8), rgba(2, 10, 6, 0)); pointer-events: none; }
.splash-foot { position: absolute; z-index: 1; left: 6%; right: 6%; bottom: 6%; color: #94a3b8; font: 400 12px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
.splash-bar { height: 3px; border-radius: 3px; background: rgba(148, 163, 184, .25); overflow: hidden; margin-bottom: 8px; }
.splash-bar i { display: block; height: 100%; width: 35%; border-radius: 3px; background: linear-gradient(90deg, #22c55e, #a3e635, #facc15, #fb923c); animation: splash-run 1.3s ease-in-out infinite; }
.splash-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#splash.failed .splash-bar { display: none; }
#splash.failed #splash-status { color: #fecaca; }
/* Narrow screens: the name on top, the whole artwork below it, then the progress. */
@media (max-width: 560px) {
  .splash-card { aspect-ratio: auto; display: flex; flex-direction: column; background: #03140c; }
  .splash-card img { position: static; height: auto; order: 1; }
  .splash-head { position: static; order: 0; padding: 22px 20px 16px; }
  .splash-foot { position: static; order: 2; padding: 14px 20px 18px; }
  .splash-card::after { display: none; }
}
@keyframes splash-run { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@keyframes splash-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .splash-bar i, .splash-card { animation: none; } #splash { transition: none; } }

/* ---------- printing ---------- */
.rlab { color: #374151; font-size: 12px; padding: 0 2px; }
#print-area { display: none; }
@media print {
  #app, #menu-layer, #splash, #printview { display: none !important; }
  html, body { overflow: visible; height: auto; background: #fff; }
  #print-area { display: block; }
}
#printview { position: fixed; inset: 0; z-index: 90; display: flex; background: #fff; outline: none; }
#printview .pv-side { width: 300px; flex: none; padding: 14px 22px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 9px; overflow-y: auto; background: #f7f7f8; }
#printview .pv-back { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: #fff; font-size: 17px; cursor: default; }
#printview .pv-back:hover { background: var(--hover); }
#printview h2 { margin: 6px 0 4px; font-size: 26px; font-weight: 400; }
#printview .pv-actions { display: flex; gap: 10px; margin-bottom: 6px; }
#printview .pv-big { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font: inherit; cursor: default; }
#printview .pv-big span { font-size: 24px; }
#printview .pv-big:hover { background: var(--hover); border-color: var(--accent); }
#printview .pv-label { font-weight: 600; font-size: 14px; margin-top: 6px; }
#printview select { height: 32px; border: 1px solid var(--border); border-radius: 4px; background: #fff; font: inherit; padding: 0 6px; }
#printview .pv-pages { display: flex; align-items: center; gap: 6px; }
#printview .pv-pages input { width: 56px; height: 26px; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font: inherit; }
#printview a { color: var(--accent); }
#printview .pv-check { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: #374151; margin-top: 6px; line-height: 1.35; }
#printview .pv-check input { margin-top: 2px; }
#printview .pv-main { flex: 1; display: flex; flex-direction: column; background: #e5e7eb; min-width: 0; }
#printview .pv-paper { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#printview .pv-paper canvas { box-shadow: 0 2px 10px rgba(0,0,0,.25); background: #fff; }
#printview .pv-empty { color: var(--muted); font-size: 15px; }
#printview .pv-nav { height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; }
#printview .pv-nav button { width: 28px; height: 26px; border: 1px solid var(--border); background: #fff; border-radius: 4px; cursor: default; }
#printview .pv-nav button:disabled { opacity: .4; }
#printview .pv-nav input { width: 48px; height: 26px; text-align: center; border: 1px solid var(--border); border-radius: 4px; font: inherit; }

/* filter dropdown */
.filterpanel { width: 260px; max-height: none; overflow: visible; }
.filterpanel .fp-body { padding: 6px 10px 8px; border-top: 1px solid var(--border); margin-top: 4px; }
.filterpanel .fp-search { width: 100%; font: inherit; border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; user-select: text; }
.filterpanel .fp-list { border: 1px solid var(--border); border-radius: 4px; height: 190px; overflow-y: auto; margin: 6px 0; padding: 2px 0; }
.filterpanel .fp-item { display: flex; gap: 6px; align-items: center; padding: 2px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
.filterpanel .fp-item:hover { background: var(--hover); }
.filterpanel .fp-foot { display: flex; justify-content: flex-end; gap: 6px; }
.filterpanel .btn { min-width: 70px; height: 26px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: default; font: inherit; }
.filterpanel .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.filterpanel .btn:disabled { opacity: .5; }

/* conditional formatting rules manager */
.cfmanage { border: 1px solid var(--border); border-radius: 4px; max-height: 300px; overflow-y: auto; margin-top: 6px; }
.cfrow { display: grid; grid-template-columns: 1fr 120px 130px auto; gap: 8px; align-items: center; padding: 5px 8px; border-bottom: 1px solid #eef0f3; }
.cfrow:last-child { border-bottom: 0; }
.cfrow .cfdesc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfrow input.cfrange { font: inherit; border: 1px solid var(--border); border-radius: 4px; padding: 2px 5px; width: 100%; }
.cfrow .cfbtns { display: flex; gap: 3px; }
.cfrow .cfbtns .btn { min-width: 26px !important; height: 24px !important; padding: 0 !important; }

/* comments */
#notes { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.note {
  position: absolute; min-width: 150px; max-width: 260px; background: #ffffe1; border: 1px solid #a3a3a3; box-shadow: 2px 3px 6px rgba(0,0,0,.18);
  padding: 4px 7px; font: 12px/1.35 Tahoma, "Segoe UI", system-ui, sans-serif; color: #111; white-space: pre-wrap; word-wrap: break-word;
}
.note b { font-weight: 700; display: block; }
.note.editing { pointer-events: auto; width: 220px; }
.note textarea { width: 100%; min-height: 70px; border: 0; background: transparent; font: inherit; resize: vertical; outline: none; padding: 0; user-select: text; }

/* data validation input message */
#dvtip {
  position: absolute; z-index: 7; max-width: 240px; background: #fffef0; border: 1px solid #c9c49a; padding: 5px 8px; border-radius: 2px;
  font: 12px/1.35 Tahoma, "Segoe UI", system-ui, sans-serif; color: #222; box-shadow: 1px 2px 5px rgba(0,0,0,.12); pointer-events: none; white-space: pre-wrap;
}
#dvtip b { display: block; margin-bottom: 2px; }

/* PivotTable Fields pane */
#main { display: flex; min-height: 0; min-width: 0; }
#main > #grid-wrap { flex: 1; min-width: 0; }
#side { width: 290px; flex: none; background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
#side .side-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 4px; font-weight: 700; font-size: 13px; }
#side .side-head button { border: 0; background: none; cursor: default; font-size: 13px; color: var(--muted); }
#side .side-sub { padding: 4px 10px; color: var(--muted); font-size: 11.5px; }
#side #pf-search { margin: 2px 10px 4px; font: inherit; border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; user-select: text; }
#pf-list { margin: 0 10px; border: 1px solid var(--border); background: #fff; border-radius: 4px; overflow-y: auto; flex: 1 1 140px; min-height: 90px; }
#pf-list .pf-f { display: flex; align-items: center; gap: 6px; padding: 3px 8px; cursor: grab; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pf-list .pf-f:hover { background: var(--hover); }
.pf-areas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px 10px 10px; flex: 1 1 220px; min-height: 180px; }
.pf-area { display: flex; flex-direction: column; min-height: 0; }
.pf-area .pf-h { font-size: 11.5px; color: #374151; padding: 2px 0 3px; font-weight: 600; }
.pf-box { flex: 1; background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 3px; overflow-y: auto; min-height: 60px; }
.pf-box.drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: #f0fdf4; }
.pf-chip { display: flex; justify-content: space-between; align-items: center; gap: 4px; background: #e8f5ee; border: 1px solid #b7dcc6; border-radius: 3px; padding: 3px 6px; margin: 2px 0; cursor: grab; white-space: nowrap; overflow: hidden; }
.pf-chip span { overflow: hidden; text-overflow: ellipsis; }
.pf-chip i { font-style: normal; color: var(--muted); font-size: 10px; }

/* comment threads */
.tcard {
  position: absolute; z-index: 8; width: 290px; background: #fff; border: 1px solid #d4d4d8; border-radius: 8px; padding: 8px 10px 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); pointer-events: auto; font: 12.5px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: #111; user-select: text;
}
.tcard .tc-bar { display: flex; justify-content: flex-end; align-items: center; gap: 6px; min-height: 18px; margin-bottom: 2px; }
.tcard .tc-icon, .tcard .tc-more { border: 0; background: none; cursor: default; color: #6b7280; font-size: 13px; padding: 2px 5px; border-radius: 4px; }
.tcard .tc-icon:hover, .tcard .tc-more:hover { background: #f3f4f6; color: #111; }
.tcard .tc-resolved { color: #059669; font-weight: 600; margin-right: auto; }
.tcard .tc-item { padding: 6px 0; border-bottom: 1px solid #f1f1f3; }
.tcard .tc-item:last-of-type { border-bottom: 0; }
.tcard .tc-head { display: flex; align-items: center; gap: 8px; }
.tcard .tc-head > div { flex: 1; min-width: 0; }
.tcard .tc-av { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tcard .tc-time, #side .tc-time { color: #6b7280; font-size: 11px; }
.tcard .tc-text { margin: 4px 0 0 34px; white-space: pre-wrap; word-wrap: break-word; }
.tcard textarea { width: 100%; min-height: 54px; margin-top: 6px; font: inherit; border: 1px solid #d4d4d8; border-radius: 6px; padding: 6px 8px; resize: vertical; outline: none; }
.tcard textarea:focus { border-color: #7c3aed; box-shadow: 0 0 0 2px #ede9fe; }
.tcard .tc-btns { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.tcard .btn { height: 26px; min-width: 60px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: default; font: inherit; }
.tcard .btn.primary { background: #7c3aed; border-color: #7c3aed; color: #fff; }
#side .cp-list { overflow-y: auto; flex: 1; padding: 0 10px 10px; }
#side .cp-thread { background: #fff; border: 1px solid var(--border); border-left: 3px solid #7c3aed; border-radius: 6px; padding: 7px 9px; margin: 6px 0; cursor: default; }
#side .cp-thread.done { border-left-color: #9ca3af; opacity: .8; }
#side .cp-thread:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
#side .cp-cell { font-weight: 700; color: #7c3aed; font-size: 11.5px; margin-bottom: 3px; }
#side .cp-reply { margin: 6px 0 0 10px; padding-left: 8px; border-left: 2px solid #e5e7eb; }
#side .btn { height: 24px; border: 1px solid var(--border); background: #fff; border-radius: 4px; cursor: default; font: inherit; }

/* message bar under the formula bar (Excel's yellow bar) */
#msgbar { display: flex; align-items: center; gap: 10px; padding: 5px 12px; background: #fff8db; border-bottom: 1px solid #ecd98c; font-size: 12.5px; }
/* (kept in the grid when hidden, so the rows below keep their places) */
#msgbar.off { height: 0; padding: 0; border: 0; overflow: hidden; }
#msgbar b { font-weight: 600; }
#msgbar button { white-space: nowrap; height: 24px; border: 1px solid #c9b45b; background: #fff; border-radius: 4px; padding: 0 10px; cursor: default; font: inherit; }
#msgbar button:hover { background: #fffdf0; }
#msgbar .x { border: 0; background: none; margin-left: auto; font-size: 15px; color: #6b7280; }
.dialog .kruti textarea { font-size: 16px; min-height: 96px; }

/* phonetic typing badge in the status bar */
#phon-badge { white-space: nowrap; flex: none; height: 18px; border: 1px solid rgba(255,255,255,.55); background: rgba(255,255,255,.14); color: inherit; border-radius: 9px; padding: 0 9px; font: inherit; font-size: 11.5px; cursor: default; }
#phon-badge:hover { background: rgba(255,255,255,.26); }
.dialog .phon-help { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; max-width: 600px; line-height: 1.5; }
.dialog .phon-help b { font-weight: 600; }

/* Insert ▸ Shapes gallery, and writing in a shape */
.shape-menu { max-height: 70vh; overflow-y: auto; }
.shape-gallery { padding: 4px 10px 8px; width: 300px; }
.shape-gallery .sg-head { font-size: 11px; font-weight: 600; color: var(--muted); margin: 8px 0 3px; }
.shape-gallery .sg-grid { display: grid; grid-template-columns: repeat(10, 26px); gap: 2px; }
.shape-gallery button { width: 26px; height: 26px; border: 1px solid transparent; background: none; border-radius: 3px; padding: 2px; cursor: default; }
.shape-gallery button:hover { border-color: var(--accent); background: var(--hover); }
textarea.shape-edit { position: absolute; z-index: 9; background: transparent; border: 1px dashed #1d7a4c; outline: none; resize: none; text-align: center; overflow: hidden; line-height: 1.2; }

/* Page Layout view: pages drawn on a canvas, with a scroll layer over it */
#layoutview { display: none; position: absolute; inset: 0; z-index: 4; }
#layoutview.on { display: block; }
#layoutview .lv-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#layoutview .lv-scroll { position: absolute; inset: 0; overflow: auto; }
#layoutview .lv-spacer { pointer-events: none; }
.lv-hf { position: absolute; z-index: 6; display: flex; gap: 6px; }
.lv-hf input { flex: 1; min-width: 0; height: 26px; border: 1px solid #1d7a4c; border-radius: 3px; padding: 0 6px; font: 14px Calibri, Carlito, "Segoe UI", sans-serif; background: #fff; }
#statusbar .view-btn { height: 18px; min-width: 22px; border: 0; background: none; color: inherit; border-radius: 3px; cursor: default; font-size: 13px; padding: 0 3px; }
#statusbar .view-btn:hover { background: rgba(255,255,255,.18); }
#statusbar .view-btn.on { background: rgba(255,255,255,.3); }

/* the date tree in a filter dropdown */
.filterpanel .fp-tree { display: flex; align-items: center; gap: 2px; }
.filterpanel .fp-tree label { display: flex; align-items: center; gap: 6px; flex: 1; }
.filterpanel .fp-tw { width: 14px; text-align: center; color: #6b7280; cursor: default; font-size: 10px; }
/* Sort dialog levels */
.dialog .slevels { border: 1px solid var(--border); border-radius: 4px; min-height: 110px; max-height: 230px; overflow-y: auto; margin-bottom: 6px; }
.dialog .row.slv, .dialog .row.slh { display: grid; grid-template-columns: 58px 1fr 112px 1.25fr; gap: 6px; align-items: center; padding: 4px 6px; margin: 0; }
.dialog .row.slh { color: var(--muted); font-size: 12px; padding-bottom: 2px; }
.dialog .row.slv.on { background: #e6f2eb; }
.dialog .slv select { width: 100%; min-width: 0; }
.dialog .sord { display: flex; gap: 6px; min-width: 0; }
.dialog .sord select { flex: 1; }
.dialog button.btn.sclr { min-width: 0; padding: 0 6px; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.dialog .sclr i { font-style: normal; color: var(--muted); font-size: 10px; }
.sw { display: inline-block; width: 16px; height: 14px; border: 1px solid rgba(0,0,0,.25); }
.sw.none { background: linear-gradient(to top right, #fff calc(50% - 1px), #d33 50%, #fff calc(50% + 1px)); }
.dialog .row.sbar > * { flex: none; }
/* Combo dialog rows */
.dialog .row.cmb { display: grid; grid-template-columns: 1fr 170px 130px; gap: 8px; align-items: center; margin: 3px 0; }
.dialog .row.cmb > * { flex: none; min-width: 0; }
.dialog .row.cmb-h { color: var(--muted); font-size: 12px; }
.dialog .cmb-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog .row.cmb label { display: flex; gap: 5px; align-items: center; margin: 0; }

/* ---------- Help ▸ Keyboard Shortcuts and About (laid out as Alekh's) ---------- */
.dialog.keys-modal { width: min(720px, calc(100vw - 32px)); max-width: none; }
.keys-modal .keys-search { width: 100%; padding: 6px 8px; font: inherit; border: 1px solid var(--border); border-radius: 5px; }
.keys-body { max-height: min(60vh, 520px); overflow-y: auto; margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 4px 28px; align-items: start; }
.keys-group { margin-bottom: 10px; }
.keys-group h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.keys-row { display: grid; grid-template-columns: minmax(118px, auto) 1fr; gap: 10px; padding: 3px 0; align-items: baseline; }
.keys-row kbd { justify-self: start; font: 600 12px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--panel); white-space: nowrap; }

.dialog.about-modal { width: min(640px, calc(100vw - 32px)); max-width: none; padding: 0; overflow: hidden; max-height: calc(100vh - 32px); }
.about-hero { position: relative; display: flex; align-items: center; gap: 16px; padding: 30px 24px 26px; color: #fff; background: #062417 url(about-art.svg) 70% 45% / cover; }
.about-logo { width: 64px; height: 64px; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .4)); }
.about-name { font: 700 30px/1.1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: -.02em; }
.about-deva { font-weight: 600; font-size: 22px; color: #bbf7d0; margin-left: 6px; letter-spacing: 0; }
.about-version { margin-top: 4px; font-size: 12px; color: #cbd5e1; }
.about-x { position: absolute; top: 10px; right: 12px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.about-x:hover { background: rgba(255, 255, 255, .26); }
.about-body { padding: 18px 24px 6px; overflow: auto; font-size: 13px; line-height: 1.5; }
.about-body p { margin: 0 0 10px; }
.about-lead { font-size: 14px; font-weight: 600; }
.about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 14px 0; }
.about-feature { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); }
.about-feature b { font-size: 12.5px; }
.about-feature span { color: var(--muted); font-size: 12px; }
.about-feature span b { font-size: 12px; color: var(--text); }
.about-section { margin: 4px 0 10px; }
.about-section h4 { margin: 0 0 4px; font-size: 12.5px; }
.about-section p { margin: 0; color: var(--muted); font-size: 12px; }
.about-credits { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.about-credits summary { cursor: pointer; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.about-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px 16px; border-top: 1px solid var(--border); }
.about-btns { display: flex; gap: 8px; }
@media (max-width: 560px) { .about-grid { grid-template-columns: 1fr; } .about-name { font-size: 24px; } }
/* File ▸ New from Template */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; width: min(640px, 86vw); }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; font: inherit; color: var(--text); }
.tpl:hover { border-color: var(--accent); background: #f6fbf8; }
.tpl svg { width: 32px; height: 32px; }
.tpl svg * { vector-effect: non-scaling-stroke; }
.tpl b { font-size: 13px; }
.tpl span { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* tables: the style gallery */
.tstyle-gallery { padding: 4px 10px 8px; width: 330px; }
.tstyle-gallery .sg-head { font-size: 11px; font-weight: 600; color: var(--muted); margin: 8px 0 3px; }
.tstyle-gallery .sg-grid { display: grid; grid-template-columns: repeat(7, 42px); gap: 4px; }
.tstyle-gallery button { width: 42px; height: 34px; border: 1px solid transparent; background: none; border-radius: 3px; padding: 2px; cursor: default; }
.tstyle-gallery button:hover, .tstyle-gallery button.on { border-color: var(--accent); background: var(--hover); }
.tstyle-gallery .ts { display: grid; grid-template-rows: repeat(5, 1fr); width: 100%; height: 100%; border: 1px solid #d1d5db; }
.tstyle-gallery .ts i { display: block; border-bottom: 1px solid transparent; }
.rinput { height: 22px; border: 1px solid var(--border); border-radius: 3px; padding: 0 5px; font: inherit; font-size: 12px; }
.names-list { border: 1px solid var(--border); height: 220px; overflow: auto; margin: 8px 0; }
.names-list table { border-collapse: collapse; width: 100%; font-size: 12px; }
.names-list th { position: sticky; top: 0; background: #f3f4f6; text-align: left; font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.names-list td { padding: 3px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.names-list tr.on td { background: var(--hover); }
.names-list tr[data-i] { cursor: default; }
.names-form { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; min-width: 380px; }
.names-form input, .names-form select { height: 24px; border: 1px solid var(--border); border-radius: 3px; padding: 0 6px; font: inherit; }
.names-list .ic { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
/* Paste Special, Text to Columns */
.ps-grid fieldset, .tc fieldset { border: 1px solid var(--border); border-radius: 4px; margin: 0 0 8px; padding: 4px 10px 6px; }
.ps-grid legend, .tc legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.ps-two { display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: column; gap: 0 18px; }
.tc-preview { border: 1px solid var(--border); max-height: 200px; overflow: auto; }
.tc-preview table { border-collapse: collapse; font-size: 12px; }
.tc-preview th { position: sticky; top: 0; background: #f3f4f6; padding: 3px; border-right: 1px solid var(--border); }
.tc-preview th select { font: inherit; font-size: 11px; }
.tc-preview td { padding: 2px 6px; border-right: 1px solid #e5e7eb; white-space: pre; }
.tc-preview td.skip { color: #9ca3af; background: #f9fafb; text-decoration: line-through; }
.tc-ruler { font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace; white-space: pre; overflow: auto; max-height: 140px; border: 1px solid var(--border); padding: 4px; cursor: text; }
.tc-ruler div:first-child { color: #9ca3af; }
.tc-ruler span.brk { box-shadow: inset 2px 0 0 var(--accent); }

/* Scenario Manager */
.sm-item { padding: 3px 8px; cursor: default; }
.sm-item.on { background: var(--hover); font-weight: 600; }

/* Watch Window */
#watch-win { position: fixed; right: 24px; bottom: 48px; width: 520px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 40; font-size: 12px; display: flex; flex-direction: column; }
#watch-win .ww-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; font-weight: 600; border-bottom: 1px solid var(--border); cursor: move; user-select: none; }
#watch-win .ww-x { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 13px; }
#watch-win .ww-tools { display: flex; gap: 6px; padding: 6px 10px; }
#watch-win .ww-tools .btn { display: inline-flex; align-items: center; gap: 4px; }
#watch-win .ww-tools .ic { width: 14px; height: 14px; }
#watch-win .ww-body { max-height: 200px; overflow: auto; border-top: 1px solid var(--border); }
#watch-win table { border-collapse: collapse; width: 100%; }
#watch-win th { position: sticky; top: 0; background: #f3f4f6; text-align: left; font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--border); }
#watch-win td { padding: 3px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
#watch-win td.num { text-align: right; }
#watch-win tr.on td { background: var(--hover); }
#watch-win .ww-empty { color: var(--muted); padding: 12px 8px; white-space: normal; }

/* ribbon alignment: a label's last word with its ▾; checkbox and label rows as tall as a select */
.rbtn .lbl .nw { white-space: nowrap; }
.rcol > .check, .rcol > .rlab { min-height: 24px; display: flex; align-items: center; }
