:root {
  --bg: #080a0f;
  --panel: #10141d;
  --panel2: #151b25;
  --panel3: #0c1018;
  --line: #2b3546;
  --line2: #3a465a;
  --text: #f3f7ff;
  --muted: #9ba8ba;
  --accent: #d8ff5d;
  --accent2: #85b8ff;
  --danger: #ff6464;
  --success: #5dff9a;
  --warning: #ffd166;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

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

button,
input,
select,
textarea {
  font: inherit;
  border-radius: 0;
}

button {
  border-radius: 0;
}

input,
select,
textarea {
  width: 100%;
  background: #090d14;
  color: var(--text);
  border: 1px solid var(--line);
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

.topbar {
  width: 100%;
  min-height: 68px;
  padding: 0 28px;
  background: rgba(8, 10, 15, .96);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.brand-mark {
  width: 18px;
  height: 18px;
  background: var(--accent);
  display: inline-block;
  border-radius: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.nav a:hover {
  color: var(--text);
}

main {
  width: 100%;
}

.wide-section,
.section {
  width: 100%;
  padding: 38px 34px;
  border-bottom: 1px solid var(--line);
}

.hero {
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(360px, .75fr);
  gap: 18px;
  align-items: stretch;
}

.hero-main,
.market-summary,
.card,
.trade-workspace,
.side-panel,
.trade-card,
.chart-panel,
.cabinet-panel {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 0;
}

.hero-main {
  padding: 48px;
}

.label {
  display: inline-block;
  padding: 7px 10px;
  background: #1b2331;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-radius: 0;
  margin-bottom: 18px;
}

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

h1 {
  max-width: 1060px;
  font-size: clamp(36px, 5vw, 72px);
  line-height: .96;
  margin-bottom: 22px;
}

h2 {
  font-size: clamp(28px, 3vw, 44px);
  margin-bottom: 10px;
}

h3 {
  font-size: 20px;
  margin-bottom: 12px;
}

p {
  color: var(--muted);
  line-height: 1.62;
}

.lead {
  max-width: 980px;
  font-size: 18px;
}

.hero-actions,
.product-tabs,
.periods {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn,
.mini {
  min-height: 44px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: #141a25;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 0;
}

.btn:hover,
.mini:hover {
  border-color: var(--accent);
}

.btn.primary,
.mini.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
  font-weight: 900;
}

.btn.full {
  width: 100%;
}

.market-summary,
.side-panel,
.cabinet-panel {
  padding: 22px;
}

.panel-title {
  color: var(--muted);
  margin-bottom: 12px;
}

.summary-row,
.metric,
.book-row,
.tape-row,
.order-row,
.history-row,
.seller-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.summary-row strong,
.metric strong {
  color: var(--accent);
}

.note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 22px;
}

.section-head.compact {
  align-items: flex-start;
}

.tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 220px;
  gap: 10px;
  min-width: min(720px, 100%);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  padding: 22px;
}

.product-image {
  height: 150px;
  background: #090d14;
  border: 1px solid var(--line);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 900;
  margin-bottom: 16px;
  border-radius: 0;
}

.card-meta {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.trade-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, .55fr);
  gap: 16px;
}

.trade-workspace {
  padding: 22px;
}

.last-price {
  min-width: 190px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: var(--panel3);
  border-radius: 0;
}

.last-price span {
  color: var(--muted);
  font-size: 12px;
  display: block;
}

.last-price strong {
  display: block;
  color: var(--accent);
  font-size: 28px;
  margin-top: 4px;
}

.product-tabs {
  margin: 18px 0;
}

.simple-trade {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.trade-card {
  padding: 18px;
}

.trade-card label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin: 12px 0 7px;
}

.result-box {
  min-height: 40px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.chart-panel {
  padding: 18px;
}

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

canvas {
  width: 100%;
  height: 360px;
  display: block;
  background:
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,.045) 1px, transparent 1px),
    #090d14;
  background-size: 58px 58px;
  border: 1px solid var(--line);
  border-radius: 0;
}

.side-panels {
  display: grid;
  gap: 16px;
  align-content: start;
}

.book-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  color: var(--danger);
  font-size: 12px;
  text-transform: uppercase;
  padding: 8px 0;
  border-bottom: 1px solid var(--line2);
}

.buy-head {
  color: var(--success);
}

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

.spread {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel3);
  color: var(--muted);
  border-radius: 0;
}

.tape-row,
.order-row {
  font-size: 14px;
}

.tape-row strong {
  color: var(--accent);
}

.seller-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr);
  gap: 16px;
}

.seller-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
}

.seller-form textarea,
.seller-form button {
  grid-column: span 2;
}

