/* ============================================================
   Shared UI: forms, toggles, history, toasts, banners
   Used by Management / Cryptoasset / Settings
   ============================================================ */

/* ---- two column working layouts ---- */
.work-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: var(--gap); align-items: start; }
.detail-grid { display: grid; grid-template-columns: 300px 1fr; gap: var(--gap); align-items: start; }
@media (max-width: 980px) {
  .work-grid, .detail-grid { grid-template-columns: 1fr; }
}

/* ---- form primitives ---- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 12px; font-weight: 500; color: var(--fg-muted); display: flex; align-items: center; gap: 6px; }
.field .opt { color: var(--fg-ghost); font-weight: 400; font-size: 11px; }
.hint { font-size: 11.5px; color: var(--fg-faint); line-height: 1.45; }

input[type="date"].input { color-scheme: dark; cursor: pointer; }
.input, .select, textarea.input {
  width: 100%; min-width: 0; height: 42px; padding: 0 13px;
  background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--fg); font-family: var(--font); font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s ease, box-shadow .15s ease;
  outline: none;
}
.input::placeholder { color: var(--fg-ghost); }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea.input { height: auto; min-height: 64px; padding: 11px 13px; resize: vertical; line-height: 1.5; }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

.input-group { position: relative; display: flex; align-items: center; min-width: 0; }
.input-group .prefix, .input-group .suffix {
  position: absolute; color: var(--fg-faint); font-size: 13px; font-variant-numeric: tabular-nums; pointer-events: none;
}
.input-group .prefix { left: 13px; }
.input-group .suffix { right: 13px; }
.input-group .input.has-prefix { padding-left: 26px; }
.input-group .input.has-suffix { padding-right: 44px; }
.input-group .reveal { position: absolute; right: 8px; background: transparent; border: 0; color: var(--fg-faint);
  cursor: pointer; padding: 6px; border-radius: 6px; display: grid; place-items: center; }
.input-group .reveal:hover { color: var(--fg); background: var(--bg-2); }
.input-group .reveal svg { width: 16px; height: 16px; }

.field-error { color: var(--loss); font-size: 11.5px; }
.input.invalid { border-color: oklch(0.69 0.150 27 / 0.6); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.divider { height: 1px; background: var(--line-soft); margin: 4px 0; }

/* ---- buy / sell toggle ---- */
.side-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-opt {
  height: 44px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--bg-0); color: var(--fg-muted); font-family: var(--font);
  font-size: 13.5px; font-weight: 600; cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px; transition: all .15s ease;
}
.side-opt svg { width: 16px; height: 16px; }
.side-opt.buy.on { border-color: oklch(0.78 0.135 158 / 0.5); background: var(--gain-dim); color: var(--gain); }
.side-opt.sell.on { border-color: oklch(0.69 0.150 27 / 0.5); background: var(--loss-dim); color: var(--loss); }

