:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #697386;
  --line: #dde3ec;
  --brand: #176b67;
  --brand-strong: #0f4f4b;
  --accent: #b9852f;
  --good: #16865a;
  --warn: #b46b12;
  --bad: #b42318;
  --info: #2563a8;
  --shadow: 0 12px 30px rgba(18, 32, 52, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.login-shell {
  align-items: center;
  background: linear-gradient(135deg, #eef5f4 0%, #f7f4ec 50%, #f4f7fb 100%);
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 32px;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 460px;
  padding: 34px;
  width: 100%;
}

.login-panel-wide {
  display: grid;
  gap: 22px;
  max-width: 760px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-submit {
  width: 100%;
}

.check-row {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 8px;
}

.check-row input {
  min-height: auto;
}

.login-error {
  background: #fdebea;
  border: 1px solid #f8c9c4;
  border-radius: 8px;
  color: var(--bad);
  padding: 10px 12px;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 10px;
  text-transform: uppercase;
}

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

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

.sidebar {
  background: #182334;
  color: #eef4f8;
  height: 100vh;
  overflow-y: auto;
  padding: 20px 14px;
  position: sticky;
  top: 0;
}

.brand-mark {
  align-items: flex-start;
  display: flex;
  margin-bottom: 26px;
  min-width: 0;
}

.brand-mark strong,
.brand-mark small {
  display: block;
}

.brand-logo {
  color: #f4f8f7;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.brand-mark small {
  color: #9fb2c4;
  font-size: 12px;
  margin-top: 2px;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #cbd6e2;
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  min-height: 66px;
  padding: 12px 22px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.scope-pill,
.topbar-user {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.topbar-user {
  margin-left: auto;
}

.topbar-user span,
.topbar-user small {
  display: block;
  white-space: nowrap;
}

.topbar-user small {
  color: var(--muted);
}

.global-search {
  min-width: 260px;
}

.content {
  height: 100vh;
  min-width: 0;
  overflow-y: auto;
}

.page {
  padding: 22px;
}

.page-header {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-header h1,
.login-panel h1 {
  letter-spacing: 0;
  margin: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(18, 32, 52, 0.04);
  min-width: 0;
  padding: 16px;
}

.card-title {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title h2 {
  font-size: 16px;
  letter-spacing: 0;
  margin: 0;
}

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

.dashboard-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 4;
}

.dashboard-grid > .card:not(.span-2):not(.span-half):not(.span-full),
.dashboard-grid > .metric-card:not(.span-2):not(.span-half):not(.span-full) {
  grid-column: span 2;
}

.span-half {
  grid-column: span 3;
}

.span-full {
  grid-column: 1 / -1;
}

.list-row {
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 22px 1fr auto;
  padding: 11px 0;
  text-align: left;
  width: 100%;
}

.list-row small,
.activity-item span,
.activity-item small {
  color: var(--muted);
  display: block;
}

.swatch {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  display: inline-block;
  height: 20px;
  width: 20px;
}

.activity-item {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 3px;
  padding: 10px 0;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 36px;
  padding: 7px 12px;
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn.secondary {
  background: var(--panel);
  color: var(--text);
}

.notice {
  border-radius: 8px;
  padding: 10px 12px;
}

.notice.info {
  background: #eaf2fb;
  color: var(--info);
}

.notice.good {
  background: #eaf7f1;
  color: var(--good);
}

.empty-state {
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar select,
.toolbar input {
  min-width: 150px;
}

.analytics-report-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-bottom: 14px;
}

.report-chart-card {
  min-width: 0;
}

.report-focus {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.report-focus span {
  color: var(--muted);
}

.action-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

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

.table small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.badge {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  min-height: 24px;
  padding: 2px 9px;
}

.badge.good {
  background: #eaf7f1;
  color: var(--good);
}

.badge.warn {
  background: #fff4df;
  color: var(--warn);
}

.badge.bad {
  background: #fdebea;
  color: var(--bad);
}

.badge.info {
  background: #eaf2fb;
  color: var(--info);
}

.dialog-backdrop {
  align-items: center;
  background: rgba(12, 20, 32, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 20;
}

.dialog {
  background: var(--panel);
  border-radius: 8px;
  max-height: calc(100vh - 40px);
  max-width: 760px;
  overflow: auto;
  width: min(760px, 100%);
}

.dialog-header,
.dialog-footer {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px;
}

.dialog-footer {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  gap: 10px;
  justify-content: flex-end;
}

.dialog-body {
  padding: 16px;
}

.icon-btn {
  background: transparent;
  border: 0;
  font-size: 24px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  display: block;
}

.metric-card strong {
  display: block;
  font-size: 28px;
  margin: 8px 0 4px;
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 80px 1fr 72px;
}

.bar-value {
  white-space: nowrap;
}

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

.bar-track i {
  align-items: center;
  background: var(--brand);
  border-radius: 999px;
  display: block;
  height: 100%;
  position: relative;
}

.bar-track-label {
  display: none;
}

.line-chart {
  align-items: end;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(12, 1fr);
  height: 220px;
  padding: 28px 16px 16px;
}

.line-chart i {
  background: linear-gradient(180deg, var(--brand), #76aaa5);
  border-radius: 5px 5px 0 0;
  display: block;
  min-height: 28px;
  position: relative;
}

.line-chart i span {
  color: var(--brand-strong);
  font-size: 11px;
  font-weight: 700;
  left: 50%;
  position: absolute;
  top: -18px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.form-row {
  display: grid;
  gap: 7px;
}

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

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

.choice-field {
  border: 0;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.choice-field legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-pill {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  gap: 7px;
  min-height: 36px;
  padding: 8px 11px;
}

.choice-pill input {
  height: 15px;
  margin: 0;
  width: 15px;
}

.choice-pill span {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.form-error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  color: #be123c;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
}

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

.store-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 66px);
  overflow: hidden;
  padding: 14px 18px;
}

.store-page .page-header {
  align-items: center;
  flex: 0 0 auto;
  margin-bottom: 10px;
}

.store-page .page-header .eyebrow,
.store-page .page-header .muted {
  margin-bottom: 4px;
  margin-top: 0;
}

.store-page .page-header h1 {
  font-size: 30px;
  line-height: 1.12;
}

.store-page .toolbar {
  flex: 0 0 auto;
  margin-bottom: 10px;
  padding: 10px 12px;
}

.store-page .toolbar input {
  min-width: 360px;
  width: min(460px, 100%);
}

.store-split {
  flex: 1;
  gap: 12px;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 0;
}

.store-split > * {
  height: 100%;
  min-height: 0;
}

.org-tree {
  align-content: start;
  display: grid;
  gap: 8px;
}

.store-org-tree {
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
}

.store-list-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.store-list-card .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.tree-node {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  padding: 10px;
  text-align: left;
}

.tree-node.active,
.tree-node:hover {
  background: #eaf5f4;
  border-color: var(--brand);
}

.tree-node.active strong {
  color: var(--brand);
}

.tree-node span,
.detail-grid span {
  color: var(--muted);
  font-size: 12px;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.detail-grid > div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.plan-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

.plan-card {
  display: grid;
  gap: 8px;
}

.plan-card h2 {
  margin: 0;
}

.plan-card strong {
  color: var(--brand);
  font-size: 24px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 36px;
  padding: 7px 10px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

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

  .content {
    height: auto;
    overflow: visible;
  }

  .topbar {
    position: static;
  }

  .store-page {
    height: auto;
    overflow: visible;
  }

  .store-split {
    min-height: auto;
  }

  .store-org-tree,
  .store-list-card,
  .store-list-card .table-wrap {
    max-height: none;
    overflow: visible;
  }

  .topbar,
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar select,
  .topbar input,
  .topbar .btn,
  .toolbar select,
  .toolbar input,
  .scope-pill,
  .topbar-user {
    margin-left: 0;
    width: 100%;
  }

  .report-focus {
    align-items: flex-start;
    flex-direction: column;
  }

  .page {
    padding: 16px;
  }

  .metric-grid,
  .dashboard-grid,
  .split-layout,
  .plan-grid,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-half,
  .span-full {
    grid-column: span 1;
  }
}
