:root {
  color-scheme: dark;
  scrollbar-color: rgba(85, 185, 199, .55) rgba(255, 255, 255, .04);
  scrollbar-width: thin;
}

:root[data-theme="light"] {
  color-scheme: light;
  scrollbar-color: rgba(34, 123, 137, .45) rgba(16, 35, 43, .05);
}

*:focus-visible {
  outline: 3px solid rgba(85, 185, 199, .52);
  outline-offset: 2px;
}

button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:active,
.cmd:active {
  transform: translateY(1px) scale(.99);
}

.page > .section-title:first-child,
.page > h2:first-child {
  text-wrap: balance;
}

.table-wrap {
  scrollbar-gutter: stable;
}

.module-tabs,
.erp-tabs,
.ops-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 2px 12px;
  scrollbar-width: none;
}

.module-tabs::-webkit-scrollbar,
.erp-tabs::-webkit-scrollbar,
.ops-tabs::-webkit-scrollbar {
  display: none;
}

.module-tabs button,
.erp-tabs button,
.ops-tabs button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--soft);
  background: var(--glass);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.module-tabs button.active,
.erp-tabs button.active,
.ops-tabs button.active {
  color: #071611;
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), var(--gold2));
  box-shadow: 0 8px 22px rgba(57, 201, 154, .14);
}

.erp-pane {
  display: none;
}

.erp-pane.active,
.ops-pane.active {
  display: block;
  animation: erpPaneIn .18s ease-out;
}

.ops-pane {
  display: none;
}

.ops-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin: 10px 0;
}

.ops-search input {
  min-width: 0;
}

#opsProfitBridge {
  line-height: 2;
}

#opsExceptions {
  display: grid;
  gap: 8px;
}

@keyframes erpPaneIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.line-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.line-metrics > div {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--glass);
}

.line-metrics span,
.line-metrics strong {
  display: block;
}

.line-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.line-metrics strong {
  margin-top: 5px;
}

body:not(.advanced-mode) .advanced-only {
  display: none !important;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}

.workflow-action {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.workflow-action strong {
  color: var(--green);
}

.workflow-action small {
  color: var(--muted);
}

.journey-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.journey-strip button {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  color: var(--soft);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.journey-strip button b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  border-radius: 50%;
  color: var(--green);
  background: rgba(46, 211, 151, .1);
}

.journey-strip button.active {
  color: #071611;
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), var(--gold2));
}

.journey-strip button.active b {
  color: #071611;
  background: rgba(255, 255, 255, .35);
}

.workflow-help {
  display: grid;
  gap: 4px;
  margin: 10px 0 14px;
  padding: 13px 15px;
  border-right: 4px solid var(--green);
  border-radius: 7px;
  background: rgba(46, 211, 151, .07);
}

.workflow-help span {
  color: var(--muted);
  line-height: 1.75;
}

.workflow-roadmap {
  margin: 10px 0 14px;
  padding: 0 14px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
}

.workflow-roadmap summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  color: var(--gold2);
  font-weight: 900;
  cursor: pointer;
}

.workflow-roadmap ol {
  margin: 4px 0 0;
  padding-right: 22px;
  color: var(--muted);
  line-height: 1.9;
}

.workflow-roadmap b {
  color: var(--text);
}

.action-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}

.action-groups details {
  padding: 0 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
}

.action-groups summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}

.action-groups .actions {
  margin: 4px 0 0;
}

.section-heading {
  margin: 18px 0 8px;
  font-size: 18px;
}

.compact-details {
  margin: 12px 0;
  padding: 0 12px;
}

.compact-details > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
}

.accounting-overview .card {
  min-height: 72px;
}

.share-ready-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(3, 12, 9, .78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.share-ready-overlay.show {
  display: grid;
}

.share-ready-box {
  width: min(460px, 100%);
  padding: 18px;
  border: 1px solid rgba(46, 211, 151, .28);
  border-radius: 10px;
  background: #10201a;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .45);
}

.share-ready-box h2 {
  margin: 0 0 6px;
  color: var(--green);
}

.share-ready-box p {
  margin: 0 0 14px;
  color: var(--muted);
}

@media (max-width: 520px) {
  body {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .page {
    padding-inline: 10px;
  }

  .module-tabs {
    margin-inline: -10px;
    padding-inline: 10px;
  }

  .module-tabs button,
  .erp-tabs button,
  .ops-tabs button {
    min-height: 42px;
    padding-inline: 12px;
  }

  .journey-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .journey-strip button {
    min-height: 52px;
    padding: 8px;
    font-size: 12px;
  }

  .action-groups {
    grid-template-columns: 1fr;
  }

  .card,
  .panel,
  .kpi-card {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  button,
  .cmd,
  input,
  select {
    min-height: 44px;
  }

  table.mobile-stack td::before {
    line-height: 1.35;
  }

  table.mobile-stack td {
    min-height: 42px;
  }

  .line-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ops-search {
    grid-template-columns: 1fr 1fr;
  }

  .ops-search input {
    grid-column: 1 / -1;
  }

  .workflow-strip {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