/* total preview */
.total-preview {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 16px; border-radius: var(--r-md); background: var(--bg-0);
  border: 1px solid var(--line-soft);
}
.total-preview .tp-label { font-size: 12px; color: var(--fg-muted); }
.total-preview .tp-val { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.total-preview .tp-sub { font-size: 11px; color: var(--fg-faint); }

/* ---- coin search combobox ---- */
.combo { position: relative; }
.combo-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 16px 40px -16px oklch(0 0 0 / 0.7); overflow: hidden; max-height: 280px; overflow-y: auto;
}
.combo-item { display: flex; align-items: center; gap: 11px; padding: 10px 13px; cursor: pointer; }
.combo-item:hover, .combo-item.active { background: var(--bg-3); }
.combo-item .ci-name { font-weight: 600; font-size: 13px; }
.combo-item .ci-sym { font-size: 11.5px; color: var(--fg-faint); }
.combo-item .ci-price { margin-left: auto; font-size: 12.5px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.combo-empty { padding: 16px; text-align: center; color: var(--fg-faint); font-size: 12.5px; }
.combo-selected { display: flex; align-items: center; gap: 11px; }
.combo-selected .cs-clear { margin-left: auto; }

/* ---- history list ---- */
.tx-list { display: flex; flex-direction: column; }
.tx-row {
  display: grid; grid-template-columns: auto 1fr auto auto auto auto;
  align-items: center; gap: 14px; padding: 12px var(--pad);
  border-top: 1px solid var(--line-soft); transition: background .12s ease;
}
.tx-row:hover { background: var(--bg-2); }
.tx-row:hover .tx-del { opacity: 1; }
.tx-side { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.tx-side svg { width: 15px; height: 15px; }
.tx-side.buy { background: var(--gain-dim); color: var(--gain); }
.tx-side.sell { background: var(--loss-dim); color: var(--loss); }
.tx-main { min-width: 0; }
.tx-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tx-meta { font-size: 11.5px; color: var(--fg-faint); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.tx-note { color: var(--fg-faint); font-style: italic; }
.tx-qty { text-align: right; font-size: 12.5px; color: var(--fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-total { text-align: right; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* current-price-vs-recorded indicator: colored bar + % (exact diff on hover) */
.tx-delta { display: inline-flex; align-items: center; gap: 5px; justify-self: end; cursor: default;
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
  padding: 2px 7px 2px 5px; border-radius: 6px; }
.tx-delta .txd-bar { width: 3px; height: 12px; border-radius: 2px; flex: none; }
.tx-delta.gain { color: var(--gain); background: var(--gain-dim); }
.tx-delta.gain .txd-bar { background: var(--gain); }
.tx-delta.loss { color: var(--loss); background: var(--loss-dim); }
.tx-delta.loss .txd-bar { background: var(--loss); }
.tx-del { opacity: 0; background: transparent; border: 0; color: var(--fg-ghost); cursor: pointer;
  padding: 7px; border-radius: 7px; display: grid; place-items: center; transition: .12s ease; }
.tx-del:hover { color: var(--loss); background: var(--loss-dim); }
.tx-del svg { width: 16px; height: 16px; }
.tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px;
}
.tag.buy { color: var(--gain); background: var(--gain-dim); }
.tag.sell { color: var(--loss); background: var(--loss-dim); }

/* per-row date chip in record form */
.cl-date { font-size: 11px; color: var(--fg-faint); font-variant-numeric: tabular-nums; margin-left: 6px;
  padding: 2px 7px; border-radius: 5px; background: var(--bg-0); border: 1px solid var(--line-soft); }

/* grouped transactions */
.tx-group { border-top: 1px solid var(--line-soft); }
.tx-grow { display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; gap: 14px;
  padding: 12px var(--pad); cursor: pointer; transition: background .12s ease; }
.tx-grow:hover { background: var(--bg-2); }
.tx-grow:hover .tx-del { opacity: 1; }
.tx-stack { display: inline-flex; align-items: center; margin-left: 8px; vertical-align: middle; }
.tx-stack .coin { width: 22px; height: 22px; font-size: 9px; box-shadow: 0 0 0 2px var(--bg-1); }
.tx-more { font-size: 11px; color: var(--fg-faint); margin-left: 4px; }
.tx-chev { color: var(--fg-ghost); display: grid; place-items: center; transition: transform .15s ease; }
.tx-chev svg { width: 16px; height: 16px; transform: rotate(90deg); }
.tx-chev.open { transform: rotate(180deg); }
.tx-sublist { background: var(--bg-0); border-top: 1px solid var(--line-soft); }
.tx-subrow { display: grid; grid-template-columns: auto 1fr auto auto auto auto; align-items: center; gap: 12px;
  padding: 9px var(--pad) 9px calc(var(--pad) + 14px); border-top: 1px solid var(--line-soft); }
.tx-subrow:first-child { border-top: 0; }
.tx-subname { font-size: 12.5px; font-weight: 500; }
.tx-subqty { text-align: right; font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.tx-subtotal { text-align: right; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.tx-subrow .tx-del { opacity: 0.5; }
@media (max-width: 560px) {
  .tx-grow { grid-template-columns: auto 1fr auto auto; }
  .tx-subqty { display: none; }
}

/* import menu — wide variant w/ date mode + coin select */
.import-menu.wide { width: 320px; max-width: calc(100vw - 24px); }
.im-section { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 10px; }
.im-seg { width: 100%; }
.im-seg button { flex: 1; justify-content: center; }
.im-field { display: flex; flex-direction: column; gap: 5px; }
.im-field label { font-size: 11px; color: var(--fg-muted); font-weight: 500; }
.im-range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.im-coins-head { display: flex; align-items: center; justify-content: space-between; }
.im-coins-head span { font-size: 11.5px; color: var(--fg-muted); font-weight: 500; }
.im-all { background: transparent; border: 0; color: var(--accent); font-family: var(--font); font-size: 11.5px;
  font-weight: 600; cursor: pointer; padding: 2px 4px; border-radius: 5px; }
.im-all:hover { background: var(--accent-dim); }
.im-coins { display: flex; flex-wrap: wrap; gap: 6px; }
.im-coin { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 5px; border-radius: 999px;
  border: 1px solid var(--line-soft); background: var(--bg-0); cursor: pointer; font-family: var(--font);
  font-size: 11.5px; font-weight: 600; color: var(--fg-muted); transition: .12s ease; }
.im-coin .coin { width: 18px; height: 18px; font-size: 8px; }
.im-coin.on { border-color: var(--accent-line); color: var(--fg); }
.im-check { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); display: grid; place-items: center;
  color: oklch(0.2 0.02 70); }
.im-check.on { background: var(--accent); border-color: transparent; }
.im-sub { padding: 9px 12px 3px; font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-ghost); }
.im-item:disabled { opacity: 0.5; }
@media (max-width: 560px) {
  .tx-row { grid-template-columns: auto 1fr auto auto auto; }
  .tx-qty { display: none; }
}

/* ---- multi-coin record lines ---- */
.coin-lines { display: flex; flex-direction: column; gap: 10px; }
.coin-line { border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 12px; background: var(--bg-0); }
.coin-line.invalid { border-color: oklch(0.69 0.150 27 / 0.5); }
.cl-head { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.cl-head .select { flex: 1; height: 38px; }
.cl-remove { background: transparent; border: 0; color: var(--fg-ghost); cursor: pointer; padding: 7px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.cl-remove:hover { color: var(--loss); background: var(--loss-dim); }
.cl-remove svg { width: 16px; height: 16px; }
.cl-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.cl-grid .field > label { font-size: 11px; white-space: nowrap; }
.cl-grid .input { height: 38px; font-size: 13px; }
.cl-grid .input[readonly] { color: var(--fg-muted); background: var(--bg-2); cursor: default; }
.add-coin { color: var(--accent) !important; }

/* ---- publish checkbox ---- */
.publish-check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-soft);
  border-radius: var(--r-md); cursor: pointer; background: var(--bg-0); transition: border-color .15s ease; position: relative; }
.publish-check:hover { border-color: var(--line); }
.publish-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.pc-box { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line); display: grid; place-items: center;
  flex: none; transition: border-color .15s ease, box-shadow .15s ease; color: transparent; }
.pc-box svg { width: 14px; height: 14px; }
.pc-box.on { background: var(--accent); border-color: transparent; color: oklch(0.2 0.02 70); }
.publish-check input:focus-visible + .pc-box { box-shadow: 0 0 0 3px var(--accent-dim); }
.pc-text { display: flex; flex-direction: column; gap: 1px; }
.pc-title { font-size: 13px; font-weight: 600; }
.pc-sub { font-size: 11.5px; color: var(--fg-faint); }
@media (max-width: 420px) { .cl-grid { grid-template-columns: 1fr 1fr; } }

/* ---- switch ---- */
.switch { position: relative; width: 42px; height: 24px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 999px; transition: .2s ease; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--fg-muted); transition: .2s cubic-bezier(.4,0,.2,1); }
.switch input:checked + .track { background: var(--accent); border-color: transparent; }
.switch input:checked + .track .knob { transform: translateX(18px); background: oklch(0.2 0.02 70); }

/* ---- status banners ---- */
.banner {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 15px;
  border-radius: var(--r-md); font-size: 13px; line-height: 1.45;
  border: 1px solid var(--line-soft); background: var(--bg-0);
}
.banner svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.banner .b-title { font-weight: 600; }
.banner .b-text { color: var(--fg-faint); font-size: 12px; margin-top: 2px; }
.banner.ok { border-color: oklch(0.78 0.135 158 / 0.3); background: var(--gain-dim); }
.banner.ok svg, .banner.ok .b-title { color: var(--gain); }
.banner.warn { border-color: var(--accent-line); background: var(--accent-dim); }
.banner.warn svg, .banner.warn .b-title { color: var(--accent); }
.banner.err { border-color: oklch(0.69 0.150 27 / 0.3); background: var(--loss-dim); }
.banner.err svg, .banner.err .b-title { color: var(--loss); }

/* ---- status pill (bot/telegram) ---- */
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-soft); }
.status-pill .led { width: 7px; height: 7px; border-radius: 50%; }
.status-pill.on { color: var(--gain); background: var(--gain-dim); border-color: oklch(0.78 0.135 158 / 0.25); }
.status-pill.on .led { background: var(--gain); box-shadow: 0 0 8px var(--gain); }
.status-pill.off { color: var(--fg-faint); }
.status-pill.off .led { background: var(--fg-ghost); }

/* ---- metric tiles (cryptoasset) ---- */
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
@media (max-width: 720px) { .metric-grid { grid-template-columns: 1fr 1fr; } }
.metric { padding: 16px var(--pad); display: flex; flex-direction: column; gap: 8px; }
.metric .m-label { font-size: 11.5px; color: var(--fg-muted); font-weight: 500; }
.metric .m-val { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; }
.metric .m-sub { font-size: 11.5px; color: var(--fg-faint); }

/* coin identity header */
.coin-head { display: flex; align-items: center; gap: 14px; padding: var(--pad); }
.coin-head .ch-name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.coin-head .ch-sym { font-size: 12.5px; color: var(--fg-faint); }
.coin-head .ch-price { margin-left: auto; text-align: right; }
.coin-head .ch-price .p { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* coin picker rail */
.coin-rail { display: flex; flex-direction: column; gap: 4px; padding: 10px; }
.coin-pick { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: var(--r-sm);
  cursor: pointer; border: 1px solid transparent; transition: background .12s ease; }
.coin-pick:hover { background: var(--bg-2); }
.coin-pick.on { background: var(--bg-2); border-color: var(--line-soft); }
.coin-pick .cp-name { font-size: 13px; font-weight: 600; }
.coin-pick .cp-alloc { font-size: 11px; color: var(--fg-faint); }
.coin-pick .cp-val { margin-left: auto; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.coin-pick .cp-pl { font-size: 11px; }
.coin-pick { position: relative; }
.cp-remove { opacity: 0; background: transparent; border: 0; color: var(--fg-ghost); cursor: pointer;
  padding: 5px; border-radius: 6px; display: grid; place-items: center; flex: none; transition: .12s ease; }
.cp-remove:hover { color: var(--loss); background: var(--loss-dim); }
.cp-remove svg { width: 15px; height: 15px; }
.coin-pick:hover .cp-remove { opacity: 1; }

/* exchange connections */
.exch-block { border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 13px; background: var(--bg-0); }
.exch-head { display: flex; align-items: center; gap: 11px; }
.exch-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 700; color: oklch(0.16 0.01 70); }
.exch-name { font-size: 13.5px; font-weight: 600; }
.exch-sub { font-size: 11.5px; color: var(--fg-faint); }
.exch-fields { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 12px; align-items: end; }
.exch-fields .field > label { white-space: nowrap; }

/* import-from-exchange dropdown */
.import-wrap { position: relative; }
.import-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; width: 290px;
  max-width: calc(100vw - 24px);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 16px 40px -16px oklch(0 0 0 / 0.7); overflow: hidden; }
.im-head { padding: 10px 12px; font-size: 11px; color: var(--fg-faint); border-bottom: 1px solid var(--line-soft); line-height: 1.4; }
.im-date { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 6px; }
.im-date label { font-size: 11px; color: var(--fg-muted); font-weight: 500; }
.im-date .input { height: 36px; }

/* ---- custom date picker ---- */
.dp { position: relative; }
.dp-field { display: flex; align-items: center; gap: 8px; cursor: pointer; text-align: left; width: 100%; }
.dp-field .dp-ph { color: var(--fg-ghost); }
.dp-field .dp-cal { width: 16px; height: 16px; color: var(--fg-faint); margin-left: auto; flex: none; }
.dp-field.dp-compact { height: 36px; font-size: 12.5px; }
.dp-pop {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; width: 252px;
  max-width: calc(100vw - 24px);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 18px 44px -18px oklch(0 0 0 / 0.8); padding: 12px;
}
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dp-title { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.dp-nav { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line-soft); background: var(--bg-1);
  color: var(--fg-muted); cursor: pointer; display: grid; place-items: center; transition: .12s ease; }
.dp-nav:hover { background: var(--bg-3); color: var(--fg); }
.dp-nav svg { width: 15px; height: 15px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd { margin-bottom: 4px; }
.dp-wdc { text-align: center; font-size: 10px; font-weight: 600; letter-spacing: 0.03em; color: var(--fg-ghost); padding: 4px 0; }
.dp-cell { aspect-ratio: 1; border: 0; background: transparent; color: var(--fg); font-family: var(--font);
  font-size: 12.5px; border-radius: 7px; cursor: pointer; font-variant-numeric: tabular-nums; transition: background .1s ease; }
.dp-cell.empty { cursor: default; }
.dp-cell:not(.empty):not(:disabled):hover { background: var(--bg-3); }
.dp-cell.today { box-shadow: 0 0 0 1px var(--line) inset; }
.dp-cell.sel { background: var(--accent); color: oklch(0.2 0.02 70); font-weight: 700; }
.dp-cell:disabled { color: var(--fg-ghost); opacity: 0.4; cursor: not-allowed; }
.dp-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; }
.dp-today-btn { background: transparent; border: 0; color: var(--accent); font-family: var(--font); font-size: 12px;
  font-weight: 600; cursor: pointer; padding: 5px 9px; border-radius: 6px; }
.dp-today-btn:hover { background: var(--accent-dim); }
.im-empty { padding: 14px 12px; font-size: 12.5px; color: var(--fg-faint); line-height: 1.5; }
.im-empty a { color: var(--accent); text-decoration: none; }
.im-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; background: transparent;
  border: 0; border-top: 1px solid var(--line-soft); cursor: pointer; font-family: var(--font); color: var(--fg); text-align: left; }
