/* Steel Phoenix EV Calculator — оформление в стиле sp-wiki (тёмная тема) */
:root {
  --sp-bg: #1f1f1f;
  --sp-surface: #252525;
  --sp-surface2: #2a2a2a;
  --sp-field: #191919;
  --sp-border: #333;
  --sp-border-hover: #444;
  --sp-border-field: #3a3a3a;
  --sp-text: #e8e8e8;
  --sp-muted: #a8a8a8;
  --sp-label: #8a8a8a;
  --sp-accent: #b7a3ff;
  --sp-accent-strong: #6d4fd8;
  --sp-pos: #7ee2a8;
  --sp-neg: #ff8a8a;
  --sp-radius: 12px;
  --sp-font: Onest, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sp-bg);
  color: var(--sp-text);
  font: 15px/1.5 var(--sp-font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--sp-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.container { max-width: 1040px; margin: 0 auto; padding: 0 24px; }

/* ---------- шапка ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--sp-bg);
  border-bottom: 1px solid var(--sp-border);
}
.site-header .container { display: flex; align-items: center; gap: 16px; height: 68px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--sp-text); margin-right: auto; }
.brand:hover { text-decoration: none; }
.brand img { width: 40px; height: auto; filter: invert(.92); }
.brand-name { display: block; font-weight: 600; font-size: 17px; line-height: 1.15; }
.brand-sub { display: block; color: var(--sp-muted); font-size: 15px; line-height: 1.15; }
.nav-link { color: #c9c9c9; font-size: 15px; padding: 6px 2px; }
.nav-link:hover { color: #fff; text-decoration: none; }
.lang { display: flex; border: 1px solid var(--sp-border-field); border-radius: 8px; overflow: hidden; }
.lang-btn {
  background: transparent; border: 0; padding: 5px 10px; font-size: 13px; font-weight: 600;
  color: var(--sp-label); cursor: pointer; letter-spacing: .04em;
}
.lang-btn.active { background: var(--sp-surface2); color: var(--sp-text); }

/* ---------- заголовок страницы ---------- */
.page-head { padding: 40px 0 8px; }
main.container > .section:first-child { margin-top: 32px; }
h1 { font-size: 34px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 10px; }
.lead { color: var(--sp-muted); font-size: 17px; margin: 0; }

.section { margin-top: 36px; }
.section-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.section-title {
  font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--sp-label); margin: 0;
}
.card { background: var(--sp-surface); border: 1px solid var(--sp-border); border-radius: var(--sp-radius); }

/* ---------- поля ---------- */
.input {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--sp-field); border: 1px solid var(--sp-border-field); border-radius: 6px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:hover { border-color: var(--sp-border-hover); }
.input:focus { border-color: var(--sp-accent); box-shadow: 0 0 0 3px rgba(183, 163, 255, .15); }
.input.num { font-variant-numeric: tabular-nums; text-align: right; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a8a8a8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select.input optgroup { color: var(--sp-label); font-style: normal; background: var(--sp-surface); }
select.input option { color: var(--sp-text); background: var(--sp-surface); }

.field { display: flex; flex-direction: column; gap: 6px; transition: opacity .15s; }
.field-label { font-size: 13px; color: var(--sp-muted); }
.field.unused { opacity: .45; }
.suffix { position: relative; }
.suffix .input { padding-right: 30px; }
.suffix::after {
  content: attr(data-suffix); position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--sp-label); pointer-events: none; font-size: 14px;
}

.settings { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; padding: 20px; }
.settings .field-roi { grid-column: span 2; }
.roi-line { display: flex; gap: 8px; }
.roi-line > * { flex: 1; }

/* ---------- x1000 / Top Jack: выделение ---------- */
.field-important .field-label { color: #d9c48f; }
.field-important .input { border-color: rgba(230, 184, 74, .28); }
.field-important .input:focus { border-color: rgba(230, 184, 74, .7); box-shadow: 0 0 0 3px rgba(230, 184, 74, .12); }

.shared-note { font-size: 13px; color: var(--sp-accent); }
.row-hint { grid-column: 2 / -1; margin: 0; font-size: 13px; color: #e6c07b; }
select.input:disabled { cursor: pointer; color: var(--sp-label); opacity: .8; }
.room-select.attention { animation: attention .9s ease; }
@keyframes attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 184, 74, 0); border-color: var(--sp-border-field); }
  30% { box-shadow: 0 0 0 4px rgba(230, 184, 74, .35); border-color: #e6b84a; }
}

