:root {
  --bg: #0b0d10;
  --bg2: #0f1216;
  --sidebar: #12161c;
  --card: #171c23;
  --card2: #1c222b;
  --border: #232a35;
  --fg: #e7ecf1;
  --dim: #8a95a3;
  --dim2: #5c6570;
  --acc: #3ea8ff;
  --acc-warm: #f79b1a;
  --pos: #34d399;
  --neg: #f87171;
  --warn: #fbbf24;
  --err: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 240px;
  --tab-h: 60px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  background-image:
    radial-gradient(1200px 800px at -10% -20%, rgba(62,168,255,.06), transparent 60%),
    radial-gradient(1000px 700px at 110% 120%, rgba(247,155,26,.05), transparent 60%);
  color: var(--fg);
  font: 14.5px/1.55 "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv02","cv03","cv04","tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

/* ============ LOGIN ============ */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px;
  box-shadow: 0 10px 60px rgba(0,0,0,.4), 0 0 60px rgba(62,168,255,.05);
}
.login-card .logo {
  width: 104px; height: 104px; margin: 0 auto 18px; display: block;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(62,168,255,.3), 0 0 34px rgba(62,168,255,.22), 0 0 60px rgba(247,155,26,.14);
}
.login-card h1 { text-align: center; font-size: 19px; font-weight: 600; margin-bottom: 4px; letter-spacing: -.01em; }
.login-card .sub { text-align: center; color: var(--dim); margin-bottom: 22px; font-size: 13px; }
.login-card form { display: grid; gap: 12px; }
.login-card label { display: grid; gap: 6px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.login-card input {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--fg); font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--acc); }
.login-card button {
  margin-top: 6px; padding: 13px; border-radius: 10px; border: 0;
  background: linear-gradient(180deg, var(--acc), #2c8dd8);
  color: #001322; font-weight: 600; font-size: 14.5px; cursor: pointer;
  transition: transform .06s;
}
.login-card button:active { transform: scale(.98); }
.err {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.35);
  color: #fca5a5; border-radius: 10px; padding: 10px 12px; font-size: 13px;
}
.warn-banner {
  background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.35);
  color: var(--warn); border-radius: 12px; padding: 12px 14px; font-size: 13px;
  margin-bottom: 16px;
}
.info-banner {
  background: rgba(62,168,255,.08); border: 1px solid rgba(62,168,255,.3);
  color: #bfe0ff; border-radius: 12px; padding: 12px 14px; font-size: 13px;
  margin-bottom: 12px;
}

