:root {
  --ink: #161616;
  --muted: #6f716f;
  --line: #d9ddd5;
  --surface: #fbfbf7;
  --panel: #ffffff;
  --panel-2: #f3f6ed;
  --accent: #0f7b63;
  --accent-dark: #075241;
  --hot: #d4512a;
  --gold: #b58a15;
  --shadow: 0 18px 45px rgba(27, 32, 25, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(22, 22, 22, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(22, 22, 22, 0.035) 1px, transparent 1px),
    #eef1e8;
  background-size: 28px 28px;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

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

.side-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  overflow: auto;
  background: rgba(251, 251, 247, 0.92);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand-block {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.18;
  letter-spacing: 0;
}

.brand-block p,
.muted,
.eyebrow {
  color: var(--muted);
}

.brand-block p {
  margin-top: 6px;
  font-size: 13px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel.compact {
  padding: 14px;
}

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

.panel-heading h2 {
  font-size: 16px;
  line-height: 1.25;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover,
.secondary-button:hover {
  border-color: var(--accent);
}

.status-grid {
  display: grid;
  gap: 8px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 13px;
}

.status-item strong {
  font-weight: 700;
}

.ok {
  color: var(--accent-dark);
}

.warn {
  color: var(--hot);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.tab {
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  color: #fff;
  background: var(--ink);
}

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

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.switch-line {
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 99, 0.13);
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.switch-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.actions,
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.link-button {
  height: 42px;
  padding: 0 15px;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-dark);
}

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

.link-button {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  text-decoration: none;
}

.link-button:hover {
  border-color: var(--accent);
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.mini-json {
  max-height: 180px;
  margin-top: 14px;
  padding: 12px;
  font-size: 11px;
}

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

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-bar h2 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

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

.metric-tile {
  min-height: 104px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-tile span {
  display: block;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
}

.metric-tile strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 26px;
  line-height: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.wide {
  grid-row: span 2;
}

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

.category-card {
  min-height: 138px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.category-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.kv {
  display: grid;
  grid-template-columns: minmax(92px, 0.8fr) minmax(0, 1.2fr);
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.kv span:first-child {
  color: var(--muted);
}

.kv span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.formula-box {
  padding: 13px;
  margin-bottom: 14px;
  color: var(--accent-dark);
  background: #e9f3ed;
  border: 1px solid #bddacb;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.settlement-list {
  display: grid;
  gap: 8px;
}

.settlement-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.risk-pill {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: #e5f3ed;
  font-size: 12px;
  font-weight: 800;
}

.risk-pill.medium,
.risk-pill.high {
  color: #fff;
  background: var(--hot);
}

.risk-list {
  display: grid;
  gap: 10px;
  padding-left: 18px;
  margin: 0;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.risk-list li {
  min-width: 0;
  overflow-wrap: anywhere;
}

.raw-panel {
  grid-column: 1 / -1;
}

pre {
  max-height: 460px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: #dfe8d8;
  background: #151814;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

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

  .side-panel {
    position: static;
    height: auto;
  }

  .content-grid,
  .metric-strip {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .side-panel,
  .workspace {
    padding: 16px;
  }

  .top-bar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .content-grid,
  .category-grid,
  .field-row,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .top-bar h2 {
    font-size: 24px;
  }
}
