/* MarżaBot — Obsidian Ledger application layer.
   Visual-only overrides: existing IDs and application mechanics stay intact. */

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

html:has(body.app-page) > #codex-browser-sidebar-comments-root {
  display: none !important;
}

:root[data-theme="midnight"] {
  --bg: #080e0c;
  --surface: #101714;
  --surface-subtle: #151e1a;
  --text: #f1f5f1;
  --muted: #8d9b94;
  --line: #26332d;
  --brand: #59dfae;
  --brand-strong: #77edc0;
  --brand-soft: #132d24;
  --input-border: #32423a;
  --sidebar-line: #1f2b26;
  --lux-panel: #101714;
  --lux-panel-raised: #151e1a;
  --lux-sidebar: #070c0a;
  --lux-highlight: transparent;
  --shadow: none;
}

.app-shell {
  min-height: 100vh;
  grid-template-columns: 236px minmax(0, 1fr);
  background: var(--bg);
}

.app-shell,
.app-shell * {
  box-sizing: border-box;
}

.app-shell :where(button, a, input, select, summary):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 22px 15px 18px;
  overflow-y: auto;
  background: #070c0a;
  border-right: 1px solid var(--sidebar-line);
  box-shadow: none;
  backdrop-filter: none;
}

.brand {
  gap: 11px;
  padding: 0 8px 24px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: none;
}

.brand-copy > span {
  font-size: 17px;
  font-weight: 760;
}

.brand-copy small {
  margin-top: 1px;
  color: #6f7d76;
  font-size: 8px;
  letter-spacing: .14em;
}

.main-nav { gap: 3px; }

.nav-section-label {
  margin: 18px 11px 6px;
  color: #59675f;
  font-size: 8px;
  font-weight: 760;
  letter-spacing: .15em;
}

.nav-item {
  min-height: 40px;
  padding: 8px 10px;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #84928b;
  font-size: 12px;
  font-weight: 610;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.nav-item:hover {
  transform: none;
  border-color: #202d27;
  background: #0d1411;
  color: #dce5df;
}

.nav-item.is-active {
  border-color: #28473b;
  background: #101d18;
  color: var(--brand);
  box-shadow: inset 2px 0 0 var(--brand);
}

.nav-item > .nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: transparent;
}

.nav-icon svg,
.mobile-tab-icon svg,
.mobile-more-icon svg,
.text-button svg,
.decision-card-action svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-badge {
  min-width: 19px;
  margin-left: auto;
  padding: 2px 5px;
  border: 1px solid #63373b;
  border-radius: 999px;
  background: #2a171a;
  color: #ee8a8a;
  font-size: 8px;
}

.sidebar-note {
  padding: 12px;
  border: 1px solid #202d27;
  border-radius: 11px;
  background: #0b1210;
  box-shadow: none;
}

.sidebar-note .status-dot,
.system-state i {
  box-shadow: none;
}

