.iwg-root {
  --iwg-navy: #17364b;
  --iwg-navy-strong: #0d2b41;
  --iwg-teal: #2c9d8f;
  --iwg-teal-dark: #187f75;
  --iwg-blue: #1673e6;
  --iwg-text: #17324a;
  --iwg-muted: #64768a;
  --iwg-border: #d4dde5;
  --iwg-border-strong: #b9c7d3;
  --iwg-surface: #ffffff;
  --iwg-surface-muted: #f5f8fa;
  --iwg-band: #e9f5fa;
  --iwg-selected: #d9eafd;
  --iwg-danger: #d82d2d;
  --iwg-danger-soft: #fff0ef;
  --iwg-success: #187d48;
  --iwg-success-soft: #eaf7ef;
  --iwg-row-header-width: 48px;
  --iwg-column-header-height: 60px;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: 50px 44px 56px 44px minmax(482px, 1fr) 42px;
  min-width: 1180px;
  min-height: 720px;
  height: 100%;
  overflow: hidden;
  color: var(--iwg-text);
  background: var(--iwg-surface);
  border: 1px solid #b9c6d0;
  font: 13px/1.35 Inter, Aptos, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  outline: none;
}

.iwg-root *, .iwg-root *::before, .iwg-root *::after { box-sizing: border-box; }
.iwg-root button, .iwg-root input, .iwg-root select { font: inherit; color: inherit; }
.iwg-root button:focus-visible, .iwg-root input:focus-visible, .iwg-root select:focus-visible { outline: 2px solid var(--iwg-blue); outline-offset: 1px; }
.iwg-root button { border: 0; background: transparent; }
.iwg-root button:not(:disabled) { cursor: pointer; }
.iwg-root button:disabled { cursor: default; opacity: .44; }
.iwg-icon { display: block; width: 19px; height: 19px; flex: 0 0 auto; }

