:root {
  color-scheme: light;
  --bg: #eef2f6;
  --sidebar: #111827;
  --sidebar-soft: #182236;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #17202a;
  --muted: #65758b;
  --line: #d7e0ec;
  --line-soft: #e7edf5;
  --red: #ef3340;
  --red-dark: #c81f32;
  --blue: #315b9c;
  --green: #0f766e;
  --amber: #b7791f;
  --console: #0e1627;
  --shadow: 0 18px 50px rgba(21, 31, 45, 0.08);
  --shadow-soft: 0 8px 24px rgba(21, 31, 45, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, var(--red), var(--green), var(--blue)) 0 0 / 100% 5px no-repeat,
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 15px;
  cursor: pointer;
  font-weight: 900;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 44px;
}

.sidebar {
  position: sticky;
  top: 22px;
  align-self: start;
  min-width: 0;
  min-height: calc(100vh - 66px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(239, 51, 64, 0.14), transparent 130px),
    var(--sidebar);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-icon {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
  background: #ffffff;
  box-shadow: 0 12px 24px rgba(239, 51, 64, 0.22);
}

.eyebrow,
.section-title {
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-top: 3px;
  color: #ffffff;
  font-size: 21px;
  line-height: 1.05;
  font-weight: 900;
}

h2 {
  font-size: 25px;
  line-height: 1.1;
  font-weight: 900;
}

h3 {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 900;
}

.muted,
.panel-note {
  color: var(--muted);
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #cbd5e1;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--sidebar-soft);
  color: #ffffff;
}

.nav-link.active {
  border-color: rgba(239, 51, 64, 0.36);
  background: rgba(239, 51, 64, 0.16);
  color: #ffffff;
}

.sidebar-status {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.workspace {
  min-width: 0;
}

.topbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.topbar-actions .muted {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric-card {
  min-width: 0;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  overflow: hidden;
  font-size: 28px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card.wide strong {
  font-size: 18px;
  line-height: 1.25;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.dashboard-grid,
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-note {
  margin-top: 4px;
}

.config-panel,
.order-panel {
  min-height: 100%;
}

.order-panel,
.docs-panel {
  border-top: 4px solid var(--red);
}

.docs-panel {
  border-top-color: var(--green);
}

.form-section {
  padding: 16px 18px 4px;
}

.form-section + .form-section {
  border-top: 1px solid var(--line-soft);
}

.section-title {
  margin-bottom: 12px;
}

.grid-two,
.grid-three {
  display: grid;
  gap: 12px;
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}

.pin-field {
  width: min(420px, 100%);
}

.field span,
.switch-row span:last-child {
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

input,
select,
.readonly-value {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.readonly-value {
  display: flex;
  align-items: center;
  overflow: hidden;
  color: #1f4f8f;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input::placeholder {
  color: #8a97aa;
}

input:focus,
select:focus {
  border-color: var(--blue);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(49, 91, 156, 0.13);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.primary {
  background: var(--red);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(239, 51, 64, 0.18);
}

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

.ghost,
.mini-button {
  background: #ffffff;
  border-color: var(--line);
  color: #263447;
}

.ghost:hover,
.mini-button:hover {
  border-color: #9ca9ba;
  box-shadow: 0 8px 18px rgba(21, 31, 45, 0.08);
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.square {
  width: 64px;
}

.full {
  width: 100%;
}

.switch-row {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin-bottom: 12px;
  cursor: pointer;
}

.switch-row.compact {
  margin: 1px 0 2px;
}

.field-switch {
  align-self: end;
  min-height: 44px;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-control {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid #c8d3e1;
  background: #dfe7f1;
  position: relative;
  transition:
    background 140ms ease,
    border-color 140ms ease;
}

.switch-control::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(21, 31, 45, 0.22);
  transition: transform 140ms ease;
}

.switch-row input:checked + .switch-control {
  background: var(--green);
  border-color: var(--green);
}

.switch-row input:checked + .switch-control::after {
  transform: translateX(18px);
}

.switch-row input:focus-visible + .switch-control {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.order-form {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.order-form .field {
  margin-bottom: 0;
}

.result-box {
  min-height: 184px;
  max-height: 360px;
  overflow: auto;
  margin: 16px 18px 18px;
  padding: 14px;
  border: 1px solid #17233a;
  border-radius: 8px;
  background: var(--console);
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.result-box.empty,
.result-box.loading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #aab8d0;
}

.result-title {
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
}

.result-box p {
  margin-top: 6px;
  color: #9fb0ca;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.result-kv {
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(219, 234, 254, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.result-kv span {
  display: block;
  color: #9fb0ca;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.result-kv strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: #ffffff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-box details {
  margin-top: 12px;
}

.result-box summary {
  cursor: pointer;
  color: #bfdbfe;
  font-weight: 900;
}

.result-box pre {
  margin: 10px 0 0;
  overflow: auto;
  white-space: pre-wrap;
}

.table-wrap {
  overflow-x: auto;
  padding: 0 14px 14px;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

th {
  color: #40516b;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f9fbfe;
}

tbody tr:last-child td {
  border-bottom-color: var(--line-soft);
}

.amount-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
}

.amount-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(239, 51, 64, 0.1);
}

.money {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #eefaf8;
  color: var(--green);
  font-weight: 900;
}

code,
.inline-code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.inline-code {
  color: #2a4365;
  font-size: 12px;
  font-weight: 800;
}

.status-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.status-badge.good {
  color: var(--green);
  background: #eefaf8;
}

.status-badge.warn {
  color: var(--amber);
  background: #fff8e8;
}

.status-badge.bad {
  color: var(--red-dark);
  background: #fff1f2;
}

.pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}

.pill.good {
  color: var(--green);
  border-color: rgba(15, 118, 110, 0.28);
  background: #eefaf8;
}

.pill.warn {
  color: var(--amber);
  border-color: rgba(183, 121, 31, 0.3);
  background: #fff8e8;
}

.pill.bad {
  color: var(--red-dark);
  border-color: rgba(200, 31, 50, 0.24);
  background: #fff1f2;
}

.docs-grid {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.doc-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.doc-main {
  min-width: 0;
}

.doc-route {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.method {
  display: inline-flex;
  min-width: 54px;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
}

.method.get {
  color: #1d4ed8;
  background: #eff6ff;
}

.method.post {
  color: #0f766e;
  background: #eefaf8;
}

.doc-url {
  min-width: 0;
  overflow: hidden;
  color: #1f4f8f;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-copy {
  display: flex;
  gap: 8px;
  align-self: start;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.doc-chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 8px;
  padding: 4px 8px;
  background: var(--surface-soft);
  color: #40516b;
  font-size: 12px;
  font-weight: 800;
}

.doc-body {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.doc-example {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fbff;
}

.doc-example span {
  display: block;
  margin-bottom: 6px;
  color: #40516b;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.doc-example pre {
  margin: 0;
  overflow: auto;
  color: #263447;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

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

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

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

  .sidebar {
    position: static;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    min-height: 0;
  }

  .nav-list {
    min-width: 0;
    max-width: 100%;
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-link {
    flex: 0 0 auto;
  }

  .sidebar-status {
    display: flex;
    margin-top: 0;
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 14px;
  }

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

  .doc-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .metric-grid,
  .grid-two,
  .grid-three,
  .result-summary {
    grid-template-columns: 1fr;
  }

  .input-row {
    grid-template-columns: 1fr 1fr;
  }

  .input-row input {
    grid-column: 1 / -1;
  }

  .square {
    width: auto;
  }

  .doc-copy {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .result-box {
    margin-left: 14px;
    margin-right: 14px;
  }

  .order-form,
  .form-section,
  .docs-grid {
    padding-left: 14px;
    padding-right: 14px;
  }

  h2 {
    font-size: 22px;
  }
}
