/* CoordiLink shared desktop/web workbench shell.
   Loaded after the legacy styles so the application logic can remain stable. */
:root {
  --cl-bg: #e8edf3;
  --cl-chrome: #cfd8e3;
  --cl-chrome-strong: #c3ceda;
  --cl-surface: #f7f9fb;
  --cl-surface-muted: #edf2f7;
  --cl-surface-selected: #dceafb;
  --cl-input: #ffffff;
  --cl-text: #142438;
  --cl-text-soft: #52657b;
  --cl-text-faint: #495c70;
  --cl-border: #aebccc;
  --cl-border-soft: #c9d3df;
  --cl-accent: #2b68b8;
  --cl-accent-strong: #1e579f;
  --cl-accent-soft: #d8e8fb;
  --cl-success: #2f7d4c;
  --cl-success-soft: #e0f0e6;
  --cl-danger: #b43a45;
  --cl-danger-soft: #f8e4e7;
  --cl-warning: #9b6918;
  --cl-focus: rgba(43, 104, 184, 0.22);
  --cl-radius: 5px;
  --cl-font: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  --cl-mono: "Cascadia Mono", "Segoe UI Mono", monospace;
  --cl-product-height: 58px;
  --cl-ribbon-tabs-height: 35px;
  --cl-ribbon-body-height: 90px;
  --cl-status-height: 30px;
  color-scheme: light;
}

:root[data-theme="light"] {
  --cl-bg: #f1f4f7;
  --cl-chrome: #e6ebf1;
  --cl-chrome-strong: #d9e1e9;
  --cl-surface: #ffffff;
  --cl-surface-muted: #f5f7fa;
  --cl-input: #ffffff;
  --cl-border: #b8c3cf;
  --cl-border-soft: #d6dde5;
}

:root[data-theme="dark"] {
  --cl-bg: #17202b;
  --cl-chrome: #222f3d;
  --cl-chrome-strong: #2a3949;
  --cl-surface: #1d2834;
  --cl-surface-muted: #243241;
  --cl-surface-selected: #234a75;
  --cl-input: #16212c;
  --cl-text: #eef5fc;
  --cl-text-soft: #bdcbd9;
  --cl-text-faint: #91a3b6;
  --cl-border: #47596c;
  --cl-border-soft: #34475a;
  --cl-accent: #63a5ef;
  --cl-accent-strong: #83b9f4;
  --cl-accent-soft: #254566;
  --cl-success: #69be84;
  --cl-success-soft: #1e4930;
  --cl-danger: #f28b92;
  --cl-danger-soft: #572c34;
  --cl-warning: #e6b860;
  --cl-focus: rgba(99, 165, 239, 0.28);
  color-scheme: dark;
}

:root[data-theme="dark"] img[src$=".svg"] {
  filter: brightness(0) invert(1) opacity(0.88);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
  overflow: hidden;
}

body {
  --bg: var(--cl-bg);
  --panel: var(--cl-surface-muted);
  --panel-strong: var(--cl-surface);
  --panel-soft: var(--cl-surface-muted);
  --text: var(--cl-text);
  --muted: var(--cl-text-soft);
  --line: var(--cl-border-soft);
  --line-strong: var(--cl-border);
  --accent: var(--cl-accent);
  --accent-strong: var(--cl-accent-strong);
  --success: var(--cl-success);
  --danger: var(--cl-danger);
  --warning: var(--cl-warning);
  --ink: var(--cl-chrome-strong);
  --ink-strong: var(--cl-chrome);
  --workbench-border: var(--cl-border);
  --workbench-border-soft: var(--cl-border-soft);
  --workbench-panel: var(--cl-surface);
  --workbench-band: var(--cl-surface-muted);
  display: grid !important;
  grid-template-rows: var(--cl-product-height) calc(var(--cl-ribbon-tabs-height) + var(--cl-ribbon-body-height)) minmax(0, 1fr) var(--cl-status-height);
  background: var(--cl-bg) !important;
  color: var(--cl-text) !important;
  font-family: var(--cl-font) !important;
  font-size: 13px;
}

body.app-locked > :not(.login-screen) {
  visibility: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border-radius: var(--cl-radius) !important;
}

button:hover {
  transform: none !important;
}

