/* vpsfleet manager frontend — flat modern, darkgray text + orange accent on
   pure white. Roboto if the self-hosted woff2 files are present (assets/fonts/),
   otherwise a system sans fallback so the UI still looks right without them. */

/* -- fonts ---------------------------------------------------------------- */
@font-face {
  font-family: "Roboto";
  font-weight: 300;
  font-style: normal;
  font-display: swap;
  src: url("../assets/fonts/roboto-300.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("../assets/fonts/roboto-400.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("../assets/fonts/roboto-500.woff2") format("woff2");
}

/* -- design tokens -------------------------------------------------------- */
:root {
  --bg:        #ffffff;   /* pure white page */
  --surface:   #fafafa;   /* cards, bars */
  --surface-2: #f2f2f2;   /* hover / inset */
  --border:    #e6e6e6;
  --fg:        #2b2b2b;   /* darkgray text */
  --fg-soft:   #555555;
  --muted:     #8a8a8a;
  --accent:        #f57c00;  /* orange */
  --accent-strong: #e26f00;
  --accent-soft:   #fff3e6;  /* tinted backgrounds */

  --up:    #2e7d32;   /* online */
  --down:  #9e9e9e;   /* offline */
  --stale: #c9a227;   /* heartbeat went quiet */
  --drift: #f57c00;   /* applied != desired */

  --nav-w: 220px;
  --topbar-h: 56px;
  --radius: 8px;
  --font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* -- reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* Operators lift values via the copy buttons / explicit inputs, never by
     dragging — make the whole UI unselectable so a stray drag never highlights
     live text. Editable field content is re-enabled just below. */
  user-select: none;
  -webkit-user-select: none;
}
/* The one exception: text inside editable fields stays selectable so the
   operator can edit/copy what they typed. */
input, textarea, [contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
}
button { font-family: inherit; }

/* -- slim themed scrollbars ----------------------------------------------- */
/* Applied to every scroll area (.content, .tbl-wrap, .cfgform, …) so the UI
   never falls back to chunky default OS scrollbars. */
.scroll-slim {
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
/* WebKit/Blink: slim, themed, fades against the surface until hovered. */
.scroll-slim::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-slim::-webkit-scrollbar-track { background: transparent; }
.scroll-slim::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
  /* inset the thumb so it reads as a thin pill, not a full-width bar */
  border: 2px solid transparent;
  background-clip: padding-box;
}
.scroll-slim::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.scroll-slim::-webkit-scrollbar-corner { background: transparent; }

/* -- generic buttons ------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--icon { padding: 8px; }
.btn[disabled] { opacity: .55; cursor: default; }

/* -- login ---------------------------------------------------------------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--surface);
}
.login__card {
  width: min(320px, calc(100vw - 32px));
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px 24px;
}
.login__brand {
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 2px;
}
.login__brand b { color: var(--accent); font-weight: 500; }
.login__sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-soft);
  margin-bottom: 5px;
}
.field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  color: var(--fg);
  background: var(--bg);
}
.field input:focus { outline: none; border-color: var(--accent); }
.login .btn--primary { width: 100%; justify-content: center; margin-top: 4px; }
.login__error {
  color: #c62828;
  font-size: 13px;
  min-height: 18px;
  margin: 8px 0 0;
}

/* -- app shell ------------------------------------------------------------ */
.shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: 100vh;
}

/* left navbar */
.nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}
.nav__brand {
  font-size: 17px;
  font-weight: 500;
  padding: 6px 10px 18px;
}
.nav__brand b { color: var(--accent); font-weight: 500; }
.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--fg-soft);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 14px;
}
.nav__item:hover { background: var(--surface-2); color: var(--fg); }
.nav__item--active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.nav__spacer { flex: 1; }
.nav__foot { color: var(--muted); font-size: 12px; padding: 8px 12px; }

/* main column */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.topbar__title { font-size: 16px; font-weight: 500; }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