.im-item:hover:not(:disabled) { background: var(--bg-3); }
.im-item:disabled { cursor: default; }
.im-name { font-size: 13px; font-weight: 600; }
.im-go { margin-left: auto; font-size: 12px; color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 560px) { .exch-fields { grid-template-columns: 1fr; } }

/* add coin to strategy panel */
.add-panel { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--bg-2); max-height: 280px; overflow-y: auto; }
.add-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; font-size: 11.5px; color: var(--fg-faint); border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; z-index: 3; background: var(--bg-2); }
.add-panel-head button { background: transparent; border: 0; color: var(--fg-faint); cursor: pointer; display: grid; place-items: center; padding: 3px; border-radius: 5px; flex: none; }
.add-panel-head button:hover { color: var(--fg); background: var(--bg-3); }
.add-panel-head button svg { width: 14px; height: 14px; }
.add-search { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.add-search svg { width: 15px; height: 15px; color: var(--fg-faint); flex: none; }
.add-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--fg); font-family: var(--font); font-size: 13px; }
.add-search input::placeholder { color: var(--fg-ghost); }

/* ---- database backups ---- */
.bk-empty { font-size: 12.5px; color: var(--fg-faint); padding: 6px 2px; }
.bk-list { display: flex; flex-direction: column; gap: 6px; }
.bk-row { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line-soft); background: var(--bg-0); }
.bk-ico { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent); }
.bk-meta { min-width: 0; flex: 1; }
.bk-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-sub { font-size: 11.5px; color: var(--fg-faint); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.bk-btn { width: 30px; height: 30px; border-radius: 7px; flex: none; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line-soft); color: var(--fg-muted); cursor: pointer;
  text-decoration: none; transition: .12s ease; }