button::after,
.product-bar::before,
main > section::before {
  display: none !important;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cl-accent) !important;
  outline-offset: 1px;
  box-shadow: 0 0 0 3px var(--cl-focus) !important;
}

.product-bar {
  grid-row: 1;
  position: relative !important;
  z-index: 30;
  min-height: 0 !important;
  height: var(--cl-product-height);
  display: grid !important;
  grid-template-columns: minmax(235px, 1fr) minmax(260px, 1.2fr) minmax(250px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 6px 14px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--cl-border) !important;
  background: var(--cl-chrome) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.product-brand,
.product-title-line,
.auth-bar {
  display: flex;
  align-items: center;
}

.product-brand {
  min-width: 0;
  gap: 10px;
}

.product-bar .brand-logo {
  width: 37px !important;
  height: 37px !important;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: none !important;
}

.product-bar .brand-copy {
  min-width: 0;
}

.product-title-line {
  gap: 7px;
}

.product-bar h1 {
  margin: 0 !important;
  color: var(--cl-text) !important;
  font-size: 18px !important;
  font-weight: 650 !important;
  letter-spacing: -0.2px;
}

.product-edition,
.product-version {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 1px 7px;
  border: 1px solid var(--cl-border);
  border-radius: 10px;
  color: var(--cl-text-soft);
  background: color-mix(in srgb, var(--cl-surface) 65%, transparent);
  font-size: 10px;
  font-weight: 650;
}

.product-edition {
  border-color: color-mix(in srgb, var(--cl-accent) 45%, var(--cl-border));
  color: var(--cl-accent-strong);
  background: var(--cl-accent-soft);
}

.product-bar .subtitle {
  max-width: 420px;
  overflow: hidden;
  color: var(--cl-text-soft) !important;
  font-size: 11px !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-context {
  justify-self: center;
  min-width: 280px;
  max-width: 520px;
  display: grid;
  grid-template-columns: auto minmax(0, auto) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-left: 1px solid var(--cl-border);
  border-right: 1px solid var(--cl-border);
}

.product-context strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-kicker,
.save-state {
  color: var(--cl-text-faint);
  font-size: 11px;
}

.save-state::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--cl-success);
}

.product-bar .auth-bar {
  justify-self: end;
  gap: 6px !important;
  margin: 0 !important;
}

.product-bar .auth-bar button,
.icon-button {
  min-height: 30px !important;
  padding: 5px 9px !important;
  border: 1px solid var(--cl-border) !important;
  color: var(--cl-text) !important;
  background: var(--cl-surface-muted) !important;
  box-shadow: none !important;
}

.icon-button {
  display: inline-grid !important;
  width: 31px;
  min-width: 31px;
  place-items: center;
}

.icon-button img {
  width: 16px;
  height: 16px;
}

.user-badge {
  border-color: var(--cl-border) !important;
  color: var(--cl-text) !important;
  background: var(--cl-surface-muted) !important;
}

/* Ribbon */
.app-ribbon {
  grid-row: 2;
  position: relative;
  z-index: 20;
  min-width: 0;
  border-bottom: 1px solid var(--cl-border);
  background: var(--cl-chrome);
}

.ribbon-tabs {
  height: var(--cl-ribbon-tabs-height);
  display: flex;
  align-items: end;
  gap: 2px;
  padding: 0 12px;
  border-bottom: 1px solid var(--cl-border);
}

.ribbon-tabs button {
  position: relative;
  height: 34px;
  min-width: 68px;
  padding: 7px 14px 8px !important;
  border: 0 !important;
  border-radius: 0 !important;
  color: var(--cl-text-soft) !important;
  background: transparent !important;
  box-shadow: none !important;
  font-weight: 550;
}

.ribbon-tabs button::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  background: transparent;
}

.ribbon-tabs button.is-active {
  color: var(--cl-accent-strong) !important;
  background: var(--cl-surface) !important;
}

.ribbon-tabs button.is-active::after {
  background: var(--cl-accent);
}

.ribbon-panels {
  height: var(--cl-ribbon-body-height);
  overflow: hidden;
  background: var(--cl-surface);
}

.ribbon-panel {
  height: 100%;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 6px 12px 4px;
}

.ribbon-panel[hidden] {
  display: none !important;
}

.ribbon-group {
  position: relative;
  min-width: 116px;
  display: flex;
  align-items: flex-start;
  gap: 3px;
  padding: 0 13px 18px 6px;
  border-right: 1px solid var(--cl-border-soft);
}

