/* ============================================================
   CROWN CAPITAL FUND — «old money» premium theme
   Глубокая зелень + латунное золото + бордо, серифная типографика
   ============================================================ */

:root {
  --bg:        #10140F;   /* глубокий тёмно-оливковый, почти чёрный */
  --bg-2:      #0B0E09;
  --emerald:   #C6A867;   /* латунное золото — основной акцент (имя переменной сохранено) */
  --emerald-d: #A5854A;
  --blue:      #1A241C;   /* тёмная охотничья зелень — поверхности */
  --blue-2:    #33473A;   /* зелёные границы/ховеры */
  --text:      #ECE4D2;   /* слоновая кость */
  --text-dim:  #9E967F;   /* приглушённый тауп */
  --danger:    #9E3B4A;   /* бордо — минус/вывод */
  --warn:      #C69A3A;   /* тёмное золото */
  --bordeaux:  #6E2433;   /* насыщенное бордо для акцентов */
  --card:      rgba(27, 40, 31, 0.42);
  --card-brd:  rgba(198, 168, 103, 0.22);
  --radius:    10px;

  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1100px 560px at 82% -12%, rgba(198,168,103,0.10), transparent 60%),
    radial-gradient(900px 500px at -8% 14%, rgba(28,46,37,0.55), transparent 55%),
    radial-gradient(700px 500px at 50% 120%, rgba(110,36,51,0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1160px; margin: 0 auto; padding: 22px 18px 80px; }

/* ---------- типографика ---------- */
h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -0.02em; }
.mono { font-family: var(--font-mono); }
.dim { color: var(--text-dim); }
.emerald { color: var(--emerald); }
.danger { color: var(--danger); }
.warn { color: var(--warn); }
.up { color: var(--emerald); }
.down { color: var(--danger); }

.section-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-dim); margin-bottom: 12px; font-weight: 600;
}

/* ---------- карточки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: relative;
}
.card.glow { box-shadow: 0 0 24px rgba(198, 168, 103, 0.25); border-color: rgba(198,168,103,0.4); }

/* ---------- шапка ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 26px; flex-wrap: wrap;
}
.logo { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.logo .dot { color: var(--emerald); }
.logo .tag { font-size: 11px; color: var(--text-dim); letter-spacing: 0.2em; display: block; font-weight: 500; }

.profile-chip {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--card-brd);
  border-radius: var(--radius); padding: 10px 14px;
}
.avatar { width: 44px; height: 44px; border-radius: 10px; overflow: hidden; flex: none; border: 1px solid var(--card-brd); }
.avatar svg { display: block; width: 100%; height: 100%; }
.profile-chip .name { font-weight: 600; font-size: 14px; }
.profile-chip .id { font-size: 12px; }

/* ---------- сетки ---------- */
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2-3 { grid-template-columns: 1.5fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 26px; }

/* ---------- баланс ---------- */
.balance-hero .label { color: var(--text-dim); font-size: 13px; text-transform: uppercase; letter-spacing: 0.14em; }
.balance-hero .value {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(38px, 7vw, 64px); line-height: 1.05; margin: 6px 0 8px;
}
.balance-hero .meta { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; font-size: 14px; }

.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); }
.stat .v { font-family: var(--font-display); font-weight: 700; font-size: clamp(20px, 3vw, 28px); margin-top: 6px; }

/* ---------- формы / инпуты ---------- */
label.fld { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
input[type="text"], input[type="number"], input[type="date"], input[type="password"], input[type="email"], select, textarea {
  width: 100%; background: rgba(10,14,26,0.6); color: var(--text);
  border: 1px solid var(--blue-2); border-radius: 10px;
  padding: 11px 13px; font-family: var(--font-body); font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--emerald); box-shadow: 0 0 0 3px rgba(198,168,103,0.12); }
input.big { font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.02em; }

/* слайдер */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, var(--emerald) var(--fill,50%), var(--blue-2) var(--fill,50%)); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--emerald); cursor: pointer; box-shadow: 0 0 12px rgba(198,168,103,0.6); border: 2px solid #0A0E1A; }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--emerald);
  cursor: pointer; border: 2px solid #0A0E1A; }

/* радио-группа */
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label {
  flex: 1; text-align: center; padding: 10px; border: 1px solid var(--blue-2);
  border-radius: 10px; cursor: pointer; font-size: 14px; color: var(--text-dim); transition: .15s; user-select: none;
}
.radio-row input { display: none; }
.radio-row input:checked + span { color: var(--emerald); }
.radio-row label:has(input:checked) { border-color: var(--emerald); background: rgba(198,168,103,0.08); color: var(--emerald); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--emerald); color: #04140f; border: none; border-radius: 10px;
  padding: 11px 16px; font-family: var(--font-body); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: 0 0 18px rgba(198,168,103,0.5); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--blue-2); }
.btn.ghost:hover { border-color: var(--emerald); color: var(--emerald); box-shadow: none; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 7px 11px; font-size: 13px; }

.link { color: var(--emerald); text-decoration: none; font-size: 14px; border-bottom: 1px dotted rgba(198,168,103,0.5); }
.link:hover { border-bottom-style: solid; }