/* ---------- фильтр румов ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--sp-border-field); color: #c9c9c9; font-size: 13px;
  transition: border-color .15s, background .15s, color .15s;
}
.chip:hover { border-color: var(--sp-border-hover); color: #fff; }
.chip.active { background: rgba(183, 163, 255, .14); border-color: rgba(183, 163, 255, .55); color: #fff; }

/* ---------- строки лимитов ---------- */
.stakes-card { padding: 8px 20px 20px; }
.grid-row {
  display: grid; align-items: center; gap: 10px;
  grid-template-columns: 22px minmax(140px, 1.3fr) minmax(160px, 1.9fr) repeat(4, minmax(72px, 1fr)) 100px 32px;
}
.rows-head { padding: 10px 0 8px; border-bottom: 1px solid var(--sp-border); }
.rows-head span { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sp-label); }
.rows-head .r { text-align: right; }
.stake-row { padding: 10px 0; border-bottom: 1px solid var(--sp-border); }
.stake-row:last-child { border-bottom: 0; }
.row-num { color: var(--sp-label); font-size: 13px; font-variant-numeric: tabular-nums; }
.cell { display: block; min-width: 0; }
.cell-label { display: none; }
.cell-ev { text-align: right; }
.row-ev { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.stake-row.has-chipev [data-f="chips"]:not(:placeholder-shown) { color: var(--sp-label); text-decoration: line-through; }
.input::placeholder { color: #6f6f6f; opacity: 1; }

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--sp-label);
}
.icon-btn:hover { border-color: var(--sp-border-field); color: var(--sp-neg); }
#rows.single .row-remove { visibility: hidden; }

.actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.hint { color: var(--sp-label); font-size: 13px; margin-left: auto; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; cursor: pointer;
  background: var(--sp-surface2); border: 1px solid var(--sp-border-hover); border-radius: 8px;
  font-size: 14px; font-weight: 500; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #555; background: #303030; }
.btn-primary { background: var(--sp-accent-strong); border-color: var(--sp-accent-strong); color: #fff; }
.btn-primary:hover { background: #7c60e6; border-color: #7c60e6; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--sp-muted); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; margin-left: auto; }
.btn-ghost:hover { background: transparent; border-color: var(--sp-border-field); color: var(--sp-text); }
.btn svg { flex: none; }
.btn.done { color: var(--sp-pos); }
.btn-share { border-color: rgba(183, 163, 255, .35); color: var(--sp-accent); background: transparent; }
.btn-share:hover { border-color: rgba(183, 163, 255, .65); background: rgba(183, 163, 255, .08); }
.tile { position: relative; }
.tile-copy {
  position: absolute; top: 14px; right: 14px; width: 28px; height: 28px; display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--sp-label); cursor: pointer;
  opacity: .55; transition: opacity .15s, border-color .15s, color .15s;
}
.tile:hover .tile-copy, .tile-copy:focus-visible { opacity: 1; }
.tile-copy:hover { border-color: var(--sp-border-field); color: var(--sp-text); }
.tile-copy.done { opacity: 1; color: var(--sp-pos); border-color: rgba(126, 226, 168, .4); }

/* ---------- результат ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); }
.tile { padding: 20px 22px; border-right: 1px solid var(--sp-border); border-bottom: 1px solid var(--sp-border); }
.tile:nth-child(3n) { border-right: 0; }
.tile:nth-last-child(-n+3) { border-bottom: 0; }
.tile-label { font-size: 13px; color: var(--sp-muted); }
.tile-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile-main .tile-value { font-size: 32px; }
.pos { color: var(--sp-pos); }
.neg { color: var(--sp-neg); }

.results-foot { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-top: 1px solid var(--sp-border); color: var(--sp-label); font-size: 13px; }
.results-foot .btn { margin-left: auto; height: 32px; }
#results.is-empty .tiles, #results.is-empty .results-foot, #results.is-empty #breakdown, #results.is-empty #impacts { display: none; }
.empty { display: none; padding: 28px 22px; color: var(--sp-muted); }
#results.is-empty .empty { display: block; }
.warnings { margin-top: 10px; color: #e6c07b; font-size: 13px; }

#breakdown { border-top: 1px solid var(--sp-border); }
#breakdown summary {
  padding: 12px 22px; cursor: pointer; color: var(--sp-muted); font-size: 13px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; list-style: none;
}
#breakdown summary::-webkit-details-marker { display: none; }
#breakdown summary::before { content: '▸ '; }
#breakdown[open] summary::before { content: '▾ '; }
.table-wrap { overflow-x: auto; padding: 0 22px 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--sp-border); white-space: nowrap; }
th { color: var(--sp-label); font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
tr:last-child td { border-bottom: 0; }

.site-footer { margin-top: 56px; border-top: 1px solid var(--sp-border); padding: 20px 0 32px; color: var(--sp-label); font-size: 13px; }

/* ---------- адаптив ---------- */
@media (max-width: 900px) {
  .settings { grid-template-columns: repeat(3, 1fr); }
  .settings .field-roi { grid-column: span 3; }
  .chips { margin-left: 0; }
}
@media (max-width: 760px) {
  .container { padding: 0 16px; }
  .site-header .container { height: 60px; }
  .brand img { width: 34px; }
  .nav-link.wide { display: none; }
  h1 { font-size: 28px; }
  .lead { font-size: 15px; }
  .settings { grid-template-columns: 1fr 1fr; padding: 16px; }
  .settings .field-roi { grid-column: span 2; }
  .stakes-card { padding: 4px 16px 16px; }
  .rows-head { display: none; }
  .grid-row { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .stake-row { padding: 16px 0; position: relative; }
  .row-num { position: absolute; top: 18px; right: 40px; }
  .cell-room { grid-column: 1 / -1; padding-right: 60px; }
  .cell-stake { grid-column: 1 / -1; }
  .row-hint { grid-column: 1 / -1; }
  .cell-label { display: block; font-size: 12px; color: var(--sp-label); margin-bottom: 4px; }
  .cell-ev { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; text-align: left; }
  .cell-ev .cell-label { margin: 0; }
  .row-remove { position: absolute; top: 12px; right: -6px; }
  #rows.single .row-num { right: 0; }
  .hint { margin-left: 0; width: 100%; order: 5; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile { padding: 16px; }
  .tile:nth-child(3n) { border-right: 1px solid var(--sp-border); }
  .tile:nth-child(2n) { border-right: 0; }
  .tile:nth-last-child(-n+3) { border-bottom: 1px solid var(--sp-border); }
  .tile:nth-last-child(-n+2) { border-bottom: 0; }
  .tile-value { font-size: 22px; }
  .tile-main .tile-value { font-size: 24px; }
}

/* ---------- влияние на EV ---------- */
.impacts { border-top: 1px solid var(--sp-border); padding: 14px 22px 16px; }
.impacts-title { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sp-label); margin-bottom: 10px; }
.impacts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile.tile-impact { border: 1px solid var(--sp-border); border-radius: 8px; padding: 12px 14px; }
.tile.tile-impact .tile-value { font-size: 20px; }
.tile.tile-impact .tile-copy { top: 8px; right: 8px; }
@media (max-width: 760px) { .impacts { padding: 14px 16px; } .impacts-grid { grid-template-columns: 1fr; } }

/* EV − Profit: недобор / перебор */
.tile.tile-diff { background: rgba(183, 163, 255, .03); box-shadow: inset 2px 0 0 rgba(183, 163, 255, .3); }
.tile-diff .tile-label { color: #c9c9c9; }
.tile-note { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 500; color: var(--sp-muted); }
.tile-note.neg { color: var(--sp-neg); }
.tile-note.pos { color: var(--sp-pos); }
.tile-note:empty { display: none; }
