/* Excel replica — overlay layer: dropdown menus, context menus, palettes,
 * Win32-styled dialogs with tab controls, tooltips, backstage. */

/* popup menus */
.popup {
  position: absolute;
  z-index: 200;
  background: #f6f5f4;
  border: 1px solid #b7b3ae;
  box-shadow: 0 7px 22px rgba(0,0,0,.28), 0 2px 5px rgba(0,0,0,.14);
  border-radius: 3px;
  padding: 3px;
  min-width: 150px;
  font-family: var(--ui-font);
  font-size: 12px;
  transform-origin: top left;
  animation: pop-open 90ms ease-out both;
}
@keyframes pop-open { from { opacity: .55; transform: scale(.985); } to { opacity: 1; transform: none; } }
.mi {
  display: flex; align-items: center; gap: 8px;
  height: 21px; padding: 0 22px 0 8px;
  cursor: default; color: #262523; white-space: nowrap;
  position: relative;
}
.mi .mic { width: 16px; text-align: center; flex: none; opacity: .9; }
.mi .mlabel { flex: none; }
.mi .mshort { margin-left: auto; color: #8a867f; font-size: 11px; padding-left: 18px; }
.mi:hover:not(.disabled):not(.sep) { background: #cfead9; color: #143c26; }
.mi.disabled { color: #a7a29c; pointer-events: none; }
.mi.checked::before {
  content: "✓"; position: absolute; left: 7px; font-size: 10px; color: #217346;
}
.mi.submenu::after {
  content: ""; position: absolute; right: 8px;
  border-left: 4.5px solid #67635e; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.msep { height: 1px; background: #d9d5d1; margin: 3px 8px; }
.mtitle {
  padding: 2px 8px 3px; font-size: 11px; color: #79756f;
}

/* palette grids */
.palette { width: 178px; }
.palette .pal-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; padding: 4px 6px; }
.pal-swatch {
  width: 14px; height: 14px;
  outline: 1px solid rgba(0,0,0,.24);
  cursor: pointer;
}
.pal-swatch:hover { transform: scale(1.28); outline: 1.5px solid var(--xl-green); z-index: 2; }
.pal-label { font-size: 11px; color: #6a6660; padding: 3px 8px 1px; }
.pal-more { padding: 4px 10px; }
.pal-empty-swatch {
  display: inline-flex; align-items: center; gap: 6px; width: 100%;
  height: 20px; padding: 0 6px; cursor: pointer; font-size: 12px;
}
.pal-empty-swatch:hover { background: #cfead9; }

/* dialogs */
#layerRoot .modalveil {
  position: fixed; inset: 0; z-index: 300;
  background: transparent;   /* Excel dialogs don't dim the app */
}
.dlg {
  position: fixed; z-index: 310;
  min-width: 260px;
  background: #f0efee;
  border: 1px solid #9a968f;
  box-shadow: 0 16px 44px rgba(0,0,0,.36), 0 2px 8px rgba(0,0,0,.18);
  font-family: var(--ui-font); font-size: 12px; color: #211f1e;
  animation: pop-open 95ms ease-out both;
  border-radius: 1px;
}
.dlg-titlebar {
  height: 30px; display: flex; align-items: center;
  padding: 0 4px 0 11px;
  background: linear-gradient(180deg,#fcfcfb,#efeeec);
  border-bottom: 1px solid #dcd8d4;
  user-select: none;
  cursor: move;
}
.dlg-titlebar .dtxt { font-size: 12.5px; color: #201f1e; }
.dlg-x {
  margin-left: auto; width: 34px; height: 25px;
  border: none; background: transparent; cursor: pointer; color: #46433f;
  display: inline-flex; align-items: center; justify-content: center;
}
.dlg-x:hover { background: #e81123; color: #fff; }
.dlg-body { padding: 14px 14px 10px; }
.dlg-foot {
  display: flex; justify-content: flex-end; gap: 7px;
  padding: 10px 14px 13px;
}
.btn {
  min-width: 76px; height: 23px;
  border-radius: 2px;
  border: 1px solid #adaba7;
  background: linear-gradient(#fdfdfd,#f1f0ef);
  font-family: inherit; font-size: 12px; color: #242320; cursor: pointer;
  padding: 0 11px;
}
.btn:hover { background: linear-gradient(#fff,#eae9e8); border-color: #8f8d89; }
.btn:active { background: #e3e2e1; box-shadow: inset 0 1px 2px rgba(0,0,0,.15); }
.btn.primary { background: var(--xl-green); color: #fff; border-color: #14512f; }
.btn.primary:hover { background: #27845255; background: #278654; }
.btn.disabled { opacity: .5; pointer-events: none; }

.dlg-tabs { display: flex; gap: 2px; padding: 6px 10px 0; border-bottom: 1px solid #ccc9c5; }
.dlg-tab {
  padding: 4px 10px 5px; cursor: pointer; border: 1px solid transparent; border-bottom: none;
  border-radius: 3px 3px 0 0; color: #47443f; user-select: none;
}
.dlg-tab:hover { background: #f9f8f7; }
.dlg-tab.on {
  background: #fff; border-color: #ccc9c5;
  color: #16151a; position: relative; top: 1px; font-weight: 600;
}
.dlg-pane { background: #fff; border: 1px solid #ccc9c5; border-top: none; padding: 13px 14px; min-height: 130px; }

.frow { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.fcol { display: flex; flex-direction: column; gap: 8px; }
label.cap { font-size: 12px; color: #333; }
.field {
  height: 22px; border: 1px solid #bab6b1; border-radius: 2px; padding: 0 6px;
  font-family: inherit; font-size: 12px; outline: none; background: #fff;
}
.field:focus { border-color: var(--xl-green); box-shadow: 0 0 0 1px #35a06a55 inset; }
select.field { height: 23px; padding: 0 4px; }

/* format-cells preview box */
.previewbox {
  height: 42px; border: 1px dashed #b9b5b0; margin-top: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--cell-font); font-size: 13px; color:#222;
  background: repeating-conic-gradient(#fafaf9 0% 25%, #fff 0% 50%) 0 0/12px 12px;
}

/* list views (insert function / go to) */
.listbox {
  height: 180px; overflow-y: auto; border: 1px solid #bab6b1; background: #fff;
  scrollbar-width: thin;
}
.listbox li {
  list-style: none; padding: 2.5px 9px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 8px;
}
.listbox li:nth-child(even) { background: #f6fbf8; }
.listbox li.sel { background: #1a66c2; color: #fff; }
.fn-desc { border-top: 1px solid #ddd; padding-top: 8px; margin-top: 9px; min-height: 62px; color: #333; font-size: 12px; }
.fn-desc b { color: #10267c; }

kbd.kbd {
  font-family: Consolas, monospace; font-size: 11px;
  border: 1px solid #bbb7b2; border-bottom-width: 2px; border-radius: 3px;
  padding: 0 4px; background: #fff;
}

/* dialogs-specific two-col helper grid */
.twocol { display: grid; grid-template-columns: 118px 1fr; align-content: start; row-gap: 7px; column-gap: 9px; }

input[type="checkbox"] { accent-color: var(--xl-green); width: 13px; height: 13px; }
fieldset.fs { border: 1px solid #cfcbc6; border-radius: 3px; padding: 8px 10px; }
legend { padding: 0 5px; color: #444; }

/* tooltips */
#tooltipRoot .tip {
  position: fixed; z-index: 500;
  max-width: 300px;
  background: #fff; color: #232220;
  border: 1px solid #b8b4af;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  font-family: var(--ui-font); font-size: 12px;
  padding: 5px 9px;
  pointer-events: none;
  animation: pop-open 80ms both;
}

/* backstage (File) */
#backstage {
  position: fixed; inset: 0; z-index: 250;
  background: var(--xl-green-dark);
  display: flex;
  animation: fadein 140ms both;
}
@keyframes fadein { from { opacity: .2; } to { opacity: 1; } }
#backstage .bs-left {
  width: 218px; flex: none; padding: 8px 0;
  display: flex; flex-direction: column;
}
#backstage .bs-item {
  color: #eaf4ec; padding: 11px 20px; font-size: 13px; cursor: pointer;
}
#backstage .bs-item:hover { background: rgba(255,255,255,.12); }
#backstage .bs-item.on { background: var(--ribbon-bg); color: #20573a; font-weight: 600; }
#backstage .bs-main {
  flex: 1; background: var(--ribbon-bg);
  padding: 26px 34px; overflow-y: auto;
}
.bs-h { font-size: 19px; color: #235c40; margin-bottom: 14px; }
.bs-tiles { display: flex; flex-wrap: wrap; gap: 14px; }
.bs-tile {
  width: 128px; height: 156px;
  border: 1px solid #cfd9d3; border-bottom: 3px solid var(--xl-green);
  background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  transition: transform 110ms ease, box-shadow 110ms ease;
}
.bs-tile:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(31,71,49,.22); }
.bs-thumb {
  width: 74px; height: 92px; border: 1px solid #ccd5cf; overflow: hidden;
  display: grid; grid-template-rows: 16% 1fr; background: #fff;
}
.bs-thumb .th { background: var(--xl-green); }
.bs-thumb .tb { padding: 5px 6px; display: grid; grid-auto-rows: 4px; gap: 3px; align-content: start; }
.bs-thumb .l1 { background: #cdd9d1; } .bs-thumb .l2 { background: #e4ebe6; }
.bs-name { font-size: 12px; color: #333; }

/* mobile-friendly narrow-viewport intentional behavior:
   the desktop-class window scales down and allows horizontal scrolling
   rather than hiding spreadsheet functionality. */
@media (max-width: 700px) {
  #desktop { padding: 0; }
  body { overflow: auto; }
  #excelWindow { min-width: 660px; }
  #excelWindow.notmaximized { max-width: none; max-height: none; }
}