/* ---------- калькулятор результат ---------- */
.calc-result { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.calc-result .cell .k { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .1em; }
.calc-result .cell .v { font-family: var(--font-display); font-weight: 700; font-size: clamp(18px,2.6vw,24px); margin-top: 4px; }

.disclaimer {
  margin-top: 14px; font-size: 11.5px; line-height: 1.5; color: var(--text-dim);
  border-left: 2px solid var(--warn); padding: 8px 0 8px 12px;
  background: rgba(198, 154, 58, 0.05); border-radius: 0 8px 8px 0;
}
.disclaimer b { color: var(--warn); font-weight: 600; }

/* ---------- фаза рынка ---------- */
.phase-name { font-family: var(--font-display); font-weight: 700; font-size: clamp(26px,4vw,40px); }
.sentiment-bar { height: 10px; border-radius: 6px; background: var(--blue-2); overflow: hidden; margin: 12px 0 6px; }
.sentiment-bar > i { display: block; height: 100%; border-radius: 6px; transition: width .8s ease; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pulse-dot.on { background: var(--emerald); box-shadow: 0 0 0 0 rgba(198,168,103,0.7); animation: pulse 1.8s infinite; }
.pulse-dot.off { background: var(--danger); box-shadow: 0 0 0 0 rgba(158,59,74,0.7); animation: pulseR 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(198,168,103,0); } 100% { box-shadow: 0 0 0 0 rgba(198,168,103,0); } }
@keyframes pulseR { 70% { box-shadow: 0 0 0 10px rgba(158,59,74,0); } 100% { box-shadow: 0 0 0 0 rgba(158,59,74,0); } }

/* skeleton */
.skeleton { background: linear-gradient(90deg, var(--blue) 25%, var(--blue-2) 37%, var(--blue) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-dim); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .08em; padding: 10px 12px; border-bottom: 1px solid var(--blue-2); }
td { padding: 12px; border-bottom: 1px solid rgba(34,51,87,0.5); }
tr:hover td { background: rgba(26,39,68,0.3); }
.num { font-family: var(--font-mono); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.done { background: rgba(198,168,103,0.15); color: var(--emerald); }
.badge.pending { background: rgba(198,154,58,0.15); color: var(--warn); }
.badge.deposit { background: rgba(198,168,103,0.12); color: var(--emerald); }
.badge.withdraw { background: rgba(158,59,74,0.12); color: var(--danger); }

/* ---------- модалка ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(3,6,14,0.75); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 18px; z-index: 50; }
.modal-bg.open { display: flex; }
.modal { width: 100%; max-width: 440px; background: var(--bg-2); border: 1px solid var(--card-brd);
  border-radius: var(--radius); padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.modal h3 { margin-bottom: 16px; }
.modal .row { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--blue); border: 1px solid var(--emerald); color: var(--text);
  padding: 12px 18px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 100; font-size: 14px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- разное ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hidden { display: none !important; }
.copy-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.copy-btn:hover { color: var(--emerald); }
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; }

/* фикс автозаполнения браузера (тёмный фон вместо белого) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px rgba(10, 14, 26, 0.85) inset !important;
  box-shadow: 0 0 0 1000px rgba(10, 14, 26, 0.85) inset !important;
  border: 1px solid var(--blue-2) !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}

/* ---------- логотип-эмблема (PNG-маска, перекрашивается одной переменной) ---------- */
.logo { display: flex; align-items: center; gap: 10px; }
.brand-emblem {
  display: inline-block; width: 40px; height: 40px; flex: none;
  /* цвет логотипа — меняется здесь: */
  background-color: var(--emerald);
  -webkit-mask: url(logo.png) center / contain no-repeat;
          mask: url(logo.png) center / contain no-repeat;
  vertical-align: middle;
}
.brand-emblem svg { display: none; }
.auth-card .logo { justify-content: center; }
.auth-card .brand-emblem { width: 56px; height: 56px; }

/* ---------- логин-оверлей ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(900px 500px at 70% 0%, rgba(198,168,103,0.12), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { font-size: 26px; text-align: center; margin-bottom: 4px; }
.auth-card .tag { text-align: center; margin-bottom: 22px; }
.auth-card .card { padding: 26px; }
.auth-card h2 { font-size: 18px; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }
.auth-err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }
.auth-card .btn { width: 100%; margin-top: 16px; padding: 13px; }
.auth-hint { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 16px; }

/* ---------- график ---------- */
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-value { font-family: var(--font-display); font-weight: 700; font-size: clamp(22px,3vw,30px); }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); margin-top: 6px; font-family: var(--font-mono); }

/* аватар редактируемый */
.avatar-edit { position: relative; cursor: pointer; }
.avatar-edit .overlay {
  position: absolute; inset: 0; background: rgba(10,14,26,0.65); color: var(--emerald);
  display: flex; align-items: center; justify-content: center; font-size: 11px; text-align: center;
  opacity: 0; transition: .15s; border-radius: 10px;
}
.avatar-edit:hover .overlay { opacity: 1; }

/* сетка редактора */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

.role-badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
  background: rgba(198,168,103,0.12); color: var(--emerald); }