/* connection pill in the top bar */
.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  padding-right: 6px;
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--down); }
.conn--live .dot { background: var(--up); }
.conn--down .dot { background: #c62828; }

.content { flex: 1; overflow: auto; padding: 22px 20px; }

/* -- node grid ------------------------------------------------------------ */
.nodes-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 16px;
}
.nodes-head h2 { font-size: 15px; font-weight: 500; margin: 0; }
.nodes-head .count { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.empty {
  color: var(--muted);
  padding: 40px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* node card */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card__head { display: flex; align-items: center; gap: 10px; }
.card__status {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--down);
  flex: 0 0 auto;
}
.card--up    .card__status { background: var(--up); }
.card--stale .card__status { background: var(--stale); }
.card--down  .card__status { background: var(--down); }
.card__id { font-weight: 500; font-size: 14px; min-width: 0; }
.card__id .label { display: block; }
.card__id .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.card__state {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--down);
}
.card--up .card__state { color: var(--up); }
.card--stale .card__state { color: var(--stale); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--fg-soft);
  background: var(--bg);
}
.badge--ok    { color: var(--up); border-color: #cde8ce; background: #f1f8f1; }
.badge--warn  { color: #b25b00; border-color: #f6d9b3; background: var(--accent-soft); }
.badge--err   { color: #c62828; border-color: #f3c7c7; background: #fdecec; }
.badge--drift { color: #fff; background: var(--drift); border-color: var(--drift); }

/* stat rows */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat--wide { grid-column: 1 / -1; }
.stat__k { font-size: 11px; color: var(--muted); }
.stat__v {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* value + copy button on one row */
.stat__row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.stat__row .stat__v { min-width: 0; }
.copybtn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  border: none;
  background: none;
  padding: 2px;
  margin: 0;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  transition: color .12s, background .12s;
}
.copybtn:hover { color: var(--fg); background: var(--surface-2); }
.copybtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.copybtn--done { color: var(--up); }
/* Copy refused (no clipboard permission / non-secure origin) — the value is NOT on the
   clipboard, so this has to read as a failure rather than a quieter success. */
.copybtn--fail { color: #c62828; }
.copybtn .icon { width: 13px; height: 13px; }

.meter {
  height: 5px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 4px;
}
.meter > span { display: block; height: 100%; background: var(--accent); }
.meter > span.hot { background: #c62828; }

/* mirrored amneziawg [Interface] config block */
.cfg { border-top: 1px solid var(--border); padding-top: 10px; }
.cfg__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 8px;
}
.cfg__edit { margin: -5px -5px -5px 0; }     /* keep the row from growing taller */
.cfg__edit .icon { width: 14px; height: 14px; }
.cfg__empty { color: var(--muted); font-size: 12px; font-style: italic; }

.card__foot {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* -- modal (settings placeholder) ---------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.28);
  display: grid; place-items: center;
  z-index: 50;
}
.modal {
  width: min(380px, calc(100vw - 32px));
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 22px;
}
.modal h3 { margin: 0 0 6px; font-size: 16px; font-weight: 500; }
.modal p { color: var(--fg-soft); margin: 0 0 18px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; }
.modal__lead { color: var(--fg); margin: 0 0 14px; }
.modal__field { margin-bottom: 14px; }
.modal__field label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--fg-soft); margin-bottom: 5px;
}
/* Scoped under .modal so it outranks the blanket `.modal p` margin reset above
   (which would otherwise force margin-top back to 0). */
.modal .modal__hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.modal__warn {
  color: #b25b00; background: var(--accent-soft);
  border: 1px solid #f6d9b3; border-radius: 6px;
  padding: 8px 10px; margin: 0 0 14px; font-size: 13px;
}
.modal__err { color: #c62828; font-size: 13px; min-height: 18px; margin: 2px 0 0; }
.captcha { display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; }
.captcha__q { font-weight: 500; }
.in--captcha { width: 90px; }

/* per-peer failures in a bulk-op result modal */
.bulk-fails {
  max-height: 180px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; margin: 0 0 14px;
}
.bulk-fails__row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 12px; padding: 3px 0;
}
.bulk-fails__row + .bulk-fails__row { border-top: 1px solid var(--border); }
.bulk-fails__err { color: #c62828; text-align: right; }

/* -- customer portal links (Accounts row action) ------------------------- */
/* One block per node hosting the account's peers: each node serves its own portal,
   so an account spread across nodes has several URLs (same token, different host). */
.portal-list { max-height: 260px; overflow-y: auto; margin: 0 0 14px; }
.portal-list__row + .portal-list__row {
  border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px;
}
.portal-list__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.portal-list__head .cell-id { display: inline; }   /* inline here, not the table's block */
.portal-list__head .cell-muted { font-size: 12px; }
.portal-list__url { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.portal-list__link {
  flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  /* The token makes this long; keep it on one line and let the copy button carry it. */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Node reports its portal is off: still shown (the operator may be enabling it), but
   visibly not-yet-live rather than hidden. */
.portal-list__link--dim { color: var(--muted); }

/* -- node config modal (read-only preview for now) ----------------------- */
.modal--config { width: min(540px, calc(100vw - 32px)); }
.cfgmodal__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cfgmodal__head .icon { width: 16px; height: 16px; color: var(--muted); }
.cfgmodal__head h3 { margin: 0; }
.modal .cfgform__lead { color: var(--muted); font-size: 12px; margin: 0 0 16px; }
.cfgform {
  max-height: min(58vh, 520px);
  overflow-y: auto;
  margin: 0 0 16px;
  /* keep gutter from crowding the inputs once the bar appears */
  padding-right: 6px;
}
.cfgform__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.cfgform__field { display: flex; flex-direction: column; min-width: 0; }
.cfgform__field--wide { grid-column: 1 / -1; }
.cfgform__field label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--fg-soft); margin-bottom: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modal .cfgform__fhint { color: var(--muted); font-size: 11px; margin: 5px 0 0; }
.cfgform__sub {
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin: 18px 0 10px;
}
.modal .cfgform__empty { color: var(--muted); font-size: 12px; font-style: italic; margin: 0; }
.in:disabled {
  background: var(--surface-2);
  color: var(--fg-soft);
  -webkit-text-fill-color: var(--fg-soft);  /* keep value legible in WebKit */
  cursor: default;
}

/* -- inline text input ---------------------------------------------------- */
.in {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
}
.in:focus { outline: none; border-color: var(--accent); }
.in--error { border-color: #c62828; }

/* native <select>, styled like .in but sized to sit inside a table cell */
select.in--select { padding: 6px 9px; cursor: pointer; }

.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--danger { background: #c62828; border-color: #c62828; color: #fff; }
.btn--danger:hover { background: #b71c1c; border-color: #b71c1c; }
.btn--danger[disabled]:hover { background: #c62828; border-color: #c62828; }

/* -- accounts table ------------------------------------------------------- */
.list-head { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; }
.list-head h2 { font-size: 15px; font-weight: 500; margin: 0; }
.list-head .count { color: var(--muted); font-size: 13px; }
.list-head__spacer { flex: 1; }

/* bulk-action bar (Peers view): shown only when peers are selected */
.bulk-bar { display: flex; align-items: center; gap: 8px; }
.bulk-bar[hidden] { display: none; }
.bulk-bar__count { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* leading multi-select column: narrow, centered checkbox */
.tbl th.col-select, .tbl td.col-select { text-align: center; padding-left: 8px; padding-right: 8px; }
.col-select input { cursor: pointer; }

.tbl-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--bg);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}
.tbl th, .tbl td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.tbl thead th {
  position: relative;
  background: var(--surface);
  color: var(--fg-soft);
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  user-select: none;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface); }

/* pre-created ("new peer") rows: not persisted, distinguished by a soft tint */
.tbl tbody tr.tr--pending,
.tbl tbody tr.tr--pending:hover { background: var(--accent-soft); }

/* -- column filters (peers table) ---------------------------------------- */
/* second header row: one filter control per column, under the labels. Inputs
   carry size="1" + min-width:0 so they never inflate the column auto-sizing. */
.tbl thead tr.filter-row th {
  background: var(--bg);
  padding: 6px 8px;
  vertical-align: middle;
}
.filter-in { min-width: 0; padding: 5px 8px; font-size: 12px; }

/* multi-select filter (Node / Account columns) */
.msf { position: relative; }
.msf__btn {
  width: 100%; min-width: 0;
  display: inline-flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 5px 8px; font: inherit; font-size: 12px;
  color: var(--fg); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.msf__btn:hover { border-color: var(--muted); }
.msf__btn--open { border-color: var(--accent); }
.msf__btn--active { border-color: var(--accent); color: var(--accent); }
.msf__sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msf__caret { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.msf__pop {
  /* fixed + JS-set top/left/width so it escapes the table's overflow clipping */
  position: fixed; z-index: 50;
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.msf__pop[hidden] { display: none; }
.msf__search { padding: 5px 8px; font-size: 12px; }
.msf__list { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; }
.msf__opt {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 6px;
  font-size: 13px; font-weight: 400; white-space: nowrap; cursor: pointer;
}
.msf__opt:hover { background: var(--surface); }
.msf__opt[hidden] { display: none; }
.msf__opt input { cursor: pointer; }

.col-resizer {
  position: absolute;
  top: 0; right: 0;
  width: 8px; height: 100%;
  cursor: col-resize;
}
.col-resizer:hover { background: var(--border); }
body.col-resizing { cursor: col-resize; user-select: none; }

.cell-id {
  display: block;
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell-num { color: var(--fg-soft); font-variant-numeric: tabular-nums; }
.cell-muted { color: var(--muted); white-space: nowrap; }
.cell-actions { text-align: right; white-space: nowrap; }

.comment-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.comment-cell .in { flex: 1; min-width: 0; padding: 6px 9px; }
.comment-cell__actions { display: inline-flex; gap: 2px; flex: 0 0 auto; }
.comment-cell__actions[hidden] { display: none; }

/* small square icon buttons used in table rows */
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  padding: 5px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: color .12s, background .12s;
}
.iconbtn:hover { background: var(--surface-2); color: var(--fg); }
.iconbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.iconbtn[disabled] { opacity: .5; cursor: default; }
.iconbtn--ok:hover { color: var(--up); }
.iconbtn--danger:hover { color: #c62828; }
.iconbtn .icon { width: 16px; height: 16px; }

/* simple inline icon sizing */
.icon { width: 18px; height: 18px; display: block; }

/* refresh button: spin its icon while a fetch is in flight */
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-spinning .icon { animation: spin .7s linear infinite; }
.btn.is-spinning { color: var(--accent); }

/* -- transactions (billing ledger) --------------------------------------- */
/* Signed money. Credits green, debits red, reverted struck-through + muted (it no
   longer counts toward the balance). tabular-nums so columns line up. */
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money--pos { color: var(--up); }
.money--neg { color: #c62828; }
.money--reverted { color: var(--muted); text-decoration: line-through; }
.tbl tbody tr.tr--reverted { color: var(--muted); }
.tbl tbody tr.tr--reverted .badge { opacity: .8; }

/* toolbar above the table: preset chips, then the filter controls */
.txn-toolbar { display: flex; flex-direction: column; gap: 10px; margin: 0 0 14px; }

.txn-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.txn-presets__label { color: var(--muted); font-size: 12px; margin-right: 2px; }
.chip {
  padding: 4px 10px; font: inherit; font-size: 12px;
  color: var(--fg-soft); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.txn-filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.txn-field { display: flex; flex-direction: column; gap: 3px; min-width: 130px; }
.txn-field__label { font-size: 11px; color: var(--muted); }
.txn-field .filter-in { font-size: 12px; }
.txn-range { display: flex; gap: 6px; }
.txn-num { width: 70px; }

/* live totals in the list head (credits / debits / net over visible active rows) */
.txn-totals { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px;
  font-size: 12px; }
.txn-totals__item { white-space: nowrap; font-variant-numeric: tabular-nums; }
.txn-totals__k { color: var(--muted); }
.txn-totals__net { font-weight: 500; }

/* the signed "will record …" preview under the add-transaction amount field */
.txn-preview { display: block; margin-top: 8px; font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums; min-height: 18px; }

/* -- responsive ----------------------------------------------------------
   Wide (default, above): fixed left rail + content. The drawer toggle and its
   backdrop are hidden; the rail is part of the grid.
   Tablet/phone (<= 860px): the rail goes off-canvas and slides in over a
   backdrop when .shell--nav-open is set; a hamburger in the top bar toggles it.
   Phone (<= 560px): tighter spacing, single-column grid, icon-only logout. */

.topbar__menu { display: none; }   /* shown only when the rail collapses */
.nav-backdrop { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }

  .nav {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--nav-w);
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 40;
    will-change: transform;
  }
  .shell--nav-open .nav {
    transform: translateX(0);
    box-shadow: 2px 0 16px rgba(0,0,0,.18);
  }
  .shell--nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.32);
    z-index: 39;
  }

  .topbar__menu { display: inline-flex; }
  .main { height: 100vh; }
}

@media (max-width: 560px) {
  :root { --topbar-h: 52px; }

  .topbar { gap: 8px; padding: 0 12px; }
  .topbar__title { font-size: 15px; }
  .content { padding: 14px 12px; }

  /* one column; let cards use the full width */
  .grid { grid-template-columns: 1fr; gap: 12px; }

  /* save horizontal room: icon-only logout, drop the connection label */
  .btn--logout .btn__label { display: none; }
  .btn--logout { padding: 8px; }
  .conn .conn__label { display: none; }
  .conn { padding-right: 2px; }
}

/* Coarse-pointer (touch) devices: comfier hit targets regardless of width.
   Scoped so square icon buttons keep their 1:1 padding. */
@media (pointer: coarse) {
  .btn:not(.btn--icon) { padding: 10px 14px; }
  .nav__item { padding: 12px; }
}
