:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fbfb;
  --ink: #142026;
  --muted: #65727c;
  --line: #dce4e8;
  --brand: #127569;
  --brand-strong: #0b5149;
  --accent: #e2b64a;
  --good: #197a45;
  --warn: #a45b00;
  --bad: #b42318;
  --soft-good: #e7f5ed;
  --soft-warn: #fff3df;
  --soft-bad: #fdecea;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid rgba(220, 228, 232, 0.82);
  background: rgba(244, 246, 248, 0.92);
  backdrop-filter: blur(16px);
}

.brand,
.site-nav,
.hero-actions,
.downloads,
.actions,
.header-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 900;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
}

.site-nav {
  justify-content: center;
  gap: 8px;
}

.site-nav a,
.nav-action,
.primary-link,
.secondary-link,
.downloads a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  text-decoration: none;
}

.header-actions {
  gap: 8px;
  justify-content: end;
}

.site-nav a {
  color: var(--muted);
}

.site-nav a:hover {
  color: var(--ink);
  background: #fff;
}

.nav-action,
.primary-link {
  border: 0;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.secondary-nav-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
}

.nav-action:hover,
.secondary-nav-action:hover,
.primary-link:hover,
.primary:hover {
  background: var(--brand-strong);
  color: #fff;
}

main {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(340px, 0.62fr);
  grid-template-areas:
    "copy media"
    "calculator calculator";
  gap: 18px;
  align-items: stretch;
  min-height: auto;
  margin-bottom: 18px;
}

.hero-copy {
  grid-area: copy;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 260px;
  padding: clamp(18px, 3vw, 36px) 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 680px;
  font-size: clamp(40px, 4.4vw, 58px);
  line-height: 1.02;
}

h2 {
  font-size: 22px;
  line-height: 1.18;
}

.lead {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.hero-actions {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.secondary-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
}

.hero-media {
  grid-area: media;
  display: flex;
  align-items: center;
  min-height: 260px;
}

.hero-media img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(13, 48, 55, 0.16);
}

.calculator-card,
.proof-band,
.file-section,
.kpi,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.calculator-card {
  grid-area: calculator;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(13, 48, 55, 0.08);
}

.calculator-head,
.topbar,
.panel-head,
.file-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.actions {
  gap: 8px;
}

.icon-button,
.primary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-size: 23px;
  text-decoration: none;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr)) 180px;
  gap: 12px;
  margin-top: 16px;
}

.report-tools {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(170px, 210px) minmax(240px, 1fr) 160px;
  align-items: end;
  gap: 12px;
  margin-top: 16px;
}

.source-tools {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(180px, 1fr) minmax(180px, 1fr);
  align-items: end;
  gap: 12px;
  margin-top: 16px;
}

.compact-field {
  margin-bottom: 0;
}

.secondary-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--bad);
  cursor: pointer;
  font-weight: 900;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.upload-zone {
  display: grid;
  gap: 6px;
  min-height: 88px;
  padding: 18px;
  border: 1px dashed #aebbc3;
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--brand);
  background: #fff;
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.upload-title {
  font-weight: 900;
}

.upload-hint,
.status,
.panel-head span,
.field span,
.summary-list span,
.kpi span,
.proof-band span {
  color: var(--muted);
}

.primary {
  min-height: 88px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
}

.status {
  min-height: 44px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.status.error {
  border-color: #efb2aa;
  background: var(--soft-bad);
  color: var(--bad);
}

.proof-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  background: var(--line);
}

.proof-band article {
  display: grid;
  gap: 5px;
  min-height: 98px;
  padding: 22px;
  background: #fff;
}