/* ============ APP SHELL ============ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 16px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand img {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(62,168,255,.25), 0 0 18px rgba(62,168,255,.18);
}
.sidebar-brand .name { font-weight: 600; letter-spacing: .01em; font-size: 14.5px; line-height: 1.15; }
.sidebar-brand .sub { color: var(--dim); font-size: 11px; }

.sidebar-section { color: var(--dim2); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; padding: 14px 12px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--dim); font-size: 14px;
  cursor: pointer; position: relative;
  margin: 2px 0;
}
.nav-item:hover { background: rgba(255,255,255,.03); color: var(--fg); }
.nav-item.on {
  background: rgba(62,168,255,.08); color: var(--fg);
}
.nav-item.on::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--acc); border-radius: 0 2px 2px 0;
}
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--acc); flex-shrink: 0; }
.nav-full { display: inline; }
.nav-short { display: none; }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }

.sidebar-foot {
  margin-top: auto; padding: 12px 12px 4px; border-top: 1px solid var(--border);
  color: var(--dim); font-size: 12px;
}
.sidebar-foot .who { color: var(--fg); font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.sidebar-foot .logout {
  display: inline-block; margin-top: 6px; color: var(--dim); font-size: 12px;
  background: transparent; border: 0; padding: 0; cursor: pointer;
}
.sidebar-foot .logout:hover { color: var(--neg); }

.main { padding: 24px 28px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; }
.page-title { font-size: 21px; font-weight: 600; letter-spacing: -.015em; }
.page-sub { color: var(--dim); font-size: 13px; }

/* ============ TILES ============ */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden; }
.tile .tile-label { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.tile .tile-value { font-size: 25px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.tile .tile-value small { font-size: 14px; color: var(--dim); font-weight: 500; margin-left: 6px; }
.tile .tile-sub { color: var(--dim); font-size: 12px; margin-top: 4px; }
.tile.pos .tile-value { color: var(--pos); }
.tile.neg .tile-value { color: var(--neg); }
.tile.acc { background: linear-gradient(150deg, var(--card), rgba(62,168,255,.05)); border-color: rgba(62,168,255,.2); }
.tile.big .tile-value { font-size: 34px; font-weight: 600; }

/* ============ CARDS / SECTIONS ============ */
.section { margin-bottom: 24px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-title { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.card + .card { margin-top: 10px; }

/* ============ LIST (rows) ============ */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.row .r-title { font-weight: 500; }
.row .r-sub { color: var(--dim); font-size: 12px; margin-top: 3px; }
.row .r-right { text-align: right; }
.row .r-amount { font-weight: 550; font-variant-numeric: tabular-nums; }
.row .r-amount.pos { color: var(--pos); }
.row .r-amount.neg { color: var(--neg); }
.row.link:hover { border-color: var(--acc); cursor: pointer; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.tag.in_progress { background: rgba(251,191,36,.15); color: var(--warn); }
.tag.done { background: rgba(52,211,153,.15); color: var(--pos); }
.tag.cancelled { background: rgba(138,149,163,.15); color: var(--dim); }

/* ============ FORMS ============ */
.form { display: grid; gap: 14px; max-width: 520px; }
.form label { display: grid; gap: 6px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.form input, .form select, .form textarea {
  padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--fg); font-size: 14px; outline: none;
  font-family: inherit;
}
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--acc); }
.form textarea { resize: vertical; min-height: 60px; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-block; padding: 10px 16px; border-radius: 10px; border: 0;
  cursor: pointer; font-weight: 500; font-size: 13.5px; text-align: center;
  font-family: inherit;
}
.btn.primary { background: linear-gradient(180deg, var(--acc), #2c8dd8); color: #001322; }
.btn.pos { background: linear-gradient(180deg, var(--pos), #22b381); color: #01221a; }
.btn.neg { background: transparent; color: var(--neg); border: 1px solid var(--neg); }
.btn.ghost { background: transparent; color: var(--dim); border: 1px solid var(--border); }
.btn:active { transform: scale(.98); }

/* ============ FILTERS ============ */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select, .filters input {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--fg); font-size: 13px;
}

/* ============ CHAT (AI) ============ */
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; min-height: 40vh; }
.msg { padding: 10px 14px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; word-break: break-word; }
.msg.user { background: var(--acc); color: #001322; align-self: flex-end; }
.msg.assistant { background: var(--card); border: 1px solid var(--border); align-self: flex-start; }
.chatbar { display: flex; gap: 8px; position: sticky; bottom: 12px; background: var(--bg); padding: 8px 0; }
.chatbar input { flex: 1; padding: 12px 14px; border-radius: 24px; border: 1px solid var(--border); background: var(--card); color: var(--fg); font-size: 15px; }
.chatbar button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--acc); color: #001322; font-size: 20px; cursor: pointer; }

/* ============ MOBILE ============ */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    height: auto; min-height: var(--tab-h);
    padding: 6px 2px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
    flex-direction: row; align-items: stretch;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    z-index: 10;
    background: rgba(18,22,28,.97); backdrop-filter: blur(12px);
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar-brand, .sidebar-section, .sidebar-foot { display: none; }

  .nav-item {
    flex: 1 0 auto; min-width: 46px; max-width: 88px;
    flex-direction: column; justify-content: flex-start; align-items: center;
    gap: 3px; padding: 6px 4px 4px; margin: 0;
    border-radius: 10px; font-size: 9.5px; line-height: 1.15;
    text-align: center; white-space: nowrap;
  }
  .nav-item .dot { width: 5px; height: 5px; margin-bottom: 1px; }
  .nav-item.on::before {
    top: 0; left: 24%; right: 24%; bottom: auto;
    width: auto; height: 2px; border-radius: 0 0 2px 2px;
  }
  .nav-badge {
    position: absolute; top: 1px; right: 50%; margin-right: -20px; margin-left: 0;
    min-width: 15px; height: 15px; line-height: 15px; font-size: 9.5px; padding: 0 4px;
  }
  .nav-full { display: none; }
  .nav-short { display: inline; }

  .main {
    padding: calc(14px + env(safe-area-inset-top)) 14px 24px;
  }
  .page-head { margin-bottom: 16px; }
  .page-title { font-size: 18px; }
  .tile .tile-value { font-size: 22px; }
  .tile.big .tile-value { font-size: 28px; }
  .tiles { gap: 10px; margin-bottom: 18px; }
  .tile { padding: 14px 16px; }
}


/* ============ RATES ============ */
.rates-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.rate {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.rate.hot {
  border-color: rgba(247,155,26,.4);
  background: linear-gradient(140deg, var(--card), rgba(247,155,26,.06));
}
.rate-pair { display: flex; align-items: center; gap: 8px; }
.rate-pair .cur { font-size: 13.5px; color: var(--fg); letter-spacing: .01em; }
.rate-pair .arrow { color: var(--dim2); font-size: 13px; }
.rate-val { font-size: 17px; font-weight: 550; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.rate-val.pct { color: var(--pos); }
.rate-val .fire { font-size: 13px; }

.personal-note {
  margin-top: 26px; padding: 16px 20px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(62,168,255,.09), rgba(247,155,26,.07));
  border: 1px solid rgba(62,168,255,.25);
  font-size: 14px; line-height: 1.6;
}
.personal-note strong { color: var(--acc-warm); font-weight: 600; }

/* ============ DEPOSIT ============ */
.deposit {
  margin-top: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
.deposit[open] { border-color: rgba(62,168,255,.35); }
.deposit summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 13px 16px; display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--fg);
}
.deposit summary::-webkit-details-marker { display: none; }
.deposit summary:hover { background: rgba(255,255,255,.02); }
.deposit-plus {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(180deg, var(--acc), #2c8dd8); color: #001322;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; font-weight: 500;
}
.deposit-net { color: var(--acc-warm); font-size: 12px; letter-spacing: .04em; }
.deposit-body { padding: 4px 16px 18px; border-top: 1px solid var(--border); }
.deposit-warn {
  margin: 14px 0; padding: 10px 13px; border-radius: 10px; font-size: 12.5px; line-height: 1.5;
  background: rgba(251,191,36,.07); border: 1px solid rgba(251,191,36,.3); color: #f5d68a;
}
.deposit-warn strong { color: var(--warn); font-weight: 600; }
.deposit-grid { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.deposit-qr {
  width: 148px; height: 148px; border-radius: 10px; background: #fff; padding: 6px; flex-shrink: 0;
}
.deposit-addr-wrap { flex: 1; min-width: 240px; }
.deposit-label { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 7px; }
.deposit-addr {
  display: block; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; line-height: 1.5; word-break: break-all; color: var(--fg);
}
.copy-btn { width: 100%; }
.copy-btn.copied { background: linear-gradient(180deg, var(--pos), #22b381); color: #01221a; }

@media (max-width: 560px) {
  .deposit-grid { justify-content: center; }
  .deposit-addr-wrap { min-width: 100%; }
}

.nav-badge {
  margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px;
  border-radius: 999px; background: var(--acc); color: #001322;
  font-size: 11px; font-weight: 600; line-height: 19px; text-align: center;
}

/* ============ ORDERS ============ */
.tag.st-draft      { background: rgba(138,149,163,.15); color: var(--dim); }
.tag.st-submitted  { background: rgba(62,168,255,.15); color: var(--acc); }
.tag.st-quoted     { background: rgba(251,191,36,.18); color: var(--warn); }
.tag.st-approved   { background: rgba(52,211,153,.15); color: var(--pos); }
.tag.st-in_progress{ background: rgba(62,168,255,.15); color: var(--acc); }
.tag.st-done       { background: rgba(52,211,153,.15); color: var(--pos); }
.tag.st-rejected,
.tag.st-cancelled,
.tag.st-expired    { background: rgba(248,113,113,.14); color: var(--neg); }

.quote-card {
  background: linear-gradient(150deg, var(--card), rgba(247,155,26,.07));
  border: 1px solid rgba(247,155,26,.35);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.quote-head {
  color: var(--acc-warm); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .1em; margin-bottom: 12px;
}
.quote-main { font-size: 17px; margin-bottom: 6px; }
.quote-main strong { font-weight: 600; }
.quote-sub { color: var(--dim); font-size: 13px; margin-top: 4px; }
.quote-timer {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  color: var(--warn); font-size: 13px; font-variant-numeric: tabular-nums;
}
.quote-timer.urgent { color: var(--neg); }

.field-hint {
  display: block; margin-top: 5px; font-size: 11.5px; color: var(--dim2);
  text-transform: none; letter-spacing: 0; line-height: 1.4;
}
.field-hint.calc { color: var(--acc); }
.field-hint.manual { color: var(--warn); }

/* ============ ACCOUNT / EXIT (мобильный) ============ */
.acct-btn { display: none; }

@media (max-width: 900px) {
  .acct-btn {
    display: flex; align-items: center; gap: 7px;
    position: fixed; top: calc(env(safe-area-inset-top) + 8px); right: 12px;
    z-index: 20; padding: 6px 12px 6px 13px;
    background: rgba(23,28,35,.92); backdrop-filter: blur(10px);
    border: 1px solid var(--border); border-radius: 999px;
    font-size: 12.5px; color: var(--dim);
  }
  .acct-btn .acct-name { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .acct-btn .acct-ico { color: var(--neg); font-size: 13px; }
  .main { padding-top: calc(52px + env(safe-area-inset-top)); }
}

.login-alt {
  display: block; text-align: center; margin-top: 18px;
  padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--dim); font-size: 12.5px;
}
.login-alt:hover { color: var(--acc); }
