:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #11151a;
  --surface-2: #171c22;
  --surface-3: #1d232a;
  --line: #29313a;
  --line-strong: #38434e;
  --text: #f1f4f6;
  --muted: #929da8;
  --faint: #64707c;
  --accent: #46d59a;
  --accent-strong: #22b97c;
  --cyan: #55b8e8;
  --gold: #e8bd57;
  --danger: #f2706f;
  --danger-soft: #3a2023;
  --success-soft: #17352b;
  --radius: 6px;
  --shadow: 0 18px 45px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
[hidden] { display: none !important; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

.loading-view { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--muted); font-size: 13px; }
.loading-view .brand-mark { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup strong { display: block; font-size: 15px; font-weight: 780; }
.brand-lockup span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #397c63; border-radius: 6px; background: #12241e; color: var(--accent); font-weight: 850; }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(390px, 1.08fr) minmax(420px, .92fr); }
.login-brand { padding: clamp(42px, 7vw, 96px); display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); background: #0e1115; }
.login-brand .brand-lockup { position: absolute; top: 40px; }
.login-signal { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 12px; font-weight: 650; text-transform: uppercase; }
.signal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(70, 213, 154, .12); }
.login-brand h1 { max-width: 680px; margin: 18px 0 14px; font-size: clamp(40px, 5.2vw, 72px); line-height: 1.02; font-weight: 780; }
.login-brand > p { max-width: 570px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.65; }
.login-preview { max-width: 620px; margin-top: 48px; display: grid; grid-template-columns: 1.5fr 1fr 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.login-preview > div { min-width: 0; padding: 18px 18px 18px 0; }
.login-preview > div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.login-preview span { display: block; margin-bottom: 7px; color: var(--faint); font-size: 11px; text-transform: uppercase; }
.login-preview strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.login-preview b { color: var(--accent); }

.login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(40px, 8vw, 110px); background: var(--bg); }
.mobile-brand { display: none; }
.login-form-heading > span, .eyebrow, .panel-heading span { color: var(--accent); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.login-form-heading h2 { margin: 10px 0 8px; font-size: 27px; }
.login-form-heading p { margin: 0 0 34px; color: var(--muted); font-size: 14px; }
#login-form { display: grid; }
#login-form label { margin: 17px 0 8px; color: #c6cdd3; font-size: 12px; font-weight: 650; }
.field-wrap { height: 48px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); padding: 0 14px; color: var(--faint); transition: border-color .16s, box-shadow .16s; }
.field-wrap:focus-within { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(70, 213, 154, .1); color: var(--accent); }
.field-wrap input { min-width: 0; width: 100%; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.field-wrap .icon-button { margin-right: -8px; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--surface-3); color: var(--text); }
.primary-button, .secondary-button { height: 46px; border: 0; border-radius: var(--radius); font-weight: 720; cursor: pointer; }
.primary-button { margin-top: 26px; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--accent); color: #07110d; }
.primary-button:hover { background: #62e3ad; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button .icon { transform: rotate(45deg); }
.form-error { margin: 14px 0 0; padding: 11px 12px; border: 1px solid #66363a; border-radius: var(--radius); background: var(--danger-soft); color: #ffb0af; font-size: 12px; }
.secure-note { margin-top: 20px; display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 11px; }
.secure-note .icon { width: 15px; height: 15px; }

.app-view { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; height: 66px; padding: 0 clamp(18px, 4vw, 54px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(11, 13, 16, .96); backdrop-filter: blur(14px); }
.brand-lockup.compact .brand-mark { width: 33px; height: 33px; }
.account-cluster { display: flex; align-items: center; gap: 8px; }
.account-copy { padding-right: 10px; text-align: right; }
.account-copy strong { display: block; font-size: 12px; }
.account-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.top-action { border: 1px solid var(--line); background: var(--surface); }

.dashboard-shell { width: min(1520px, calc(100% - 36px)); margin: 0 auto; padding: 36px 0 56px; }
.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.dashboard-heading h1 { margin: 6px 0 5px; font-size: 28px; line-height: 1.2; }
.dashboard-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.filters { display: flex; align-items: center; gap: 10px; }
.select-control { position: relative; height: 38px; min-width: 190px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0 10px; color: var(--muted); }
.select-control select { width: 100%; border: 0; outline: 0; appearance: none; background: transparent; color: var(--text); font-size: 12px; cursor: pointer; }
.select-control .chevron { width: 15px; }
.segmented { height: 38px; display: flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.segmented button { min-width: 62px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { min-width: 0; height: 112px; display: flex; align-items: center; gap: 15px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 5px; }
.metric-icon .icon { width: 20px; height: 20px; }
.metric-card.coin .metric-icon { background: #30281a; color: var(--gold); }
.metric-card.net .metric-icon { background: #172c35; color: var(--cyan); }
.metric-card.incoming .metric-icon { background: var(--success-soft); color: var(--accent); }
.metric-card.outgoing .metric-icon { background: var(--danger-soft); color: var(--danger); }
.metric-card span { display: block; color: var(--muted); font-size: 11px; }
.metric-card strong { display: block; margin: 5px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(19px, 2vw, 25px); }
.metric-card small { display: block; color: var(--faint); font-size: 10px; }
.positive { color: var(--accent) !important; }
.negative { color: var(--danger) !important; }

.dashboard-grid { margin-top: 12px; display: grid; grid-template-columns: minmax(0, 3fr) minmax(240px, 1fr); gap: 12px; }
.content-grid { margin-top: 12px; display: grid; grid-template-columns: minmax(0, 1.17fr) minmax(0, .83fr); gap: 12px; align-items: start; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel-heading { min-height: 70px; padding: 17px 19px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 5px 0 0; font-size: 16px; }
.panel-heading span { color: var(--muted); }
.panel-icon { color: var(--faint); }
.chart-summary { color: var(--text); font-size: 13px; font-weight: 700; }
.chart-wrap { position: relative; height: 264px; padding: 12px 10px 0; }
#coin-chart { width: 100%; height: 100%; overflow: visible; }
.grid-line { stroke: #26303a; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-line { fill: none; stroke: var(--cyan); stroke-width: 2.2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart-area { fill: rgba(85, 184, 232, .10); stroke: none; }
.chart-axis { height: 32px; padding: 0 20px; display: flex; justify-content: space-between; color: var(--faint); font-size: 10px; }
.bag-panel { min-height: 366px; }
.bag-gauge { height: 225px; display: grid; place-items: center; }
.bag-ring { width: 150px; height: 150px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--accent) var(--bag-progress, 0%), var(--surface-3) 0); position: relative; }
.bag-ring::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); }
.bag-ring > div { z-index: 1; text-align: center; }
.bag-ring strong { display: block; font-size: 30px; }
.bag-ring span { color: var(--muted); font-size: 10px; }
.bag-meta { height: 70px; padding: 0 19px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.bag-meta strong { color: var(--text); }

.activity-panel, .ledger-panel { min-height: 430px; }
.count-badge { padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted) !important; font-size: 10px !important; text-transform: none !important; }
.activity-list { max-height: 620px; overflow: auto; }
.activity-row { padding: 16px 19px; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border-bottom: 0; }
.activity-time { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 5px; background: var(--surface-3); color: var(--muted); }
.activity-time .icon { width: 17px; height: 17px; }
.activity-main { min-width: 0; }
.activity-title { display: flex; align-items: baseline; gap: 7px; }
.activity-title strong { font-size: 12px; }
.activity-title span { color: var(--faint); font-size: 10px; }
.activity-items { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.item-chip { max-width: 100%; padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); color: #cbd3d9; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-chip.added { border-color: #285241; color: #86e4bc; }
.item-chip.removed { border-color: #573137; color: #f2a4a3; }
.activity-money { text-align: right; }
.activity-money strong { display: block; font-size: 12px; }
.activity-money span { display: block; margin-top: 5px; color: var(--faint); font-size: 9px; }
.secondary-button { width: calc(100% - 38px); margin: 12px 19px 18px; border: 1px solid var(--line-strong); background: var(--surface-2); color: #cbd3d9; font-size: 11px; }
.secondary-button:hover { background: var(--surface-3); }

.table-wrap { position: relative; min-height: 358px; overflow: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 12px 15px; border-bottom: 1px solid var(--line); text-align: right; font-size: 11px; }
th { color: var(--faint); font-size: 9px; text-transform: uppercase; font-weight: 650; }
th:first-child, td:first-child { width: 49%; text-align: left; }
td:first-child strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td:first-child span { display: block; margin-top: 3px; color: var(--faint); font-size: 9px; }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 7px; color: var(--faint); text-align: center; }
.empty-state .icon { width: 26px; height: 26px; margin-bottom: 4px; }
.empty-state strong { color: var(--muted); font-size: 12px; }
.empty-state span { font-size: 10px; }
.compact-empty { min-height: 300px; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; max-width: min(380px, calc(100vw - 36px)); padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #1b2127; box-shadow: var(--shadow); color: #d8dee3; font-size: 11px; }

@media (max-width: 1100px) {
  .login-view { grid-template-columns: 1fr 1fr; }
  .login-brand { padding: 54px; }
  .login-preview { grid-template-columns: 1fr; }
  .login-preview > div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .login-view { display: block; padding: 22px; }
  .login-brand { display: none; }
  .login-panel { min-height: calc(100vh - 44px); padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); }
  .mobile-brand { display: flex; margin-bottom: 62px; }
  .topbar { padding: 0 14px; }
  .account-copy { display: none; }
  .dashboard-shell { width: min(100% - 24px, 1520px); padding-top: 24px; }
  .dashboard-heading { align-items: stretch; flex-direction: column; }
  .filters { align-items: stretch; flex-direction: column; }
  .select-control { width: 100%; }
  .segmented { width: 100%; }
  .segmented button { min-width: 0; flex: 1; padding: 0 4px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .bag-panel { min-height: 330px; }
  .bag-gauge { height: 190px; }
  .activity-row { grid-template-columns: 34px minmax(0, 1fr); }
  .activity-money { grid-column: 2; text-align: left; display: flex; align-items: center; gap: 7px; }
  .activity-money span { margin-top: 0; }
}

@media (max-width: 520px) {
  .brand-lockup.compact span { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { height: 94px; }
  .chart-wrap { height: 230px; }
  th, td { padding: 11px 9px; }
  th:first-child, td:first-child { width: 43%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