.ribbon-group-compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(84px, auto));
  grid-auto-rows: 27px;
}

.ribbon-group-label {
  position: absolute;
  right: 8px;
  bottom: 0;
  left: 4px;
  overflow: hidden;
  color: var(--cl-text-faint);
  font-size: 9px;
  letter-spacing: 0.15px;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.ribbon-command {
  min-width: 74px;
  min-height: 28px;
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 5px 7px !important;
  border: 1px solid transparent !important;
  color: var(--cl-text) !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 12px;
  text-align: left;
}

.ribbon-command:not(.ribbon-command-large) {
  max-width: 124px;
  flex: 0 1 auto;
}

.ribbon-command-large {
  min-width: 76px;
  height: 63px;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.ribbon-command img {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.ribbon-command-large img {
  width: 27px;
  height: 27px;
}

.ribbon-command:hover,
.source-views button:hover,
.source-card:hover {
  border-color: var(--cl-border) !important;
  background: var(--cl-surface-selected) !important;
  transform: none !important;
}

/* Three-pane workbench */
main {
  grid-row: 3;
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  min-height: 0;
  display: grid !important;
  grid-template-columns: 210px minmax(560px, 1fr) 460px;
  grid-template-areas: "sources workspace inspector";
  gap: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  background: var(--cl-bg);
}

.source-rail,
.workspace-shell,
.input-shell {
  min-width: 0;
  min-height: 0;
}

.source-rail {
  grid-area: sources;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--cl-border);
  background: var(--cl-surface-muted);
}

.source-rail-head,
.inspector-head {
  min-height: 51px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--cl-border-soft);
  background: var(--cl-chrome-strong);
}

.source-rail-head div,
.inspector-head div {
  display: grid;
  gap: 1px;
}

.source-rail-head span,
.inspector-head span,
.panel-kicker {
  color: var(--cl-text-faint);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.55px;
  text-transform: uppercase;
}

.source-rail-head strong,
.inspector-head h2 {
  margin: 0 !important;
  color: var(--cl-text) !important;
  font-size: 14px !important;
  font-weight: 650;
}

.source-card {
  width: calc(100% - 12px);
  min-height: 64px;
  display: grid !important;
  grid-template-columns: 34px minmax(0, 1fr) 9px;
  align-items: center;
  gap: 7px;
  margin: 8px 6px 3px;
  padding: 8px !important;
  border: 1px solid var(--cl-border-soft) !important;
  color: var(--cl-text) !important;
  background: var(--cl-surface) !important;
  box-shadow: none !important;
  text-align: left;
}

.source-card.is-active {
  border-color: var(--cl-accent) !important;
  background: var(--cl-surface-selected) !important;
  box-shadow: inset 3px 0 0 var(--cl-accent) !important;
}

.source-type-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--cl-accent) 55%, var(--cl-border));
  border-radius: 4px;
  color: var(--cl-accent-strong);
  background: var(--cl-accent-soft);
  font-family: var(--cl-mono);
  font-size: 11px;
  font-weight: 700;
}

.source-card-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.source-card-copy strong,
.source-card-copy em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-card-copy strong {
  font-size: 12px;
}

.source-card-copy em {
  color: var(--cl-text-soft);
  font-size: 10px;
  font-style: normal;
}

.source-state {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cl-success);
}

.source-state.is-error {
  background: var(--cl-danger);
}

.source-views {
  display: grid;
  gap: 2px;
  padding: 14px 7px;
}

.source-views > span {
  padding: 0 7px 4px;
  color: var(--cl-text-faint);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.55px;
  text-transform: uppercase;
}

.source-views button,
.source-rail-footer button {
  width: 100%;
  min-height: 32px;
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 6px 9px !important;
  border: 1px solid transparent !important;
  color: var(--cl-text) !important;
  background: transparent !important;
  box-shadow: none !important;
  text-align: left;
}

.source-views button.is-active {
  color: var(--cl-accent-strong) !important;
  background: var(--cl-surface-selected) !important;
}

.source-views img {
  width: 17px;
  height: 17px;
}

.source-rail-footer {
  margin-top: auto;
  padding: 7px;
  border-top: 1px solid var(--cl-border-soft);
}

