/* =========================================================================
 * NexaSheet — Gaya (style.css)
 * Tema "Excel 2016" — putih & hijau #217346 persis tangkapan layar Excel:
 * bilah judul hijau, ribbon bergrup dengan ikon SVG, galeri gaya sel,
 * grid putih dengan garis abu-abu & seleksi hijau.
 * Tema gelap & terang tetap tersedia lewat variabel CSS.
 * ========================================================================= */
:root {
  /* ---------- Palet inti ala Excel ---------- */
  --brand: #217346;          /* hijau Excel */
  --brand-dark: #1e6b40;
  --brand-light: #2e9e5f;
  --title-bg: #217346;
  --title-bg2: #1e6b40;
  --title-fg: #ffffff;
  --title-input: rgba(255, 255, 255, 0.16);
  --title-input-focus: rgba(255, 255, 255, 0.26);
  --tabs-bg: #ffffff;
  --tabs-fg: #444444;
  --ribbon-bg: #f5f6f6;
  --ribbon-sep: #e1e1e1;
  --ribbon-label: #7f7f7f;
  --btn-hover: #e3efe7;
  --btn-hover-bd: #ccd9cf;
  --btn-active: #d2e5d8;
  --fx-bg: #ffffff;
  --fx-border: #d4d4d4;
  --namebox-bd: #c6c6c6;
  --sheetbar-bg: #f5f6f6;
  --status-bg: #f5f6f6;
  --status-fg: #44546a;
  /* ---------- Grid ---------- */
  --bg: #eef1f4;
  --bg2: #ffffff;
  --panel: #ffffff;
  --panel2: #f3f6f4;
  --border: #d8dee5;
  --border2: #c3ccd6;
  --text: #262626;
  --text2: #4d5b6b;
  --text3: #8fa0b3;
  --accent: #217346;
  --accent2: #0e7490;
  --accent3: #3d7a5c;
  --danger: #d64550;
  --warn: #b7791f;
  --sel: rgba(33, 115, 70, 0.08);
  --selHdr: rgba(33, 115, 70, 0.14);
  --selBorder: #217346;
  --gridline: #d6d6d6;
  --hdrbg: #f5f5f5;
  --hdrhover: #e9e9e9;
  --hdrtext: #44546a;
  --hdrborder: #d4d4d4;
  --glow: 0 0 0 1px rgba(33, 115, 70, 0.10);
  --activeGlow: none;
  --hdrH: 26px;
  --hdrW: 46px;
  /* ---------- Popup & dialog ---------- */
  --menu-bg: #ffffff;
  --menu-bd: #d4d4d4;
  --menu-hover: #e8f1ec;
  --menu-shadow: 0 8px 26px rgba(60, 75, 70, 0.22);
  --modal-bg: #ffffff;
  --shadow-soft: 0 4px 18px rgba(31, 45, 58, 0.16);
  --shadow-pop: 0 16px 44px rgba(31, 45, 58, 0.24);
}
[data-theme="light"] {
  --title-bg: #3d4752;
  --title-bg2: #333c46;
  --tabs-bg: #f7f8f9;
  --ribbon-bg: #eef0f2;
  --btn-hover: #dfe4e9;
  --btn-hover-bd: #ccd3da;
  --btn-active: #cfd8df;
  --sheetbar-bg: #eef0f2;
  --status-bg: #eef0f2;
  --accent: #0d5c38;
}
[data-theme="dark"] {
  --title-bg: #0d2018;
  --title-bg2: #0a1a13;
  --title-input: rgba(255, 255, 255, 0.10);
  --title-input-focus: rgba(255, 255, 255, 0.18);
  --tabs-bg: #0f1622;
  --tabs-fg: #9fb0c0;
  --ribbon-bg: #131c2e;
  --ribbon-sep: #26344d;
  --ribbon-label: #7d8ea3;
  --btn-hover: #1d2a3f;
  --btn-hover-bd: #2c3d58;
  --btn-active: #24344e;
  --fx-bg: #101828;
  --fx-border: #26344d;
  --namebox-bd: #2c3d58;
  --sheetbar-bg: #101828;
  --status-bg: #0f1622;
  --status-fg: #94a3b8;
  --bg: #0a0e17;
  --bg2: #0d1420;
  --panel: #101828;
  --panel2: #131c2e;
  --border: #1e2a3f;
  --border2: #26344d;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --sel: rgba(52, 211, 153, 0.14);
  --selHdr: rgba(52, 211, 153, 0.14);
  --selBorder: #34d399;
  --gridline: #1a2436;
  --hdrbg: #0e1522;
  --hdrhover: #16223a;
  --hdrtext: #7dd3fc;
  --hdrborder: #26344d;
  --menu-bg: #131c2e;
  --menu-bd: #26344d;
  --menu-hover: rgba(52, 211, 153, 0.12);
  --menu-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
  --modal-bg: #101828;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 16px 44px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', Calibri, 'Noto Sans', Roboto, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  user-select: none;
}
#nx-app { display: flex; flex-direction: column; height: 100vh; }
.spacer { flex: 1; }