.sidebar-note strong { font-size: 11px; }
.sidebar-note small { color: #69766f; font-size: 9px; line-height: 1.45; }

.main-content {
  min-width: 0;
  padding: 30px clamp(28px, 4vw, 62px) 72px;
}

.topbar {
  min-height: 74px;
  margin-bottom: 27px;
  align-items: center;
}

.topbar-identity { min-width: 0; }
.topbar-heading { min-width: 0; }
.mobile-app-brand { display: none; }

.topbar h1 {
  margin-top: 3px;
  font-size: clamp(33px, 3.2vw, 46px);
  font-weight: 690;
  line-height: 1;
  letter-spacing: -.052em;
}

.eyebrow {
  color: var(--brand);
  font-size: 9px;
  font-weight: 780;
  letter-spacing: .15em;
}

.topbar-actions { gap: 10px; }

.system-state {
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d1411;
}

.system-state > span { display: grid; gap: 1px; }
.system-state > span > small { color: #637168; font-size: 8px; font-weight: 560; }

.button {
  min-height: 42px;
  border-radius: 10px;
  box-shadow: none;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.button:hover { transform: none; }

.button-primary {
  border-color: #72e8bc;
  background: var(--brand);
  color: #06110d;
  box-shadow: none;
}

.button-primary:hover { background: var(--brand-strong); }

.button-secondary {
  border-color: var(--line);
  background: #141d19;
}

.page.is-active { animation: none; }

.stat-card,
.panel,
.table-card,
.result-hero,
.recommendation-card,
.alert-item,
.store-channel-bar,
.connections-hero,
.connection-card,
.settings-save-bar {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: none;
}

.dashboard-lead-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(350px, .88fr);
  gap: 14px;
}

.dashboard-profit-card {
  min-height: 274px;
  padding: clamp(25px, 3vw, 36px);
  display: flex;
  flex-direction: column;
  border: 1px solid #c7d3ca;
  border-radius: 15px;
  background: #e5ebe4;
  color: #0a1510;
}

.dashboard-card-meta,
.decision-card-top,
.metric-foot,
.decision-card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dashboard-profit-card .eyebrow { color: #1a6d4d; }

.metric-period {
  padding: 5px 8px;
  border: 1px solid #b8c6bc;
  border-radius: 999px;
  color: #44564b;
  font-size: 8px;
  font-weight: 760;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.dashboard-profit-card > p {
  margin: auto 0 2px;
  color: #536258;
  font-size: 13px;
  font-weight: 650;
}

.dashboard-profit-card > strong {
  display: block;
  margin: 2px 0 7px;
  color: #0b6a48;
  font-size: clamp(52px, 5.8vw, 76px);
  font-weight: 735;
  line-height: .96;
  letter-spacing: -.065em;
}

.dashboard-profit-card > strong.negative { color: #a8333b; }
.dashboard-profit-card > small { color: #67766c; font-size: 10px; }

.metric-foot {
  margin-top: 25px;
  padding-top: 15px;
  border-top: 1px solid #c6d0c8;
}

.metric-foot > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #4e5d53;
  font-size: 9px;
  font-weight: 650;
}

.metric-foot > span i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #139067;
}

.metric-foot .text-button { color: #0d5139; }

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.text-button svg { width: 14px; height: 14px; }

.decision-card {
  min-height: 274px;
  margin-top: 0;
  padding: clamp(24px, 2.6vw, 32px);
  display: flex;
  flex-direction: column;
  border: 1px solid #3a3327;
  border-radius: 15px;
  background: #15150f;
}

.decision-index {
  color: #736b5d;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .1em;
}

.decision-card-body {
  margin: auto 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 15px;
  align-items: start;
}

.recommendation-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #d99a46;
  color: #24180a;
  box-shadow: none;
}

.decision-card h2 {
  margin: 0 0 7px;
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.15;
}

.decision-card p {
  color: #a9aca4;
  font-size: 11px;
  line-height: 1.55;
}

.decision-card-action {
  padding-top: 15px;
  border-top: 1px solid #332f26;
}

.decision-card-action .button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.decision-card-action svg { width: 15px; height: 15px; }
.decision-card-action small { color: #6f7069; font-size: 8px; }

.dashboard-support-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.stat-card {
  min-height: 126px;
  padding: 19px 20px;
  border-radius: 12px;
  background: #101714;
}

.stat-card::before,
.stat-card::after { display: none; }

.stat-card span {
  color: #7d8a83;
  font-size: 10px;
  font-weight: 630;
}

.stat-card strong {
  margin: auto 0 5px;
  padding-top: 18px;
  font-size: 28px;
  font-weight: 690;
}

.stat-card small { color: #66746c; font-size: 9px; }

.dashboard-grid {
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, .72fr);
  gap: 12px;
  margin-top: 12px;
}

.panel {
  padding: 23px;
  border-radius: 14px;
}

.panel-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--brand);
  font-size: 8px;
  font-weight: 760;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.panel-heading h2 { font-size: 17px; }
.panel-heading p { color: #748079; }
.pill { border-color: #294039; background: #11231c; }

.forecast-panel { min-height: 390px; }
.forecast-chart { margin-top: 15px; }
.forecast-chart .revenue-path,
.forecast-chart .profit-path { filter: none; }

.chart-legend {
  padding-top: 10px;
  border-top: 1px solid #202c27;
}

.ranking-panel { min-width: 0; }
.ranking-row {
  min-height: 69px;
  padding: 14px 0;
  border-color: #202c27;
  transition: background-color 140ms ease;
}

.ranking-row:hover { padding-inline: 0; background: transparent; }
.ranking-row strong { font-size: 11px; }
.ranking-row small { color: #69766f; }
.ranking-value strong { color: #e6eee9; }

.table-card {
  overflow: hidden;
  border-radius: 14px;
}

.table-card thead { background: #151e1a; }
.table-card th {
  color: #718078;
  font-size: 8px;
  letter-spacing: .08em;
}
.table-card td { border-color: #222f29; }
.table-card tbody tr:hover { background: #111a16; }

.store-channel-bar,
.connections-hero,
.connection-card,
.result-hero,
.settings-save-bar { border-radius: 14px; box-shadow: none; }

.app-shell .connections-summary,
.app-shell .result-status { backdrop-filter: none; }

.form-grid input,
.form-grid select,
.select-label select,
.compact-field select,
.input-suffix,
.auth-field input {
  border-radius: 9px;
}

.mobile-tabbar,
.mobile-more-sheet { display: none; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 218px minmax(0, 1fr); }
  .main-content { padding-inline: 28px; }
  .dashboard-lead-grid { grid-template-columns: minmax(0, 1fr) minmax(320px, .85fr); }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { display: none; }

  .main-content {
    padding: 18px 16px calc(112px + env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 0;
    margin-bottom: 22px;
    align-items: flex-end;
  }

  .topbar-identity { display: grid; gap: 24px; }

  .mobile-app-brand {
    width: max-content;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-size: 15px;
    font-weight: 760;
  }

  .mobile-app-brand img { width: 32px; height: 32px; border-radius: 9px; }

  .topbar h1 { font-size: clamp(30px, 8.8vw, 39px); }
  .topbar-actions { align-self: flex-end; }
  .system-state, .account-chip, .logout-button { display: none !important; }
  .topbar-actions .button { min-height: 39px; padding-inline: 13px; font-size: 10px; }

  .dashboard-lead-grid,
  .dashboard-grid { grid-template-columns: 1fr; }

  .dashboard-support-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-support-stats .stat-card:last-child { grid-column: 1 / -1; }

  .dashboard-profit-card,
  .decision-card { min-height: 248px; }

  .mobile-tabbar {
    position: fixed;
    z-index: 100;
    right: 10px;
    bottom: calc(9px + env(safe-area-inset-bottom));
    left: 10px;
    min-height: 72px;
    padding: 7px 6px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: end;
    border: 1px solid #26332d;
    border-radius: 17px;
    background: #0b1210;
    box-shadow: 0 14px 34px rgba(0,0,0,.36);
  }

  .mobile-tabbar .mobile-tab {
    width: 100%;
    min-width: 0;
    min-height: 54px;
    padding: 5px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #74827a;
    font: inherit;
    cursor: pointer;
    box-shadow: none;
  }

  .mobile-tabbar .mobile-tab:hover,
  .mobile-tabbar .mobile-tab.is-active {
    transform: none;
    border: 0;
    background: transparent;
    color: var(--brand);
    box-shadow: none;
  }

  .mobile-tabbar .mobile-tab > .mobile-tab-icon {
    width: 26px;
    height: 24px;
    display: grid;
    place-items: center;
    background: transparent;
  }

  .mobile-tabbar .mobile-tab small {
    display: block;
    color: inherit;
    font-size: 8px;
    font-weight: 650;
  }

  .mobile-tabbar .mobile-tab-primary {
    position: relative;
    top: -10px;
    color: #06120d;
  }

  .mobile-tabbar .mobile-tab-primary > .mobile-tab-icon {
    width: 45px;
    height: 45px;
    border-radius: 14px;
    background: var(--brand);
    color: #06120d;
  }

  .mobile-tabbar .mobile-tab-primary small { color: var(--brand); }

  .mobile-more-sheet {
    position: fixed;
    z-index: 95;
    right: 10px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    left: 10px;
    padding: 18px;
    display: block;
    border: 1px solid #2a3831;
    border-radius: 17px;
    background: #0e1612;
    box-shadow: 0 20px 44px rgba(0,0,0,.44);
  }

  .mobile-more-sheet[hidden] { display: none; }

  .mobile-more-head {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .mobile-more-head strong { display: block; margin-top: 3px; font-size: 18px; }
  .mobile-more-head > button {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #151e1a;
    color: var(--text);
    font-size: 22px;
  }

  .mobile-more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

  .mobile-more-grid > button {
    min-width: 0;
    min-height: 74px;
    padding: 11px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #25332c;
    border-radius: 11px;
    background: #121b17;
    color: var(--text);
    text-align: left;
  }

  .mobile-more-grid > button:last-child { grid-column: 1 / -1; }
  .mobile-more-icon { flex: 0 0 auto; color: var(--brand); }
  .mobile-more-grid strong, .mobile-more-grid small { display: block; }
  .mobile-more-grid strong { font-size: 10px; }
  .mobile-more-grid small { margin-top: 3px; color: #718078; font-size: 8px; line-height: 1.3; }

  .table-card { overflow: visible; border: 0; background: transparent; }
  .table-card table,
  .table-card tbody,
  .table-card tr,
  .table-card td { display: block; width: 100%; }
  .table-card thead { display: none; }
  .table-card tbody { display: grid; gap: 10px; }
  .table-card tbody tr {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
  }
  .table-card tbody td { padding: 0; border: 0; }
  .table-card tbody td:first-child,
  .table-card tbody td:last-child { grid-column: 1 / -1; }
  .table-card tbody td:nth-child(2)::before { content: "Kanał"; }
  .table-card tbody td:nth-child(3)::before { content: "Cena"; }
  .table-card tbody td:nth-child(4)::before { content: "Sprzedaż"; }
  .table-card tbody td:nth-child(5)::before { content: "Zysk / szt."; }
  .table-card tbody td:nth-child(6)::before { content: "Marża"; }
  .table-card tbody td:nth-child(n+2):nth-child(-n+6)::before {
    display: block;
    margin-bottom: 4px;
    color: #66736c;
    font-size: 7px;
    font-weight: 760;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .table-card .actions { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .main-content { padding-inline: 14px; }
  .topbar { gap: 10px; }
  .topbar-actions .button { max-width: 112px; white-space: normal; line-height: 1.15; }
  .dashboard-profit-card,
  .decision-card { min-height: 230px; padding: 22px; }
  .dashboard-profit-card > strong { font-size: 53px; }
  .decision-card-action small { display: none; }
  .dashboard-support-stats { gap: 8px; }
  .stat-card { min-height: 111px; padding: 15px; }
  .stat-card strong { font-size: 24px; }
  .panel { padding: 18px; }
  .forecast-panel { min-height: 330px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell *,
  .app-shell *::before,
  .app-shell *::after { transition: none !important; animation: none !important; }
}

@media print {
  .mobile-tabbar,
  .mobile-more-sheet { display: none !important; }
}
