:root {
  color-scheme: light;
  --page: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --line: #e8ebef;
  --line-strong: #dfe4ea;
  --ink: #121417;
  --muted: #6f7780;
  --muted-2: #a2a9b1;
  --teal: #21c7c4;
  --teal-dark: #13aaa6;
  --teal-soft: #def8f6;
  --purple: #6752d9;
  --purple-soft: #f0edff;
  --danger: #d44555;
  --danger-soft: #ffe9ed;
  --warning-soft: #fff6dc;
  --shadow: 0 18px 45px rgba(31, 39, 52, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

.sidebar {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  min-height: 72px;
  padding: 18px 17px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.logoMark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--purple), #4b39bf);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

h1 {
  font-size: 17px;
  line-height: 1.05;
  font-weight: 780;
  color: var(--purple);
}

.navBlock {
  padding: 15px 10px 13px;
  border-bottom: 1px solid var(--line);
}

.navBlock p {
  padding: 0 12px 8px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.navItem {
  height: 30px;
  width: 100%;
  margin-bottom: 7px;
  border: 0;
  padding: 0 10px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  color: #2f3338;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.navItem:hover {
  background: #f6f7f9;
}

.navItem.active {
  background: #f2f3f6;
  color: var(--ink);
}

.navIcon {
  width: 16px;
  color: var(--ink);
  font-size: 12px;
}

.search {
  display: grid;
  gap: 8px;
  padding: 17px 14px 14px;
  border-bottom: 1px solid var(--line);
}

.search span,
.controls label > span {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 13px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

input:focus {
  outline: 3px solid rgba(103, 82, 217, 0.12);
  border-color: rgba(103, 82, 217, 0.45);
}

.list {
  overflow: auto;
  padding: 10px 8px 16px;
}

#productNavArea {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.productButton {
  width: 100%;
  min-height: 74px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 11px;
  background: transparent;
  color: var(--ink);
  display: grid;
  align-items: center;
  justify-items: start;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
}

.productButton:hover {
  background: #f7f8fa;
}

.productButton.active {
  background: linear-gradient(180deg, #f4f1ff, #f8f7ff);
  border-color: #e1dbff;
}

.productButton strong,
.productButton span {
  display: block;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.productButton strong {
  margin-bottom: 5px;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  text-align: left;
}

.productButton span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-align: left;
}

.productFlags {
  margin-top: 7px;
  display: flex;
  gap: 5px;
  font-style: normal;
}

.productFlags small {
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  color: var(--muted-2);
  background: #fff;
  font-size: 10px;
  font-weight: 760;
}

.productFlags small.done {
  border-color: #bee8e5;
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.main {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 26px 26px 28px;
  background: var(--surface-soft);
}

.appHeader {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.globalSearch {
  width: min(360px, 100%);
  height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.globalSearch input {
  height: auto;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: 12px;
}

.globalSearch input:focus {
  outline: 0;
}

.headerActions,
.topActions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.iconButton {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fff;
  color: var(--muted);
  box-shadow: none;
}

.profilePill {
  min-width: 112px;
  height: 42px;
  padding: 0 12px;
  border-left: 1px solid var(--line);
  display: grid;
  align-content: center;
  gap: 2px;
}

.profilePill strong {
  font-size: 12px;
  font-weight: 760;
}

.profilePill small {
  color: var(--muted);
  font-size: 11px;
}

.controls,
.metric,
.panel,
.details,
.overviewCard {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: none;
}

.isHidden {
  display: none !important;
}

.productsView {
  display: grid;
  gap: 16px;
}

.overviewView {
  display: grid;
  gap: 18px;
}

.overviewTitle {
  display: grid;
  gap: 6px;
}

.overviewTitle p {
  color: var(--muted);
  font-size: 13px;
}

.overviewGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.overviewCard {
  min-height: 126px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.overviewCard span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.overviewCard strong {
  font-size: 34px;
  line-height: 1;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.overviewCard small {
  color: var(--muted);
  font-size: 12px;
}

.topbar {
  min-height: 58px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: transparent;
}

h2 {
  font-size: 20px;
  line-height: 1.1;
  font-weight: 770;
}

.topbar h2 {
  max-width: 760px;
  font-size: clamp(23px, 2.4vw, 32px);
  line-height: 1.08;
  font-weight: 800;
}

#selectedCode {
  margin-left: 8px;
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 800;
  vertical-align: baseline;
}

.subtle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.userPill,
.workbookLink,
.controls button {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #333941;
  text-decoration: none;
  font-size: 12px;
  font-weight: 720;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none;
}

.workbookLink,
#saveButton {
  border-color: transparent;
  background: var(--purple);
  color: #fff;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.controls {
  padding: 13px 14px;
  display: grid;
  grid-template-columns: 180px minmax(160px, 210px) minmax(160px, 210px) auto auto auto 1fr;
  gap: 12px;
  align-items: end;
}

.controlIntro {
  display: grid;
  gap: 3px;
  align-self: center;
}

.controlIntro strong {
  font-size: 14px;
  font-weight: 760;
}

.controlIntro span {
  color: var(--muted);
  font-size: 12px;
  text-transform: none;
  font-weight: 500;
}

.controls label {
  display: grid;
  gap: 6px;
}

.controls input {
  background: #fffaf0;
  font-weight: 760;
}

.statusCheck {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  background: #fff;
  cursor: pointer;
}

.statusCheck input {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--purple);
}

.statusCheck span {
  color: #333941;
  font-size: 12px;
  font-weight: 760;
  text-transform: none;
  white-space: nowrap;
}

#saveStatus {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}

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

.metric {
  min-height: 92px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  grid-template-rows: auto 1fr;
  gap: 8px 11px;
  align-items: start;
  overflow: hidden;
}

.metric i {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #f2f5f7;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.metric span {
  align-self: center;
  color: var(--ink);
  font-size: 13px;
  font-weight: 690;
}

.metric strong {
  grid-column: 1 / 3;
  align-self: end;
  font-size: 24px;
  line-height: 1;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.metric small {
  grid-column: 3;
  align-self: end;
  justify-self: end;
  min-width: 54px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 790;
}

.primaryMetric i {
  background: var(--purple-soft);
  color: var(--purple);
}

.primaryMetric small {
  background: var(--purple-soft);
  color: var(--purple);
}

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

.panel {
  overflow: hidden;
}

.panel header {
  min-height: 55px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.panel h3,
.details h3 {
  font-size: 14px;
  font-weight: 760;
}

.panel header span {
  border-radius: 7px;
  padding: 6px 9px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 790;
}

.panel header span.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.rows {
  display: grid;
}

.rows div {
  min-height: 43px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #f0f2f5;
}

.rows div:first-child {
  border-top: 0;
}

.rows span,
.costGrid span,
.barLabel span {
  color: var(--muted);
  font-size: 13px;
}

.rows strong,
.costGrid strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 740;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.rows .result {
  min-height: 49px;
  background: #f5fffe;
  font-weight: 760;
}

.yingfa .rows .result {
  background: var(--warning-soft);
}

.details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  overflow: hidden;
}

.details > div {
  padding: 16px;
}

.details > div + div {
  border-left: 1px solid var(--line);
}

.costGrid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
}

.costGrid span,
.costGrid strong {
  min-height: 34px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f0f2f5;
}

.costGrid strong {
  justify-content: flex-end;
}

.barBlock {
  margin-top: 14px;
  display: grid;
  gap: 9px;
}

.barLabel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.barLabel strong {
  font-size: 12px;
}

.bar {
  height: 13px;
  border-radius: 6px;
  background: #eef1f4;
  overflow: hidden;
}

.bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.bar i.negative {
  background: var(--danger);
}

@media (max-width: 1100px) {
  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .controlIntro,
  #saveStatus {
    grid-column: 1 / -1;
  }

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

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    max-height: 430px;
  }

  .main {
    padding: 18px 14px 22px;
  }

  .topbar,
  .topActions {
    align-items: flex-start;
    flex-direction: column;
  }

  .globalSearch {
    width: 100%;
  }

  .controls,
  .overviewGrid,
  .summary,
  .companies,
  .details {
    grid-template-columns: 1fr;
  }

  .details > div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