/* =================== Bilah judul hijau (ala Excel) ====================== */
.nx-titlebar {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 8px;
  background: linear-gradient(90deg, var(--title-bg2), var(--title-bg) 220px);
  color: var(--title-fg);
  flex: none;
}
.nx-qat { display: flex; align-items: center; gap: 1px; }
.nx-qatbtn {
  width: 28px; height: 26px;
  background: transparent; border: none; color: var(--title-fg);
  cursor: pointer; border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.nx-qatbtn:hover { background: rgba(255, 255, 255, 0.18); }
.nx-qatbtn:disabled { opacity: 0.45; cursor: default; background: transparent; }
.nx-qatbtn svg { display: block; }
.nx-wbname {
  font-size: 12.5px; color: var(--title-fg); cursor: pointer;
  padding: 3px 8px; border-radius: 3px; font-weight: 400;
  white-space: nowrap;
}
.nx-wbname:hover { background: rgba(255, 255, 255, 0.14); }
.nx-dirty { font-size: 11px; color: #ffd98a; min-width: 80px; white-space: nowrap; }
.nx-searchwrap {
  display: flex; align-items: center; gap: 6px;
  background: var(--title-input);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px; height: 24px; padding: 0 10px;
  width: 300px; transition: background .15s, width .2s;
}
.nx-searchwrap:focus-within { background: var(--title-input-focus); width: 360px; }
.nx-searchico { display: inline-flex; align-items: center; opacity: 0.9; }
.nx-searchwrap input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--title-fg); font-size: 12px; font-family: inherit;
}
.nx-searchwrap input::placeholder { color: rgba(255, 255, 255, 0.75); }
.nx-modebadge {
  font-size: 10.5px; padding: 2px 9px; border-radius: 999px;
  color: rgba(255, 255, 255, 0.85); border: 1px solid rgba(255, 255, 255, 0.25);
  white-space: nowrap;
}
.nx-modebadge.srv { color: #ffffff; background: rgba(255, 255, 255, 0.14); }
.nx-modebadge.loc { color: #ffe9a8; border-color: rgba(255, 233, 168, 0.4); }
.nx-iconbtn {
  background: transparent; border: 1px solid transparent; color: var(--text2);
  width: 30px; height: 24px; border-radius: 3px; cursor: pointer; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.nx-iconbtn:hover { background: var(--btn-hover); color: var(--text); }
.nx-iconbtn:disabled { opacity: 0.35; cursor: default; }

/* ============================== Ribbon ================================== */
.nx-ribbon { flex: none; background: var(--ribbon-bg); border-bottom: 1px solid var(--fx-border); }
.nx-ribbon-tabsrow {
  display: flex; align-items: flex-end; gap: 2px; height: 30px;
  background: var(--tabs-bg); padding: 0 4px;
}
.nx-filetab {
  background: var(--brand); color: #ffffff; border: none; cursor: pointer;
  font-size: 12.5px; font-family: inherit;
  height: 30px; padding: 0 18px; margin-right: 6px;
  transition: background .12s;
}
.nx-filetab:hover { background: var(--brand-dark); }
.nx-ribbon-tabs { display: flex; gap: 2px; align-items: stretch; height: 100%; }
.nx-rtab {
  background: transparent; border: none; color: var(--tabs-fg);
  padding: 0 14px; cursor: pointer; font-size: 12.5px; font-family: inherit;
  position: relative; transition: color .12s, background .12s;
  border-bottom: 2px solid transparent;
}
.nx-rtab:hover { color: var(--text); background: var(--btn-hover); }
.nx-rtab.on { color: var(--text); font-weight: 700; border-bottom-color: var(--brand); }
.nx-sharebtn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--brand); color: #ffffff; border: none; cursor: pointer;
  font-size: 12px; font-family: inherit;
  height: 22px; padding: 0 14px; border-radius: 11px; margin-bottom: 6px;
  transition: background .12s;
}
.nx-sharebtn:hover { background: var(--brand-dark); }
.nx-sharebtn .nx-caret { font-size: 9px; opacity: 0.85; }
.nx-sharebtn svg { display: block; }

.nx-ribbon-body { display: flex; padding: 5px 8px 6px; gap: 0; overflow-x: auto; min-height: 88px; }
.nx-rgroup-wrap { display: flex; gap: 0; }
.nx-rgroup {
  display: flex; flex-direction: column; justify-content: space-between; gap: 2px;
  padding: 0 10px; border-right: 1px solid var(--ribbon-sep); min-width: 60px;
}
.nx-rgroup:last-child { border-right: none; }
.nx-rbtns { display: flex; gap: 3px; align-items: flex-start; flex-wrap: wrap; }
.nx-rstack { display: flex; flex-direction: column; gap: 2px; }
.nx-rrow { display: flex; gap: 2px; align-items: center; }
.nx-rlabel { font-size: 10px; color: var(--ribbon-label); text-align: center; letter-spacing: 0.2px; }
.nx-rbtn {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 1px solid transparent; color: var(--text);
  padding: 3px 7px; border-radius: 3px; cursor: pointer; font-size: 12px; font-family: inherit;
  transition: background .1s, border-color .1s; min-height: 24px;
}
.nx-rbtn:hover { background: var(--btn-hover); border-color: var(--btn-hover-bd); }
.nx-rbtn:active { background: var(--btn-active); }
.nx-rbtn .ico { font-size: 14px; color: var(--text); min-width: 16px; text-align: center; line-height: 1; }
.nx-rbtn .ico svg { display: block; margin: 0 auto; }
.nx-rbtn .lbl { line-height: 1.1; }
.nx-rbtn .caret { font-size: 8px; color: var(--text3); margin-left: 1px; }
.nx-rbtn .swatch { font-size: 14px; }
/* tombol besar: ikon di atas, label di bawah (ala Excel Paste) */
.nx-rbtn.big { flex-direction: column; gap: 3px; min-width: 56px; padding: 5px 8px; }
.nx-rbtn.big .ico { font-size: 18px; }
.nx-rbtn.big .ico svg { width: 24px; height: 24px; }
.nx-rbtn.on, .nx-rbtn.toggled { background: var(--btn-active); border-color: var(--btn-hover-bd); }
.nx-select {
  background: var(--bg2); color: var(--text); border: 1px solid var(--namebox-bd);
  border-radius: 2px; padding: 3px 5px; font-size: 12px; outline: none; cursor: pointer;
  font-family: inherit; height: 24px;
}
.nx-select:focus { border-color: var(--brand); }
.nx-select.fontsel { width: 118px; }
.nx-select.sizsel { width: 50px; }
.nx-select.fmtsel { width: 150px; }

/* ============================ Formula bar =============================== */
.nx-fxbar {
  display: flex; align-items: center; gap: 0;
  padding: 3px 8px; background: var(--fx-bg); border-bottom: 1px solid var(--fx-border); flex: none;
}
#nx-namebox {
  width: 96px; height: 24px; background: var(--bg2); border: 1px solid var(--namebox-bd); color: var(--text);
  padding: 0 8px; border-radius: 2px; font-size: 12px; text-align: left; outline: none;
  font-family: inherit; flex: none;
}
#nx-namebox:focus { border-color: var(--brand); }
.nx-fxbtn {
  width: 22px; height: 22px; margin-left: 4px;
  background: transparent; border: none; border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text3);
  transition: background .1s, color .1s;
}
.nx-fxbtn:hover { background: var(--btn-hover); }
.nx-fxbtn.ok { color: var(--brand); }
.nx-fxbtn.cancel { color: #c43232; }
.nx-fxbtn svg { display: block; }
.nx-fxsep {
  color: var(--text3); font-style: italic; font-weight: 700; font-size: 13px;
  margin: 0 6px 0 8px; cursor: pointer; padding: 2px 4px; border-radius: 3px;
}
.nx-fxsep:hover { background: var(--btn-hover); color: var(--brand); }
#nx-formulabar {
  flex: 1; background: transparent; border: none; outline: none; color: var(--text);
  font-family: inherit; font-size: 13px; padding: 3px 6px;
}