.proof-band strong {
  font-size: 24px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.kpi strong {
  font-size: 24px;
  line-height: 1.15;
}

.kpi.warn strong {
  color: var(--warn);
}

.workspace,
.adjustments,
.finance-details,
.auth-panel,
.projects-panel {
  margin-bottom: 18px;
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
}

.finance-row {
  display: grid;
  gap: 5px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.finance-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.finance-row strong {
  font-size: 19px;
}

.finance-row.positive strong {
  color: var(--good);
}

.finance-row.negative strong {
  color: var(--bad);
}

.auth-grid,
.project-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.account-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-settings {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(180px, 1fr)) 260px;
}

.project-grid {
  grid-template-columns: minmax(200px, 1fr) repeat(3, minmax(160px, 1fr)) 220px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.small-primary {
  min-height: 40px;
  padding: 0 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.filters-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-head {
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.adjustment-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.55fr) minmax(720px, 1.45fr);
  gap: 14px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  font-weight: 900;
}

.charge-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 0 12px;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.content {
  display: grid;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
}

.content > .panel {
  min-width: 0;
  overflow: hidden;
}

.bars {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px minmax(120px, 1fr) 170px;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  font-size: 14px;
}

.bar-row strong {
  display: grid;
  gap: 2px;
  justify-items: end;
}

.bar-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #edf2f4;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.bad-fill {
  background: linear-gradient(90deg, var(--bad), #ef8a7f);
}

.monthly-profit-panel {
  margin-top: 0;
}

.monthly-bar {
  width: 100%;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.monthly-bar:hover .bar-track {
  background: #dfe8ec;
}

.empty-bars {
  min-height: 30px;
  color: var(--muted);
  font-size: 14px;
}

.table-panel {
  padding-bottom: 0;
  min-width: 0;
}

.dashboard-placeholder {
  margin-top: 28px;
  min-height: 220px;
}

.supply-plan-page {
  margin-top: 28px;
}

.supply-controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  align-items: end;
}

.supply-actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.supply-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 10px;
}

.supply-table-wrap {
  max-height: 72vh;
}

.supply-table {
  min-width: 1850px;
  table-layout: fixed;
}

.supply-name-col {
  width: 240px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-filter {
  cursor: pointer;
}

.status-filter.active,
.stock-filter.active {
  box-shadow: 0 0 0 2px var(--brand);
}

.stock-filter {
  cursor: pointer;
  background: #e8f6f3;
  color: #007060;
}

.stock-filter-counters {
  margin-top: 0;
}

.status-risk {
  background: #ffe2e2;
  color: #b42318;
}

.status-ship {
  background: #ddf7ea;
  color: #087443;
}

.status-surplus {
  background: #fff4ce;
  color: #8a6100;
}

.status-hold {
  background: #eef2f6;
  color: #586474;
}

.supply-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin: 12px 0 0;
}

.page-button {
  min-width: 34px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.page-button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.page-ellipsis {
  color: var(--muted);
  font-weight: 800;
  padding: 0 4px;
}

.table-wrap {
  overflow: auto;
  max-height: 116vh;
  margin: 0 -16px;
  width: calc(100% + 32px);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  text-align: right;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f9fbfc;
  color: var(--muted);
  z-index: 1;
}

.sort-button {
  width: 100%;
  min-height: 28px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  text-align: right;
}

.sort-button.active {
  color: var(--brand);
}

.stock-head {
  width: 108px;
  min-width: 108px;
  vertical-align: top;
}

.stock-head span {
  display: block;
  font-weight: 900;
}

.mini-refresh-button {
  display: block;
  margin: 3px 0 0 auto;
  border: 1px solid #cfe0ec;
  border-radius: 6px;
  background: #ffffff;
  color: var(--brand);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  padding: 4px 6px;
}

.mini-refresh-button:hover {
  border-color: var(--brand);
  background: #eefaf7;
}

.mini-refresh-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.stock-cell {
  display: grid;
  gap: 2px;
  justify-items: end;
  line-height: 1.15;
}

.stock-cell b {
  color: var(--ink);
}

.stock-cell span,
.stock-empty {
  color: var(--muted);
  font-size: 11px;
}

.product-name-col {
  width: 220px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  text-align: left;
}

.thumb-cell {
  width: 78px;
}

.product-thumb {
  display: block;
  width: 61px;
  height: 61px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
  object-fit: contain;
}

.empty-thumb {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.product-row {
  cursor: pointer;
}

.product-row:hover,
.product-row:focus {
  background: #f4f8f8;
  outline: none;
}

.product-modal[hidden] {
  display: none;
}

.product-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
}

.product-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 37, 42, 0.48);
}

.product-sheet {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(23, 37, 42, 0.24);
}

.app-modal {
  align-items: start;
  padding-top: 72px;
}

