/* ==========================================================================
   Dashboard
   ========================================================================== */

body.app { overflow: hidden; }

/* ---------- boot splash ---------- */
.boot {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  background: var(--bg);
}
.logo-mark-lg { width: 52px; height: 52px; border-radius: 15px; }
.logo-mark-lg svg { width: 29px; height: 29px; }
.boot-bar { width: 132px; height: 3px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 40%; border-radius: 99px; background: var(--grad); animation: bootslide 1.1s var(--ease) infinite; }
@keyframes bootslide { 0% { transform: translateX(-105%); } 100% { transform: translateX(320%); } }

/* ---------- auth ---------- */
.auth { display: grid; grid-template-columns: 1.03fr 1fr; height: 100vh; }
.auth-aside {
  position: relative; overflow: hidden;
  padding: 40px 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  border-right: 1px solid var(--border);
  background: linear-gradient(155deg, var(--surface) 0%, var(--bg) 62%);
}
.auth-orb {
  position: absolute; width: 620px; height: 620px; left: -190px; bottom: -270px;
  background: radial-gradient(circle, rgba(59,130,246,.34), transparent 66%);
  filter: blur(58px); pointer-events: none;
}
/* Lift the real content above the orb — but never the orb itself: it must stay
   absolutely positioned, or it joins the flex flow and shoves everything down.
   (Same specificity as .auth-orb, and it comes later, so it would win.) */
.auth-aside > *:not(.auth-orb) { position: relative; }
.auth-pitch { max-width: 420px; }
.auth-pitch h2 { font-size: clamp(1.6rem, 2.6vw, 2.15rem); margin-bottom: 26px; letter-spacing: -0.03em; }
.auth-pitch ul { list-style: none; display: flex; flex-direction: column; gap: 13px; }
.auth-pitch li { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: .92rem; }
.tick {
  width: 19px; height: 19px; border-radius: 6px; flex: none;
  background: var(--green-soft); border: 1px solid rgba(34,197,94,.3);
  position: relative;
}
.tick::after {
  content: ''; position: absolute; left: 5px; top: 4.5px; width: 5px; height: 8px;
  border: solid var(--green); border-width: 0 1.8px 1.8px 0; transform: rotate(43deg);
}
.auth-back {
  display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
  font-size: .84rem; color: var(--dim); transition: color .18s, gap .18s var(--ease);
}
.auth-back:hover { color: var(--text); gap: 10px; }
.auth-back svg { width: 14px; height: 14px; }

.auth-main { display: grid; place-items: center; padding: 32px 24px; overflow-y: auto; }
.auth-card { width: 100%; max-width: 400px; }
.auth-tabs { width: 100%; margin-bottom: 26px; }
.auth-tabs button { flex: 1; }
.auth-form h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-sub { color: var(--dim); font-size: .9rem; margin-bottom: 26px; }
.auth-form .btn-lg { margin-top: 6px; }
.link-btn {
  display: block; width: 100%; text-align: center; margin-top: 16px;
  font-size: .85rem; color: var(--dim); transition: color .18s;
}
.link-btn:hover { color: var(--accent-2); }
#authError, #authOk { margin-bottom: 18px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }

.sidebar {
  display: flex; flex-direction: column; gap: 8px;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 20px 14px 16px;
  z-index: 30;
}
.sidebar-logo { padding: 4px 10px 22px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--dim); font-size: .91rem; font-weight: 500; text-align: left;
  position: relative; transition: background .18s, color .18s;
}
.side-link svg { width: 18px; height: 18px; flex: none; }
.side-link span { flex: 1; }
.side-link:hover { background: var(--surface); color: var(--text-2); }
.side-link.active { background: var(--surface-2); color: var(--text); }
.side-link.active::before {
  content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--grad);
}
.side-count {
  font-style: normal; font-size: .72rem; font-weight: 600;
  background: var(--surface-3); color: var(--dim);
  padding: 1px 7px; border-radius: 99px; min-width: 20px; text-align: center;
}
.side-link.active .side-count { background: var(--accent-soft); color: #8ec2ff; }

.sidebar-foot { display: flex; flex-direction: column; gap: 10px; }
.live-card {
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.live-row { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--text-2); }
.live-sub { font-size: .74rem; color: var(--faint); padding-left: 15px; }

.user-card {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); padding: 9px 10px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--grad); color: #04070e;
  display: grid; place-items: center; font-weight: 700; font-size: .82rem;
}
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.user-meta strong { font-size: .8rem; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: .7rem; color: var(--faint); }
.user-card .btn-icon { color: var(--dim); border-radius: 7px; }
.user-card .btn-icon:hover { color: #ff9d97; background: var(--red-soft); }
.user-card .btn-icon svg { width: 16px; height: 16px; }

.sidebar-scrim { display: none; }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 28px; border-bottom: 1px solid var(--border);
  background: rgba(6,9,17,.65); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  flex: none;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.22rem; letter-spacing: -0.025em; }
