:root {
  --bg: #ffffff; --surface: #f6f6f4; --line: #e3e3df;
  --text: #1c1c1a; --muted: #6b6b66;
  --pos: #15803d; --neg: #b91c1c;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; letter-spacing: .04em; }
.hamburger { display: none; background: none; border: none; font-size: 22px;
  line-height: 1; cursor: pointer; color: var(--text); padding: 2px 6px; }
.topnav { display: flex; align-items: center; gap: 6px; flex: 1; }
.topnav a { color: var(--text); text-decoration: none; font-size: 14px;
  padding: 6px 14px; border-radius: 20px; }
.topnav a:hover { background: var(--surface); }
.nav-foot { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.nav-foot a { color: var(--muted); }
.nav-overlay { display: none; }

@media (max-width: 680px) {
  .hamburger { display: block; }
  .brand { font-size: 15px; }
  .topnav {
    position: fixed; top: 0; left: 0; bottom: 0; width: 246px; z-index: 50;
    flex: none; flex-direction: column; align-items: stretch; gap: 2px;
    padding: 18px 12px; background: var(--bg); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 24px rgba(0,0,0,.12);
  }
  body.nav-open .topnav { transform: translateX(0); }
  .topnav a { padding: 13px 14px; border-radius: 10px; font-size: 16px; }
  .nav-foot { margin: auto 0 4px; padding: 12px 14px; }
  body.nav-open .nav-overlay { display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 40; }
}

.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; margin: 14px 0 6px;
  border-bottom: 1px solid var(--line); }
.admin-nav a { padding: 9px 14px; font-size: 14px; text-decoration: none;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-nav a:hover { color: var(--text); }
.admin-nav a.active { color: var(--text); border-bottom-color: #1c1c1a; font-weight: 500; }

.filter-tabs { display: flex; gap: 6px; margin: 14px 0; }
.filter-tabs a { padding: 6px 14px; font-size: 13px; text-decoration: none;
  color: var(--muted); border: 1px solid var(--line); border-radius: 20px; }
.filter-tabs a.active { background: #1c1c1a; color: #fff; border-color: #1c1c1a; }

.assigned { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.assign-cell { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kebab { display: inline-flex; align-items: center; justify-content: center; width: 32px;
  height: 32px; border-radius: 50%; border: none; background: none; cursor: pointer;
  color: var(--muted); }
.kebab:hover { background: var(--surface); color: var(--text); }
.kebab svg { display: block; }

.action-overlay { position: fixed; inset: 0; z-index: 90; background: transparent; }
.action-overlay.dim { background: rgba(0,0,0,.4); }
.action-overlay[hidden], .action-menu[hidden] { display: none; }
.action-menu { position: fixed; z-index: 100; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 10px 34px rgba(0,0,0,.18); min-width: 210px; padding: 6px; }
.action-menu a, .action-menu button { display: block; width: 100%; box-sizing: border-box;
  text-align: left; padding: 12px 12px; font-size: 15px; text-decoration: none; color: var(--text);
  background: none; border: none; border-radius: 8px; cursor: pointer; }
.action-menu a:hover, .action-menu button:hover { background: var(--surface); }
.action-menu .danger { color: var(--neg); }
.action-menu form { margin: 0; }
.action-menu select { width: 100%; box-sizing: border-box; padding: 9px 10px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.menu-move { display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 4px; }
.kebab-wrap { display: inline-flex; }
.kebab-menu { display: none; }
.action-menu.sheet { left: 0; right: 0; bottom: 0; top: auto !important;
  border-radius: 16px 16px 0 0; min-width: 0; padding: 8px 8px 24px;
  box-shadow: 0 -10px 34px rgba(0,0,0,.2); }
.action-menu.sheet a, .action-menu.sheet button { padding: 15px 16px; font-size: 16px; }
.rowmenu { display: flex; flex-direction: column; align-items: flex-end; }
.rowmenu > summary { cursor: pointer; list-style: none; display: inline-flex;
  align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 50%; color: var(--muted); }
.rowmenu > summary::-webkit-details-marker { display: none; }
.rowmenu > summary svg { display: block; }
.rowmenu > summary:hover, .rowmenu[open] > summary { background: var(--surface); color: var(--text); }
.rowmenu .menu { margin-top: 6px; display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 4px;
  background: var(--bg); min-width: 180px; }
.rowmenu .menu a, .rowmenu .menu button { display: block; width: 100%; text-align: left;
  padding: 8px 10px; font-size: 14px; text-decoration: none; color: var(--text);
  background: none; border: none; border-radius: 6px; cursor: pointer; }
.rowmenu .menu a:hover, .rowmenu .menu button:hover { background: var(--surface); }
.rowmenu .menu .danger { color: var(--neg); }
.rowmenu .menu form { margin: 0; }
.copy { background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 13px; padding: 0 4px; margin-left: 6px; vertical-align: middle; }
.copy:hover { color: var(--text); }

.tx-controls { display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; }
.per-page { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.per-page a { padding: 4px 10px; text-decoration: none; color: var(--muted);
  border: 1px solid var(--line); border-radius: 20px; }
.per-page a.active { background: #1c1c1a; color: #fff; border-color: #1c1c1a; }
.pager { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
.page-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 0 16px; }
.page-head h1 { margin: 0; }
.refresh-btn { display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; text-decoration: none; color: var(--muted); border-radius: 50%; }
.refresh-btn svg { display: block; }
.refresh-btn:hover { color: var(--text); background: var(--surface); }

.pending-box { border: 1px solid #f0d9a8; background: #fffaf0; border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 18px; }
.writeoff-box { border: 1px solid var(--line, #e3e6ea); border-radius: var(--radius);
  padding: 8px 14px; margin: 12px 0; }
.writeoff-box summary { cursor: pointer; font-weight: 500; }
.writeoff-box .entry-form { margin-top: 10px; }
.writeoff-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.writeoff-row .wo-amt { font-size: 13px; }
.pnl-totals { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.pnl-card-sum { border: 1px solid var(--line, #e3e6ea); border-radius: var(--radius);
  padding: 10px 16px; min-width: 150px; }
.pnl-card-sum .pnl-cur { font-weight: 600; margin-bottom: 4px; }
.tx-cmt { font-size: 12px; color: #6b7280; margin-top: 2px; max-width: 240px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kebab-cmt { display: flex; flex-direction: column; gap: 4px; padding: 6px 4px 2px; }
.kebab-cmt input[type=text] { font-size: 13px; padding: 4px 6px; }
.pending-box .sec { margin-top: 6px; }

.place { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.place-web { background: var(--surface); color: var(--text); }
.place-bot { background: #e6f1fb; color: #0c447c; }

.badge-pending { background: #fde9c8; color: #92560a; font-size: 12px;
  padding: 2px 8px; border-radius: 10px; }
.badge { display: inline-block; min-width: 16px; text-align: center;
  background: #e8862b; color: #fff; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 9px; margin-left: 4px; vertical-align: middle; }
h1 .badge, h2 .badge { font-size: 12px; }
.rate-toggle { background: none; border: 1px dashed #c9cdd4; color: #6b7280;
  font-size: 11px; line-height: 1.4; padding: 0 7px; border-radius: 7px;
  cursor: pointer; margin-left: 6px; font-weight: 500; }
.rate-toggle:hover { color: #1f2937; border-color: #8b93a1; }
.row-off { opacity: .5; }
.drag-handle { user-select: none; text-align: center; font-size: 16px; color: var(--muted); cursor: grab; }
.col-drag { display: none; }
.reordering .col-drag { display: table-cell; width: 28px; }
.reordering .kassa-row:hover .drag-handle { color: var(--text); }
tr.dragging { opacity: .5; background: var(--surface); }
.wallet-del { display: inline-block; }
.wallet-del > summary { list-style: none; cursor: pointer; display: inline-block; }
.wallet-del > summary::-webkit-details-marker { display: none; }
.wallet-del-menu { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); text-align: left;
  display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.wallet-del-menu p { margin: 0 0 2px; font-size: 13px; }
.admin-table .btn.small { padding: 5px 9px; }

/* Fluid container: fills the viewport with scaling side padding, capped on
   very large screens. No rigid narrow column — adapts to any device. */
main { width: 100%; max-width: 1100px; margin: 0 auto;
  padding: clamp(14px, 3vw, 30px); }
main.wide { max-width: 1100px; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 680px) {
  .tx-controls { align-items: flex-start; }
  .deal-card { padding: 16px 14px; }
  .col-type, .col-wallet { display: none; }
  .page-head h1 { font-size: 17px; }
  .page-head h1 .muted { font-size: 12px; }
}

.dash-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.cap { font-size: 12px; color: var(--muted); margin: 0 0 8px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.card.metric { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.card.metric .label { font-size: 12px; color: var(--muted); }
.card.metric .value { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.panel .sec { margin: 0 0 8px; font-size: 14px; }
.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mini tr:last-child td { border-bottom: none; }
.mini .addr { font-family: ui-monospace, Menlo, monospace; font-size: 11px; word-break: break-all; }
.mini .empty { color: var(--muted); }

@media (max-width: 680px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
}

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.summary .card { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.summary .label { font-size: 12px; color: var(--muted); }
.summary .value { font-size: 22px; font-weight: 600; margin-top: 2px; }

.toolbar { margin-bottom: 10px; }
.toolbar input[type=search] {
  width: 100%; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
}

table.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
table.ledger th, table.ledger td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.ledger th.num, table.ledger td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.empty { color: var(--muted); text-align: center; padding: 20px 0; }

.login { padding: 40px 0; text-align: center; color: var(--muted); }
.login .hint { font-size: 13px; }

.muted { color: var(--muted); }
.cmt { color: var(--text); }
table.ledger td .muted { font-size: 12px; }
.error { color: var(--neg); }
a { color: inherit; }

.btn {
  display: inline-block; padding: 8px 14px; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--text); text-decoration: none;
}
.btn:hover { background: var(--surface); }
.btn.primary { background: #1c1c1a; color: #fff; border-color: #1c1c1a; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--neg); border-color: var(--neg); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.primary:hover { background: #000; }
.btn.btn-icon { display: inline-flex; align-items: center; gap: 6px; }
.btn.btn-icon svg { width: 15px; height: 15px; display: block; }
.push-right { margin-left: auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.is-refreshing svg { animation: spin .7s linear infinite; }
.fade-in { animation: fadeIn .35s ease; }
.panel-head { display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 8px; }
.panel-head .sec { margin: 0; }
.page-head .dash-actions { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 5px; padding: 5px 13px;
  font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg);
  transition: color .12s, background .12s, border-color .12s; }
.back::before { content: "‹"; font-size: 16px; line-height: 1; }
.back:hover { color: var(--text); background: var(--surface); border-color: var(--text); }
.mlabel { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.mval { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 22px 0 18px; }
.plan-side { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.plan-side-recv { background: #f6fbf1; border-color: #d8ead0; }
.plan-side-pay { background: #fdf6f6; border-color: #efd9d9; }
.plan-side-head { display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; font-size: 13px; font-weight: 500; margin-bottom: 10px; }
.plan-side-head.pos { color: var(--pos); }
.plan-side-head.neg { color: var(--neg); }
.plan-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.plan-amt-line { font-size: 12px; color: var(--muted); margin: 4px 0; }
.track { height: 6px; border-radius: 999px; background: #e8e8e4; overflow: hidden; margin: 6px 0; }
.track-fill { height: 100%; border-radius: 999px; }
.pos-fill { background: var(--pos); }
.neg-fill { background: var(--neg); }
.plan-item-bar { margin: 14px 0 4px; }
.row-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }
.plan-row { display: flex; align-items: center; gap: 8px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; margin-bottom: 7px; }
.plan-row > div:first-child { flex: 1; min-width: 0; }
.plan-cp { font-weight: 500; font-size: 14px; }
.plan-link, .plan-note { font-size: 11px; color: var(--muted); margin-top: 1px; }
.plan-right { text-align: right; white-space: nowrap; }
.plan-amt { font-weight: 500; font-variant-numeric: tabular-nums; }
.plan-date { font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: #e6f1fb; color: #0c447c; }
.plan-del button { border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 2px 4px; }
.plan-del button:hover { color: var(--neg); }
.plan-empty { color: var(--muted); font-size: 13px; padding: 8px 4px; }
.plan-totals { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.plan-net-neg { background: #fceaea; }
.plan-net-pos { background: #eaf3de; }
.date-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.date-nav-form { margin: 0; }
.date-nav-form input[type=date] { padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.date-arrow { display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 32px; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--text); font-size: 18px; line-height: 1; }
.date-arrow:hover { background: var(--surface); border-color: var(--text); }
.date-pill { padding: 6px 12px; font-size: 13px; text-decoration: none; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; }
.date-pill.active { background: #1c1c1a; color: #fff; border-color: #1c1c1a; }
.plan-cards { display: flex; flex-direction: column; gap: 8px; }
.plan-card { display: block; text-decoration: none; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; }
.plan-card:hover { border-color: var(--text); background: var(--surface); }
.plan-card-total { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.plan-card-count { font-size: 12px; color: var(--muted); margin-top: 1px; }
.date-combos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.date-combos button { font-size: 12px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.date-combos button:hover { border-color: var(--text); }
@media (max-width: 680px) {
  .plan-grid { grid-template-columns: 1fr; }
  .plan-totals { grid-template-columns: 1fr 1fr; }
}
.tx-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tx-left .filter-tabs { margin: 0; }
.wallet-filter { margin: 0; display: inline-flex; gap: 6px; align-items: center; }
.wf-ac { position: relative; }
.wf-ac input[type=text] { padding: 8px 12px; font-size: 14px; border: 1px solid #dcdfe4;
  border-radius: 10px; background: #fff; min-width: 220px; }
.wf-ac input[type=text]:focus { outline: none; border-color: #1c1c1a; box-shadow: 0 0 0 3px rgba(0,0,0,.05); }
.wf-drop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; margin: 0; padding: 6px;
  list-style: none; background: #fff; border: 1px solid #e6e8ec; border-radius: 14px;
  box-shadow: 0 12px 34px rgba(20,20,20,.14); min-width: 280px; max-height: 320px; overflow: auto; }
.wf-drop li { padding: 9px 12px; border-radius: 10px; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center; gap: 14px; }
.wf-drop li:hover, .wf-drop li.active { background: #f2f2ef; }
.wf-drop .wf-name { font-weight: 500; font-size: 13px; color: var(--text); }
.wf-drop .wf-addr { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.wf-drop .wf-empty { padding: 9px 12px; color: var(--muted); font-size: 13px; }
.ok-msg { color: var(--pos); }

.sec { font-size: 16px; font-weight: 500; margin: 24px 0 10px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sec-head .sec { margin-bottom: 6px; }
.admin-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-add input, .admin-add select { padding: 9px 11px; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.admin-add input[name=telegram_id] { width: 140px; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 9px 8px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: middle; }
.admin-table select, .admin-table input { padding: 7px 9px; font-size: 13px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.inline-f { display: flex; gap: 6px; align-items: center; margin: 0; }
.login-f input[name=username] { width: 110px; }
.login-f input[name=password] { width: 130px; }
.hint { font-size: 12px; margin-top: 10px; }
.pos-btn { border-color: var(--pos); color: var(--pos); }
.neg-btn { border-color: var(--neg); color: var(--neg); }

.toolbar { display: flex; gap: 8px; align-items: center; }
.toolbar input[type=search] { flex: 1; }

tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--surface); }

.acc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 8px 0 16px; }
.acc-head h1 { margin: 0; font-size: 22px; }
.acc-balance { font-size: 22px; font-weight: 600; white-space: nowrap; }

.entry-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.entry-form input { padding: 9px 11px; font-size: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.entry-form input[name=amount] { width: 120px; }
.entry-form input[name=notes] { flex: 1; min-width: 120px; }
.entry-form select { padding: 9px 10px; font-size: 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); }

.kassa-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.kassa-edit input[name=name] { min-width: 200px; flex: 1; padding: 7px 9px; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.kassa-edit select { padding: 7px 9px; font-size: 13px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); }
.kassa-edit .num { min-width: 110px; text-align: right; }
.chk { font-size: 13px; color: var(--muted); display: inline-flex; gap: 5px; align-items: center; }
.wallet-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wallet-actions select { padding: 6px 8px; font-size: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }

.form { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form input, .form select { padding: 9px 11px; font-size: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); width: 100%; box-sizing: border-box; }
.form .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

.rename-box { margin-top: 6px; }
.rename-box summary { display: inline-block; font-size: 12px; color: var(--muted);
  cursor: pointer; padding: 4px 10px; border: 1px solid var(--line); border-radius: 20px;
  list-style: none; }
.rename-box summary::-webkit-details-marker { display: none; }
.rename-box summary:hover { background: var(--surface); }
.name-edit { display: flex; gap: 6px; align-items: center; margin: 8px 0 0; }
.name-edit input { font-size: 15px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); color: var(--text); min-width: 200px; }

.wallets { margin: 0 0 18px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.wallets-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.wallet { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 13px; }
.wallet .addr { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }

.acc-balances { text-align: right; }
.other-bal { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 20px; background: var(--surface); }
.chip.pos { color: var(--pos); }
.chip.neg { color: var(--neg); }

.deal-box { margin: 0 0 18px; border: 1px solid var(--line); border-radius: var(--radius); }
.deal-box summary { cursor: pointer; padding: 10px 12px; font-size: 14px; user-select: none; }
.deal-form { display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; }
.deal-form .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.deal-form .lbl { width: 80px; font-size: 13px; color: var(--muted); }
.deal-form input, .deal-form select { padding: 8px 10px; font-size: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.deal-form input[type=number], .deal-form input[type=text] { flex: 1; min-width: 120px; }
.deal-form .rad { font-size: 14px; color: var(--text); }
.deal-form .btn { align-self: flex-start; margin-top: 4px; }
.login-box { max-width: 360px; margin: 40px auto; }
.login-box h1 { font-size: 22px; }
.login-box .hint { font-size: 13px; color: var(--muted); margin-top: 14px; }

/* ---- Deal entry (new design) ---- */
.deal-card { max-width: 560px; margin: 4px auto 0; background: var(--bg);
  border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; }
.deal-card h1 { font-size: 20px; margin: 0 0 16px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field select, .field > input { width: 100%; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.field .opt { color: var(--muted); font-weight: 400; }

.legs { display: flex; flex-direction: column; gap: 12px; }
.leg-rate { max-width: 200px; }
.leg-label { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.leg-label .auto { background: var(--surface); color: var(--muted); font-size: 10px;
  padding: 1px 6px; border-radius: 10px; margin-left: 4px; }
.leg-row { display: flex; gap: 6px; }
.leg-row input { flex: 1; min-width: 0; padding: 11px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
  font-variant-numeric: tabular-nums; }
.leg-row select { width: 76px; flex: 0 0 76px; padding: 0 8px; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.leg-get .leg-row input { border-color: #bfe3cf; }
.leg-give .leg-row input { background: var(--surface); }
.leg-rate .leg-row input { text-align: center; }

.deal-preview { margin: 14px 0 4px; padding: 10px 14px; font-size: 14px;
  background: var(--surface); border-radius: var(--radius); color: var(--text);
  text-align: center; }

.deal-extra { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.field.inline { display: flex; align-items: center; gap: 12px; }
.field.inline > label { margin: 0; min-width: 92px; }
.field.inline .leg-row { flex: 1; }

.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg input { display: none; }
.seg label { padding: 8px 16px; font-size: 14px; cursor: pointer; color: var(--muted);
  text-align: center; }
.seg input:checked + label { background: #1c1c1a; color: #fff; }

.deal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.date-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex: 1; }
.date-row input[type=date] { padding: 8px 10px; font-size: 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); color: var(--text); }
.date-presets { display: flex; gap: 4px; }
.date-presets button { padding: 6px 10px; font-size: 12px; border: 1px solid var(--line);
  border-radius: 20px; background: var(--bg); color: var(--text); cursor: pointer; }
.date-presets button:hover { background: var(--surface); }

@media (max-width: 520px) {
  .field.inline { flex-direction: column; align-items: stretch; gap: 6px; }
  .field.inline > label { min-width: 0; }
}

@media (max-width: 480px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .summary .card:last-child { grid-column: 1 / -1; }
}
