/* BioStudio AI — Word & Excel (Office-like) apps. */

.office-app {
  background: #f3f3f3;
}

.office-titlebar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 12px;
  font-size: 11.5px;
  color: #fff;
  font-weight: 600;
  min-height: 24px;
}
.word-app .office-titlebar { background: #1b5bb0; }
.excel-app .office-titlebar { background: #107c41; }
.office-filename,
.word-filename { letter-spacing: 0.2px; }
.office-titlebar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.office-titlebar-spacer { flex: 1 1 auto; min-width: 8px; }
.office-tsep {
  width: 1px;
  align-self: stretch;
  margin: 2px 5px;
  background: rgba(255, 255, 255, 0.32);
}
.office-tbtn {
  height: 24px;
  min-width: 24px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.office-tbtn:hover { background: rgba(255, 255, 255, 0.22); border-color: rgba(255, 255, 255, 0.18); }
.office-tbtn:active { background: rgba(255, 255, 255, 0.3); }
.office-tbtn.primary { background: rgba(255, 255, 255, 0.24); }
.office-tbtn.primary:hover { background: rgba(255, 255, 255, 0.34); }

/* --- Ribbon ---------------------------------------------------------------- */
.office-ribbon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #fafafa;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  flex-wrap: wrap;
}
.office-ribbon-group {
  display: flex;
  align-items: center;
  gap: 3px;
}
.office-ribbon-divider {
  width: 1px;
  align-self: stretch;
  margin: 2px 5px;
  background: rgba(0, 0, 0, 0.12);
}

.word-btn,
.excel-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: #333;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.word-btn:hover,
.excel-btn:hover { background: #e9eef7; border-color: rgba(0, 0, 0, 0.12); }
.word-btn:active,
.excel-btn:active { background: #dbe5f3; }

.word-primary { background: #1b5bb0; color: #fff; }
.word-primary:hover { background: #1a52a0; border-color: transparent; }
.excel-primary { background: #107c41; color: #fff; }
.excel-primary:hover { background: #0d6b38; border-color: transparent; }
.excel-strong { font-weight: 800; }
.excel-em { font-style: italic; font-family: Georgia, serif; }
.excel-ul { text-decoration: underline; }
.excel-strike { text-decoration: line-through; }
.excel-btn.on { background: #cfe8d8; border-color: #107c41; color: #0d6b38; }

.excel-app > .office-titlebar {
  min-height: 22px;
  padding: 2px 10px;
  font-size: 11px;
}
.excel-app > .office-ribbon {
  padding: 4px 8px;
  gap: 3px;
  flex-wrap: nowrap;
  overflow-x: auto;
  min-height: 34px;
  scrollbar-width: thin;
}

.word-strong { font-weight: 800; }
.word-em { font-style: italic; font-family: Georgia, serif; }
.word-ul { text-decoration: underline; }
.word-strike { text-decoration: line-through; }

.word-select {
  height: 28px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 5px;
  background: #fff;
  font-size: 12.5px;
  padding: 0 4px;
  color: #222;
  cursor: pointer;
}
.word-size { width: 56px; }
.word-color {
  width: 28px;
  height: 28px;
  padding: 2px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}

/* --- Word document page ---------------------------------------------------- */
.word-scroll {
  flex: 1 1 auto;
  overflow: auto;
  background: #cdd0d6;
  padding: 26px 0 60px;
  display: flex;
  justify-content: center;
}
/* Letter-sized page stack: white sheets sit behind the editor; gray shows only
   in the deliberate gaps between pages (see .word-page-gap in JS). */
.word-doc-frame {
  --pg-h: 1056px;   /* 11in @ 96dpi */
  --pg-gap: 26px;
  position: relative;
  width: 816px;     /* 8.5in @ 96dpi */
  max-width: 96%;
  flex-shrink: 0;
}
.word-page-sheets {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.word-page-sheet {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--pg-h);
  background: #fff;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.28);
}
.word-page {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  min-height: var(--pg-h);
  padding: 96px;    /* 1in page margins */
  outline: none;
  color: #1b1b1f;
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  font-size: 11pt;
  line-height: 1.5;
  background: transparent;
}
.word-page-gap {
  height: var(--pg-gap);
  margin: 0 -96px;
  pointer-events: none;
  user-select: none;
}
.word-page:focus { outline: none; }
.word-page p { margin: 0 0 10px; }
.word-page h1 { font-size: 20pt; margin: 0 0 12px; font-weight: 600; }
.word-page h2 { font-size: 16pt; margin: 0 0 10px; font-weight: 600; }
.word-page h3 { font-size: 13pt; margin: 0 0 8px; font-weight: 600; }
.word-page img { max-width: 100%; height: auto; }
.word-page table { border-collapse: collapse; }
.word-page td, .word-page th { border: 1px solid #bbb; padding: 4px 6px; }
.word-status { background: #1b5bb0; color: #eaf1fb; border-top: none; }

/* --- Excel ----------------------------------------------------------------- */
.excel-formula-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.14);
  background: #fff;
}
.excel-namebox {
  width: 86px;
  height: 26px;
  border: none;
  border-right: 1px solid rgba(0, 0, 0, 0.14);
  text-align: center;
  font-size: 12.5px;
  color: #222;
  background: #fafafa;
}
.excel-fx {
  padding: 0 10px;
  font-style: italic;
  font-family: Georgia, serif;
  color: #777;
  border-right: 1px solid rgba(0, 0, 0, 0.14);
  line-height: 26px;
}
.excel-formula-input {
  flex: 1 1 auto;
  height: 26px;
  border: none;
  padding: 0 10px;
  font-size: 13px;
  color: #222;
  outline: none;
}

/* Grid palette, matched to Excel's own light theme. */
.excel-app {
  --xl-accent: #107c41;          /* Excel green — selection + fill handle     */
  --xl-gridline: #d0d0d0;        /* "Automatic" gridline colour               */
  --xl-head-bg: #f5f5f5;
  --xl-head-fg: #616161;
  --xl-head-sel-bg: #d7e9df;
  --xl-head-sel-fg: #0e6a37;
  --xl-range-fill: rgba(16, 124, 65, 0.1);
  --xl-grid-font: Calibri, "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
}

.excel-grid-scroll {
  flex: 1 1 auto;
  overflow: auto;
  background: #fff;
  outline: none;
}
.excel-table {
  border-collapse: collapse;
  table-layout: fixed;
  font-family: var(--xl-grid-font);
  font-size: 13px;
  color: #000;
}
.excel-table th,
.excel-table td {
  border: 1px solid var(--xl-gridline);
  height: 20px;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.excel-table td.excel-cell {
  text-align: left;
  background: #fff;
  cursor: cell;
  /* Selection edges compose from four independent custom properties so a
     corner cell can carry two or three of them at once. */
  --xl-e-t: 0 0 0 0 transparent;
  --xl-e-b: 0 0 0 0 transparent;
  --xl-e-l: 0 0 0 0 transparent;
  --xl-e-r: 0 0 0 0 transparent;
  box-shadow: var(--xl-e-t), var(--xl-e-b), var(--xl-e-l), var(--xl-e-r);
}
.excel-table td.excel-cell.num { text-align: right; }
.excel-table td.excel-cell.err { color: #c0392b; }
/* Excel outlines the active cell and leaves it unfilled, even inside a range. */
.excel-table td.excel-cell.sel {
  background-color: #fff;
  outline: 2px solid var(--xl-accent);
  outline-offset: -1px;
  z-index: 2;
}
.excel-table td.excel-cell.editing {
  padding: 0;
  outline: 2px solid var(--xl-accent);
  outline-offset: -1px;
  background: #fff;
}
.excel-cell-input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 0 3px;
  font-size: 13px;
  font-family: var(--xl-grid-font);
  background: transparent;
}

.excel-corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 9;
  background: var(--xl-head-bg);
}
/* Excel's Select All marker in the corner box. */
.excel-corner::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-bottom: 7px solid #a0a0a0;
}
.excel-colhead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--xl-head-bg);
  color: var(--xl-head-fg);
  font-weight: 400;
  text-align: center;
}
.excel-rowhead {
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--xl-head-bg);
  color: var(--xl-head-fg);
  font-weight: 400;
  text-align: center;
}
.excel-table tr.excel-row-spacer,
.excel-table tr.excel-row-spacer td {
  border: none;
  padding: 0;
  background: transparent;
  pointer-events: none;
  line-height: 0;
  font-size: 0;
}
/* Headers spanned by the selection tint, with Excel's accent rule on the edge
   that faces the grid; a whole-column/row selection inverts them instead. */
.excel-colhead.sel {
  background: var(--xl-head-sel-bg);
  color: var(--xl-head-sel-fg);
  box-shadow: inset 0 -2px 0 0 var(--xl-accent);
}
.excel-rowhead.sel {
  background: var(--xl-head-sel-bg);
  color: var(--xl-head-sel-fg);
  box-shadow: inset -2px 0 0 0 var(--xl-accent);
}
.excel-colhead.sel.full,
.excel-rowhead.sel.full {
  background: var(--xl-accent);
  color: #fff;
  box-shadow: none;
}

.excel-sheet-tabs {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  background: #f0f0f0;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  overflow-x: auto;
}
.excel-tab {
  height: 24px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  font-size: 12px;
  color: #444;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}
.excel-tab:hover { background: #e3e3e3; }
.excel-tab.active {
  background: #fff;
  color: #107c41;
  font-weight: 600;
  border-color: rgba(0, 0, 0, 0.12);
}
.excel-tab-add {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  font-size: 16px;
  color: #555;
  cursor: pointer;
  border-radius: 4px;
}
.excel-tab-add:hover { background: #e3e3e3; }
.excel-status { background: #107c41; color: #eafaf0; border-top: none; }

.excel-open-progress {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 80;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(2px);
}
.excel-open-progress.is-visible { display: flex; }
.excel-open-progress-card {
  width: min(420px, calc(100% - 48px));
  padding: 20px 22px 18px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(16, 36, 24, 0.18);
  border: 1px solid #d9e6dc;
  color: #1a1a1a;
}
.excel-open-progress-card strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
  color: #0e6a37;
  margin-bottom: 6px;
}
.excel-open-progress-label {
  font-size: 13px;
  color: #3d3d3d;
  margin-bottom: 12px;
}
.excel-open-progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e6efe9;
  overflow: hidden;
}
.excel-open-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #13a34a, #107c41);
  transition: width 120ms ease;
}
.excel-open-progress-detail {
  margin-top: 10px;
  font-size: 12px;
  color: #5a5a5a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (prefers-reduced-motion: reduce) {
  .excel-open-progress-fill { transition: none; }
}

/* ===================================================================== */
/* Excel — floating AI assistant (bubble + chat window)                  */
/* ===================================================================== */
.excel-app { position: relative; }

.xl-ai-fab {
  position: absolute; right: 20px; bottom: 44px; width: 50px; height: 50px;
  border-radius: 50%; border: none; cursor: pointer; z-index: 40;
  background: linear-gradient(135deg, #16a34a, #107c41);
  color: #fff; font-size: 21px; line-height: 1;
  box-shadow: 0 6px 20px rgba(16, 124, 65, 0.4);
  transition: transform .12s ease, box-shadow .12s ease;
}
.xl-ai-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 10px 26px rgba(16, 124, 65, 0.5); }

.xl-aiwin {
  position: absolute; right: 20px; bottom: 44px; width: 400px; height: 540px;
  z-index: 41; display: flex; flex-direction: column;
  background: #fff; border: 1px solid #d4d9d5; border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28); overflow: hidden;
  color: #1b1b1f; font-size: 13px;
}
.xl-aiwin-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; cursor: move; user-select: none;
  background: linear-gradient(135deg, #16a34a, #107c41); color: #fff;
}
.xl-aiwin-title { font-weight: 700; font-size: 13px; }
.xl-aiwin-btn {
  background: rgba(255,255,255,.2); color: inherit; border: none; border-radius: 6px;
  cursor: pointer; font-size: 13px; line-height: 1; padding: 3px 9px;
}
.xl-aiwin-btn:hover { background: rgba(255,255,255,.34); }
.xl-aiwin-resize {
  position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, #b7bdb8 50%); opacity: .6;
}

.xl-ai-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.xl-ai-enc { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: #5a615c; }
.xl-ai-enc input { accent-color: #107c41; }

.xl-ai-chat { flex: 1 1 auto; overflow: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.xl-ai-msg { padding: 7px 10px; border-radius: 9px; max-width: 92%; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.xl-ai-msg.user { align-self: flex-end; background: #107c41; color: #fff; border-bottom-right-radius: 3px; }
.xl-ai-msg.bot { align-self: flex-start; background: #f0f3f1; color: #1b1b1f; border-bottom-left-radius: 3px; }
.xl-ai-msg.system { align-self: center; background: transparent; color: #6b726c; font-size: 11.5px; font-style: italic; }

.xl-ai-input { display: flex; gap: 6px; }
.xl-ai-input-box { flex: 1 1 auto; border: 1px solid #cdd3ce; border-radius: 8px; padding: 7px 9px; font-size: 13px; }
.xl-ai-input-box:focus { outline: none; border-color: #107c41; }
.xl-ai-send { border: none; background: #107c41; color: #fff; border-radius: 8px; padding: 0 14px; cursor: pointer; font-weight: 600; }
.xl-ai-send:hover { background: #0d6835; }
.xl-ai-send:disabled { opacity: .55; cursor: default; }

.xl-ai-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.xl-ai-chip { background: #f0f3f1; border: 1px solid #dbe0dc; border-radius: 20px; padding: 4px 10px; font-size: 11px; cursor: pointer; color: #2f4137; }
.xl-ai-chip:hover { border-color: #107c41; color: #107c41; }

.xl-ai-card { align-self: stretch; border: 1px solid #cfe6d8; background: #f4fbf6; border-radius: 10px; padding: 9px 11px; }
.xl-ai-card-h { font-weight: 700; font-size: 12px; margin-bottom: 5px; color: #12603a; }
.xl-ai-card-list { margin: 0 0 8px; padding-left: 18px; font-size: 12px; color: #33413a; }
.xl-ai-card-list li { margin: 2px 0; }
.xl-ai-card-btns { display: flex; gap: 6px; }
.xl-ai-apply { border: none; background: #107c41; color: #fff; border-radius: 7px; padding: 5px 14px; cursor: pointer; font-weight: 600; }
.xl-ai-apply:hover { background: #0d6835; }
.xl-ai-cancel { border: 1px solid #cdd3ce; background: #fff; color: #4a514b; border-radius: 7px; padding: 5px 12px; cursor: pointer; }
.xl-ai-cancel:hover { border-color: #a9b0aa; }
.xl-ai-done { font-size: 12px; color: #12603a; margin: 4px 0 6px; }
.xl-ai-undo { border: 1px solid #cdd3ce; background: #fff; color: #4a514b; border-radius: 7px; padding: 4px 12px; cursor: pointer; }
.xl-ai-undo:hover { border-color: #a9b0aa; }
.xl-ai-undone { font-size: 11.5px; color: #6b726c; font-style: italic; }

/* ===================================================================== */
/* Excel — data-management upgrade (ribbon, selection, fill, filter…)    */
/* ===================================================================== */

/* Excel — single narrow ribbon row (no tabs, no in-app title bar). */
.excel-ribbon {
  padding: 2px 8px;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  background: #f8f8f8;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.excel-ribbon .office-ribbon-divider {
  margin: 1px 3px;
  align-self: stretch;
}
.excel-ribbon .office-ribbon-group {
  flex: 0 0 auto;
}

/* Legacy tabbed ribbon helpers (unused by Excel; kept for print rules). */
.xl-ribbon-shell {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}
.xl-ribbon-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 6px;
  background: #f3f3f3;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.xl-ribbon-tab {
  height: 22px;
  padding: 0 10px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #555;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.xl-ribbon-tab:hover { background: rgba(16, 124, 65, 0.07); color: #107c41; }
.xl-ribbon-tab.active {
  color: #107c41;
  border-bottom-color: #107c41;
  background: #fafafa;
}
.xl-ribbon-panel {
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  min-height: 0;
  overflow-x: auto;
  background: #fafafa;
}
.xl-ribbon-panel .office-ribbon-divider {
  margin: 1px 3px;
  align-self: stretch;
}

.xlb {
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: #333;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.xlb:hover { background: #e4efe8; border-color: rgba(16, 124, 65, 0.25); }
.xlb:active { background: #d2e6da; }
.xlb.on { background: #cfe8d8; border-color: #107c41; color: #0d6b38; }
.xlb.xl-primary { background: #107c41; color: #fff; }
.xlb.xl-primary:hover { background: #0d6b38; border-color: transparent; }
.xlb.xl-b { font-weight: 800; }
.xlb.xl-i { font-style: italic; font-family: Georgia, serif; }
.xlb.xl-u { text-decoration: underline; }
.xlb.xl-strike { text-decoration: line-through; }

.xl-font { max-width: 96px; }

.xl-select {
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 3px;
  background: #fff;
  font-size: 11px;
  padding: 0 2px;
  color: #222;
  cursor: pointer;
}
.xl-size { width: 46px; }
.xl-fmt { max-width: 108px; }
.xl-colorwrap {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: 11px;
  font-weight: 700;
  color: #444;
  cursor: pointer;
}
.xl-color {
  width: 20px;
  height: 20px;
  padding: 1px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

/* --- Grid: selection, headers, resize grips -------------------------------- */
.excel-table td.excel-cell {
  width: auto;               /* colgroup drives layout now */
  max-width: none;
  position: relative;
}
.excel-table td.excel-cell.in-range {
  background-color: var(--xl-range-fill);
}
/* One border around the whole selection, the way Excel draws it — each edge
   cell contributes only the side that lies on the perimeter. */
.excel-table td.excel-cell.rng-t { --xl-e-t: inset 0 1px 0 0 var(--xl-accent); }
.excel-table td.excel-cell.rng-b { --xl-e-b: inset 0 -1px 0 0 var(--xl-accent); }
.excel-table td.excel-cell.rng-l { --xl-e-l: inset 1px 0 0 0 var(--xl-accent); }
.excel-table td.excel-cell.rng-r { --xl-e-r: inset -1px 0 0 0 var(--xl-accent); }

.excel-table td.excel-cell.fill-prev {
  outline: 1px dashed var(--xl-accent);
  outline-offset: -1px;
}
.excel-table td.excel-cell.bd { border: 1px solid #444; }

/* Marching ants on the copied range. Four independent background layers, so a
   corner cell can show two edges at once — a single background-image could not. */
.excel-table td.excel-cell {
  --xl-a-t: none;
  --xl-a-b: none;
  --xl-a-l: none;
  --xl-a-r: none;
  background-image: var(--xl-a-t), var(--xl-a-b), var(--xl-a-l), var(--xl-a-r);
  background-size: 100% 2px, 100% 2px, 2px 100%, 2px 100%;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  background-repeat: no-repeat;
}
.excel-table td.excel-cell.ant-t { --xl-a-t: repeating-linear-gradient(90deg, var(--xl-accent) 0 4px, transparent 4px 8px); }
.excel-table td.excel-cell.ant-b { --xl-a-b: repeating-linear-gradient(90deg, var(--xl-accent) 0 4px, transparent 4px 8px); }
.excel-table td.excel-cell.ant-l { --xl-a-l: repeating-linear-gradient(180deg, var(--xl-accent) 0 4px, transparent 4px 8px); }
.excel-table td.excel-cell.ant-r { --xl-a-r: repeating-linear-gradient(180deg, var(--xl-accent) 0 4px, transparent 4px 8px); }
.excel-table td.excel-cell.ant-t,
.excel-table td.excel-cell.ant-b,
.excel-table td.excel-cell.ant-l,
.excel-table td.excel-cell.ant-r { animation: xl-march 0.7s linear infinite; }
@keyframes xl-march {
  to { background-position: 8px 0, -8px 100%, 0 -8px, 100% 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .excel-table td.excel-cell.ant-t,
  .excel-table td.excel-cell.ant-b,
  .excel-table td.excel-cell.ant-l,
  .excel-table td.excel-cell.ant-r { animation: none; }
}

/* Text that runs past its column paints over the empty cells beside it, the
   way Excel spills a long label. */
.excel-table td.excel-cell.spill { overflow: visible; z-index: 1; }

/* The handle sits on the corner of the selection and has to escape the cell's
   clip, or it is neither fully visible nor hit-testable. */
.excel-table td.excel-cell.fh-host { overflow: visible; z-index: 3; }
.excel-fillhandle {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 6px;
  height: 6px;
  background: var(--xl-accent);
  box-shadow: 0 0 0 1px #fff;
  cursor: crosshair;
  z-index: 6;
}

.excel-colhead, .excel-rowhead { user-select: none; cursor: default; }
.excel-colgrip {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 4;
}
.excel-rowgrip {
  position: absolute;
  left: 0;
  bottom: -3px;
  height: 7px;
  width: 100%;
  cursor: row-resize;
  z-index: 4;
}

/* --- AutoFilter ------------------------------------------------------------ */
.excel-filterbtn {
  position: absolute;
  right: 1px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  line-height: 1;
  font-size: 9px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 3px;
  background: #fff;
  color: #555;
  cursor: pointer;
  padding: 0;
}
.excel-filterbtn:hover { border-color: #107c41; color: #107c41; }
.excel-filterbtn.on { background: #107c41; border-color: #107c41; color: #fff; }

.excel-filter-pop {
  position: fixed;
  z-index: 10000;
  width: 230px;
  background: #fff;
  border: 1px solid #c9cfca;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.25);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #222;
}
.excel-filter-head { font-weight: 700; font-size: 12px; color: #12603a; }
.excel-filter-search {
  border: 1px solid #cdd3ce;
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 12px;
}
.excel-filter-search:focus { outline: none; border-color: #107c41; }
.excel-filter-list {
  max-height: 180px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid #e4e7e4;
  border-radius: 5px;
  padding: 3px;
}
.excel-filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.excel-filter-item:hover { background: #f0f6f2; }
.excel-filter-item input { accent-color: #107c41; }
.excel-filter-all { font-weight: 600; }
.excel-filter-btns { display: flex; gap: 5px; justify-content: flex-end; }

/* --- Find & Replace bar ----------------------------------------------------- */
.excel-findbar {
  position: absolute;
  top: 96px;
  right: 18px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 560px;
  background: #fff;
  border: 1px solid #c9cfca;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  padding: 8px;
  font-size: 12px;
}
.excel-find-in {
  border: 1px solid #cdd3ce;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12.5px;
  width: 150px;
}
.excel-find-in:focus { outline: none; border-color: #107c41; }
.excel-find-opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #555;
  white-space: nowrap;
}
.excel-find-opt input { accent-color: #107c41; }

/* --- Status bar: left text + right aggregates -------------------------------- */
.excel-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
/* The desktop themes style .app-statusbar through an #os-scoped rule, which
   out-specified Excel's own bar: the green never painted and the zoom controls,
   which are drawn for a dark background, came out nearly invisible. */
#os .excel-app .app-statusbar.excel-status {
  background: #107c41;
  color: #eafaf0;
  border-top: none;
}
.excel-status-agg {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0.95;
}
.excel-status-zoom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.excel-zoom-label {
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}
.excel-zoom-label:hover { background: rgba(255, 255, 255, 0.18); }
.excel-zoom-btn {
  height: 20px;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.excel-zoom-btn:hover { background: rgba(255, 255, 255, 0.24); }

@media print {
  .office-titlebar,
  .excel-ribbon,
  .office-rb,
  .xl-chart-layer,
  .xl-dlg-overlay,
  .xl-ribbon-shell,
  .excel-formula-bar,
  .excel-sheet-tabs,
  .excel-status,
  .xl-ai-fab,
  .xl-aiwin,
  .excel-findbar,
  .excel-open-progress { display: none !important; }
  .excel-app { background: #fff !important; }
  .excel-grid-scroll {
    overflow: visible !important;
    height: auto !important;
  }
  .excel-table th,
  .excel-table td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ============================================================================
   Shared Office ribbon (js/platform/office-ribbon.js)
   Tabbed ribbon in the PowerPoint-Studio shape: tab strip + grouped body.
   Per-app accents come from --orb-accent / --orb-accent-soft.
   ========================================================================== */
.office-rb {
  --orb-accent: #2f5496;
  --orb-accent-soft: #eaf0fa;
  --orb-accent-dark: #24406f;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.14);
  font-size: 12px;
  color: #20242d;
}
.office-rb.xl-ribbon {
  --orb-accent: #107c41;
  --orb-accent-soft: #e6f2ea;
  --orb-accent-dark: #0d6b38;
}

.office-rb-tabs {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 0 8px;
  min-height: 30px;
  background: #f6f7f9;
  border-bottom: 1px solid rgba(0, 0, 0, 0.09);
}
.office-rb-quick {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}
.office-rb-quick-btn {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #4a5160;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.office-rb-quick-btn:hover:not(:disabled) { background: #eceef2; color: #20242d; }
.office-rb-quick-btn:disabled { opacity: 0.32; cursor: default; }

.office-rb-tabset {
  display: flex;
  align-items: stretch;
  gap: 1px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.office-rb-tabset::-webkit-scrollbar { height: 0; }
.office-rb .office-rb-tab {
  position: relative;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: #4a5160;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.office-rb .office-rb-tab:hover { background: #eef0f3; color: #20242d; }
.office-rb .office-rb-tab.active { color: var(--orb-accent); background: #fff; }
.office-rb .office-rb-tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--orb-accent);
}
.office-rb .office-rb-tab.contextual {
  color: #8a4b16;
  background: #fdf3e7;
  border-top: 2px solid #d98324;
  border-radius: 3px 3px 0 0;
}
.office-rb .office-rb-tab.contextual.active { color: #8a4b16; background: #fff; }
.office-rb .office-rb-tab.contextual.active::after { background: #d98324; }

.office-rb-context {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-left: 8px;
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  color: #6b7280;
}
.office-rb-context-label { text-transform: uppercase; letter-spacing: 0.04em; font-size: 9.5px; opacity: 0.75; }
.office-rb-context strong { color: #20242d; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.office-rb-body {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 5px 6px 3px;
  overflow-x: auto;
  scrollbar-width: thin;
  min-height: 62px;
}
.office-rb-group {
  /* Never shrink below the controls' natural width: the body scrolls
     horizontally instead, so groups can't overlap each other. */
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3px;
  padding: 0 8px;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
}
.office-rb-group:last-child { border-right: 0; }
.office-rb-group.custom { min-width: 180px; }
.office-rb-group.wide { min-width: 260px; }
.office-rb-items {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex-wrap: nowrap;
}
.office-rb-sep {
  width: 1px;
  margin: 3px 4px;
  background: rgba(0, 0, 0, 0.09);
}
.office-rb-label {
  text-align: center;
  font-size: 9.5px;
  color: #8a90a0;
  letter-spacing: 0.02em;
  padding-top: 1px;
}

.office-rb-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #2b3140;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease;
}
.office-rb-btn:hover { background: var(--orb-accent-soft); border-color: rgba(0, 0, 0, 0.08); }
.office-rb-btn.active { background: var(--orb-accent-soft); border-color: var(--orb-accent); color: var(--orb-accent-dark); }
.office-rb-btn.big {
  flex-direction: column;
  gap: 1px;
  justify-content: center;
  min-width: 52px;
  padding: 3px 8px;
  min-height: 46px;
}
.office-rb-btn.primary { background: var(--orb-accent); border-color: var(--orb-accent); color: #fff; }
.office-rb-btn.primary:hover { background: var(--orb-accent-dark); border-color: var(--orb-accent-dark); }
.office-rb-btn.ai { color: #176d68; background: #e8f4f2; border-color: #cae5e1; }
.office-rb-btn.ai:hover { background: #d7ebe8; }
.office-rb-btn.danger { color: #b3261e; }
.office-rb-btn.disabled { opacity: 0.36; cursor: default; }
.office-rb-btn.disabled:hover { background: transparent; border-color: transparent; }
.office-rb-icon { font-size: 13px; line-height: 1; }
.office-rb-btn.big .office-rb-icon { font-size: 17px; }
.office-rb-text { line-height: 1.15; }
.office-rb-btn.big .office-rb-text { font-size: 10.5px; text-align: center; }
.office-rb-caret { font-size: 8px; opacity: 0.6; }

.office-rb-select {
  height: 22px;
  min-width: 70px;
  padding: 0 4px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  background: #fff;
  color: #20242d;
  font-size: 11.5px;
}
.office-rb-color {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 26px;
  height: 24px;
  padding: 1px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
.office-rb-color:hover { background: var(--orb-accent-soft); border-color: rgba(0, 0, 0, 0.08); }
.office-rb-color-glyph { font-size: 11px; font-weight: 700; line-height: 1; }
.office-rb-color-bar { width: 16px; height: 4px; border-radius: 1px; border: 1px solid rgba(0, 0, 0, 0.18); }
.office-rb-color-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

@media (max-width: 900px) {
  .office-rb-context { display: none; }
  .office-rb-btn.big { min-width: 44px; }
}

/* ============================================================================
   Excel report features — charts, dialogs, conditional formatting, validation
   ========================================================================== */

/* The grid scroller hosts the floating chart layer, so it anchors it. */
.excel-grid-scroll { position: relative; }

.xl-rb-stack { flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; }
.xl-rb-stack > .office-rb-items { justify-content: flex-start; }

/* --- Excel ribbon layout --------------------------------------------------
   word-app.css restyles the shared .office-rb-* classes for Word/PowerPoint
   (a two-row 24px CSS grid) and loads after this file, so those rules also hit
   Excel's ribbon: rows of buttons wrapped into a second track, Excel's custom
   Font/Number stacks grew to four rows (a ~152px-tall Home tab), and the
   fixed-size .big buttons let their labels spill over the neighbouring group.
   These rules restore Excel's single-row flex layout with enough specificity
   to win regardless of stylesheet order, and pin every group to one height so
   the tabs line up. ------------------------------------------------------- */
.office-rb.xl-ribbon .office-rb-body {
  align-items: flex-start;
  min-height: 0;
  padding: 4px 6px 2px;
}
.office-rb.xl-ribbon .office-rb-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 3px;
  /* One big button (50px) + the group label — every group is the same height. */
  min-height: 68px;
}
.office-rb.xl-ribbon .office-rb-items {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  min-height: 24px;
}
/* Group label sits on the baseline shared by every group. */
.office-rb.xl-ribbon .office-rb-label { margin-top: auto; }
.office-rb.xl-ribbon .office-rb-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  flex: 0 0 auto;
  height: 24px;
  min-height: 0;
  width: auto;
  padding: 2px 7px;
}
.office-rb.xl-ribbon .office-rb-btn.big {
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  height: 50px;
  width: auto;
  min-width: 54px;
  padding: 3px 8px;
}
/* Labels never overflow their button — that is what overlapped neighbours. */
.office-rb.xl-ribbon .office-rb-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Big buttons wrap their caption over two lines, as Excel does, rather than
   ellipsing it or letting it run over the next button. */
.office-rb.xl-ribbon .office-rb-btn.big .office-rb-text {
  max-width: 78px;
  white-space: normal;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-size: 10px;
  line-height: 1.12;
  text-align: center;
}
/* Two stacked 24px rows match the height of one big button. */
.office-rb.xl-ribbon .xl-rb-stack > .office-rb-items { min-height: 24px; }
.xl-rb-zoom {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; font-size: 11px; color: #4a5160;
}
.excel-app.painting .excel-grid-scroll { cursor: cell; }
.excel-app.no-gridlines .excel-table td { border-color: transparent; }

/* --- Floating charts ------------------------------------------------------ */
.xl-chart-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}
.xl-chart {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #c9ced8;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(15, 22, 36, 0.14);
  overflow: hidden;
}
.xl-chart.selected { border-color: #107c41; box-shadow: 0 0 0 2px rgba(16, 124, 65, 0.28), 0 4px 18px rgba(15, 22, 36, 0.2); }
.xl-chart.dragging, .xl-chart.resizing { opacity: 0.92; }
.xl-chart-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding: 0 6px;
  background: #f4f6f8;
  border-bottom: 1px solid #e2e6ec;
  cursor: move;
  font-size: 11px;
  user-select: none;
}
.xl-chart-name { font-weight: 600; color: #20242d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xl-chart-src { color: #7a8699; font-size: 10px; margin-left: auto; }
.xl-chart-menu {
  width: 20px; height: 18px; border: 0; border-radius: 3px;
  background: transparent; color: #5a6272; cursor: pointer; line-height: 1;
}
.xl-chart-menu:hover { background: #e3e7ed; }
.xl-chart-body {
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  padding: 4px;
}
.xl-chart-body svg { max-width: 100%; max-height: 100%; }
.xl-chart-loading, .xl-gallery-hint { color: #8a90a0; font-size: 12px; }
.xl-chart-warn {
  position: absolute; left: 6px; right: 6px; bottom: 4px;
  font-size: 10px; color: #8a4b16; background: #fdf3e7;
  border: 1px solid #f0d9bd; border-radius: 4px; padding: 2px 6px;
}
.xl-chart-error {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px; text-align: center; font-size: 11.5px; color: #6b7280;
}
.xl-chart-error strong { color: #b3261e; font-size: 12px; }
.xl-chart-grip {
  position: absolute; width: 10px; height: 10px; z-index: 2;
  background: #107c41; border: 1px solid #fff; border-radius: 2px;
  opacity: 0; transition: opacity 0.1s ease;
}
.xl-chart.selected .xl-chart-grip { opacity: 1; }
.xl-chart-grip.nw { left: -5px; top: -5px; cursor: nwse-resize; }
.xl-chart-grip.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.xl-chart-grip.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.xl-chart-grip.se { right: -5px; bottom: -5px; cursor: nwse-resize; }

/* --- Conditional formatting ----------------------------------------------- */
.excel-table td.cf-bar { position: relative; }
.excel-table td.cf-bar::before {
  content: "";
  position: absolute;
  left: 1px; top: 2px; bottom: 2px;
  width: var(--cf-bar-pct, 0%);
  background: var(--cf-bar-color, #638ec6);
  opacity: 0.42;
  border-radius: 2px;
  pointer-events: none;
}
.excel-table td.cf-bar > * { position: relative; }
.excel-table td.formula { font-family: "Cascadia Code", Consolas, monospace; font-size: 11px; color: #2f5496; }

/* --- Data validation ------------------------------------------------------ */
.excel-table td.has-validation { position: relative; padding-right: 16px; }
.excel-dvbtn {
  position: absolute;
  right: 1px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 15px;
  border: 1px solid #b7bdc8;
  border-radius: 2px;
  background: #f1f3f5;
  color: #4a5160;
  font-size: 8px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.excel-dvbtn:hover { background: #e2e6ec; }
.excel-table td.dv-invalid { outline: 2px solid #e03131; outline-offset: -2px; border-radius: 8px; }

/* --- Dialogs -------------------------------------------------------------- */
.xl-dlg-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 24, 32, 0.36);
  backdrop-filter: blur(1.5px);
  padding: 16px;
}
.xl-dlg {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 12px 44px rgba(10, 15, 25, 0.32);
  overflow: hidden;
  font-size: 12.5px;
  color: #20242d;
}
.xl-dlg.busy { pointer-events: none; opacity: 0.72; }
.xl-dlg-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #e6e9ee;
}
.xl-dlg-titles { flex: 1 1 auto; min-width: 0; }
.xl-dlg-title { font-size: 14px; font-weight: 600; }
.xl-dlg-sub { font-size: 11.5px; color: #6b7280; margin-top: 2px; }
.xl-dlg-x {
  width: 24px; height: 24px; border: 0; border-radius: 4px;
  background: transparent; color: #6b7280; font-size: 18px; line-height: 1; cursor: pointer;
}
.xl-dlg-x:hover { background: #f0f2f5; color: #20242d; }
.xl-dlg-body { flex: 1 1 auto; overflow-y: auto; padding: 12px 14px; }
.xl-dlg-error {
  margin: 0; padding: 7px 14px;
  background: #fdecea; color: #9c0006;
  border-bottom: 1px solid #f5c6cb; font-size: 11.5px;
}
.xl-dlg-busy { padding: 8px 14px; font-size: 11.5px; color: #6b7280; }
.xl-dlg-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #e6e9ee;
  background: #fafbfc;
}
.xl-dlg-btn {
  min-height: 27px;
  padding: 0 12px;
  border: 1px solid #c9ced8;
  border-radius: 5px;
  background: #fff;
  color: #20242d;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.xl-dlg-btn:hover:not(:disabled) { background: #f2f4f7; }
.xl-dlg-btn:disabled { opacity: 0.4; cursor: default; }
.xl-dlg-btn.primary { background: #107c41; border-color: #107c41; color: #fff; }
.xl-dlg-btn.primary:hover:not(:disabled) { background: #0d6b38; }
.xl-dlg-btn.danger { color: #b3261e; border-color: #e7c4c1; }
.xl-dlg-btn.danger:hover:not(:disabled) { background: #fdecea; }
.xl-dlg-note { font-size: 11.5px; color: #6b7280; margin: 6px 0 0; }
.xl-dlg-section { margin-bottom: 14px; }
.xl-dlg-section-title {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #8a90a0; margin-bottom: 6px;
}
.xl-dlg-row { display: flex; gap: 10px; flex-wrap: wrap; }
.xl-dlg-row > * { flex: 1 1 140px; min-width: 0; }
.xl-notes-kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.xl-notes-kv th,
.xl-notes-kv td {
  text-align: left;
  vertical-align: top;
  padding: 7px 8px;
  border-bottom: 1px solid #e6e9ee;
}
.xl-notes-kv th {
  width: 38%;
  color: #4a5160;
  font-weight: 600;
}
.xl-notes-lines {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #374151;
  font-size: 12.5px;
  line-height: 1.45;
}

.xl-field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.xl-field-label { font-size: 11.5px; font-weight: 500; color: #4a5160; }
.xl-field-hint { font-size: 10.5px; color: #8a90a0; }
.xl-input, .xl-select-field {
  height: 27px;
  padding: 0 7px;
  border: 1px solid #c9ced8;
  border-radius: 5px;
  background: #fff;
  color: #20242d;
  font-size: 12px;
  width: 100%;
}
.xl-input:focus, .xl-select-field:focus { outline: 2px solid rgba(16, 124, 65, 0.35); outline-offset: -1px; border-color: #107c41; }
.xl-check { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; font-size: 12px; cursor: pointer; }
.xl-color-field { width: 42px; height: 26px; padding: 0; border: 1px solid #c9ced8; border-radius: 5px; background: #fff; cursor: pointer; }

/* --- Chart gallery -------------------------------------------------------- */
.xl-gallery { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 14px; }
.xl-gallery-list { max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.xl-gallery-group {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #8a90a0; margin: 10px 0 5px;
}
.xl-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 5px; }
.xl-gallery-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px;
  border: 1px solid #e0e4ea;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 10.5px;
  color: #2b3140;
  text-align: center;
}
.xl-gallery-item:hover { background: #e6f2ea; border-color: #b6d9c5; }
.xl-gallery-item.selected { background: #e6f2ea; border-color: #107c41; box-shadow: inset 0 0 0 1px #107c41; }
.xl-gallery-item.ineligible { opacity: 0.34; }
.xl-gallery-icon { font-size: 17px; line-height: 1; }
.xl-gallery-label { line-height: 1.2; }
.xl-gallery-preview {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 10px;
  border: 1px solid #e0e4ea; border-radius: 6px; background: #fbfcfd;
  min-height: 320px;
}
.xl-gallery-preview svg { max-width: 100%; height: auto; }
.xl-gallery-preview-title { font-size: 11.5px; font-weight: 600; color: #4a5160; }

/* --- Chart format dialog -------------------------------------------------- */
.xl-chart-dlg-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 14px; }
.xl-chart-dlg-preview {
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #e0e4ea; border-radius: 6px; background: #fbfcfd;
  min-height: 300px; padding: 8px;
}
.xl-chart-dlg-preview svg { max-width: 100%; height: auto; }

/* --- Analysis dialog ------------------------------------------------------ */
.xl-analysis-recs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.xl-analysis-recs-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: #8a90a0;
}
.xl-analysis-rec {
  padding: 3px 9px;
  border: 1px solid #cae5e1; border-radius: 12px;
  background: #e8f4f2; color: #176d68;
  font-size: 11.5px; cursor: pointer;
}
.xl-analysis-rec:hover { background: #d7ebe8; }
.xl-analysis-req, .xl-analysis-assume, .xl-analysis-plot {
  font-size: 11.5px; color: #6b7280; margin-bottom: 4px;
}
.xl-analysis-req strong, .xl-analysis-assume strong, .xl-analysis-plot strong { color: #4a5160; }
.xl-analysis-warn {
  background: #fdf3e7; border: 1px solid #f0d9bd; border-radius: 5px;
  padding: 6px 9px; font-size: 11.5px; color: #8a4b16; margin-bottom: 8px;
}
.xl-analysis-table { border-collapse: collapse; width: 100%; margin: 4px 0 12px; font-size: 11.5px; }
.xl-analysis-table th, .xl-analysis-table td { border: 1px solid #e0e4ea; padding: 3px 7px; text-align: left; }
.xl-analysis-table th { background: #f1f3f5; font-weight: 600; }
.xl-analysis-table-title { font-size: 11.5px; font-weight: 600; color: #4a5160; margin-top: 8px; }
.xl-analysis-interp {
  background: #f6f8fa; border-left: 3px solid #107c41;
  padding: 7px 10px; font-size: 11.5px; line-height: 1.45;
}
.xl-analysis-result { margin-top: 10px; }

/* --- Conditional formatting manager --------------------------------------- */
.xl-cf-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.xl-cf-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border: 1px solid #e0e4ea; border-radius: 6px; background: #fff;
}
.xl-cf-swatch {
  width: 46px; height: 22px; flex: 0 0 auto;
  border: 1px solid #d5d9e0; border-radius: 4px;
  display: flex; align-items: center; justify-content: center; font-size: 10px;
}
.xl-cf-desc { flex: 1 1 auto; min-width: 0; }
.xl-cf-title { font-size: 12px; }
.xl-cf-range { font-size: 10.5px; color: #8a90a0; }
.xl-cf-btns { display: flex; gap: 4px; }
.xl-cf-btns .xl-dlg-btn { min-height: 23px; padding: 0 8px; font-size: 11px; }
.xl-cf-actions { display: flex; gap: 8px; }

/* --- Pivot / tools -------------------------------------------------------- */
.xl-pivot-line { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.xl-pivot-line .xl-select-field { flex: 1 1 auto; }
.xl-pivot-line .xl-dlg-btn { min-height: 25px; padding: 0 8px; }
.xl-pivot-preview { max-height: 260px; overflow: auto; }
.xl-tool-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px; margin-bottom: 8px; }
.xl-tool-btns, .xl-tool-levels { display: flex; gap: 8px; }
.xl-tool-levels { flex-direction: column; gap: 5px; }
.xl-tool-level-label { font-size: 11px; color: #6b7280; min-width: 52px; }
.xl-tool-preview { max-height: 200px; overflow: auto; }

@media (max-width: 1000px) {
  .xl-gallery, .xl-chart-dlg-wrap { grid-template-columns: 1fr; }
  .xl-gallery-preview, .xl-chart-dlg-preview { min-height: 220px; }
}