.input-shell {
  grid-area: inspector;
  height: 100% !important;
  max-height: none !important;
  display: block !important;
  padding: 0 10px 16px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  border: 0 !important;
  border-left: 1px solid var(--cl-border) !important;
  border-radius: 0 !important;
  background: var(--cl-surface-muted) !important;
  box-shadow: none !important;
  animation: none !important;
}

.inspector-head {
  position: sticky;
  top: 0;
  z-index: 4;
  margin: 0 -10px 8px;
}

.inspector-close {
  display: none !important;
}

.inspector-group {
  margin: 7px 0 !important;
  border: 1px solid var(--cl-border-soft) !important;
  border-radius: var(--cl-radius) !important;
  background: var(--cl-surface) !important;
  box-shadow: none !important;
}

.inspector-group > summary {
  min-height: 34px;
  padding: 8px 10px !important;
  color: var(--cl-text) !important;
  background: var(--cl-surface-muted) !important;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.inspector-group[open] > summary {
  border-bottom: 1px solid var(--cl-border-soft);
}

.inspector-group-body {
  padding: 9px;
}

.input-shell label {
  margin-bottom: 3px !important;
  color: var(--cl-text-soft) !important;
  font-size: 10px !important;
  font-weight: 650 !important;
  letter-spacing: 0.15px;
}

.input-shell .grid,
.input-shell .grid-3 {
  grid-template-columns: 1fr !important;
  gap: 7px !important;
}

.input-shell input:not([type="checkbox"]),
.input-shell select,
.input-shell textarea {
  min-height: 31px !important;
  padding: 5px 7px !important;
  border: 1px solid var(--cl-border) !important;
  border-radius: 4px !important;
  color: var(--cl-text) !important;
  background: var(--cl-input) !important;
  box-shadow: none !important;
}

.input-shell textarea {
  min-height: 80px !important;
  max-height: 150px;
  resize: vertical;
  font-family: var(--cl-mono);
  font-size: 11px;
}

.input-shell button {
  min-height: 30px !important;
  border: 1px solid var(--cl-border) !important;
  color: var(--cl-text) !important;
  background: var(--cl-surface-muted) !important;
  box-shadow: none !important;
}

.input-shell .upload-bar {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.input-shell input[type="file"] {
  width: 100%;
  font-size: 10px;
}

.input-shell .file-meta,
.input-shell .note {
  color: var(--cl-text-faint) !important;
  font-size: 10px !important;
  line-height: 1.4;
}

.input-shell .file-meta {
  margin: 6px 0 8px;
}

.input-shell > .note {
  margin-top: 10px;
  padding: 8px;
  border-left: 3px solid var(--cl-accent);
  background: var(--cl-surface);
}

.inspector-single-field {
  margin-top: 7px;
}

.crs-dictionary {
  margin-top: 8px !important;
  border-color: var(--cl-border-soft) !important;
  background: var(--cl-surface-muted) !important;
}

.role-strip {
  margin-top: 8px !important;
}

.workspace-shell {
  grid-area: workspace;
  height: 100% !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--cl-bg) !important;
  box-shadow: none !important;
  animation: none !important;
}

.command-bar {
  min-height: 45px !important;
  padding: 6px 10px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--cl-border) !important;
  border-radius: 0 !important;
  background: var(--cl-surface-muted) !important;
  box-shadow: none !important;
}

.command-title strong {
  color: var(--cl-text) !important;
  font-size: 13px !important;
}

.command-actions .primary,
.primary {
  border-color: var(--cl-accent-strong) !important;
  color: #ffffff !important;
  background: var(--cl-accent) !important;
  box-shadow: none !important;
}

.workflow-path {
  flex: 0 0 auto;
  margin: 0 !important;
  padding: 6px 10px !important;
  border-bottom: 1px solid var(--cl-border-soft);
  background: var(--cl-surface) !important;
}

.workflow-step {
  min-height: 35px !important;
  border-radius: 3px !important;
  background: transparent !important;
  box-shadow: none !important;
}

.workflow-step.is-active {
  background: var(--cl-accent-soft) !important;
}

.output-tabs {
  margin: 0 !important;
  padding: 4px 8px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--cl-border-soft) !important;
  border-radius: 0 !important;
  background: var(--cl-surface) !important;
  box-shadow: none !important;
}