.iwg-topbar {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 18px;
  padding: 0 18px;
  color: #fff;
  background: var(--iwg-navy);
  border-bottom: 1px solid #0a2a3f;
  white-space: nowrap;
}
.iwg-brand { display: flex; align-items: center; gap: 9px; font-size: 20px; font-weight: 720; letter-spacing: -.03em; }
.iwg-brand-mark { position: relative; display: grid; grid-template-columns: repeat(3, 4px); gap: 3px; width: 18px; height: 18px; transform: rotate(45deg); }
.iwg-brand-mark i { width: 4px; height: 4px; border-radius: 50%; background: #5fd3dc; }
.iwg-brand-mark i:nth-child(4), .iwg-brand-mark i:nth-child(7) { grid-column: 2; }
.iwg-workbook-title { max-width: 280px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 650; }
.iwg-topbar-divider { width: 1px; height: 22px; background: rgb(255 255 255 / 24%); }
.iwg-bindings { display: flex; align-items: center; min-width: 0; gap: 0; color: #d7e5ed; font-size: 12px; }
.iwg-bindings > span { min-width: 0; padding: 0 15px; border-left: 1px solid rgb(255 255 255 / 20%); }
.iwg-bindings > span:first-child { border-left: 0; }
.iwg-binding-value { color: #fff; font-weight: 620; }

.iwg-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 56px;
  background: #fff;
  border-bottom: 1px solid var(--iwg-border);
}
.iwg-tab { position: relative; min-width: 104px; padding: 0 20px; font-size: 13px; font-weight: 540; }
.iwg-tab:hover { background: #f7f9fb; }
.iwg-tab.is-active { color: var(--iwg-text); font-weight: 680; }
.iwg-tab.is-active::after { content: ""; position: absolute; right: 13px; bottom: 0; left: 13px; height: 3px; background: var(--iwg-blue); }

.iwg-toolbar {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 3px;
  padding: 8px 12px;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid var(--iwg-border);
}
.iwg-command {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  height: 36px;
  padding: 0 9px;
  border-radius: 4px;
  color: #244159;
  font-size: 12px;
  font-weight: 560;
}
.iwg-command:hover:not(:disabled), .iwg-command.is-active { background: #eaf2f8; color: #0c4f82; }
.iwg-command-icon-only { width: 30px; height: 30px; justify-content: center; padding: 0; }
.iwg-command-icon-only .iwg-icon { width: 16px; height: 16px; }
.iwg-command-separator { flex: 0 0 auto; width: 1px; height: 28px; margin: 0 5px; background: var(--iwg-border); }
.iwg-command-spacer { flex: 1 1 auto; min-width: 4px; }
.iwg-search { display: flex; align-items: center; width: 190px; height: 36px; gap: 5px; padding-left: 10px; border: 1px solid var(--iwg-border); border-radius: 4px; background: #fff; }
.iwg-search > .iwg-icon { width: 17px; height: 17px; color: #587086; }
.iwg-search-input { min-width: 0; width: 100%; height: 32px; padding: 0 2px; border: 0; outline: 0 !important; background: transparent; font-size: 12px; }
.iwg-search:focus-within { border-color: var(--iwg-blue); box-shadow: 0 0 0 1px var(--iwg-blue); }

.iwg-formula-bar { display: grid; grid-template-columns: 132px 42px minmax(0, 1fr); align-items: center; padding: 6px 10px; background: #f9fbfc; border-bottom: 1px solid var(--iwg-border); }
.iwg-name-box, .iwg-formula-input { height: 32px; border: 1px solid var(--iwg-border-strong); background: #fff; }
.iwg-name-box { width: 100%; padding: 0 10px; border-radius: 4px 0 0 4px; font-weight: 620; }
.iwg-fx { display: grid; place-items: center; height: 32px; color: #36566f; border-top: 1px solid var(--iwg-border-strong); border-bottom: 1px solid var(--iwg-border-strong); background: #f3f6f8; font: italic 650 14px Georgia, serif; }
.iwg-formula-input { width: 100%; min-width: 0; padding: 0 10px; border-radius: 0 4px 4px 0; }
.iwg-formula-input[readonly] { color: #516579; background: #f8fafb; }

.iwg-main { display: grid; grid-template-columns: minmax(0, 1fr) 250px; min-width: 0; min-height: 0; overflow: hidden; }
.iwg-main.is-inspector-closed { grid-template-columns: minmax(0, 1fr); }
.iwg-grid-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #fff; }
.iwg-grid-corner { position: absolute; z-index: 5; top: 0; left: 0; width: var(--iwg-row-header-width); height: var(--iwg-column-header-height); background: #f2f5f7; border-right: 1px solid var(--iwg-border); border-bottom: 1px solid var(--iwg-border-strong); }
.iwg-grid-corner::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 0; height: 0; border-right: 7px solid #93a3b2; border-top: 7px solid transparent; }
.iwg-header-viewport { position: absolute; z-index: 4; top: 0; right: 0; left: var(--iwg-row-header-width); height: var(--iwg-column-header-height); overflow: hidden; background: #f8fafb; border-bottom: 1px solid var(--iwg-border-strong); }
.iwg-header-track { position: relative; height: 100%; will-change: transform; }
.iwg-header-cell { position: absolute; top: 0; bottom: 0; display: grid; grid-template-rows: 24px 35px; overflow: hidden; color: #fff; background: var(--iwg-teal); border-right: 1px solid rgb(17 103 96 / 58%); user-select: none; }
.iwg-header-cell:hover { background: #268f83; }
.iwg-header-cell.is-sorted { background: var(--iwg-teal-dark); }
.iwg-header-letter { display: grid; place-items: center; color: #425a6c; background: #f2f5f7; border-bottom: 1px solid var(--iwg-border); font-size: 11px; font-weight: 520; }
.iwg-header-label { display: block; align-self: center; padding: 0 25px 0 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 720; }
.iwg-sort-indicator { position: absolute; right: 8px; bottom: 9px; width: 14px; height: 14px; }
.iwg-resize-handle { position: absolute; z-index: 2; top: 24px; right: -3px; bottom: 0; width: 8px; cursor: col-resize; }
.iwg-resize-handle:hover { background: rgb(255 255 255 / 50%); }
.iwg-row-header-viewport { position: absolute; z-index: 3; top: var(--iwg-column-header-height); bottom: 0; left: 0; width: var(--iwg-row-header-width); overflow: hidden; background: #f5f7f9; border-right: 1px solid var(--iwg-border-strong); }
.iwg-row-header-track { position: relative; width: 100%; will-change: transform; }
.iwg-row-header { position: absolute; right: 0; left: 0; display: grid; place-items: center; color: #5f7182; border-bottom: 1px solid var(--iwg-border); font-size: 11px; user-select: none; }
.iwg-body-viewport { position: absolute; top: var(--iwg-column-header-height); right: 0; bottom: 0; left: var(--iwg-row-header-width); overflow: auto; outline: none; background: #fff; scrollbar-color: #a7b6c3 #edf1f4; scrollbar-width: thin; }
.iwg-body-content, .iwg-cells-layer { position: relative; min-width: 100%; min-height: 100%; }
.iwg-cell { position: absolute; display: flex; align-items: center; min-width: 0; overflow: hidden; padding: 0 8px; color: #2a4053; background: #fff; border-right: 1px solid var(--iwg-border); border-bottom: 1px solid var(--iwg-border); font-size: 11px; white-space: nowrap; user-select: none; }
.iwg-cell.is-banded { background: var(--iwg-band); }
.iwg-cell.is-selected { background: var(--iwg-selected); }
.iwg-cell.is-active { z-index: 2; box-shadow: inset 0 0 0 2px var(--iwg-blue); }
.iwg-cell.is-danger-soft { color: var(--iwg-danger); background: var(--iwg-danger-soft); }
.iwg-cell.is-success-soft { color: var(--iwg-success); background: var(--iwg-success-soft); }
.iwg-cell.is-danger-text { color: var(--iwg-danger); }
.iwg-cell.is-numeric { justify-content: flex-end; font-variant-numeric: tabular-nums; }
.iwg-cell-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.iwg-cell-chevron { width: 13px; height: 13px; margin-left: auto; color: #718598; }
.iwg-formula-marker { margin-left: 5px; color: #58758d; font: italic 600 9px Georgia, serif; }
.iwg-validation-icon { width: 13px; height: 13px; margin-left: 5px; color: var(--iwg-danger); }
.iwg-checkbox { width: 17px; height: 17px; margin: auto; accent-color: var(--iwg-blue); }
.iwg-cell-editor { position: absolute; z-index: 4; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); padding: 0 6px; border: 1px solid var(--iwg-blue); border-radius: 2px; background: #fff; box-shadow: 0 2px 8px rgb(20 54 80 / 20%); font-size: 11px; }

.iwg-inspector { min-width: 0; overflow: hidden; background: #fff; border-left: 1px solid var(--iwg-border-strong); }
.iwg-inspector-header { display: flex; align-items: center; justify-content: space-between; height: 48px; padding: 0 14px; border-bottom: 1px solid var(--iwg-border); font-size: 12px; }
.iwg-close { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 3px; }
.iwg-close:hover { background: #edf3f7; }
.iwg-close .iwg-icon { width: 17px; height: 17px; }
.iwg-inspector-body { height: calc(100% - 48px); overflow: auto; }
.iwg-inspector-section { padding: 13px 14px; border-bottom: 1px solid var(--iwg-border); }
.iwg-inspector-section h3 { margin: 0 0 10px; font-size: 12px; font-weight: 720; }
.iwg-inspector-list { display: grid; gap: 8px; margin: 0; }
.iwg-inspector-list div { display: grid; gap: 2px; }
.iwg-inspector-list dt { color: var(--iwg-muted); font-size: 10px; }
.iwg-inspector-list dd { margin: 0; overflow-wrap: anywhere; font-size: 11px; font-weight: 560; }
.iwg-inspector-action, .iwg-panel-button { min-height: 30px; margin-top: 11px; padding: 0 10px; color: #1e5478; border: 1px solid #b8c9d6 !important; border-radius: 3px; background: #fff !important; font-size: 11px !important; font-weight: 650 !important; }
.iwg-inspector-action:hover:not(:disabled), .iwg-panel-button:hover:not(:disabled) { background: #eef5f8 !important; }
.iwg-hook-result { max-height: 150px; margin: 0; padding: 12px 14px; overflow: auto; color: #244259; background: #f6f9fa; border-top: 1px solid var(--iwg-border); font: 10px/1.45 "Cascadia Code", Consolas, monospace; white-space: pre-wrap; }
.iwg-empty { margin: 0; padding: 18px 14px; color: var(--iwg-muted); font-size: 11px; }

.iwg-statusbar { display: flex; align-items: center; min-width: 0; gap: 22px; padding: 0 18px; overflow: hidden; color: #e8f1f6; background: var(--iwg-navy-strong); border-top: 1px solid #08243a; font-size: 11px; white-space: nowrap; }
.iwg-status-spacer { flex: 1 1 auto; }
.iwg-status-message { min-width: 0; max-width: 360px; overflow: hidden; color: #b9d9e7; text-overflow: ellipsis; }
.iwg-status-message[data-tone="error"] { color: #ffaaa3; }
.iwg-status-message[data-tone="success"] { color: #91e0b2; }

.iwg-popover { position: absolute; z-index: 20; top: 142px; padding: 14px; color: var(--iwg-text); background: #fff; border: 1px solid var(--iwg-border-strong); border-radius: 4px; box-shadow: 0 12px 30px rgb(27 53 73 / 22%); }
.iwg-popover[hidden] { display: none; }
.iwg-popover header { display: flex; align-items: center; justify-content: space-between; min-height: 32px; margin: -5px -5px 9px 0; }
.iwg-filter-panel { left: 420px; width: 300px; }
.iwg-filter-panel label { display: grid; gap: 4px; margin-top: 9px; color: var(--iwg-muted); font-size: 10px; font-weight: 650; }
.iwg-field { width: 100%; height: 34px; padding: 0 8px; color: var(--iwg-text); border: 1px solid var(--iwg-border-strong); border-radius: 3px; background: #fff; }
.iwg-filter-panel footer { display: flex; justify-content: flex-end; gap: 8px; }
.iwg-panel-button.is-primary { color: #fff !important; border-color: var(--iwg-blue) !important; background: var(--iwg-blue) !important; }
.iwg-columns-panel { left: 520px; width: 340px; max-height: calc(100% - 170px); overflow: auto; }
.iwg-columns-panel > p { margin: 0 0 10px; color: var(--iwg-muted); font-size: 10px; }
.iwg-columns-list { display: grid; }
.iwg-column-row { display: flex; align-items: center; justify-content: space-between; min-height: 36px; gap: 10px; border-top: 1px solid #edf1f4; }
.iwg-column-row label { display: flex; align-items: center; min-width: 0; gap: 8px; font-size: 11px; }
.iwg-column-row label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iwg-column-actions { display: flex; }
.iwg-column-actions button { display: grid; place-items: center; width: 28px; height: 28px; }
.iwg-column-actions button:hover:not(:disabled) { background: #edf3f7; }
.iwg-column-actions .iwg-icon { width: 15px; height: 15px; }

@media (prefers-reduced-motion: reduce) {
  .iwg-root *, .iwg-root *::before, .iwg-root *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* WP-CD04 authoritative, server-windowed read surface. */
.iwg-authoritative { grid-template-rows: 50px 56px 34px 44px minmax(482px, 1fr) 42px; }
.iwg-authoritative-inline { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 11px; }
.iwg-authoritative-badge { padding: 4px 8px; color: #d9fff8; border: 1px solid rgb(217 255 248 / 45%); border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.iwg-authoritative-select, .iwg-authoritative-input { height: 32px; min-width: 110px; max-width: 180px; padding: 0 7px; border: 1px solid var(--iwg-border-strong); border-radius: 3px; background: #fff; font-size: 11px; }
.iwg-authoritative-toolbar { gap: 6px; overflow-x: auto; }
.iwg-authoritative-toolbar .iwg-search { flex: 0 0 190px; }
.iwg-authoritative-toolbar .iwg-panel-button { flex: 0 0 auto; margin: 0; }
.iwg-authoritative-query-state { display: flex; align-items: center; padding: 0 14px; overflow: hidden; color: var(--iwg-muted); background: #f8fafb; border-bottom: 1px solid var(--iwg-border); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.iwg-authoritative-columns { display: flex; align-items: center; gap: 12px; padding: 5px 12px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--iwg-border); font-size: 10px; white-space: nowrap; }
.iwg-authoritative-column-toggle { display: inline-flex; align-items: center; gap: 4px; }
.iwg-authoritative-columns .iwg-panel-button { flex: 0 0 auto; min-height: 28px; margin: 0; }
.iwg-authoritative-grid-stage { display: grid; grid-template-rows: 42px minmax(0, 1fr); min-width: 0; min-height: 0; overflow: hidden; background: #fff; }
.iwg-authoritative-grid-header { display: grid; overflow: hidden; padding-right: 12px; color: #fff; background: var(--iwg-teal); border-bottom: 1px solid var(--iwg-border-strong); }
.iwg-authoritative-header-cell { min-width: 0; padding: 0 9px; overflow: hidden; color: #fff !important; border-right: 1px solid rgb(17 103 96 / 58%) !important; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.iwg-authoritative-header-cell:hover { background: var(--iwg-teal-dark); }
.iwg-authoritative-header-cell.is-pinned { font-weight: 750; }
.iwg-authoritative-body { position: relative; min-width: 0; min-height: 0; overflow: auto; outline: none; background: #fff; scrollbar-color: #a7b6c3 #edf1f4; scrollbar-width: thin; }
.iwg-authoritative-spacer { width: 1px; min-height: 100%; }
.iwg-authoritative-row-layer { position: absolute; top: 0; right: 0; left: 0; }
.iwg-authoritative-row { display: grid; width: 100%; height: 32px; padding: 0; color: var(--iwg-text); background: #fff; border-bottom: 1px solid var(--iwg-border) !important; text-align: left; }
.iwg-authoritative-row:nth-child(even) { background: var(--iwg-band); }
.iwg-authoritative-row:hover { background: #e8f1fb; }
.iwg-authoritative-row.is-selected { background: var(--iwg-selected); box-shadow: inset 0 0 0 2px var(--iwg-blue); }
.iwg-authoritative-row > span { min-width: 0; padding: 8px 9px; overflow: hidden; border-right: 1px solid var(--iwg-border); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.iwg-authoritative-row > span.is-pinned { font-weight: 650; }
.iwg-authoritative-inspector { overflow: auto; }
.iwg-authoritative-inspector .iwg-inspector-body { height: auto; }
.iwg-authoritative-cells, .iwg-authoritative-diff-list { display: grid; }
.iwg-authoritative-cell-card { padding: 10px 14px; border-bottom: 1px solid var(--iwg-border); }
.iwg-authoritative-cell-card h4 { margin: 0 0 8px; font-size: 11px; }
.iwg-authoritative-relations { display: flex; flex-wrap: wrap; gap: 5px; }
.iwg-authoritative-relations .iwg-panel-button { margin: 0; }
.iwg-authoritative-status { gap: 10px; }
.iwg-authoritative-status .iwg-authoritative-select { height: 28px; }
.iwg-authoritative-status-button { min-height: 28px; padding: 0 9px; color: #fff !important; border: 1px solid rgb(255 255 255 / 35%) !important; border-radius: 3px; }
.iwg-authoritative-status-button:hover { background: rgb(255 255 255 / 12%); }

.iwg-interactions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 42px; padding: 7px 12px; border-top: 1px solid var(--iwg-border); background: #f7fafc; color: var(--iwg-text); font: 12px/1.35 Inter, ui-sans-serif, system-ui, sans-serif; }
.iwg-interactions .iwg-status-message { margin-left: auto; }
.iwg-interaction-help { max-width: 260px; color: var(--iwg-muted); }
.iwg-interaction-annotation { width: 220px; max-height: 72px; resize: vertical; border: 1px solid var(--iwg-border); border-radius: 3px; color: var(--iwg-text); background: #fff; }
.iwg-interaction-range { min-width: 170px; max-height: 92px; border: 1px solid var(--iwg-border); border-radius: 3px; background: #fff; }
.iwg-interaction-matrix { display: flex; flex-wrap: wrap; max-width: 440px; max-height: 92px; gap: 4px; overflow: auto; }
.iwg-interaction-matrix-cell { padding: 4px 7px; border: 1px solid var(--iwg-border); border-radius: 3px; background: #fff; font-size: 10px; }
.iwg-interaction-value-bar { flex: 1 1 430px; min-width: 360px; border: 1px solid var(--iwg-border); }
.iwg-interaction-value-bar .iwg-interaction-editor-host > * { width: 100%; }
.iwg-interaction-measures { display: flex; flex-wrap: wrap; gap: 4px; max-width: 420px; margin: 0; padding: 0; list-style: none; }
.iwg-interaction-measures li { display: inline-flex; align-items: center; gap: 4px; padding-left: 6px; background: #eef3f6; border-radius: 3px; font-size: 10px; }
.iwg-interaction-measures .iwg-panel-button { min-height: 24px; margin: 0; }
.iwg-interaction-groups [aria-level="2"] { margin-left: 14px; }
.iwg-interaction-groups [aria-level="3"] { margin-left: 28px; }
.iwg-interaction-groups [aria-level="4"] { margin-left: 42px; }
.iwg-aggregate-subtotal { font-weight: 700; }
.iwg-interaction-path, .iwg-interaction-binding { padding: 3px 6px; color: var(--iwg-muted); background: #eef3f6; border-radius: 3px; font-size: 10px; }
.iwg-interaction-editor-host { display: inline-flex; padding: 2px; border-radius: 3px; }
.iwg-interaction-groups, .iwg-interaction-calculated { max-width: 420px; max-height: 110px; margin: 0; padding: 5px 8px 5px 24px; overflow: auto; color: var(--iwg-text); background: #fff; border: 1px solid var(--iwg-border); border-radius: 3px; font-size: 10px; }
.iwg-interactions .is-danger-soft { color: var(--iwg-danger); background: var(--iwg-danger-soft); }
.iwg-interactions .is-danger-text { color: var(--iwg-danger); }
.iwg-interactions .is-success-soft { color: var(--iwg-success); background: var(--iwg-success-soft); }
.iwg-interactions .is-warning-soft { color: #7a4a00; background: #fff2cc; }