.topbar-title p { font-size: .82rem; color: var(--dim); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; color: var(--text-2); border: 1px solid var(--border-2); border-radius: 8px; }
.menu-btn svg { width: 18px; height: 18px; }

.views { flex: 1; overflow-y: auto; padding: 24px 28px 60px; }
.view { display: none; }
.view.active { display: block; }

/* ---------- panels ---------- */
.panel {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); margin-bottom: 20px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 1rem; }
.panel-head p { font-size: .8rem; color: var(--dim); margin-top: 2px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.two-col .panel { margin-bottom: 0; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.tile {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); padding: 18px 20px 19px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
  transition: border-color .22s var(--ease), transform .22s var(--ease);
}
.tile:hover { border-color: var(--border-2); transform: translateY(-2px); }
.tile-label { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.tile-value { font-size: 1.72rem; font-weight: 700; letter-spacing: -0.035em; line-height: 1.15; }
.tile-foot { font-size: .78rem; color: var(--dim); }
.tile-live::after {
  content: ''; position: absolute; top: 16px; right: 18px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--faint);
}
.tile-live.is-live::after { background: var(--green); animation: pulse 2s infinite; }

/* ---------- equity chart ---------- */
.chart-wrap { position: relative; padding: 18px 22px 14px; }
#equityChart { width: 100%; height: 240px; overflow: visible; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 3;
  background: rgba(14,22,38,.97); border: 1px solid var(--border-2);
  border-radius: var(--r-sm); padding: 8px 11px; box-shadow: var(--shadow);
  font-size: .76rem; white-space: nowrap; transform: translate(-50%, -122%);
}
.chart-tip .ct-date { color: var(--faint); font-size: .7rem; margin-bottom: 3px; }
.chart-tip .ct-val { font-weight: 650; font-size: .86rem; }
.chart-tip .ct-sub { color: var(--dim); font-size: .7rem; margin-top: 2px; }
.empty-inline { padding: 30px; text-align: center; color: var(--faint); font-size: .87rem; }

/* ---------- running list ---------- */
.running-list { padding: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
.run-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--bg-elev); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .18s, background .18s;
}
.run-item:hover { border-color: var(--border-2); background: var(--surface-2); }
.run-main { flex: 1; min-width: 0; }
.run-name { font-size: .88rem; font-weight: 550; display: flex; align-items: center; gap: 8px; }
.run-meta { font-size: .74rem; color: var(--faint); margin-top: 2px; }
.run-pnl { font-size: .95rem; font-weight: 650; }
.run-bar { height: 3px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 7px; }
.run-bar i { display: block; height: 100%; border-radius: 99px; background: var(--grad); transition: width .5s var(--ease); }

/* ---------- activity console ---------- */
.activity {
  font-family: var(--mono); font-size: .75rem;
  max-height: 340px; overflow-y: auto;
  padding: 12px 16px;
  display: flex; flex-direction: column-reverse; gap: 5px;
}
.activity .line { display: flex; gap: 9px; color: var(--dim); line-height: 1.5; }
.activity .line .t { color: var(--faint); flex: none; }
.activity .line .b { color: var(--accent-2); flex: none; }
.activity .line.win  { color: var(--green); }
.activity .line.loss { color: var(--red); }
.activity .line.warn { color: var(--amber); }
.activity .line.err  { color: var(--red); }
.activity-empty { padding: 26px 0; text-align: center; color: var(--faint); font-family: var(--font); }