.cabinet-grid {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.status {
  display: inline-flex;
  padding: 5px 8px;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 12px;
  border-radius: 0;
}

footer {
  width: 100%;
  padding: 24px 34px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

@media (max-width: 1100px) {
  .hero,
  .trade-layout,
  .seller-layout,
  .cabinet-grid {
    grid-template-columns: 1fr;
  }

  .product-grid,
  .simple-trade {
    grid-template-columns: 1fr;
  }

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

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .seller-form {
    grid-template-columns: 1fr;
  }

  .seller-form textarea,
  .seller-form button {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
  }

  .nav {
    display: none;
  }

  .wide-section,
  .section {
    padding: 24px 16px;
  }

  .hero-main {
    padding: 28px;
  }

  .panel-top {
    align-items: stretch;
    flex-direction: column;
  }

  footer {
    padding: 22px 16px;
    flex-direction: column;
  }
}

/* STEP 5 MVP polish: sharp, strict, no rounded corners */
.explain-box {
  background: #0c1018;
  border: 1px solid var(--line);
  padding: 18px;
  margin: 18px 0;
  border-radius: 0;
}

.explain-box h3 {
  margin-bottom: 8px;
}

.explain-box p {
  margin-bottom: 0;
}

.depth-row {
  position: relative;
  overflow: hidden;
}

.depth-row::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  right: 0;
  width: var(--depth, 0%);
  background: rgba(216, 255, 93, .08);
  z-index: 0;
  border-radius: 0;
}

.depth-row.sell-depth::before {
  background: rgba(255, 100, 100, .10);
}

.depth-row.buy-depth::before {
  background: rgba(93, 255, 154, .10);
}

.depth-row > span,
.depth-row > strong {
  position: relative;
  z-index: 1;
}

.result-box.success {
  color: var(--success);
  border: 1px solid rgba(93, 255, 154, .35);
  background: rgba(93, 255, 154, .06);
  padding: 10px;
  border-radius: 0;
}

.result-box.empty {
  color: var(--warning);
  border: 1px solid rgba(255, 209, 102, .35);
  background: rgba(255, 209, 102, .06);
  padding: 10px;
  border-radius: 0;
}

.trade-summary {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.trade-summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

@media (max-width: 760px) {
  .side-panels {
    grid-template-columns: 1fr;
  }

  .side-panel {
    max-height: 460px;
    overflow: auto;
  }
}

/* STEP 6 second kwork foundation */
.stage2-section {
  background: #080a0f;
}

.stage2-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 16px;
}

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

.stage2-row strong {
  display: block;
  margin-bottom: 6px;
}

.stage2-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.stage2-row em {
  color: var(--accent);
  font-style: normal;
  white-space: nowrap;
}

.seller-public-card {
  border: 1px solid var(--line);
  background: #090d14;
  padding: 16px;
  border-radius: 0;
}

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

.admin-cell {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  padding: 18px;
  border-radius: 0;
}

.admin-cell span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.admin-cell strong {
  display: block;
  color: var(--accent);
  font-size: 30px;
}

.notification-item {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  color: var(--muted);
}

@media (max-width: 1300px) {
  .stage2-grid {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }

  .admin-matrix {
    grid-template-columns: repeat(2, minmax(190px, 1fr));
  }
}

@media (max-width: 760px) {
  .stage2-grid,
  .admin-matrix {
    grid-template-columns: 1fr;
  }
}

/* STEP 7 second kwork interactive actions */
.stage2-extended-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr);
  gap: 16px;
  margin-top: 16px;
}

.stage2-row-action {
  align-items: flex-start;
}

.stage2-actions {
  min-width: 150px;
  display: grid;
  gap: 7px;
  justify-items: stretch;
}

.stage2-actions button {
  min-height: 34px;
  padding: 7px 9px;
  background: #111722;
  color: var(--text);
  border: 1px solid var(--line);
  cursor: pointer;
  border-radius: 0;
}

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

.stage2-actions em.ok,
.stage2-row em.ok {
  color: var(--success);
}

.stage2-actions em.warn,
.stage2-row em.warn {
  color: var(--warning);
}

.stage2-actions em.bad,
.stage2-row em.bad {
  color: var(--danger);
}

.status-step {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.status-step strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
}

.status-step span {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 900px) {
  .stage2-extended-grid {
    grid-template-columns: 1fr;
  }

  .stage2-row-action {
    flex-direction: column;
  }

  .stage2-actions {
    width: 100%;
  }
}

/* STEP 8 second kwork SEO finish */
.seo-page {
  min-height: calc(100vh - 68px);
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.finish-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
}

.finish-card {
  display: block;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  padding: 18px;
  border-radius: 0;
}

.finish-card:hover {
  border-color: var(--accent);
}

.finish-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.finish-card span {
  display: block;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .finish-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 760px) {
  .seo-grid,
  .finish-grid {
    grid-template-columns: 1fr;
  }
}

/* STEP 13 real API bridge */
.api-status-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: #090d14;
  padding: 11px 12px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  border-radius: 0;
}

.api-status-panel strong {
  color: var(--text);
}

.api-status-panel.ok {
  border-color: rgba(93, 255, 154, .45);
}

.api-status-panel.ok span {
  color: var(--success);
}

.api-status-panel.bad {
  border-color: rgba(255, 100, 100, .45);
}

.api-status-panel.bad span {
  color: var(--danger);
}

/* STEP 14 API frontend polish */
.api-status-panel {
  flex-wrap: wrap;
}

.api-status-panel button {
  margin-left: auto;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #111722;
  color: var(--text);
  cursor: pointer;
  border-radius: 0;
}

.api-status-panel button:hover {
  border-color: var(--accent);
}

.book-row.best-level {
  border-color: rgba(216, 255, 93, .45);
}

.book-row.best-level strong {
  color: var(--accent);
}

.empty-book {
  color: var(--muted);
  opacity: .85;
}

@media (max-width: 760px) {
  .api-status-panel button {
    width: 100%;
    margin-left: 0;
  }
}
