:root {
  --fm-navy: #171c8f;
  --fm-navy-dark: #12125f;
  --header-bg: #e6e6e6;
  --header-border: #b0b0b0;
  --grid: #d0d0d0;
  --sel: #171c8f;
  --sel-bg: #ddebf7;
  --formula-bg: #fff;
  --sheet-bg: #f3f3f3;
  --font: "Segoe UI", Calibri, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
}
body {
  font-family: var(--font);
  background: var(--sheet-bg);
  color: #000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.has-menubar { padding-top: 32px; }

.xl-menubar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  background: var(--fm-navy);
  color: #fff;
  font-size: 12px;
}
.xl-menubar-home {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 6px 0 2px;
  margin-right: 4px;
  text-decoration: none;
}
.xl-menubar-logo {
  height: 18px;
  width: auto;
  display: block;
  filter: brightness(0) invert(1);
}
.xl-menubar-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.28);
  margin: 0 4px;
}
.xl-menubar-dropdown { position: relative; }
.xl-menubar-item {
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 2px;
}
.xl-menubar-item:hover,
.xl-menubar-dropdown.is-open > .xl-menubar-item {
  background: rgba(255, 255, 255, 0.16);
}
.xl-menubar-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #fff;
  color: #222;
  border: 1px solid var(--header-border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  padding: 4px 0;
  z-index: 40;
}
.xl-menubar-dropdown.is-open > .xl-menubar-menu { display: block; }
.xl-menubar-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  padding: 7px 12px;
  cursor: pointer;
}
.xl-menubar-menu button:hover { background: #f3f3f3; }
.xl-menubar-spacer { flex: 1; }
.xl-menubar-hint {
  font-size: 11px;
  opacity: 0.75;
  padding-right: 8px;
  white-space: nowrap;
}

.xl-formula {
  flex: 0 0 auto;
  height: 28px;
  display: flex;
  align-items: stretch;
  background: #fff;
  border-bottom: 1px solid var(--header-border);
  font-size: 12px;
}
.xl-namebox {
  width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--header-border);
  background: #fafafa;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.xl-fx {
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--header-border);
  color: #666;
  font-style: italic;
  font-family: Georgia, serif;
}
.xl-formula-input {
  flex: 1;
  border: 0;
  outline: none;
  padding: 0 8px;
  font: inherit;
  background: var(--formula-bg);
}
.xl-formula-input[readonly] { color: #333; }

.xl-stage {
  flex: 1 1 auto;
  min-height: 12rem;
  height: calc(100dvh - 56px);
  overflow: auto;
  background: #c6c6c6;
  position: relative;
}
body.has-menubar .xl-stage {
  height: calc(100dvh - 88px);
}
.xl-grid-wrap {
  display: inline-block;
  min-width: 100%;
  background: #fff;
}

table.xl-sheet {
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
  background: #fff;
}
table.xl-sheet thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 20px;
  background: var(--header-bg);
  border: 1px solid var(--header-border);
  font-size: 11px;
  font-weight: 600;
  color: #333;
  text-align: center;
  user-select: none;
}
table.xl-sheet thead th.corner {
  left: 0;
  z-index: 5;
  width: 40px;
  min-width: 40px;
}
table.xl-sheet tbody th {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 40px;
  min-width: 40px;
  background: var(--header-bg);
  border: 1px solid var(--header-border);
  font-size: 11px;
  font-weight: 600;
  color: #333;
  text-align: center;
  user-select: none;
}
table.xl-sheet td {
  border: 1px solid var(--grid);
  padding: 2px 6px;
  height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  background: #fff;
}
table.xl-sheet td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.xl-sheet td.header-row {
  background: #d9e2f3;
  font-weight: 700;
}
table.xl-sheet td.subtotal {
  background: #fff2cc;
  font-weight: 700;
}
table.xl-sheet td.section-row {
  background: var(--fm-navy) !important;
  color: #fff !important;
  font-weight: 700;
}
table.xl-sheet td.note-cell {
  background: #f0f7ff;
  white-space: normal;
  overflow: visible;
  height: auto;
  min-height: 22px;
  line-height: 1.35;
  padding: 4px 6px;
}
table.xl-sheet td.wrap {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.35;
  height: auto;
  min-height: 22px;
}
table.xl-sheet td.xl-input { background: #fff2cc; }
table.xl-sheet tr.selected td,
table.xl-sheet tr.selected th { background: var(--sel-bg) !important; }
table.xl-sheet tr.selected td.section-row {
  background: var(--fm-navy) !important;
  color: #fff !important;
}
table.xl-sheet td.selected-cell {
  outline: 2px solid var(--sel);
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

input.xl-edit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  font: inherit;
  padding: 0 6px;
  background: #fff;
}

.cA { width: 340px; }
.cB { width: 110px; }
.cC { width: 130px; }
.cD { width: 360px; }
.cE { width: 380px; }
.cF { width: 90px; }
.cG { width: 90px; }
.cH { width: 90px; }
.cI { width: 90px; }
.cJ { width: 80px; }
.cK { width: 280px; }
.cL { width: 90px; }

.xl-sheet-pricing .cA { width: 200px; }
.xl-sheet-pricing .cB { width: 180px; }
.xl-sheet-pricing .cC { width: 180px; }
.xl-sheet-pricing .cD,
.xl-sheet-pricing .cE { width: 120px; }

.xl-tabs {
  flex: 0 0 auto;
  height: 28px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 8px;
  background: #e9e9e9;
  border-top: 1px solid var(--header-border);
}
.xl-tab {
  height: 24px;
  padding: 0 14px;
  border: 1px solid var(--header-border);
  border-bottom: 0;
  background: #dcdcdc;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: #333;
}
.xl-tab.active {
  background: #fff;
  font-weight: 600;
  border-top: 2px solid var(--fm-navy);
}
.xl-tab-add {
  width: 24px;
  justify-content: center;
  font-weight: 700;
  color: #666;
  cursor: default;
}
.hidden-sheet { display: none; }

.logout-bar {
  position: fixed;
  top: 2px;
  right: 8px;
  z-index: 35;
  background: transparent;
  border: 0;
  padding: 0;
}
.logout-bar-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font: 12px/1 var(--font);
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 2px;
}
.logout-bar-btn:hover { background: rgba(255, 255, 255, 0.16); }

@media (max-width: 900px) {
  .xl-stage {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }
  .xl-menubar-hint { display: none; }
}

@media print {
  body.has-menubar { padding-top: 0; }
  .xl-menubar, .xl-formula, .xl-tabs, .logout-bar { display: none !important; }
  .xl-stage { height: auto; overflow: visible; background: #fff; }
  table.xl-sheet thead th,
  table.xl-sheet tbody th { position: static; }
}
