:root {
  --ink: #111d3d;
  --muted: #69758b;
  --line: #dfe4ed;
  --soft: #f6f7fa;
  --pink: #f40079;
  --purple: #7d20ff;
  --orange: #ff5a00;
  --success: #7621d8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f5f6f9;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f5f6f9; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.site-header { height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(28px, calc((100vw - 1540px) / 2)); border-bottom: 1px solid var(--line); background: white; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 22px; }
.brand img { width: 43px; height: 43px; object-fit: cover; border-radius: 10px; }
.header-right { display: flex; align-items: center; gap: 22px; }
.online { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.online i { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); box-shadow: 0 0 0 4px #f0e7ff; }
.quiet { padding: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }

.page { width: min(1540px, calc(100% - 56px)); margin: 0 auto; padding: 45px 0 70px; }
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 31px; }
h1 { margin: 0; font-size: clamp(28px, 3vw, 40px); letter-spacing: -.035em; }
.title-row p, .modal-heading p, .details-heading p { margin: 8px 0 0; color: var(--muted); font-size: 16px; }
.create-wrap { position: relative; }
.create-button, .primary { border: 0; border-radius: 9px; color: white; background: linear-gradient(110deg, var(--pink), var(--purple)); cursor: pointer; font-weight: 750; }
.create-button { min-width: 190px; padding: 15px 19px; font-size: 16px; box-shadow: 0 9px 24px rgba(125,32,255,.17); }
.create-button span { margin-left: 15px; }
.create-menu { position: absolute; z-index: 12; top: calc(100% + 7px); right: 0; width: 300px; padding: 7px; border: 1px solid #d6dce6; border-radius: 10px; background: white; box-shadow: 0 18px 45px rgba(23,31,55,.16); }
.create-menu button { width: 100%; display: grid; gap: 3px; padding: 12px; border: 0; border-radius: 7px; background: transparent; text-align: left; cursor: pointer; }
.create-menu button:hover { background: #f8f4ff; }
.create-menu b { font-size: 14px; }
.create-menu small { color: var(--muted); font-size: 12px; }

.table-panel, .details { border: 1px solid var(--line); border-radius: 12px; background: white; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 17px 19px; background: #f7f8fa; color: #536077; font-size: 13px; text-align: left; }
td { padding: 18px 19px; border-top: 1px solid #e8ebf1; font-size: 14px; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: #fbf9ff; }
.empty { padding: 48px; color: var(--muted); text-align: center; }
.side-pill, .status-pill { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.side-pill.supply { color: #a20c68; background: #fff0f7; }
.side-pill.demand { color: #6320b8; background: #f3ebff; }
.status-pill { color: #6320b8; background: #f0e6ff; }
.copy-link { border: 0; background: transparent; color: var(--purple); cursor: pointer; font-weight: 700; padding: 0; }
.connected { display: inline-flex; align-items: center; gap: 7px; }
.connected::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--purple); }

.details { margin-top: 16px; padding: 28px; }
.details-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.details h2 { margin: 0; font-size: 21px; }
.copy-output { padding: 9px 13px; border: 1px solid #d8cfec; border-radius: 8px; color: var(--purple); background: white; cursor: pointer; font-weight: 700; }
.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; margin-top: 27px; }
label { display: grid; gap: 8px; color: #4f5b70; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #d8dee8; border-radius: 7px; outline: none; color: var(--ink); background: white; font-size: 14px; }
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(125,32,255,.09); }
input[readonly], textarea[readonly] { background: #fafbfc; }
.flow { display: flex; align-items: center; gap: 14px; margin-top: 27px; padding-top: 22px; border-top: 1px solid #e8ebf1; }
.flow span, .flow strong { min-width: 145px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; text-align: center; font-size: 14px; }
.flow strong { border: 0; color: white; background: linear-gradient(110deg, var(--pink), var(--purple)); }
.flow b { color: #8893a5; }

.form-error { min-height: 18px; color: #c52255 !important; font-size: 13px; }

dialog { width: min(720px, calc(100% - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: white; box-shadow: 0 32px 90px rgba(23,31,55,.22); }
dialog::backdrop { background: rgba(17,29,61,.45); backdrop-filter: blur(3px); }
.modal-form { padding: 26px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.modal-heading h2 { margin: 0; font-size: 22px; }
.modal-heading p { font-size: 14px; }
.close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: white; cursor: pointer; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.span-2 { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 8px; align-self: end; min-height: 44px; }
.check input { width: 16px; min-height: 16px; accent-color: var(--purple); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.primary, .secondary { padding: 11px 16px; }
.secondary { border: 1px solid var(--line); border-radius: 8px; background: white; cursor: pointer; font-weight: 700; }
#result-modal label + label { margin-top: 15px; }
.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; padding: 12px 16px; border-radius: 9px; color: white; background: var(--ink); box-shadow: 0 15px 40px rgba(17,29,61,.22); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1050px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
  .flow { overflow-x: auto; }
}
@media (max-width: 700px) {
  .site-header { padding: 0 18px; }
  .page { width: calc(100% - 30px); padding-top: 28px; }
  .title-row { display: grid; }
  .create-button { width: 100%; }
  .create-menu { left: 0; right: auto; width: min(330px, calc(100vw - 30px)); }
  .field-grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .details { padding: 20px; }
  .flow { display: grid; grid-template-columns: 1fr; }
  .flow b { transform: rotate(90deg); text-align: center; }
  .header-right .online { display: none; }
}
