/* ═══════════════════════════════════════════
   BATYA v1.0.2 — Dark Theme
═══════════════════════════════════════════ */
:root {
  --bg-0:    #07090f;
  --bg-1:    #0d1220;
  --bg-2:    #111827;
  --bg-3:    #151d2e;
  --bg-4:    #1e2c42;
  --border:  #1e2c42;
  --text-1:  #e8f0fd;
  --text-2:  #7b91b0;
  --text-3:  #4a5e7a;
  --ton:     #0098ea;
  --ton-dim: rgba(0,152,234,.15);
  --green:   #26d87c;
  --red:     #ef4444;
  --yellow:  #f9a825;
  --purple:  #7c6fcd;
  --radius:  12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-0);
  color: var(--text-1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app { display: flex; flex-direction: column; height: 100dvh; height: 100vh; overflow: hidden; }

/* ════════ HEADER ════════ */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--bg-1);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  height: 54px;
}
.header-left  { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--ton); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #fff; flex-shrink: 0;
}
.header-title-wrap { display: flex; align-items: baseline; gap: 5px; }
.app-name    { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.app-version { font-size: 10px; color: var(--text-3); font-weight: 500; }

/* TON price (plain text, no badge) */
.ton-price-inline {
  display: flex; align-items: baseline; gap: 4px;
}
.ton-price-label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.ton-price-value { font-size: 14px; font-weight: 800; color: var(--text-1); }

.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--bg-3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2); transition: all .2s;
}
.icon-btn:active { transform: scale(.92); color: var(--ton); }
.icon-btn svg    { width: 17px; height: 17px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinning svg { animation: spin .7s linear infinite; }

/* ════════ MAIN CONTENT ════════ */
.main-content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 0 80px; }

.section-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px;
  color: var(--text-3); padding: 18px 16px 8px;
}
.section-icon { width: 13px; height: 13px; }