/* ================================ Grid ================================== */
.nx-grid {
  flex: 1; display: grid; grid-template-columns: var(--hdrW) minmax(0, 1fr); grid-template-rows: var(--hdrH) minmax(0, 1fr);
  position: relative; background: var(--bg2); min-height: 0;
}
.nx-corner {
  grid-row: 1; grid-column: 1;
  background: var(--hdrbg); border-right: 1px solid var(--hdrborder); border-bottom: 1px solid var(--hdrborder);
  cursor: pointer; z-index: 12;
  position: relative;
}
.nx-corner::after {
  content: ''; position: absolute; right: 7px; bottom: 7px;
  border: 4px solid transparent; border-top-color: #b3b3b3; border-left-color: #b3b3b3;
  opacity: 0.9;
}
.nx-corner:hover::after { border-top-color: var(--brand); border-left-color: var(--brand); }
.nx-colhead {
  grid-row: 1; grid-column: 2; overflow: hidden; position: relative;
  background: var(--hdrbg); border-bottom: 1px solid var(--hdrborder); z-index: 11;
}
.nx-rowhead {
  grid-row: 2; grid-column: 1; overflow: hidden; position: relative;
  background: var(--hdrbg); border-right: 1px solid var(--hdrborder); z-index: 11;
}
.nx-colhead-inner, .nx-rowhead-inner { position: relative; }
.nx-hcell {
  position: absolute; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--hdrtext); background: var(--hdrbg);
  border-right: 1px solid var(--hdrborder); border-bottom: 1px solid var(--hdrborder);
  cursor: pointer; transition: background .1s;
  font-variant-numeric: tabular-nums;
}
.nx-hcell:hover { background: var(--hdrhover); }
.nx-hcell.sel { background: var(--selHdr); color: var(--accent); font-weight: 600; }
.nx-hcell.sel.nx-hcol { border-bottom: 2px solid var(--selBorder); }
.nx-hcell.sel.nx-hrow { border-right: 2px solid var(--selBorder); }
.nx-hcell.active-col, .nx-hcell.active-row { color: var(--accent); font-weight: 700; }
.nx-hcell.frozen { box-shadow: -1px 0 0 var(--selBorder) inset, 0 -1px 0 var(--selBorder) inset; opacity: 0.96; }
.nx-hcell.in-filter::after {
  content: '▽'; position: absolute; right: 3px; top: 1px; font-size: 8px; color: var(--accent2);
}
.nx-hcell.filtered::after { color: var(--warn); }
.nx-hcell.hidden-hint { color: var(--text3); font-style: italic; }
.nx-viewport {
  grid-row: 2; grid-column: 2; overflow: auto; position: relative; outline: none;
  scrollbar-width: thin; scrollbar-color: #c1c1c1 transparent;
}
.nx-viewport::-webkit-scrollbar { width: 14px; height: 14px; }
.nx-viewport::-webkit-scrollbar-track { background: var(--bg2); }
.nx-viewport::-webkit-scrollbar-thumb { background: #c1c1c1; border: 3px solid var(--bg2); border-radius: 8px; }
.nx-viewport::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }
.nx-canvas { position: relative; }
html.no-gridlines .nx-cell { background-image: none !important; }
html.no-headers .nx-corner, html.no-headers .nx-colhead, html.no-headers .nx-rowhead { display: none; }
html.no-gridlines .nx-viewport, html.no-gridlines .nx-canvas { background-image: none !important; }