/* ---------- bot cards ---------- */
/* start-aligned: a stopped bot's card shouldn't stretch to match a running
   one's live panel and leave a hole in the middle. */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.bot-card {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .22s var(--ease), transform .22s var(--ease), box-shadow .22s var(--ease);
}
.bot-card:hover { border-color: var(--border-2); transform: translateY(-3px); box-shadow: var(--shadow); }
.bot-card.running { border-color: rgba(34,197,94,.28); }
.bot-card.running::before {
  content: ''; display: block; height: 2px; background: linear-gradient(90deg, var(--green), var(--accent-2));
}
.bot-top { padding: 17px 19px 0; display: flex; align-items: flex-start; gap: 12px; }
.bot-title { flex: 1; min-width: 0; }
.bot-title h3 {
  font-size: 1rem; display: flex; align-items: center; gap: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bot-sub { font-size: .76rem; color: var(--faint); margin-top: 3px; }

.bot-body { padding: 15px 19px 0; }
.bot-pnl { display: flex; align-items: baseline; gap: 9px; margin-bottom: 3px; }
.bot-pnl .amount { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.035em; }
.bot-pnl .unit { font-size: .76rem; color: var(--faint); }
.bot-pnl-label { font-size: .72rem; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }

.bot-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.fact {
  font-size: .73rem; padding: 3px 9px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); white-space: nowrap;
}
.fact b { color: var(--text); font-weight: 600; }

