:root {
  --bg: #0b1220;
  --panel: #111a2e;
  --panel-2: #0f172a;
  --border: #22314f;
  --text: #e5ecff;
  --muted: #8fa4cc;
  --positive: #2ecc71;
  --negative: #ef5350;
  --accent: #4f8cff;
}

* { box-sizing: border-box; }
html, body { width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: radial-gradient(1000px 500px at 50% -10%, #15203b 0%, var(--bg) 55%);
  color: var(--text);
}
.app-shell { width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { max-width: 100%; overflow-x: hidden;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.topbar { padding: 18px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
h1 { margin: 0; font-size: clamp(1.5rem, 5vw, 2rem); }
.subtext { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.switch-row { font-size: 13px; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; }
.btn, .tab, .range-toggle, .icon-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  background: #182340;
  color: var(--text);
  cursor: pointer;
}
.btn-primary { background: linear-gradient(180deg, #3f7ef5, #2c63d4); border-color: #3d70d4; }
.btn-secondary { background: #182340; }
.btn-danger { background: linear-gradient(180deg, #b84444, #8f2f2f); border-color: #bc4d4d; }
.tabs { display: flex; gap: 8px; }
.tab.active { border-color: #426ec2; background: #1f315a; }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.metric { padding: 14px; }
.metric p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.metric h3 { margin: 0; font-size: 1.25rem; }
.charts-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 12px; margin-top: 12px; }
.chart-card, .table-card { padding: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 1.05rem; }
.chart-controls { display: flex; gap: 8px; }
.range-toggle { padding: 6px 10px; }
.range-toggle.active { background: #264588; border-color: #406cc7; }
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { border-bottom: 1px solid var(--border); padding: 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 8px; font-size: 11px; border: 1px solid transparent; }
.badge-stale { background: #4a3f1f; color: #ffd05c; border-color: #7a6522; margin-left: 6px; }
.badge-buy { background: #173b29; color: #68e4a0; border-color: #276d4b; }
.badge-sell { background: #46202a; color: #ff8ea7; border-color: #7d3548; }
.pos { color: var(--positive); }
.neg { color: var(--negative); }
.status { margin: 2px 2px 0; color: var(--muted); font-size: 13px; min-height: 18px; }
.chart-empty { color: var(--muted); margin: 0 0 10px; }
.hidden { display: none !important; }

.modal {
  position: fixed; inset: 0; background: rgba(4, 8, 20, 0.75); display: grid; place-items: center; padding: 16px;
}
.modal-card { width: min(620px, 100%); padding: 14px; }
.icon-btn { padding: 6px 10px; }
.tx-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tx-form label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.tx-form input, .tx-form select {
  background: #0e1629; border: 1px solid var(--border); border-radius: 9px; color: var(--text); padding: 10px;
}
.tx-form .full { grid-column: 1 / -1; }
.tx-form .check { display: flex; align-items: center; gap: 8px; }

.field-error { color: var(--negative); font-size: 11px; }
.input-error { border-color: var(--negative) !important; }
.tx-form input:disabled { opacity: 0.7; cursor: not-allowed; }
.modal-actions { display: flex; justify-content: flex-end; }
.toast {
  position: fixed; bottom: 14px; right: 14px; max-width: 320px;
  background: #17315f; color: #dce8ff; border: 1px solid #355aa2; border-radius: 10px; padding: 10px 12px;
}

@media (max-width: 860px) {
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .app-shell { padding: 12px; }
  .tx-form { grid-template-columns: 1fr; }
  table { min-width: 540px; }
}

.monitor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 10px; }
.monitor-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.monitor-grid input, .monitor-grid select { background: #0e1629; border: 1px solid var(--border); border-radius: 9px; color: var(--text); padding: 10px; }
.monitor-actions { display: flex; gap: 10px; margin: 8px 0 12px; flex-wrap: wrap; }
.monitor-result ul { margin: 6px 0 12px; padding-left: 18px; color: var(--text); }

.assets-head { align-items: flex-start; }
.assets-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.assets-controls input, .assets-controls select { background: #0e1629; border: 1px solid var(--border); border-radius: 9px; color: var(--text); padding: 8px 10px; }
.badge-hidden { background: #21384f; color: #9ac7ff; border-color: #335f88; margin-left: 6px; }
.badge-partial { background: #4a3f1f; color: #ffd05c; border-color: #7a6522; margin-left: 6px; }
.btn-small { padding: 6px 10px; font-size: 12px; }

.spark { width: 96px; height: 24px; display: inline-block; }

.asset-row-main { cursor: pointer; }
.asset-details-body { display: grid; gap: 10px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.asset-kpi { background: #0e1629; border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.asset-kpi .label { color: var(--muted); font-size: 12px; margin-bottom: 4px; display: block; }
.asset-list { margin: 0; padding-left: 18px; }
.asset-modal-card { width: min(760px, 100%); max-height: 90vh; overflow: auto; }


.clear-confirm-grid { display: grid; gap: 10px; margin: 12px 0; }
.clear-confirm-grid label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.clear-confirm-grid input[type="text"], .clear-confirm-grid input:not([type]) { background: #0e1629; border: 1px solid var(--border); border-radius: 9px; color: var(--text); padding: 10px; }

.bank-grid { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.bank-actions { display:flex; gap:8px; flex-wrap:wrap; }

.bank-inline-error { margin: 0 0 10px; padding: 8px 10px; border: 1px solid #7d3548; border-radius: 10px; background: #46202a; color: #ffbfcb; font-size: 13px; }
canvas { width: 100% !important; max-width: 100%; }

html, body { max-width: 100%; }
body { min-height: calc(var(--app-vh, 1vh) * 100); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.topbar > div { min-width: 0; }
.top-controls, .actions, .tabs { flex-wrap: wrap; }
.tabs { row-gap: 8px; }
.actions .btn { min-width: 0; }
.table-wrap { -webkit-overflow-scrolling: touch; }


.chart-card canvas { display:block; }
@media (max-width: 520px) { .metrics-grid { grid-template-columns: 1fr; } .bank-grid { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .app-shell { padding: 8px; gap: 10px; } .topbar { padding: 12px; } .card-head h2 { font-size: 0.95rem; } .btn,.tab,.range-toggle,.icon-btn { padding: 8px 10px; font-size: 12px; } th, td { padding: 8px 6px; font-size: 12px; } }

.plans-list { display:flex; flex-direction:column; gap:8px; }
.plan-row { display:flex; gap:8px; align-items:center; justify-content:space-between; flex-wrap:wrap; border:1px solid rgba(255,255,255,.08); border-radius:10px; padding:8px; }
.plan-actions { display:flex; gap:6px; flex-wrap:wrap; }


body { min-height: 100dvh; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.top-controls { display:flex; justify-content:flex-end; margin-bottom:8px; }
.lang-select select { background:#0e1629; border:1px solid var(--border); color:var(--text); border-radius:8px; padding:6px 8px; }
.actions { max-width:100%; }
#monitor-asset-changes, #monitor-recent-alerts { margin: 0 0 12px; padding-left: 18px; }

@media (max-width: 480px) { .actions { width:100%; justify-content:flex-start; } .actions .btn { padding:8px 9px; font-size:12px;} .topbar { gap:8px; } .tabs { overflow-x:auto; } }