.nx-celllayer { position: absolute; inset: 0; }
.nx-cell {
  position: absolute; display: flex; padding: 0;
  font-size: 12px; line-height: 1.2;
  background-clip: padding-box;
  border-top: 1px solid var(--gridline); border-left: 1px solid var(--gridline);
  overflow: visible;
}
html.no-gridlines .nx-cell { border-color: transparent; }
.nx-cell-txt {
  display: flex; width: 100%; overflow: hidden;
  padding: 0 4px; pointer-events: none;
  font-variant-numeric: tabular-nums;
  white-space: pre;
}
.nx-cell.has-comment::after {
  content: ''; position: absolute; top: 0; right: 0;
  border-top: 7px solid var(--warn); border-left: 7px solid transparent;
  opacity: 0.9;
}
.nx-cell.has-link .nx-cell-txt { text-decoration: underline; color: #0563c1; }
.nx-cell.num-overflow .nx-cell-txt { letter-spacing: 1px; }
.nx-cfbar {
  position: absolute; left: 1px; bottom: 1px; height: calc(100% - 4px);
  border-radius: 1px; z-index: 0; opacity: 0.55; pointer-events: none;
}
.nx-cell-txt { position: relative; z-index: 1; }

/* ------------------------------ Overlay seleksi ------------------------- */
.nx-ov { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.ov-main { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.nx-selbox {
  position: absolute; border: 1px solid rgba(33, 115, 70, 0.45); background: var(--sel);
}
.nx-selbox-extra { border-style: dashed; }
.nx-activebox {
  position: absolute; border: 2px solid var(--selBorder);
  border-radius: 0;
}
.nx-fillhandle {
  position: absolute; width: 7px; height: 7px;
  background: var(--selBorder); border: 1px solid #ffffff;
  outline: 1px solid var(--selBorder);
  border-radius: 0; z-index: 8; cursor: crosshair;
}
.nx-fillpreview { position: absolute; border: 1.6px dashed var(--selBorder); background: var(--sel); pointer-events: none; z-index: 7; }
.nx-filltip {
  position: absolute; z-index: 30; background: var(--menu-bg); color: var(--brand);
  border: 1px solid var(--menu-bd); padding: 3px 9px; font-size: 11px;
  pointer-events: none; box-shadow: var(--shadow-soft);
}
.nx-marquee {
  position: absolute; pointer-events: none; z-index: 9;
  border: 1.5px dashed var(--selBorder);
  animation: marquee 0.6s linear infinite;
}
@keyframes marquee { to { border-style: dashed; filter: brightness(1.6); } }
/* marching ants untuk rentang rumus terpilih */
.nx-refants {
  position: absolute; pointer-events: none; z-index: 9;
  border: 1.8px dashed var(--accent2);
  animation: ants 0.5s linear infinite;
}
@keyframes ants { to { filter: brightness(1.55); } }
/* bayangan posisi tujuan saat menyeret tepi seleksi */
.nx-moveghost {
  position: absolute; pointer-events: none; z-index: 9;
  border: 1.6px dashed var(--selBorder); background: var(--sel);
  box-shadow: var(--shadow-soft);
}
/* garis bantu saat menggeser lebar kolom */
.nx-resizeline {
  position: absolute; top: 0; bottom: 0; width: 0;
  border-left: 2px solid var(--selBorder); z-index: 50; pointer-events: none;
}
/* frozen panes */
.nx-fr { position: absolute; top: 0; left: 0; z-index: 10; overflow: hidden; background: var(--bg2); }
.fr-top { box-shadow: 0 1px 0 var(--hdrborder); }
.fr-left { box-shadow: 1px 0 0 var(--hdrborder); }
.fr-corner { box-shadow: 1px 1px 0 var(--hdrborder); z-index: 11; }
.nx-fr .nx-celllayer { position: absolute; inset: 0; }

/* ------------------------------- Editor sel ----------------------------- */
.nx-editor-wrap { position: absolute; z-index: 40; }
.nx-editor {
  position: absolute; resize: none; outline: none;
  background: var(--bg2); color: var(--text);
  border: 2px solid var(--selBorder); border-radius: 0;
  font-size: 12px; padding: 0 4px; line-height: 1.3;
  box-shadow: 0 6px 20px rgba(31, 45, 58, 0.28);
  white-space: pre; overflow: hidden;
}
.nx-autoc {
  position: absolute; z-index: 41; min-width: 240px; max-width: 340px;
  background: var(--menu-bg); border: 1px solid var(--menu-bd); border-radius: 0;
  box-shadow: var(--menu-shadow); overflow: hidden;
}
.nx-autoc-item {
  display: grid; grid-template-columns: auto auto 1fr; gap: 6px; align-items: baseline;
  padding: 5px 10px; cursor: pointer; font-size: 12px; border-bottom: 1px solid var(--border);
}
.nx-autoc-item:last-child { border-bottom: none; }
.nx-autoc-item:hover, .nx-autoc-item.on { background: var(--menu-hover); }
.nx-autoc-item b { color: var(--brand); font-family: Consolas, monospace; }
.nx-autoc-item .cat { font-size: 10px; color: var(--text3); }
.nx-autoc-item .desc { font-size: 11px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nx-validbtn {
  position: absolute; z-index: 42; width: 18px;
  background: var(--brand); color: #ffffff; border: none; border-radius: 0 3px 3px 0;
  cursor: pointer; font-size: 10px;
}

/* ------------------------------ Sparkline ------------------------------- */
.nx-spark { position: absolute; pointer-events: none; z-index: 3; }

/* ------------------------------- Grafik --------------------------------- */
.nx-chartlayer { position: absolute; inset: 0; z-index: 8; }
.nx-chart-panel {
  position: absolute; background: var(--modal-bg);
  border: 1px solid var(--menu-bd);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; overflow: hidden;
  transition: box-shadow .2s ease;
}
.nx-chart-panel:hover { box-shadow: var(--shadow-pop), 0 0 14px rgba(33, 115, 70, 0.12); }
.nx-chart-panel.dragging { opacity: 0.92; cursor: grabbing; }
.nx-chart-head {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: var(--panel2);
  border-bottom: 1px solid var(--menu-bd); cursor: grab;
}
.nx-chart-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; }
.nx-chart-title { flex: 1; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nx-chart-title-input {
  flex: 1; background: var(--bg2); border: 1px solid var(--brand); color: var(--text);
  border-radius: 2px; font-size: 12px; padding: 2px 6px; outline: none;
}
.nx-chart-tools { display: flex; gap: 4px; }
.nx-cbtn {
  background: transparent; border: 1px solid transparent; color: var(--text2);
  width: 22px; height: 22px; border-radius: 3px; cursor: pointer; font-size: 12px;
}
.nx-cbtn:hover { background: var(--btn-hover); color: var(--brand); border-color: var(--btn-hover-bd); }
.nx-chart-canvas { flex: 1; width: 100%; }
.nx-chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--menu-bg); border: 1px solid var(--menu-bd); border-radius: 2px;
  padding: 5px 9px; font-size: 11px; color: var(--text);
  box-shadow: var(--shadow-soft);
}
.nx-chart-resize {
  position: absolute; right: 2px; bottom: 2px; width: 14px; height: 14px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--menu-bd) 50%);
}