/* ════════ TREASURY ════════ */
.treasury-card {
  margin: 0 16px 4px; border-radius: var(--radius); overflow: hidden;
  position: relative; border: 1px solid var(--border);
}
.treasury-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--ton);
}
.empty-treasury {
  padding: 24px 20px; display: flex; flex-direction: column; align-items: center;
  gap: 12px; background: var(--bg-2);
}
.treasury-empty-text { font-size: 13px; color: var(--text-3); }
.add-treasury-btn {
  background: var(--ton); color: #fff; border: none; border-radius: 8px;
  padding: 8px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.treasury-filled {
  padding: 16px; display: flex; justify-content: space-between; align-items: flex-start;
  background: var(--bg-2);
}
.treasury-name    { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.treasury-balance { font-size: 22px; font-weight: 700; }
.treasury-balance-usd { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.treasury-icon    { font-size: 28px; opacity: .6; }

/* ════════ SUMMARY CARDS ════════ */
.summary-row { display: flex; gap: 10px; padding: 0 16px 4px; overflow-x: auto; }
.summary-card {
  min-width: 100px; flex: 1; border-radius: var(--radius); padding: 14px 12px;
  background: var(--bg-2); border: 1px solid var(--border);
}
.sc-label { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.sc-value { font-size: 16px; font-weight: 700; white-space: nowrap; }
.sc-sub   { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.card-total  { border-top: 2px solid var(--ton); }
.card-day    { border-top: 2px solid var(--yellow); }
.card-night  { border-top: 2px solid var(--purple); }

/* ════════ CHART ════════ */
.chart-card {
  margin: 0 16px 4px; border-radius: var(--radius); background: var(--bg-2);
  border: 1px solid var(--border); padding: 14px;
}
.chart-legend {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 11px; color: var(--text-2);
}
.legend-dot   { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.day-dot      { background: var(--yellow); }
.night-dot    { background: var(--purple); }
.total-dot    { background: var(--ton); }
.chart-wrap   { height: 140px; }
.chart-empty  { text-align: center; font-size: 12px; color: var(--text-3); padding: 24px 0; display: none; }
.chart-empty.visible { display: block; }

/* ════════ WALLETS TAB ════════ */
.wallets-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px 8px;
}
.add-wallet-btn {
  display: flex; align-items: center; gap: 5px;
  background: var(--ton); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.add-wallet-btn svg { width: 14px; height: 14px; }

.shift-group { margin-bottom: 6px; }
.shift-group-header {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--text-2);
  padding: 8px 16px 6px;
}
.shift-count {
  margin-left: auto; background: var(--bg-3); border-radius: 9px;
  padding: 1px 8px; font-size: 11px; color: var(--text-3);
}
.day-header   { border-left: 3px solid var(--yellow); }
.night-header { border-left: 3px solid var(--purple); }

.wallets-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; padding: 4px 16px 12px;
  min-height: 60px;
}
.no-wallets-hint {
  grid-column: 1/-1; text-align: center;
  font-size: 12px; color: var(--text-3); padding: 16px 0;
}

/* ── wallet card ── */
.wallet-card {
  background: var(--bg-2); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  cursor: grab; user-select: none; touch-action: none;
  transition: transform .2s, box-shadow .2s;
}
.wallet-card:active { cursor: grabbing; }
.sortable-ghost  { opacity: .35; background: var(--bg-3); }
.sortable-chosen { box-shadow: 0 6px 24px rgba(0,0,0,.5); transform: scale(1.03); z-index: 10; }
.sortable-drag   { opacity: 1; }

.wc-header { height: 4px; }
.wc-body   { padding: 10px 10px 12px; }
.wc-top    { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.wc-badge  { font-size: 11px; padding: 2px 6px; border-radius: 5px; font-weight: 600; }
.wc-badge.day   { background: rgba(249,168,37,.15); color: var(--yellow); }
.wc-badge.night { background: rgba(124,111,205,.15); color: var(--purple); }
.wc-actions { display: flex; gap: 4px; }
.wc-action-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-3); display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-3); transition: color .2s; touch-action: manipulation;
}
.wc-action-btn:active { color: var(--text-1); }
.wc-action-btn.delete-btn:active { color: var(--red); }
.wc-action-btn svg { width: 12px; height: 12px; }
.wc-name    { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.wc-balance { font-size: 16px; font-weight: 700; }
.wc-balance-unit { font-size: 11px; margin-left: 3px; color: var(--text-2); }
.wc-usd     { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.wc-loading { font-size: 12px; color: var(--text-3); }

/* ════════ HISTORY / FILTERS ════════ */
.filter-wrap { margin: 0 16px 8px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--border); overflow: hidden; }
.filter-toggle-row {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  cursor: pointer; user-select: none;
}
.filter-toggle-label { font-size: 13px; font-weight: 600; flex: 1; }
.filter-active-hint  { font-size: 11px; color: var(--ton); }
.filter-toggle-icon  { font-size: 10px; color: var(--text-3); }
.filter-panel        { padding: 0 14px; max-height: 0; overflow: hidden; transition: max-height .3s ease, padding .3s; }
.filter-panel.open   { max-height: 400px; padding: 0 14px 14px; }
.filter-section-title { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 7px; margin-top: 2px; }

.tx-filter-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.filter-chip {
  padding: 5px 10px; border-radius: 16px; font-size: 12px; font-weight: 500;
  background: var(--bg-3); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; gap: 5px; transition: all .15s;
}
.filter-chip.active { background: var(--ton-dim); border-color: var(--ton); color: var(--ton); }
.filter-chip-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.dir-filter { display: flex; gap: 8px; }
.dir-btn {
  flex: 1; padding: 7px 4px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
  transition: all .15s;
}
.dir-btn.active { background: var(--ton-dim); border-color: var(--ton); color: var(--ton); }

.date-filter-row { display: flex; align-items: center; gap: 8px; }
.date-input {
  flex: 1; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; color: var(--text-1); font-size: 12px;
  color-scheme: dark;
}
.date-input:focus { outline: none; border-color: var(--ton); }
.date-sep { color: var(--text-3); }
.date-clear-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-3); color: var(--text-2); cursor: pointer; font-size: 12px;
}

/* ── TX LIST ── */
.tx-list { padding: 0 16px; }
.tx-empty { text-align: center; font-size: 13px; color: var(--text-3); padding: 32px 16px; }

/* ── TX ITEM (expandable) ── */
.tx-item { border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--border); margin-bottom: 8px; overflow: hidden; }
.tx-summary {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  cursor: pointer; transition: background .15s;
}
.tx-summary:active { background: var(--bg-3); }
.tx-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.tx-icon svg { width: 17px; height: 17px; }
.tx-icon.in  { background: rgba(38,216,124,.12); color: var(--green); }
.tx-icon.out { background: rgba(239,68,68,.12);  color: var(--red); }
.tx-info  { flex: 1; min-width: 0; }
.tx-wallet-name { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.tx-desc  { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date  { font-size: 10px; color: var(--text-3); margin-top: 2px; }
.tx-amount-wrap  { text-align: right; flex-shrink: 0; }
.tx-amount { font-size: 13px; font-weight: 700; white-space: nowrap; }
.tx-amount.in    { color: var(--green); }
.tx-amount.out   { color: var(--red); }
.tx-amount-usd   { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* expanded details */
.tx-details {
  max-height: 0; overflow: hidden; transition: max-height .3s ease;
  border-top: 0px solid var(--border);
}
.tx-item.expanded .tx-details { max-height: 400px; border-top-width: 1px; }
.tx-detail-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 7px 14px; font-size: 12px; border-bottom: 1px solid var(--bg-3);
  gap: 12px;
}
.tx-detail-row span:first-child { color: var(--text-3); flex-shrink: 0; }
.tx-detail-row span:last-child  { color: var(--text-1); text-align: right; word-break: break-all; }
.tx-detail-addr { font-size: 10px; font-family: monospace; word-break: break-all; text-align: right; }
.tx-hash-link  { color: var(--ton); text-decoration: none; font-size: 12px; }
.tx-hash-link:hover  { text-decoration: underline; }
.tx-addr-link  { color: var(--ton); text-decoration: none; font-size: 11px; font-family: monospace; word-break: break-all; }
.tx-addr-link:hover  { text-decoration: underline; }
.tx-peer-addr  { color: var(--ton); text-decoration: none; font-size: 12px; }
.tx-peer-addr:hover  { text-decoration: underline; }
.tx-desc-text  { color: var(--text-2); }

.load-more-wrap { text-align: center; padding: 12px; }
.load-more-btn {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--ton); border-radius: 8px; padding: 9px 20px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ════════ DAILY TAB ════════ */
.daily-date-badge { font-size: 12px; color: var(--text-3); font-weight: 500; margin-left: 4px; text-transform: none; letter-spacing: 0; }
.daily-summary-row { display: flex; gap: 10px; padding: 0 16px 8px; overflow-x: auto; }
.daily-sum-card {
  min-width: 140px; flex: 1; border-radius: var(--radius); padding: 14px 13px;
  background: var(--bg-2); border: 1px solid var(--border); border-top: 2px solid var(--ton);
}
.daily-sum-label  { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.daily-sum-value  { font-size: 18px; font-weight: 700; }
.daily-sum-change { font-size: 12px; margin-top: 3px; }
.daily-sum-change.pos { color: var(--green); }
.daily-sum-change.neg { color: var(--red); }

.daily-table-wrap { margin: 0 16px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.daily-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.daily-table thead th {
  padding: 9px 10px; background: var(--bg-3); color: var(--text-3); font-weight: 600;
  text-align: left; font-size: 11px; border-bottom: 1px solid var(--border);
}
.daily-table tbody tr { border-bottom: 1px solid var(--border); }
.daily-hist-row { cursor: pointer; transition: background .15s; }
.daily-hist-row:hover, .daily-hist-row.open { background: var(--bg-3); }
.daily-hist-row td { padding: 10px 10px; vertical-align: top; }
.today-row td { font-weight: 600; }
.dt-change { font-weight: 600; }
.dt-change.pos { color: var(--green); }
.dt-change.neg { color: var(--red); }

/* sub-section (wallet details) */
.daily-sub-section { background: var(--bg-0); display: none; }
.daily-sub-section.visible { display: table-row; }
.daily-sub-table { width: 100%; border-collapse: collapse; }
.daily-sub-row td { padding: 7px 10px; font-size: 11px; color: var(--text-2); border-bottom: 1px solid var(--border); }
.dt-wallet-cell { display: flex; align-items: center; gap: 6px; }
.dt-color-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dt-shift-badge { font-size: 11px; margin-left: 4px; }

.daily-load-more {
  text-align: center; padding: 12px; cursor: pointer;
  color: var(--ton); font-size: 13px; font-weight: 600;
  background: var(--bg-2); border-top: 1px solid var(--border);
}
.daily-load-more:active { opacity: .7; }

/* ════════ SETTINGS TAB ════════ */
.settings-block {
  margin: 0 16px 12px; border-radius: var(--radius);
  background: var(--bg-2); border: 1px solid var(--border); padding: 16px;
}
.settings-block-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.settings-block-desc  { font-size: 12px; color: var(--text-2); margin-bottom: 12px; line-height: 1.5; }

.currency-options { display: flex; flex-direction: column; gap: 8px; }
.currency-option {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: 10px; background: var(--bg-3); border: 1.5px solid var(--border);
  cursor: pointer; transition: all .15s;
}
.currency-option.active { border-color: var(--ton); background: var(--ton-dim); }
.currency-symbol { font-size: 22px; width: 36px; text-align: center; }
.currency-code   { font-size: 13px; font-weight: 700; }
.currency-name   { font-size: 11px; color: var(--text-2); }

.settings-action-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-1); border-radius: 9px; padding: 12px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.settings-action-btn:hover  { background: var(--bg-4); border-color: var(--ton); color: var(--ton); }
.settings-action-btn:active { transform: scale(.97); }
.settings-action-btn:disabled { opacity: .5; cursor: not-allowed; }

.settings-info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.settings-info-row:last-child  { border-bottom: none; }
.settings-info-row span:first-child { color: var(--text-2); }

/* ════════ BOTTOM NAV ════════ */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--bg-1); border-top: 1px solid var(--border);
  padding: 4px 0 env(safe-area-inset-bottom, 4px); z-index: 100; height: 60px;
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; color: var(--text-3);
  font-size: 10px; cursor: pointer; padding: 4px 2px; transition: color .15s;
}
.tab-btn svg  { width: 20px; height: 20px; }
.tab-btn.active { color: var(--ton); }

/* ════════ MODAL ════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  width: 100%; max-width: 520px; max-height: 90dvh; max-height: 90vh;
  background: var(--bg-1); border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-drag-handle { width: 36px; height: 4px; background: var(--bg-4); border-radius: 2px; margin: 10px auto 0; flex-shrink: 0; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 0; flex-shrink: 0; }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close-btn { width: 30px; height: 30px; border-radius: 8px; background: var(--bg-3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-2); }
.modal-close-btn svg { width: 14px; height: 14px; }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.modal-footer { padding: 12px 20px 24px; display: flex; gap: 10px; flex-shrink: 0; border-top: 1px solid var(--border); }

.form-group   { margin-bottom: 16px; }
.form-label   { display: block; font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.form-input {
  width: 100%; background: var(--bg-2); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 12px 14px; color: var(--text-1); font-size: 14px;
}
.form-input:focus { outline: none; border-color: var(--ton); }
.input-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }

.segmented-control { display: flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.seg-btn { flex: 1; padding: 9px 8px; border-radius: 8px; border: none; background: transparent; color: var(--text-2); font-size: 12px; font-weight: 600; cursor: pointer; transition: all .2s; }
.seg-btn.active { background: var(--ton); color: #fff; }

.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch { width: 30px; height: 30px; border-radius: 8px; cursor: pointer; border: 2.5px solid transparent; transition: transform .15s; }
.color-swatch.selected { border-color: #fff; transform: scale(1.15); }

.toggle-label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-input { display: none; }
.toggle-track { width: 44px; height: 24px; border-radius: 12px; background: var(--bg-4); position: relative; transition: background .2s; flex-shrink: 0; }
.toggle-input:checked + .toggle-track { background: var(--ton); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 10px; background: #fff; transition: left .2s; }
.toggle-input:checked + .toggle-track .toggle-thumb { left: 22px; }
.toggle-text { font-size: 13px; color: var(--text-2); }

.btn-cancel, .btn-save { flex: 1; padding: 13px; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; border: none; }
.btn-cancel { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border); }
.btn-save   { background: var(--ton); color: #fff; }

/* ════════ TOAST ════════ */
.toast {
  position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 18px; font-size: 13px; font-weight: 600; color: var(--text-1);
  opacity: 0; transition: opacity .25s, transform .25s; z-index: 2000;
  pointer-events: none; white-space: nowrap;
}
.toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: rgba(38,216,124,.15); border-color: var(--green); color: var(--green); }
.toast.error   { background: rgba(239,68,68,.15);  border-color: var(--red);   color: var(--red); }

/* ════════ MISC ════════ */
.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* Tab panes */
.tab-pane { display: none; }
.tab-pane.active { display: block; }