.workspace-shell > .panel {
  min-height: 0;
  flex: 1 1 auto;
  margin: 0 !important;
  padding: 12px !important;
  overflow: auto;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--cl-bg) !important;
  box-shadow: none !important;
}

.workspace-shell > .panel[hidden] {
  display: none !important;
}

.workspace-shell input:not([type="checkbox"]),
.workspace-shell select,
.workspace-shell textarea {
  border-color: var(--cl-border) !important;
  color: var(--cl-text) !important;
  background: var(--cl-input) !important;
  box-shadow: none !important;
}

.workspace-shell button:not(.primary) {
  border-color: var(--cl-border) !important;
  color: var(--cl-text) !important;
  background: var(--cl-surface-muted) !important;
  box-shadow: none !important;
}

.workspace-shell label,
.workspace-shell h3,
.workspace-shell p {
  color: var(--cl-text) !important;
}

.workspace-shell .note,
.workspace-shell .map-layer-status,
.workspace-shell .state-pill,
.workspace-shell .metric span {
  color: var(--cl-text-soft) !important;
}

.panel h2 {
  color: var(--cl-text) !important;
  font-size: 18px !important;
  font-weight: 620 !important;
  letter-spacing: -0.15px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.panel-title-row h2 {
  margin: 1px 0 0 !important;
}

.table-view-bar {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--cl-border);
  border-radius: 5px;
  background: var(--cl-surface-muted);
}

.table-view-bar button {
  min-height: 28px;
  padding: 4px 12px !important;
  border: 0 !important;
  color: var(--cl-text-soft) !important;
  background: transparent !important;
  box-shadow: none !important;
}

.table-view-bar button.is-active {
  color: var(--cl-accent-strong) !important;
  background: var(--cl-surface) !important;
  box-shadow: inset 0 -2px 0 var(--cl-accent) !important;
}

.result-check-strip,
.settings-panel,
.cleanup-card,
.export-group,
.table-pane,
.result-validation-card {
  border-color: var(--cl-border-soft) !important;
  border-radius: var(--cl-radius) !important;
  background: var(--cl-surface) !important;
  box-shadow: none !important;
}

.table-pane:hover,
.cleanup-card:hover,
.export-group:hover,
.workflow-card:hover {
  transform: none !important;
  box-shadow: none !important;
}

.comparison-grid {
  height: calc(100% - 92px);
  min-height: 280px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 8px !important;
}

#resultPanel.table-view-source .comparison-grid,
#resultPanel.table-view-result .comparison-grid {
  grid-template-columns: minmax(0, 1fr) !important;
}

#resultPanel.table-view-source .comparison-grid > .table-pane:nth-child(2),
#resultPanel.table-view-result .comparison-grid > .table-pane:nth-child(1) {
  display: none;
}

.table-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-head {
  min-height: 43px;
  flex: 0 0 auto;
  padding: 6px 8px !important;
  border-bottom: 1px solid var(--cl-border-soft);
  background: var(--cl-chrome-strong) !important;
}

.pane-title strong {
  color: var(--cl-text) !important;
}

.pane-title span,
.summary-line,
.cleanup-summary {
  color: var(--cl-text-soft) !important;
}

.table-pane .table-wrap {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

.table-pager {
  min-height: 35px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 4px 7px;
  border-bottom: 1px solid var(--cl-border-soft);
  color: var(--cl-text-soft);
  background: var(--cl-surface-muted);
  font-size: 10px;
}

.table-pager[hidden] {
  display: none !important;
}

.table-pager button,
.table-pager select {
  width: auto !important;
  min-width: 30px;
  min-height: 25px !important;
  padding: 2px 7px !important;
  border: 1px solid var(--cl-border) !important;
  color: var(--cl-text) !important;
  background: var(--cl-input) !important;
  box-shadow: none !important;
}

.table-pager label {
  margin-left: 4px;
  color: var(--cl-text-soft) !important;
  font-size: 10px;
}

table {
  color: var(--cl-text) !important;
  background: var(--cl-surface) !important;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 34px;
  border-color: var(--cl-border) !important;
  color: var(--cl-text) !important;
  background: var(--cl-chrome-strong) !important;
  font-weight: 620 !important;
}

td {
  height: 32px;
  border-color: var(--cl-border-soft) !important;
  color: var(--cl-text) !important;
  background: var(--cl-surface) !important;
}

tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--cl-surface-muted) 70%, var(--cl-surface)) !important;
}