/* ======================= Tab sheet & status bar ========================= */
.nx-sheetbar {
  display: flex; align-items: center; gap: 3px; padding: 0 6px; height: 26px;
  background: var(--sheetbar-bg); border-top: 1px solid var(--fx-border); flex: none; overflow-x: auto;
}
.nx-shnav {
  width: 20px; height: 20px; border: none; background: transparent; color: var(--text2);
  border-radius: 3px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.nx-shnav:hover { background: var(--btn-hover); color: var(--text); }
.nx-shnav svg { display: block; }
.nx-sheettabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; height: 100%; align-items: stretch; }
.nx-stab {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--text2);
  padding: 0 12px; cursor: pointer; font-size: 12px; font-family: inherit;
  transition: background .1s; white-space: nowrap;
}
.nx-stab:hover { background: var(--btn-hover); color: var(--text); }
.nx-stab.on {
  background: var(--bg2); color: var(--brand); font-weight: 600;
  border-bottom-color: var(--brand);
}
.nx-stab .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.nx-addsheet {
  background: transparent; border: none; color: var(--text2);
  width: 24px; height: 22px; border-radius: 3px; cursor: pointer; font-size: 13px;
}
.nx-addsheet:hover { color: var(--brand); background: var(--btn-hover); }
.nx-statusbar {
  display: flex; align-items: center; gap: 14px; height: 26px; padding: 0 12px;
  background: var(--status-bg); border-top: 1px solid var(--fx-border); flex: none;
  font-size: 11.5px; color: var(--status-fg);
}
#nx-mode { color: var(--brand); min-width: 90px; font-weight: 600; }
#nx-stats { flex: 1; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nx-zoomwrap { display: flex; align-items: center; gap: 8px; }
.nx-zoombtn {
  width: 20px; height: 20px; border: none; background: transparent; color: var(--status-fg);
  border-radius: 3px; cursor: pointer; font-size: 12px;
}
.nx-zoombtn:hover { background: var(--btn-hover); color: var(--brand); }
#nx-zoom { width: 110px; accent-color: var(--brand); }
#nx-zoomlabel { min-width: 40px; text-align: right; color: var(--status-fg); font-variant-numeric: tabular-nums; }