.role-badge.super { background: rgba(198,154,58,0.15); color: var(--warn); }

/* ---------- сделки ---------- */
.trade-builder { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.trade-builder .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .trade-builder { grid-template-columns: 1fr; } }

.dir-row label { flex: 1; }
.price-live { font-family: var(--font-mono); font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--emerald); box-shadow: 0 0 0 0 rgba(198,168,103,0.7); animation: pulse 1.8s infinite; margin-right: 5px; vertical-align: middle; }
.live-dot.sim { background: var(--warn); animation: none; }

.trade-open { border: 1px solid var(--card-brd); border-radius: 10px; padding: 14px; margin-top: 12px; background: rgba(10,14,26,0.35); }
.trade-open .th { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.pill.long { background: rgba(198,168,103,0.15); color: var(--emerald); }
.pill.short { background: rgba(158,59,74,0.15); color: var(--danger); }

.avail-bad { color: var(--danger) !important; }
.part-check { width: 18px; height: 18px; accent-color: var(--emerald); }
.trade-live-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; background: rgba(198,168,103,0.08); border: 1px solid var(--card-brd); border-radius: 8px; padding: 6px 12px; margin-top: 10px; }

/* ---------- топ-цены в карточке рынка ---------- */
.market-prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 6px; }
.mp-item { background: rgba(10,14,26,0.5); border: 1px solid var(--blue-2); border-radius: 10px; padding: 8px 10px; text-align: center; }
.mp-sym { font-family: var(--font-display); font-weight: 700; font-size: 13px; }
.mp-price { font-size: 13px; margin: 2px 0; }
.mp-chg { font-size: 11px; font-weight: 600; }

/* ---------- KPI: числа на одном уровне ---------- */
.kpi-strip { grid-template-columns: repeat(6, 1fr); }
.kpi-strip .stat { display: flex; flex-direction: column; justify-content: space-between; min-height: 104px; }
.kpi-strip .stat .k { min-height: 30px; }
.kpi-strip .stat .v { font-size: clamp(15px, 1.5vw, 20px); white-space: nowrap; font-variant-numeric: tabular-nums; margin-top: auto; }
@media (max-width: 1100px) { .kpi-strip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .kpi-strip { grid-template-columns: repeat(2, 1fr); } .kpi-strip .stat { min-height: 92px; } }

/* ---------- вкладки-панель ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.tab-btn { background: var(--card); border: 1px solid var(--blue-2); color: var(--text-dim);
  border-radius: 10px; padding: 9px 16px; font-family: var(--font-body); font-weight: 600; font-size: 14px; cursor: pointer; transition: .15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: rgba(198,168,103,0.1); border-color: var(--emerald); color: var(--emerald); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.icon-btn { background: rgba(198,168,103,0.1); border: 1px solid var(--card-brd); color: var(--emerald);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; transition: .15s; }
.icon-btn:hover { box-shadow: 0 0 12px rgba(198,168,103,0.4); }
.icon-btn.danger { background: rgba(158,59,74,0.12); border-color: rgba(158,59,74,0.35); color: var(--danger); }

/* ---------- чат / поддержка ---------- */
.faq-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.faq-chip { background: rgba(10,14,26,0.5); border: 1px solid var(--blue-2); color: var(--text);
  border-radius: 20px; padding: 7px 13px; font-size: 12.5px; cursor: pointer; transition: .15s; }
.faq-chip:hover { border-color: var(--emerald); color: var(--emerald); }
.chat-box { background: rgba(10,14,26,0.4); border: 1px solid var(--blue-2); border-radius: 12px;
  padding: 12px; height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { position: relative; max-width: 82%; padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg-del { position: absolute; top: 3px; right: 5px; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 11px; opacity: 0; transition: .15s; padding: 0 2px; line-height: 1; }
.msg:hover .msg-del { opacity: 0.8; }
.msg-del:hover { color: var(--danger); opacity: 1; }
.msg .msg-who { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; margin-bottom: 3px; }
.msg.investor { align-self: flex-end; background: rgba(198,168,103,0.14); border: 1px solid var(--card-brd); }
.msg.ai { align-self: flex-start; background: var(--blue); border: 1px solid var(--blue-2); }
.msg.admin { align-self: flex-start; background: rgba(198,154,58,0.12); border: 1px solid rgba(198,154,58,0.3); }
.chat-input-row { display: flex; gap: 8px; margin-top: 12px; }
.chat-input-row input { flex: 1; }
.chat-thread { border: 1px solid var(--blue-2); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.chat-thread .cth { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; cursor: pointer; background: rgba(26,39,68,0.3); }
.chat-thread .cbody { padding: 12px 14px; border-top: 1px solid var(--blue-2); display: none; }
.chat-thread.open .cbody { display: block; }

/* ---------- футер ---------- */
.app-footer { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--blue-2); }

/* ---------- адаптив ---------- */
@media (max-width: 860px) {
  .grid-3, .grid-2-3, .grid-4 { grid-template-columns: 1fr; }
  .calc-result { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  th.hide-sm, td.hide-sm { display: none; }
}