.bot-live {
  margin-top: 14px; padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--bg-elev); border: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.lv { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lv-k { font-size: .66rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; }
.lv-v { font-size: .84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bot-progress { margin-top: 13px; }
.bot-progress .pg-head { display: flex; justify-content: space-between; font-size: .72rem; color: var(--faint); margin-bottom: 5px; }
.pg-track { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.pg-fill { height: 100%; border-radius: 99px; transition: width .6s var(--ease); }
.pg-fill.up { background: linear-gradient(90deg, var(--green), #6ee7a8); }
.pg-fill.down { background: linear-gradient(90deg, var(--red), #ff9d97); }

.bot-err {
  margin: 13px 0 0; padding: 9px 12px; border-radius: var(--r-sm);
  background: var(--red-soft); border: 1px solid rgba(240,71,71,.32);
  color: #ffb4ae; font-size: .77rem; line-height: 1.45;
}
.bot-actions {
  display: flex; gap: 7px; padding: 16px 19px 17px; margin-top: auto;
  flex-wrap: wrap;
}
.bot-actions .btn { flex: none; }
.bot-actions .spacer { flex: 1; }

/* ---------- accounts ---------- */
.link-form { display: flex; gap: 12px; align-items: flex-start; padding: 20px 22px; }
.link-form .btn { margin-top: 25px; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; align-items: start; }
.account-card {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .22s var(--ease), transform .22s var(--ease);
}
.account-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.acc-top { display: flex; align-items: center; gap: 11px; }
.acc-icon {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: .68rem; font-weight: 700; letter-spacing: .04em;
}
/* Real money is the one that warrants a second look, so it wears the warning
   colour; demo is the neutral sandbox. (The reverse reads as "real = safe".) */
.acc-icon.demo { background: var(--accent-soft); color: #8ec2ff; border: 1px solid rgba(59,130,246,.28); }
.acc-icon.real { background: var(--amber-soft); color: #ffc76b; border: 1px solid rgba(240,160,32,.32); }
.acc-id { flex: 1; min-width: 0; }
.acc-id strong { display: block; font-size: .93rem; font-family: var(--mono); letter-spacing: -0.01em; }
.acc-id span { font-size: .73rem; color: var(--faint); }
.acc-balance { display: flex; align-items: baseline; gap: 7px; }
.acc-balance .bal { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.03em; }
.acc-balance .cur { font-size: .76rem; color: var(--faint); }
.acc-balance .skel { width: 90px; height: 22px; border-radius: 6px; }
.acc-foot { display: flex; align-items: center; gap: 8px; }
.acc-foot .spacer { flex: 1; }
.acc-bots { font-size: .74rem; color: var(--faint); }

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.dtable { width: 100%; border-collapse: collapse; font-size: .83rem; }
.dtable th {
  text-align: left; padding: 10px 16px; font-size: .68rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: .08em; color: var(--faint);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.dtable td { padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dtable tbody tr { transition: background .14s; }
.dtable tbody tr:hover { background: var(--bg-elev); }
.dtable td.r, .dtable th.r { text-align: right; }
.dtable .sym { font-family: var(--mono); font-size: .8rem; }

/* ---------- empty states ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 72px 24px; text-align: center;
  border: 1px dashed var(--border-2); border-radius: var(--r-lg);
}
.empty-icon {
  width: 52px; height: 52px; border-radius: 15px; margin-bottom: 12px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--dim); border: 1px solid var(--border);
}
.empty-icon svg { width: 26px; height: 26px; }
.empty h3 { font-size: 1.05rem; }
.empty p { color: var(--dim); font-size: .88rem; max-width: 38ch; margin-bottom: 14px; }

/* ---------- overlays / modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(2, 5, 11, .74);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 42px 18px; overflow-y: auto;
}
.overlay-right { align-items: stretch; justify-content: flex-end; padding: 0; overflow: hidden; }

.modal {
  width: 100%; max-width: 560px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: calc(100vh - 84px);
}
.modal-lg { max-width: 720px; }
.modal-sm { max-width: 420px; align-self: center; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  padding: 22px 26px 18px; flex: none;
}
.modal-head h2 { font-size: 1.12rem; }
.modal-head p { font-size: .83rem; color: var(--dim); margin-top: 3px; }
.modal-head .btn-icon { color: var(--dim); border-radius: 8px; }
.modal-head .btn-icon:hover { background: var(--surface-2); color: var(--text); }
.modal-head .btn-icon svg { width: 17px; height: 17px; }
.modal-body { padding: 20px 26px 6px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 26px 20px; border-top: 1px solid var(--border); flex: none;
}
.modal-tabs {
  display: flex; gap: 2px; padding: 0 26px; border-bottom: 1px solid var(--border);
  overflow-x: auto; flex: none;
}
.modal-tabs button {
  padding: 11px 14px; font-size: .86rem; font-weight: 550; color: var(--dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color .18s, border-color .18s;
}
.modal-tabs button:hover { color: var(--text-2); }
.modal-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { display: none; }
.tabpane.active { display: block; animation: fadeUp .32s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.seg-full { display: flex; width: 100%; }
.seg-full button { flex: 1; }

/* radio pickers */
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick { position: relative; cursor: pointer; }
.pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.pick-body {
  display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--border-2); border-radius: var(--r-sm);
  padding: 13px 15px; height: 100%;
  background: var(--bg-elev); transition: border-color .2s, background .2s, transform .2s var(--ease);
}
.pick:hover .pick-body { border-color: rgba(148,176,224,.3); }
.pick input:checked + .pick-body {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.pick input:focus-visible + .pick-body { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick-title { font-size: .89rem; font-weight: 600; }
.pick-desc { font-size: .74rem; color: var(--dim); line-height: 1.45; }
.pick-sm .pick-body { padding: 10px 12px; }
.pick-sm .pick-title { font-size: .84rem; }
.pick-sm .pick-desc { font-size: .69rem; }

.risk-preview {
  margin-top: 6px; padding: 13px 15px; border-radius: var(--r-sm);
  background: var(--bg-elev); border: 1px solid var(--border);
  font-family: var(--mono); font-size: .74rem; color: var(--dim); line-height: 1.75;
}
.risk-preview b { color: var(--text-2); font-weight: 500; }
.risk-preview .warn { color: var(--amber); }

/* ---------- ladder builder ---------- */
.ladder { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.rung {
  border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--bg-elev); overflow: hidden;
}
.rung-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.rung-n {
  font-family: var(--mono); font-size: .72rem; color: var(--accent-2);
  background: var(--accent-soft); border-radius: 5px; padding: 2px 7px; flex: none;
}
.rung-desc { flex: 1; font-size: .78rem; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rung-head .btn-icon { width: 26px; height: 26px; padding: 5px; border-radius: 6px; color: var(--faint); }
.rung-head .btn-icon:hover { background: var(--surface-3); color: var(--text); }
.rung-head .btn-icon.del:hover { background: var(--red-soft); color: #ff9d97; }
.rung-head .btn-icon svg { width: 14px; height: 14px; }
.rung-body { padding: 13px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.rung-body .field { margin-bottom: 10px; }
.rung-body .field > label { font-size: .68rem; }
.rung-body .field input, .rung-body .field select { padding: 7px 10px; font-size: .84rem; }
.rung-body .field select { background-position: right 8px center; padding-right: 26px; }
.ladder-actions { display: flex; gap: 8px; margin-bottom: 14px; }

/* ---------- drawer ---------- */
.drawer {
  width: min(540px, 100vw); height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 24px 18px; border-bottom: 1px solid var(--border); flex: none;
}
.drawer-head h2 { font-size: 1.1rem; }
.drawer-head p { font-size: .8rem; color: var(--dim); margin-top: 2px; }
.drawer-head .btn-icon { color: var(--dim); border-radius: 8px; }
.drawer-head .btn-icon:hover { background: var(--surface-2); color: var(--text); }
.drawer-head .btn-icon svg { width: 17px; height: 17px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }
.drawer-section { margin-bottom: 26px; }
.drawer-section > h3 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--faint); font-weight: 650; margin-bottom: 11px;
}
.kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.kv {
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-elev); padding: 10px 13px;
  display: flex; flex-direction: column; gap: 2px;
}
.kv .k { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; }
.kv .v { font-size: .92rem; font-weight: 600; }
.drawer .dtable th { background: var(--surface); }
.drawer .table-wrap { border: 1px solid var(--border); border-radius: var(--r-sm); overflow: auto; max-height: 320px; }
.drawer .dtable td:first-child, .drawer .dtable th:first-child { padding-left: 13px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; bottom: 22px; right: 22px; z-index: 90;
  display: flex; flex-direction: column-reverse; gap: 10px; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  min-width: 270px; max-width: 380px;
  background: rgba(14,22,38,.97); border: 1px solid var(--border-2);
  border-radius: var(--r); padding: 12px 15px; box-shadow: var(--shadow-lg);
  pointer-events: auto;
}
.toast-icon { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-body strong { display: block; font-size: .86rem; font-weight: 600; }
.toast-body span { display: block; font-size: .79rem; color: var(--dim); margin-top: 2px; line-height: 1.45; }
.toast-close { color: var(--faint); padding: 2px; }
.toast-close:hover { color: var(--text); }
.toast-close svg { width: 13px; height: 13px; }
.toast.ok    { border-color: rgba(34,197,94,.4); }
.toast.ok    .toast-icon { color: var(--green); }
.toast.error { border-color: rgba(240,71,71,.45); }
.toast.error .toast-icon { color: var(--red); }
.toast.warn  { border-color: rgba(240,160,32,.45); }
.toast.warn  .toast-icon { color: var(--amber); }
.toast.info  .toast-icon { color: var(--accent-2); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px;
    transform: translateX(-100%); transition: transform .3s var(--ease);
  }
  .sidebar.open { transform: none; }
  .sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: 25;
    background: rgba(2,5,11,.6); opacity: 0; pointer-events: none; transition: opacity .3s;
  }
  .sidebar-scrim.open { opacity: 1; pointer-events: auto; }
  .menu-btn { display: grid; place-items: center; }
  .views { padding: 18px 16px 60px; }
  .topbar { padding: 14px 16px; }
  .hide-sm { display: none; }
}
@media (max-width: 620px) {
  /* The page subtitle is the first thing to go — the title plus two actions
     already fill a phone-width topbar. */
  .topbar-title p { display: none; }
  .topbar-title h1 { font-size: 1.1rem; }
  .tiles { grid-template-columns: 1fr; }
  .bot-grid, .account-grid { grid-template-columns: 1fr; }
  .grid2, .pick-grid { grid-template-columns: 1fr; }
  .pick-row { grid-template-columns: 1fr; }
  .rung-body { grid-template-columns: 1fr 1fr; }
  .link-form { flex-direction: column; }
  .link-form .btn { margin-top: 0; width: 100%; }
  .kv-grid { grid-template-columns: 1fr; }
  .overlay { padding: 16px 12px; }
  .modal { max-height: calc(100vh - 32px); }
  .modal-head, .modal-body, .modal-foot, .modal-tabs { padding-left: 18px; padding-right: 18px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}