/* ============================ Menu konteks ============================== */
.nx-menu {
  position: fixed; z-index: 2000; min-width: 190px;
  background: var(--menu-bg);
  border: 1px solid var(--menu-bd);
  box-shadow: var(--menu-shadow);
  padding: 3px; animation: pop .12s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(-3px); } }
.nx-menu-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px;
  border-radius: 2px; cursor: pointer; font-size: 12.5px; color: var(--text);
  transition: background .08s;
}
.nx-menu-item:hover { background: var(--menu-hover); }
.nx-menu-item.disabled { opacity: 0.4; cursor: default; }
.nx-menu-item.disabled:hover { background: transparent; }
.nx-menu-item.danger { color: var(--danger); }
.nx-menu-item.danger:hover { background: rgba(214, 69, 80, 0.08); }
.nx-menu-item.has-sub::after { content: '▸'; margin-left: auto; color: var(--text3); }
.nx-menu-ico { width: 18px; text-align: center; color: var(--text2); flex: none; }
.nx-menu-ico svg { display: block; margin: 0 auto; }
.nx-menu-label { flex: 1; }
.nx-menu-key { font-size: 10.5px; color: var(--text3); }
.nx-menu-sep { height: 1px; background: var(--border); margin: 4px 8px; }

/* ----------------------------- Palet warna ------------------------------ */
.nx-colorpal { padding: 10px; }
.nx-colorgrid { display: grid; grid-template-columns: repeat(8, 22px); gap: 4px; }
.nx-colorcell { width: 22px; height: 22px; border-radius: 2px; cursor: pointer; border: 1px solid rgba(0, 0, 0, 0.15); transition: transform .1s; }
.nx-colorcell:hover { transform: scale(1.15); outline: 2px solid var(--brand); }
.nx-colorcell.on { outline: 2px solid var(--brand); }
.nx-colorrow { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.nx-colorcustom { width: 34px; height: 26px; border: none; background: transparent; cursor: pointer; }

/* ---------------------- Galeri Gaya Sel (ala Excel) --------------------- */
.nx-stylemenu { padding: 8px; width: 264px; }
.nx-stylemenu .nx-style-title { font-size: 10.5px; color: var(--ribbon-label); margin: 2px 0 6px 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.nx-stylegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.nx-stylechip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; cursor: pointer; border: 1px solid var(--menu-bd);
  font-size: 12px; font-family: inherit; background: var(--menu-bg); color: var(--text);
  border-radius: 2px; transition: outline .08s;
}
.nx-stylechip:hover { outline: 2px solid var(--brand); }
.nx-stylechip .chipname { pointer-events: none; white-space: nowrap; }

/* ========================== Modal & form ================================ */
.nx-backdrop {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(31, 45, 58, 0.38);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 9vh; animation: fadein .15s ease;
}
@keyframes fadein { from { opacity: 0; } }
.nx-backdrop.closing { opacity: 0; transition: opacity .15s; }
.nx-modal {
  width: 420px; max-width: calc(100vw - 40px); max-height: 80vh;
  background: var(--modal-bg);
  border: 1px solid var(--menu-bd);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  animation: modalin .16s ease;
}
@keyframes modalin { from { opacity: 0; transform: translateY(-12px); } }
.nx-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px 9px; border-bottom: 1px solid var(--border);
}
.nx-modal-title { font-weight: 600; font-size: 14px; color: var(--text); }
.nx-modal-x { background: transparent; border: none; color: var(--text3); cursor: pointer; font-size: 14px; padding: 3px 6px; border-radius: 3px; }
.nx-modal-x:hover { color: var(--danger); background: var(--btn-hover); }
.nx-modal-body { padding: 14px 16px; overflow-y: auto; }
.nx-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 11px 16px; border-top: 1px solid var(--border); }
.nx-btn {
  background: var(--bg2); color: var(--text); border: 1px solid var(--namebox-bd);
  border-radius: 2px; padding: 6px 14px; font-size: 12.5px; cursor: pointer; font-family: inherit;
  transition: background .1s, border-color .1s;
}
.nx-btn:hover { border-color: var(--brand); background: var(--menu-hover); }
.nx-btn.primary {
  background: var(--brand); color: #ffffff; font-weight: 600; border: 1px solid var(--brand-dark);
}
.nx-btn.primary:hover { background: var(--brand-dark); }
.nx-btn.danger { color: var(--danger); }
.nx-btn.danger:hover { border-color: var(--danger); background: rgba(214, 69, 80, 0.06); }
.nx-btn.tiny { padding: 3px 9px; font-size: 11px; }
.nx-form { display: flex; flex-direction: column; gap: 8px; }
.nx-label { font-size: 11.5px; color: var(--text2); font-weight: 600; margin-top: 4px; }
.nx-input {
  background: var(--bg2); border: 1px solid var(--namebox-bd); color: var(--text);
  border-radius: 2px; padding: 7px 10px; font-size: 13px; outline: none; width: 100%;
  transition: border .1s; user-select: text; font-family: inherit;
}
.nx-input:focus { border-color: var(--brand); }
.nx-input.invalid { border-color: var(--danger); }
.nx-input.tiny { width: 90px; }
.nx-hint { font-size: 11px; color: var(--text3); }
.nx-check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text2); cursor: pointer; }
.nx-check input { accent-color: var(--brand); }
.nx-checkrow { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.nx-empty { color: var(--text3); font-size: 12.5px; padding: 18px; text-align: center; }
.nx-bdrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* -------------------------- Format sel dialog --------------------------- */
.nx-fmt-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.nx-fmt-tab {
  background: transparent; border: 1px solid var(--menu-bd); color: var(--text2);
  padding: 5px 12px; border-radius: 2px; cursor: pointer; font-size: 12px; font-family: inherit;
}
.nx-fmt-tab.on { color: var(--brand); border-color: var(--brand); background: var(--menu-hover); }
.nx-fmt-pane { display: none; flex-direction: column; gap: 6px; }
.nx-fmt-pane.on { display: flex; }
.nx-fmt-preview { background: var(--bg2); border: 1px dashed var(--menu-bd); padding: 8px 10px; font-size: 12px; margin-top: 8px; }

/* ----------------------------- Dialog lainnya --------------------------- */
.nx-fx-list { max-height: 330px; overflow-y: auto; margin-top: 8px; }
.nx-fx-item { padding: 8px 10px; border-radius: 2px; cursor: pointer; display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: baseline; font-size: 12.5px; }
.nx-fx-item:hover { background: var(--menu-hover); }
.nx-fx-item b { color: var(--brand); font-family: Consolas, monospace; }
.nx-fx-item .cat { font-size: 10px; color: var(--text3); }
.nx-fx-item .desc { grid-column: 1 / -1; font-size: 11.5px; color: var(--text2); }
.nx-pal-list { margin-top: 8px; }
.nx-pal-item { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 2px; cursor: pointer; font-size: 13px; }
.nx-pal-item.on, .nx-pal-item:hover { background: var(--menu-hover); }
.nx-pal-item .ico { color: var(--brand); width: 20px; text-align: center; }
.nx-chart-types { display: flex; flex-wrap: wrap; gap: 6px; }
.nx-chtype {
  background: var(--bg2); border: 1px solid var(--menu-bd); color: var(--text2);
  padding: 6px 12px; border-radius: 2px; cursor: pointer; font-size: 12px; font-family: inherit;
}
.nx-chtype.on { color: var(--brand); border-color: var(--brand); background: var(--menu-hover); }
.nx-help h3 { color: var(--brand); font-size: 13px; margin: 12px 0 6px; }
.nx-kbd-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.nx-kbd-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); color: var(--text2); }
.nx-kbd-table td:first-child { color: var(--hdrtext); font-weight: 600; width: 90px; }
.nx-hint-list { padding-left: 18px; font-size: 12px; color: var(--text2); display: flex; flex-direction: column; gap: 5px; }
.nx-cf-list, .nx-cf-form { display: flex; flex-direction: column; gap: 7px; }
.nx-cf-list { margin-bottom: 14px; }
.nx-cf-rule { display: flex; align-items: center; gap: 9px; padding: 7px 10px; background: var(--bg2); border-radius: 2px; font-size: 12.5px; }
.nx-cf-rule .nx-btn { margin-left: auto; }
.nx-cf-swatch { width: 18px; height: 18px; border-radius: 2px; flex: none; }
.nx-openlist { max-height: 380px; overflow-y: auto; }
.nx-filterpop .nx-filter-list { max-height: 240px; overflow-y: auto; margin-top: 8px; }
.nx-filter-search { padding: 2px 0 6px; }
.nx-filter-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 2px; font-size: 12.5px; cursor: pointer; }
.nx-filter-item:hover { background: var(--btn-hover); }
.nx-filter-item.head { color: var(--hdrtext); font-weight: 600; border-bottom: 1px solid var(--border); }
.nx-filter-item input { accent-color: var(--brand); }

