:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #607083;
  --line: #dbe2ea;
  --green: #0f8f70;
  --red: #c84630;
  --amber: #b97913;
  --blue: #2563a9;
  --teal: #16857a;
  --radius: 8px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #111820;
  color: #eef4f8;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--teal);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #9eb0bf;
  font-size: 12px;
  margin-top: 3px;
}

.month-picker,
.scope-picker {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: #b8c6d2;
  font-size: 13px;
}

.scope-picker {
  margin-bottom: 22px;
}

.month-picker select,
.scope-picker select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #344657;
  border-radius: 8px;
  background: #182430;
  color: #fff;
  padding: 0 10px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c8d3dd;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.tab.is-active,
.tab:hover {
  background: #22303d;
  color: #fff;
}

.workspace {
  padding: 28px;
  min-width: 0;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-weight: 700;
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
}

.hero p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card,
.panel,
.opportunity-card,
.action-row,
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.kpi-card {
  min-height: 118px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.kpi-card span,
.kpi-card small,
.panel-header span,
.health-item span,
.action-row span,
.objective span {
  color: var(--muted);
  font-size: 12px;
}

.kpi-card strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
  margin: 10px 0;
}

.login-card {
  grid-column: 1 / -1;
  padding: 22px;
}

.login-card h2,
.login-card p {
  margin: 0;
}

.login-card p {
  color: var(--muted);
  margin-top: 8px;
}

.login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.login-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  text-decoration: none;
  padding: 0 14px;
}

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

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.health-list,
.bridge,
.cost-bars,
.opportunity-list,
.action-plan {
  display: grid;
  gap: 10px;
}

.health-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-left: 4px solid var(--line);
  background: #f8fafb;
  padding: 12px;
  border-radius: 6px;
}

.health-item strong,
.health-item span {
  display: block;
}

.health-item em {
  font-style: normal;
  font-weight: 800;
}

.status-0 {
  border-left-color: var(--red);
}

.status-1 {
  border-left-color: var(--amber);
}

.status-2 {
  border-left-color: var(--green);
}

.bridge-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.bridge-row.cost strong {
  color: var(--red);
}

.bridge-row.final {
  border-bottom: 0;
  color: var(--green);
}

.cost-row {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.cost-meta strong,
.cost-meta span {
  display: block;
}

.cost-meta span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  height: 28px;
  background: #e9eef3;
  border-radius: 8px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--blue);
}

.bar-fill.traffic,
.bar-fill.payroll,
.bar-fill.dailyOps,
.bar-fill.office {
  background: var(--red);
}

.bar-fill.product,
.bar-fill.fulfillment {
  background: var(--teal);
}

.opportunity-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
}

.rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #e4f2ef;
  color: var(--teal);
  font-weight: 800;
}

.opportunity-card h3,
.opportunity-card p {
  margin: 0;
}

.opportunity-card p {
  color: var(--muted);
  margin-top: 8px;
}

.opportunity-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.opportunity-metrics span,
.action-row footer span {
  background: #eef3f6;
  border-radius: 999px;
  padding: 6px 10px;
  color: #334454;
  font-size: 12px;
}

.objective {
  background: #10251f;
  color: #fff;
  border-radius: 8px;
  padding: 16px;
}

.objective span {
  color: #9ec9bd;
  display: block;
  margin-bottom: 6px;
}

.action-row {
  padding: 16px;
}

.action-row strong,
.action-row span {
  display: block;
}

.action-row p {
  margin: 12px 0;
  color: var(--muted);
}

.action-row footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

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

.permission-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafb;
}

.permission-grid span,
.permission-grid p {
  color: var(--muted);
  font-size: 12px;
}

.permission-grid strong,
.permission-grid span {
  display: block;
}

.permission-grid strong {
  margin: 8px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #17202a;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .tab {
    text-align: center;
  }

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

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

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

@media (max-width: 680px) {
  .workspace {
    padding: 18px;
  }

  .hero {
    display: block;
  }

  h1 {
    font-size: 28px;
  }

  .hero-actions {
    margin-top: 12px;
  }

  .nav-tabs,
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cost-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