#inputTable td[data-column] {
  cursor: cell;
}

#inputTable td.is-editing {
  padding: 0 !important;
  box-shadow: inset 0 0 0 2px var(--cl-accent);
}

.shell-cell-editor {
  width: 100%;
  height: 31px;
  padding: 4px 7px;
  border: 0;
  color: var(--cl-text);
  background: var(--cl-input);
  outline: 0;
}

.map-preview,
.ol-map,
.map-fallback {
  border-color: var(--cl-border) !important;
  border-radius: var(--cl-radius) !important;
  box-shadow: none !important;
}

/* Status bar */
.app-status-bar {
  grid-row: 4;
  z-index: 40;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 4px;
  overflow: hidden;
  border-top: 1px solid var(--cl-border);
  background: var(--cl-chrome);
}

.status-chip {
  min-width: 0;
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  padding: 3px 9px !important;
  border: 0 !important;
  border-right: 1px solid var(--cl-border) !important;
  border-radius: 0 !important;
  color: var(--cl-text-soft) !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 10px;
  white-space: nowrap;
}

.status-chip strong {
  max-width: 180px;
  overflow: hidden;
  color: var(--cl-text) !important;
  font-weight: 620;
  text-overflow: ellipsis;
}

.app-status-bar .status {
  min-width: 80px;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  margin: 0 !important;
  padding: 3px 10px !important;
  overflow: hidden;
  border: 0 !important;
  border-radius: 0 !important;
  color: var(--cl-text-soft) !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 10px !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-status-bar .status.error {
  color: var(--cl-danger) !important;
  background: var(--cl-danger-soft) !important;
}

.status-crs {
  margin-left: auto;
  border-right: 0 !important;
  border-left: 1px solid var(--cl-border) !important;
  color: var(--cl-accent-strong) !important;
  background: var(--cl-success-soft) !important;
}

.status-crs:hover {
  background: var(--cl-accent-soft) !important;
}

/* App dialogs */
.shell-modal {
  width: min(440px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--cl-border);
  border-radius: 7px;
  color: var(--cl-text);
  background: var(--cl-surface);
  box-shadow: 0 18px 48px rgba(14, 29, 46, 0.28);
}

.shell-modal::backdrop {
  background: rgba(15, 28, 42, 0.42);
  backdrop-filter: blur(2px);
}

.shell-modal-card {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0 16px 16px;
}

.shell-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -16px;
  padding: 11px 13px 10px 16px;
  border-bottom: 1px solid var(--cl-border-soft);
  background: var(--cl-chrome);
}

.shell-modal-head span {
  color: var(--cl-text-faint);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.shell-modal-head h2 {
  margin: 2px 0 0;
  font-size: 17px;
}

.shell-modal p {
  margin: 0;
  line-height: 1.5;
}

.shell-modal input {
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--cl-border);
  border-radius: 4px;
  color: var(--cl-text);
  background: var(--cl-input);
}

.shell-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.shell-modal-actions button {
  min-height: 34px;
  padding: 6px 13px;
  border: 1px solid var(--cl-border);
  color: var(--cl-text);
  background: var(--cl-surface-muted);
}

.shell-modal.is-destructive .shell-modal-actions .primary {
  border-color: var(--cl-danger) !important;
  background: var(--cl-danger) !important;
}

/* Login is part of the same product language. */
.login-screen {
  z-index: 1000 !important;
  background:
    linear-gradient(120deg, rgba(43, 104, 184, 0.13), transparent 42%),
    var(--cl-chrome) !important;
}

.login-card {
  width: min(420px, calc(100vw - 32px)) !important;
  padding: 0 24px 24px !important;
  overflow: hidden;
  border: 1px solid var(--cl-border) !important;
  border-radius: 8px !important;
  color: var(--cl-text) !important;
  background: var(--cl-surface) !important;
  box-shadow: 0 22px 54px rgba(27, 46, 68, 0.22) !important;
}

.login-head {
  margin: 0 -24px 20px !important;
  padding: 20px 24px 17px !important;
  border-bottom: 1px solid var(--cl-border-soft);
  background: var(--cl-chrome) !important;
}

.login-head img {
  width: 50px !important;
  height: 50px !important;
}

.login-head strong {
  color: var(--cl-text) !important;
  font-size: 19px !important;
}