/* -------------------------------- Toast --------------------------------- */
.nx-toasts { position: fixed; right: 16px; bottom: 44px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.nx-toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--menu-bg);
  border: 1px solid var(--menu-bd); border-left: 3px solid var(--accent2);
  padding: 9px 14px; font-size: 12.5px; color: var(--text);
  box-shadow: var(--shadow-pop);
  transform: translateX(30px); opacity: 0; transition: all .25s cubic-bezier(.2, 1.2, .4, 1);
  max-width: 340px;
}
.nx-toast.show { transform: none; opacity: 1; }
.nx-toast.success { border-left-color: var(--brand); }
.nx-toast.error { border-left-color: var(--danger); }
.nx-toast.info { border-left-color: var(--accent2); }
.nx-toast-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent2); flex: none; }
.nx-toast.success .nx-toast-dot { background: var(--brand); }
.nx-toast.error .nx-toast-dot { background: var(--danger); }

/* ============================ Layar beranda ============================= */
#nx-home {
  position: fixed; inset: 0; z-index: 1000;
  background:
    linear-gradient(180deg, var(--brand) 0, var(--brand) 88px, transparent 88px),
    #ffffff;
  display: none; flex-direction: column; align-items: center;
  overflow-y: auto; padding: 26px 24px 30px;
  opacity: 0; transition: opacity .2s ease;
}
#nx-home.show { opacity: 1; }
.nx-home-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; padding-top: 8px; }
.nx-home-brand h1 { font-size: 34px; letter-spacing: 0.5px; color: #ffffff; }
.nx-home-brand .grad { color: #ffffff; }
.nx-tagline { color: var(--text2); font-size: 13.5px; margin-bottom: 4px; text-align: center; line-height: 1.5; }
.nx-modebadge.big { margin: 10px 0 18px; color: var(--text2); border-color: var(--menu-bd); }
.nx-modebadge.big.srv { color: var(--brand); background: rgba(33, 115, 70, 0.08); }
.nx-modebadge.big.loc { color: var(--warn); background: rgba(183, 121, 31, 0.08); }
.nx-home-h2 { color: var(--text2); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; margin: 18px 0 12px; text-align: center; }
#nx-templates {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; width: min(980px, 100%); margin-bottom: 8px;
}
.nx-tpl-card {
  background: var(--bg2); border: 1px solid var(--menu-bd); padding: 12px;
  cursor: pointer; transition: all .15s ease;
  display: flex; flex-direction: column; gap: 8px;
}
.nx-tpl-card:hover { border-color: var(--brand); box-shadow: var(--shadow-soft); transform: translateY(-2px); }
.nx-tpl-thumb {
  height: 88px; position: relative; overflow: hidden;
  background: linear-gradient(140deg, color-mix(in srgb, var(--tint, #217346) 18%, var(--bg2)), var(--bg2));
  border: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 10px; gap: 5px;
}
.nx-tpl-thumb span { display: block; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--tint, #217346) 55%, transparent); }
.nx-tpl-thumb .d1 { width: 70%; } .nx-tpl-thumb .d2 { width: 50%; opacity: .7; } .nx-tpl-thumb .d3 { width: 85%; opacity: .4; }
.nx-tpl-thumb.imp { display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--brand); }
.nx-tpl-name { font-weight: 600; font-size: 14px; }
.nx-tpl-desc { font-size: 11.5px; color: var(--text3); line-height: 1.45; }
.nx-recent-wrap { width: min(980px, 100%); }
#nx-recent-list { display: flex; flex-direction: column; gap: 8px; }
.nx-file-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
}
.nx-file-row:hover { border-color: var(--brand); }
.nx-file-ico { color: var(--brand); font-size: 16px; }
.nx-file-name { font-weight: 600; font-size: 13.5px; flex: 1; }
.nx-file-meta { font-size: 11px; color: var(--text3); }
.nx-file-actions { display: flex; gap: 6px; }
#nx-home-foot { margin-top: 26px; color: var(--text3); font-size: 11.5px; text-align: center; max-width: 640px; }

/* ------------------------------ Scrollbar ------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #26344d; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #2c3d58; }