.bk-btn:hover { background: var(--bg-2); color: var(--fg); border-color: var(--line); }
.bk-btn.danger:hover { color: var(--loss); border-color: oklch(0.69 0.150 27 / 0.4); background: var(--loss-dim); }

/* ---- toasts ---- */
#toaster { position: fixed; bottom: 22px; right: 22px; z-index: 9000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 11px; min-width: 260px; max-width: 380px;
  padding: 13px 15px; border-radius: var(--r-md); background: var(--bg-2);
  border: 1px solid var(--line); box-shadow: 0 16px 40px -16px oklch(0 0 0 / 0.8);
  font-size: 13px; transform: translateX(120%); opacity: 0;
  transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .25s ease;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast .t-ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.toast .t-ico svg { width: 15px; height: 15px; }
.toast.ok .t-ico { background: var(--gain-dim); color: var(--gain); }
.toast.err .t-ico { background: var(--loss-dim); color: var(--loss); }
.toast.info .t-ico { background: var(--accent-dim); color: var(--accent); }
.toast .t-body { flex: 1; }
.toast .t-title { font-weight: 600; }
.toast .t-sub { font-size: 11.5px; color: var(--fg-faint); margin-top: 1px; }
.toast .t-undo { background: transparent; border: 0; color: var(--accent); font-weight: 600; font-size: 12.5px;
  cursor: pointer; font-family: var(--font); padding: 4px 6px; border-radius: 6px; }
