:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1a2330;
  --muted: #6b7684;
  --line: #e6eaf0;
  --blue: #2f6fe4;
  --blue-d: #2257bf;
  --green: #1a9e54;
  --red: #e0443e;
  --soft: #eef2f7;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh; font-size: 15px;
}
a { color: var(--blue); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 18px; }

.topbar { background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark { display: block; flex: 0 0 auto; border-radius: 10px; box-shadow: 0 3px 9px rgba(22,24,29,.20); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 600; font-size: 21px; color: #16181d; letter-spacing: -.02em; white-space: nowrap;
}
.brand-name .tech {
  background: linear-gradient(90deg, #7a5cff, #2f9bf0, #15c474);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.brand-tag { font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.topbar-sub { color: var(--muted); font-size: 14px; font-weight: 400; }

.ym { display: flex; gap: 8px; }
.ym select { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 15px; background: var(--panel); color: var(--text); cursor: pointer; }
.ym select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,111,228,.12); }
#startMonth { min-width: 130px; } #startYear { min-width: 90px; }

.logo-wrap { position: relative; width: 22px; height: 22px; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.logo, .logo-ph { position: absolute; inset: 0; width: 22px; height: 22px; border-radius: 5px; }
.logo { object-fit: contain; background: #fff; z-index: 1; border: 1px solid var(--line); }
.logo-ph { display: flex; align-items: center; justify-content: center; background: #dbe2ec; color: #5a6677; font-size: 11px; font-weight: 700; }
.tk-cell { display: flex; align-items: center; gap: 10px; }
.tk-text { display: flex; flex-direction: column; }
.auth-area { display: flex; align-items: center; gap: 14px; }
.auth-email { color: var(--muted); font-size: 14px; }
.link { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 14px; font-weight: 600; padding: 4px; }
.link:hover { text-decoration: underline; }
.btn-sm { padding: 8px 14px; font-size: 14px; }

.res-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.res-bar .res-h { margin: 0; }
.share-btn { background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(47,111,228,.30); }
.share-btn:hover { background: var(--blue-d); }
.share-btn.ok { background: var(--green); box-shadow: 0 2px 8px rgba(26,158,84,.30); }

/* модалки */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(20,30,50,.45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-card { position: relative; width: min(440px, 100%); background: var(--panel); border-radius: 16px; padding: 26px 24px; box-shadow: 0 24px 60px rgba(20,30,50,.25); }
.modal-card.modal-wide { width: min(620px, 100%); }
.modal-x { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-x:hover { color: var(--text); }
.modal-title { font-size: 19px; margin: 0 0 6px; }
.modal-sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.modal-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px; margin-bottom: 14px; }
.modal-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,111,228,.12); }
.btn-block { width: 100%; }

.port-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.port-item:last-child { border-bottom: none; }
.port-main { display: flex; flex-direction: column; gap: 3px; }
.port-main b { font-size: 15px; }
.port-main span { color: var(--muted); font-size: 13px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--text); color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(20,30,50,.25); opacity: 0; transition: opacity .2s, transform .2s; z-index: 80; }
.toast.hidden { display: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.page-title { font-size: clamp(22px, 3.5vw, 30px); margin: 26px 0 18px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 1px 3px rgba(20,30,50,.04); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h2 { font-size: 18px; margin: 0; }
.panel-actions { display: flex; align-items: center; gap: 14px; }

.sum { font-size: 14px; font-weight: 600; }
.sum.ok { color: var(--green); }
.sum.bad { color: var(--red); }

.assets-head { display: grid; grid-template-columns: 1fr 130px 40px; gap: 12px; padding: 0 2px 8px; color: var(--muted); font-size: 13px; }
.asset-row { display: grid; grid-template-columns: 1fr 130px 40px; gap: 12px; margin-bottom: 10px; align-items: start; }

.ac { position: relative; }
.ti, .wi, .params input {
  width: 100%; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 15px;
}
.ti:focus, .wi:focus, .params input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,111,228,.12); }
.wt { display: flex; align-items: center; gap: 6px; }
.wt span { color: var(--muted); }
.rm { width: 40px; height: 42px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; color: var(--muted); font-size: 20px; cursor: pointer; }
.rm:hover { border-color: var(--red); color: var(--red); }

.ac-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20,30,50,.14); overflow: hidden; max-height: 320px; overflow-y: auto; }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 9px 13px; cursor: pointer; }
.ac-item:hover, .ac-item.on { background: var(--soft); }
.ac-item b { font-weight: 700; min-width: 60px; }
.ac-item span { color: var(--muted); font-size: 14px; }

.btn { border: none; border-radius: 10px; cursor: pointer; font-size: 15px; font-weight: 600; padding: 11px 18px; transition: background .12s, border-color .12s; }
.btn-add { background: var(--soft); color: var(--blue); margin-top: 4px; }
.btn-add:hover { background: #e3eaf6; }
.btn-ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--blue); }
.btn-reset { color: var(--muted); }
.btn-reset:hover { color: var(--red); border-color: var(--red); }
.btn-primary { background: var(--blue); color: #fff; padding: 13px 28px; font-size: 16px; }
.btn-primary:hover { background: var(--blue-d); }
.btn-primary:disabled { opacity: .6; cursor: progress; }

.params { display: flex; flex-wrap: wrap; gap: 18px; margin: 22px 0 4px; padding-top: 20px; border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { color: var(--muted); font-size: 13px; }
.tax { display: flex; gap: 16px; align-items: center; height: 42px; }
.tax label { display: flex; align-items: center; gap: 6px; font-size: 15px; cursor: pointer; }
.check { display: flex; align-items: center; gap: 7px; height: 42px; font-size: 15px; cursor: pointer; }
.check input { width: 17px; height: 17px; }

.seo { margin: 40px 0 8px; color: var(--muted); }
.seo h2 { font-size: 17px; color: var(--text); margin: 0 0 12px; }
.seo p { font-size: 13.5px; line-height: 1.7; margin: 0 0 12px; }
.seo b { color: var(--text); }

.calc-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 18px; }
.err { color: var(--red); font-size: 14px; margin: 0; }

/* результат */
#out { margin-top: 26px; }
.loading { text-align: center; color: var(--muted); padding: 30px; }
.res-h { font-size: 22px; margin: 0 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.card .lbl { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.card .val { font-size: 23px; font-weight: 700; white-space: nowrap; }
.card .sub { font-size: 14px; font-weight: 600; margin-top: 4px; }
.pos { color: var(--green); } .neg { color: var(--red); } .muted { color: var(--muted); }

.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 18px; }
.chart-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.chart { width: 100%; height: auto; display: block; cursor: crosshair; }
.chart-cap { color: var(--muted); font-size: 12px; text-align: center; margin-top: 8px; }
.nochart { color: var(--muted); text-align: center; padding: 30px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.shares { white-space: nowrap; color: var(--text); }
.shares .arr { color: var(--muted); margin: 0 5px; }
.res-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; font-size: 15px; }
.res-table th { text-align: right; color: var(--muted); font-weight: 600; font-size: 13px; padding: 13px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.res-table th:first-child, .res-table td:first-child { text-align: left; }
.res-table td { text-align: right; padding: 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.res-table tr:last-child td { border-bottom: none; }
.res-table tbody tr:hover { background: var(--soft); }
.tk { font-weight: 700; }
.tk small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; margin: 36px 0; line-height: 1.6; }

@media (max-width: 560px) {
  .assets-head, .asset-row { grid-template-columns: 1fr 96px 38px; }
  .res-table { font-size: 13px; }
  .res-table td, .res-table th { padding: 10px 8px; }
}