.login-head span,
.login-form label {
  color: var(--cl-text-soft) !important;
}

.login-form input {
  border-color: var(--cl-border) !important;
  color: var(--cl-text) !important;
  background: var(--cl-input) !important;
  box-shadow: none !important;
}

/* Tablet and compact desktop */
@media (max-width: 1320px) {
  main {
    grid-template-columns: 184px minmax(500px, 1fr) 390px;
  }

  .ribbon-command {
    min-width: 62px;
    font-size: 11px;
  }

  .ribbon-group {
    padding-right: 8px;
  }
}

@media (max-width: 1080px) {
  main {
    grid-template-columns: minmax(480px, 1fr) 340px;
    grid-template-areas: "workspace inspector";
  }

  .source-rail {
    display: none;
  }

  .product-bar {
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  }

  .product-context .context-kicker,
  .product-context .save-state {
    display: none;
  }

  .product-context {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  :root {
    --cl-product-height: 52px;
    --cl-ribbon-body-height: 62px;
  }

  body {
    grid-template-rows: var(--cl-product-height) calc(var(--cl-ribbon-tabs-height) + var(--cl-ribbon-body-height)) minmax(0, 1fr) var(--cl-status-height);
  }

  .product-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 5px 8px !important;
  }

  .product-context,
  .product-bar .auth-bar .user-badge,
  .product-bar .auth-bar #adminPanelBtn,
  .product-version {
    display: none !important;
  }

  .product-bar .brand-logo {
    width: 34px !important;
    height: 34px !important;
  }

  .product-bar h1 {
    font-size: 16px !important;
  }

  .ribbon-tabs {
    overflow-x: auto;
    padding: 0 4px;
  }

  .ribbon-tabs button {
    min-width: 62px;
    padding-inline: 8px !important;
  }

  .ribbon-panels {
    overflow-x: auto;
  }

  .ribbon-panel {
    width: max-content;
    min-width: 100%;
    padding: 4px;
  }

  .ribbon-command-large,
  .ribbon-command {
    width: auto;
    min-width: 64px;
    height: 47px;
    min-height: 47px;
    flex-direction: column;
    justify-content: center;
    padding: 3px 5px !important;
    text-align: center;
  }

  .ribbon-command img,
  .ribbon-command-large img {
    width: 19px;
    height: 19px;
  }

  .ribbon-group {
    padding: 0 5px;
    border-right: 0;
  }

  .ribbon-group-label {
    display: none;
  }

  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "workspace";
  }

  .input-shell {
    position: fixed;
    top: calc(var(--cl-product-height) + var(--cl-ribbon-tabs-height) + var(--cl-ribbon-body-height));
    right: 0;
    bottom: var(--cl-status-height);
    z-index: 80;
    width: min(340px, 92vw);
    display: none !important;
    box-shadow: -12px 0 32px rgba(15, 28, 42, 0.24) !important;
  }

  body.inspector-open .input-shell {
    display: block !important;
  }

  .inspector-close {
    display: inline-grid !important;
  }

  .workflow-path {
    overflow-x: auto;
  }

  .workflow-step {
    min-width: 130px;
  }

  .comparison-grid {
    height: auto;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #resultPanel.table-view-source .comparison-grid > .table-pane:nth-child(2),
  #resultPanel.table-view-result .comparison-grid > .table-pane:nth-child(1) {
    display: none;
  }

  #resultPanel.table-view-compare .comparison-grid > .table-pane {
    min-height: 330px;
  }

  .status-chip:not(.status-crs):not(.status-source) {
    display: none !important;
  }
}

@media (max-width: 520px) {
  .product-bar .subtitle,
  .product-edition,
  .command-title,
  .status-source,
  .result-format-toggle {
    display: none !important;
  }

  .command-bar {
    justify-content: flex-end !important;
  }

  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-view-bar {
    width: 100%;
  }

  .table-view-bar button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media print {
  body.print-map {
    display: block !important;
    overflow: visible !important;
  }

  body.print-map .app-ribbon,
  body.print-map .source-rail,
  body.print-map .app-status-bar {
    display: none !important;
  }

  body.print-map main {
    display: block !important;
    overflow: visible !important;
  }

  body.print-map .workspace-shell {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  body.print-map #mapPanel {
    overflow: visible !important;
  }
}