.toast .t-undo:hover { background: var(--accent-dim); }

/* ---- confirm dialog (showConfirm) ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9500; display: grid; place-items: center;
  padding: 24px; background: rgba(0, 0, 0, .55);
  background: color-mix(in srgb, var(--bg-0) 70%, transparent);
  backdrop-filter: blur(3px); opacity: 0; transition: opacity .16s ease;
}
.modal-overlay.show { opacity: 1; }
.modal {
  width: min(420px, 100%); background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.45);
  transform: translateY(8px) scale(.98); transition: transform .18s ease;
}
.modal-overlay.show .modal { transform: none; }
.modal-icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent); margin-bottom: 14px;
}
.modal-icon svg { width: 22px; height: 22px; }
.modal-icon.danger { background: var(--loss-dim); color: var(--loss); }
.modal-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.modal-msg { font-size: 13.5px; color: var(--fg-muted); line-height: 1.5; margin-top: 8px; white-space: pre-line; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal-actions .btn { min-width: 92px; justify-content: center; }
.btn.btn-danger { background: var(--loss); color: #fff; border-color: transparent; }
.btn.btn-danger:hover { background: color-mix(in srgb, var(--loss) 88%, #000); }

/* ---- boot (initial API load / error) ---- */
.boot {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px;
}
.boot-mark {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent); margin-bottom: 4px;
}
.boot-mark svg { width: 26px; height: 26px; }
.boot-mark.err { background: rgba(234,57,67,.12); color: var(--loss); }
.boot-spin { color: var(--fg-muted); }
.boot-spin svg { width: 22px; height: 22px; }
.boot-text { font-size: 15px; font-weight: 600; color: var(--fg); }
.boot-sub { font-size: 12.5px; color: var(--fg-faint); max-width: 340px; }