.app-modal-sheet {
  width: min(1180px, 100%);
}

.modal-body {
  padding: 18px;
}

.modal-body .panel,
.app-modal .finance-details {
  margin: 0;
}

.inline-detail-button {
  width: 100%;
  min-height: 38px;
  color: var(--brand);
}

.product-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #f4f8f8;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.product-view {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
  gap: 22px;
  padding: 28px;
}

.product-media {
  display: grid;
  place-items: center;
  min-height: 360px;
  border-radius: 8px;
  background: #f7fafb;
  overflow: hidden;
}

.product-media img {
  width: 100%;
  height: 100%;
  max-height: 480px;
  object-fit: contain;
}

.empty-media {
  color: var(--muted);
  font-weight: 800;
}

.product-info {
  display: grid;
  align-content: start;
  gap: 14px;
  padding-right: 28px;
}

.product-info h2 {
  margin: 0;
  padding-right: 24px;
  font-size: 28px;
  line-height: 1.1;
}

.product-meta,
.product-fields,
.product-stats,
.product-finance {
  display: grid;
  gap: 10px;
}

.product-meta {
  color: var(--muted);
  font-size: 14px;
}

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

.product-stats div,
.product-fields div,
.finance-line {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.product-stats span,
.product-fields span,
.finance-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.product-finance h3 {
  margin: 4px 0 0;
  font-size: 17px;
}

.finance-line {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.finance-line.positive b {
  color: var(--good);
}

.finance-line.negative b {
  color: var(--bad);
}

.product-link {
  display: inline-flex;
  width: fit-content;
  min-height: 38px;
  align-items: center;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-weight: 800;
}

.good {
  color: var(--good);
  background: var(--soft-good);
}

.warn {
  color: var(--warn);
  background: var(--soft-warn);
}

.bad {
  color: var(--bad);
  background: var(--soft-bad);
}

.muted {
  color: var(--muted);
}

.file-section {
  margin-top: 24px;
  padding: 22px;
}

.downloads {
  flex-wrap: wrap;
  gap: 12px;
}

.downloads a {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
}

.downloads a:hover {
  border-color: var(--brand);
}

.calculator-download-card {
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.calculator-download-card p {
  margin: 0 0 12px;
  line-height: 1.45;
}

.calculator-download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

.calculator-download-link:hover {
  filter: brightness(0.96);
}

.calculator-download-link:disabled {
  cursor: wait;
  opacity: 0.72;
}

@media (max-width: 1100px) {
  .site-header {
    grid-template-columns: auto auto;
  }

  .site-nav {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    grid-template-areas:
      "copy"
      "media"
      "calculator";
  }

  .hero-copy,
  .hero-media {
    min-height: auto;
  }

  .kpi-grid,
  .proof-band {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .product-view {
    grid-template-columns: 1fr;
  }

  .adjustment-grid,
  .charge-grid,
  .finance-grid,
  .auth-grid,
  .project-grid,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 760px) {
  .site-header {
    min-height: 64px;
    padding: 0 12px;
  }

  .brand span:last-child {
    display: none;
  }

  .nav-action {
    min-height: 38px;
    padding: 0 10px;
  }

  main {
    width: min(100% - 24px, 1480px);
    padding-top: 16px;
  }

  h1 {
    font-size: 40px;
  }

  .lead {
    font-size: 17px;
  }

  .calculator-head,
  .file-section {
    align-items: flex-start;
    flex-direction: column;
  }

  .upload-grid,
  .period-tools,
  .report-tools,
  .source-tools,
  .kpi-grid,
  .proof-band,
  .adjustment-grid,
  .charge-grid,
  .auth-grid,
  .project-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .primary,
  .upload-zone {
    min-height: 72px;
  }

  .bar-row {
    grid-template-columns: 88px minmax(80px, 1fr);
  }

  .bar-row strong {
    grid-column: 1 / -1;
  }

  .product-modal {
    padding: 10px;
  }

  .product-view {
    padding: 18px;
  }

  .product-media {
    min-height: 240px;
  }

  .product-info {
    padding-right: 0;
  }

  .product-info h2 {
    font-size: 22px;
  }

  .product-stats {
    grid-template-columns: 1fr;
  }
}
