:root {
  color-scheme: dark;
  --bg: #0f1014;
  --panel: #16171d;
  --panel-2: #1b1d24;
  --line: #2a2d36;
  --line-soft: rgba(255, 255, 255, 0.07);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --soft: #71717a;
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.12);
  --red: #fb7185;
  --red-bg: rgba(251, 113, 133, 0.12);
  --gray: #7c818c;
  --gray-bg: rgba(124, 129, 140, 0.12);
  --blue: #8ab4ff;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  font-size: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), transparent 360px),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  flex-direction: column;
  flex: 0 0 270px;
  gap: 4px;
}

.brand-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.brand-title-row h1 {
  flex: 0 0 auto;
}

.app-version {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

h1 {
  margin: 0;
  font-size: 29px;
  line-height: 1.05;
  letter-spacing: 0;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.month-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.month-nav-group {
  display: grid;
  justify-items: center;
  gap: 1px;
  margin-right: 12px;
}

.month-nav-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.month-report-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  transition: color 160ms ease;
}

.month-report-link:hover,
.month-report-link:focus-visible {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-btn,
.text-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-btn {
  width: 38px;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}

.text-btn {
  padding: 0 14px;
  font-size: 14px;
}

.icon-btn:hover,
.text-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
}

.month-title {
  min-width: 168px;
  text-align: center;
  color: #e7e7ea;
  font-weight: 650;
}

#nextMonth { margin-right: 0; }

.support-btn {
  color: #fda4af;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.main-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.panel,
.stat,
.settings,
.editor {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(22, 23, 29, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 0;
  overflow: visible;
}

.stat {
  position: relative;
  z-index: 1;
  padding: 14px;
  min-height: 108px;
  box-shadow: none;
}

.stat:hover,
.stat:focus-within {
  z-index: 200;
}

.starting-stat .stat-value {
  color: var(--muted);
}

.starting-stat, .current-stat { display: flex; flex-direction: column; }
.stat-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 10px; }
.stat-actions .stat-edit-btn { position: static; min-height: 27px; font-size: 11px; }
.stat-actions .allocation-btn { color: var(--blue); border-color: rgba(138, 180, 255, .38); }

.stat-edit-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.stat-help {
  position: relative;
  z-index: 50;
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  margin-left: 5px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 11px;
  cursor: help;
  vertical-align: middle;
}

.stat-help::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 1000;
  left: 50%;
  top: calc(100% + 8px);
  width: min(280px, calc(100vw - 32px));
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101116;
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translate(-50%, -4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.stat-help:hover::after,
.stat-help:focus::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 10px;
}

.stat-value {
  font-size: clamp(20px, 2.8vw, 30px);
  font-weight: 720;
  line-height: 1;
  white-space: nowrap;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.calendar {
  padding: 14px;
}

.weekdays,
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekdays {
  margin-bottom: 8px;
}

.weekday {
  color: var(--soft);
  font-size: 13px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0;
}

.day {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 112px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #13141a;
  color: var(--text);
  text-align: left;
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.day:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.22);
  background: #181a21;
}

.day.is-empty {
  opacity: 0.3;
  pointer-events: none;
  background: transparent;
  border-style: dashed;
}

.day.is-selected {
  outline: 2px solid rgba(138, 180, 255, 0.75);
  outline-offset: 2px;
}

.day.win {
  background: linear-gradient(180deg, var(--green-bg), #13141a 64%);
  border-color: rgba(52, 211, 153, 0.26);
}

.day.loss {
  background: linear-gradient(180deg, var(--red-bg), #13141a 64%);
  border-color: rgba(251, 113, 133, 0.26);
}

.day.off {
  background: linear-gradient(180deg, var(--gray-bg), #13141a 64%);
  border-color: rgba(124, 129, 140, 0.24);
}

.day-number {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 650;
  font-size: 16px;
  margin-bottom: 10px;
}

.day-head-icons {
  display: flex;
  align-items: center;
  gap: 7px;
}

.day-share-trigger {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 500;
  line-height: 1;
  transition: color 140ms ease, background 140ms ease, transform 140ms ease;
}

.day-share-trigger:hover,
.day-share-trigger:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, .08);
  color: var(--blue);
  transform: scale(1.06);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
}

.win .dot {
  background: var(--green);
}

.loss .dot {
  background: var(--red);
}

.off .dot {
  background: var(--gray);
}

.day-profit {
  font-size: 18px;
  font-weight: 720;
  line-height: 1.1;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.day-content {
  display: grid;
  grid-template-rows: minmax(24px, auto) 20px 24px;
  gap: 4px;
  flex: 1;
  min-height: 76px;
}

.day-primary {
  min-width: 0;
  font-size: 16px;
  font-weight: 680;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.day-content .day-profit {
  margin: 0;
}

.is-empty-content .day-primary {
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.day-indicators {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  min-height: 24px;
}

.day-indicator {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  line-height: 1;
}

.day-indicator.deposit { color: var(--green); }
.day-indicator.cashout { color: var(--red); }
.day-indicator.transfer { color: var(--blue); }
.day-indicator.note { color: #c9c9cf; }

.day-meta {
  color: var(--muted);
  font-size: 14px;
}

.day-note {
  margin-top: 8px;
  color: #c9c9cf;
  font-size: 14px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.day-tooltip {
  position: fixed;
  z-index: 30;
  width: min(280px, calc(100vw - 24px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 17, 22, 0.98);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.day-tooltip[hidden] {
  display: none;
}

.day-tooltip-date {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 6px;
}

.day-tooltip-note {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 18px;
}

.side .file-panel {
  order: 1;
}

.side .editor {
  order: 2;
}

.side .operations {
  order: 3;
}

.chart-card,
.settings {
  padding: 14px;
}

.chart-title-row { display: flex; align-items: center; gap: 2px; }
.chart-title-row .section-title { margin: 0; }

.main-column .chart-card canvas {
  height: 280px;
}

.chart-wrap {
  position: relative;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 118px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(16, 17, 22, 0.96);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-tooltip-date {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.chart-tooltip-value {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.section-hint {
  color: var(--soft);
  font-size: 13px;
}

.settings {
  box-shadow: none;
}

.bankroll-start-value {
  font-size: 24px;
  font-weight: 720;
  margin-bottom: 12px;
}

.operations {
  padding: 14px;
  box-shadow: none;
}

.operation-summary {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.operation-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.operation-summary-row strong {
  color: var(--text);
  font-size: 15px;
}

.manage-operations-btn {
  width: 100%;
}

.operations-modal {
  width: min(920px, 100%);
}

.operations-modal .operation-list {
  max-height: min(470px, 48vh);
}

.operations-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px;
  gap: 10px;
  margin-bottom: 12px;
}

.operations-toolbar select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101116;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

.operation-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.operation-total {
  min-height: 38px;
  padding: 6px 9px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #111218;
}

.operation-total span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.operation-total strong {
  display: block;
  font-size: 15px;
  white-space: nowrap;
}

.operation-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 310px;
  overflow: auto;
}

.operation-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #111218;
}

.operation-main {
  min-width: 0;
}

.operation-title {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 3px;
}

.operation-meta {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.operation-amount {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.operation-tools {
  display: flex;
  gap: 4px;
}

.mini-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.chart-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101116;
}

.chart-mode {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.chart-mode.active {
  background: #242732;
  color: var(--text);
}

.chart-card .section-head {
  flex-wrap: wrap;
}

.chart-periods {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101116;
}

.chart-period {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.chart-period:hover {
  background: #1b1e26;
  color: var(--text);
}

.chart-period.active {
  background: #242732;
  color: var(--text);
}

.transaction-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.transaction-form .field:last-child {
  grid-column: 1 / -1;
}

.file-panel {
  padding: 14px;
  box-shadow: none;
}

.file-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.save-data-primary {
  min-height: 44px;
  border-radius: var(--radius);
  background: #f4f4f5;
  color: #111217;
  font-weight: 750;
  transition: transform 160ms ease, opacity 160ms ease;
}

.save-data-primary:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.file-secondary-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.export-json-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color 160ms ease;
}

.export-json-link:hover {
  color: var(--text);
}

.unlink-json-link:hover {
  color: var(--red);
}

.broken-link-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.file-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.file-status.is-dirty {
  color: #fbbf24;
}

.file-status.is-saved {
  color: var(--green);
}

.file-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

canvas {
  width: 100%;
  height: 210px;
  display: block;
  cursor: crosshair;
}

.editor {
  padding: 14px;
  box-shadow: none;
}

.selected-date {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}

label {
  color: var(--muted);
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101116;
  color: var(--text);
  padding: 10px 11px;
  font-size: 15px;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(138, 180, 255, 0.65);
  background-color: #12141b;
}

select {
  min-height: 43px;
  padding-right: 36px;
  appearance: none;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background-color: #14161d;
}

select option {
  background: #16171d;
  color: var(--text);
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.45;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101116;
}

.segment {
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  transition: background 160ms ease, color 160ms ease;
}

.segment.active {
  color: var(--text);
  background: #242732;
}

.row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.row .field label {
  min-height: 54px;
  display: flex;
  align-items: flex-end;
  line-height: 1.3;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 14px;
}

.primary {
  min-height: 40px;
  border-radius: var(--radius);
  background: #f4f4f5;
  color: #111217;
  font-weight: 700;
  transition: transform 160ms ease, opacity 160ms ease;
}

.primary:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.ghost {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.report-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 11, 15, 0.72);
  backdrop-filter: blur(12px);
  animation: fadeIn 160ms ease;
}

#transactionOverlay {
  z-index: 2100;
  background: rgba(10, 11, 15, 0.46);
}

.report-overlay[hidden] {
  display: none;
}

.report-modal {
  width: min(860px, 100%);
  max-height: min(780px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #15161c;
  box-shadow: var(--shadow);
  animation: liftIn 180ms ease;
}

.report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.report-title {
  margin: 0 0 5px;
  font-size: 24px;
  line-height: 1.15;
}

.report-subtitle {
  color: var(--muted);
  font-size: 14px;
}

.report-subtitle.negative {
  color: var(--red);
  font-weight: 700;
}

.report-year-nav {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}

.report-year {
  min-width: 78px;
  text-align: center;
  font-size: 22px;
  line-height: 1;
  font-weight: 750;
}

.report-period-btn {
  margin-left: 8px;
}

.report-period-btn.active {
  border-color: rgba(94, 156, 255, .5);
  background: rgba(94, 156, 255, .14);
  color: var(--text);
}

.report-body {
  padding: 16px;
}

.support-copy {
  color: #d4d4d8;
  font-size: 15px;
  line-height: 1.6;
}

.support-modal .report-body {
  padding-left: 52px;
  padding-right: 52px;
}

.support-modal .report-head {
  padding-left: 52px;
  padding-right: 52px;
}

.support-copy,
.support-contact,
.wallet-list,
.wallet-row,
.wallet-label,
.wallet-address {
  text-align: left;
}

.support-copy p {
  margin: 0 0 12px;
}

.support-brand {
  color: var(--text);
  font-size: 19px;
  font-weight: 750;
}

.support-contact {
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #111218;
}

.support-contact a {
  color: var(--blue);
  overflow-wrap: anywhere;
}

.wallet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.wallet-row {
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #111218;
}

.wallet-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.wallet-address {
  min-width: 0;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.copy-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.support-thanks {
  margin-top: 18px;
  color: var(--text);
  font-weight: 700;
  text-align: center;
}

.help-modal { width: min(860px, 100%); }
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; padding: 22px 26px 26px; }
.help-grid section { padding: 14px 0 16px; border-bottom: 1px solid var(--line-soft); }
.help-grid h3 { margin: 0 0 7px; color: var(--text); font-size: 16px; }
.help-grid p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.help-transfer { color: var(--blue); }

.session-share-modal { width: min(980px, calc(100vw - 28px)); }
.session-share-body { display: grid; grid-template-columns: minmax(360px, 1fr) 280px; gap: 24px; align-items: start; }
.session-share-preview { display: grid; place-items: center; min-width: 0; padding: 18px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: #16181e; }
.session-share-preview canvas { display: block; width: min(100%, 490px); height: auto; aspect-ratio: 1; border-radius: 7px; box-shadow: 0 18px 44px rgba(0, 0, 0, .26); }
.session-share-controls { display: flex; flex-direction: column; gap: 14px; }
.session-share-controls p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.share-signature-field { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.share-signature-field input { width: 100%; min-height: 42px; box-sizing: border-box; }
.share-toggle { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #111218; color: var(--text); }
.share-toggle input { width: 17px; height: 17px; margin: 0; accent-color: var(--blue); }
.month-share-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.month-share-options legend { padding: 0 5px; color: var(--muted); font-size: 12px; }
.month-share-options label { display: flex; align-items: center; gap: 8px; min-height: 30px; color: var(--text); font-size: 13px; cursor: pointer; }
.month-share-options input { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); }
.share-actions { display: grid; gap: 8px; }
.share-actions .primary, .share-actions .text-btn { width: 100%; min-height: 42px; }
.share-status { min-height: 38px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.share-status.is-success { color: var(--green); }
.share-status.is-error { color: var(--red); }

.copy-toast {
  position: fixed;
  z-index: 2200;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: var(--radius);
  background: #111b18;
  color: var(--green);
  box-shadow: var(--shadow);
  font-size: 15px;
}

.copy-toast[hidden] {
  display: none;
}

.app-footer {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 24px;
  color: var(--soft);
  font-size: 14px;
  text-align: center;
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.report-stat,
.report-month {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #111218;
  padding: 12px;
}

.report-stat span,
.report-month span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.report-stat strong,
.report-month strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, auto));
  grid-auto-flow: column;
  gap: 10px;
}

.report-month {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.report-month strong {
  text-align: right;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand {
    flex: 0 0 auto;
  }

  .month-controls {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
  }
}

@media (max-width: 720px) {
  .app {
    width: min(100% - 20px, 1240px);
    padding-top: 18px;
  }

  .topbar {
    flex-direction: column;
  }

  .month-controls {
    width: 100%;
    justify-content: space-between;
  }

  .month-title {
    min-width: 0;
    flex: 1;
  }

  #nextMonth {
    margin-right: 0;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .report-stats,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .help-grid {
    grid-template-columns: 1fr;
    padding: 16px 20px 20px;
  }

  .report-grid {
    grid-template-rows: none;
    grid-auto-flow: row;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .file-actions {
    grid-template-columns: 1fr;
  }

  .operation-actions,
  .transaction-form {
    grid-template-columns: 1fr;
  }

  .operations-toolbar {
    grid-template-columns: 1fr;
  }

  .transaction-form .field:last-child {
    grid-column: auto;
  }

  .wallet-row {
    grid-template-columns: 1fr auto;
  }

  .wallet-label {
    grid-column: 1 / -1;
  }

  .support-modal .report-body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .support-modal .report-head {
    padding-left: 20px;
    padding-right: 20px;
  }

  .weekdays,
  .days {
    gap: 5px;
  }

  .day {
    min-height: 86px;
    padding: 7px;
  }

  .day-profit {
    font-size: 16px;
  }

  .day-note {
    display: none;
  }
}

@media (max-width: 820px) {
  .session-share-body { grid-template-columns: 1fr; }
  .session-share-preview canvas { width: min(100%, 360px); }
}
.layout-source-mode { grid-template-columns: minmax(0, 1fr); }
.dashboard-overview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 360px); gap: 16px; align-items: stretch; margin-bottom: 16px; }
.top-action-panels { display: flex; flex-direction: column; gap: 16px; margin: 0; min-width: 0; align-self: start; }
.file-panel-wide { margin: 0; padding: 16px; display: grid; grid-template-columns: 1fr; gap: 12px; align-items: center; }
.file-panel-wide .section-head { margin: 0; }
.file-panel-wide .file-status, .file-panel-wide .file-hint, .file-panel-wide .export-json-link { grid-column: auto; }
.file-panel-wide .file-actions { grid-template-columns: 1fr; }
.average-buyin-panel { position: relative; padding: 16px; min-height: 108px; }
.average-buyin-panel:hover, .average-buyin-panel:focus-within { z-index: 200; }
.average-buyin-value { font-size: 30px; font-weight: 720; line-height: 1; }
.operation-history-modal { width: min(760px, calc(100vw - 28px)); }
.allocation-modal { width: min(760px, calc(100vw - 28px)); }
.allocation-total, .allocation-remaining { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: #111218; }
.allocation-total { margin-bottom: 16px; }
.allocation-total span, .allocation-remaining span { color: var(--muted); }
.allocation-total strong, .allocation-remaining strong { font-size: 20px; }
.allocation-date { max-width: 240px; }
.allocation-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.allocation-existing { min-width: 76px; color: var(--muted); font-size: 12px; text-align: right; }
.allocation-remaining { margin: 16px 0; }
.operation-history-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.operation-history-summary > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: #111218; }
.operation-history-summary span { color: var(--muted); font-size: 14px; }
.operation-history-summary strong { font-size: 18px; }
.operation-history-filters { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)) auto; gap: 10px; align-items: end; margin-bottom: 10px; padding: 14px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: #111218; }
.operation-history-filters .field { margin: 0; }
.operation-history-count { margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.operation-history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; min-height: 44px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.operation-history-row div { display: flex; flex-direction: row; align-items: center; gap: 10px; min-width: 0; }
.operation-history-row div strong { flex: 0 0 auto; white-space: nowrap; }
.operation-history-row span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.operation-history-row > strong { font-size: 14px; white-space: nowrap; }
.operation-history-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 42px; margin-top: 10px; }
.operation-history-pagination[hidden] { display: none; }
.operation-history-pagination span { min-width: 130px; color: var(--muted); font-size: 13px; text-align: center; }
.operation-history-pagination .icon-btn:disabled { cursor: default; opacity: .35; transform: none; }
#dayEditorOverlay { padding: 10px; }
.day-editor-modal { width: min(1240px, calc(100vw - 48px)); max-height: calc(100vh - 20px); }
.day-editor-modal .report-head { position: sticky; z-index: 5; top: 0; padding: 20px 30px; background: rgba(21, 22, 28, .97); backdrop-filter: blur(14px); }
.day-editor-head { align-items: center; }
.day-editor-head .report-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; font-size: 26px; }
.day-header-date { color: var(--text); font-size: 22px; font-weight: 680; }
.day-head-actions { display: flex; align-items: center; gap: 10px; }
.day-header-save { min-height: 40px; padding: 0 20px; }
#dayEditorHost { padding: 22px 30px 24px; }
.editor-modal-content { padding: 0; background: transparent; border: 0; box-shadow: none; }
.editor-modal-content > .section-head { display: none; }
.day-editor-grid { display: grid; grid-template-columns: minmax(320px, 350px) minmax(300px, 360px) minmax(340px, 1fr); gap: 16px; align-items: start; }
.day-left-column, .day-middle-column, .day-note-column { min-width: 0; }
.day-middle-column, .day-note-column { padding-top: 12px; }
.day-middle-column { display: grid; gap: 10px; align-content: start; }
.day-middle-column .row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; width: 100%; }
.day-middle-column .field { gap: 4px; margin-bottom: 4px; }
.day-middle-column .row label { display: flex; align-items: flex-end; min-height: 34px; line-height: 1.2; font-size: 13px; white-space: normal; overflow-wrap: anywhere; }
.day-middle-column input[readonly] { cursor: default; color: var(--muted); background: #0d0e12; }
.day-note-column textarea { min-height: 246px; }
.day-status-panel, .day-source-section, .day-operation-section { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #13141a; }
.day-status-panel { width: 100%; max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; justify-content: flex-start; }
.day-status-panel .segmented { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; margin-top: 4px; }
.day-status-panel .segment { min-height: 36px; padding: 0 10px; }
.day-source-section { margin: 0; }
.day-operation-section { margin: 16px 0 12px; padding: 14px 16px; }
.editor-modal-content #sessionFields { margin-top: 0; }
.day-operation-head { align-items: center; gap: 14px; }
.day-operation-tabs { grid-template-columns: repeat(3, minmax(90px, 1fr)); width: min(390px, 100%); padding: 0; border: 0; background: transparent; }
.day-operation-tabs .segment { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: #191b22; color: var(--muted); font-weight: 400; }
.day-operation-tabs .segment span { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-right: 4px; font-size: 16px; line-height: 18px; }
.day-operation-tabs .segment:hover { border-color: rgba(255, 255, 255, .25); background: #242732; }
.day-operation-tabs [data-add-day-operation="deposit"] span { color: var(--green); }
.day-operation-tabs [data-add-day-operation="cashout"] span { color: var(--red); }
.day-operation-tabs [data-add-day-operation="transfer"] span { color: var(--blue); }
.source-balance-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(140px, 220px); align-items: center; gap: 14px; margin-top: 10px; }
.source-balance-row input { text-align: right; }
.legacy-balance-row { opacity: .72; }
.legacy-balance-row input[readonly] { cursor: not-allowed; border-style: dashed; color: var(--muted); background: #0d0e12; }
.day-operation-row { display: grid; grid-template-columns: 130px minmax(220px, 1fr) minmax(120px, 170px) 34px; gap: 8px; align-items: center; margin-top: 7px; }
.day-operation-row.is-invalid [data-operation-amount], .source-balance-row input.is-invalid { border-color: var(--red); box-shadow: 0 0 0 1px rgba(255, 93, 108, .2); }
.operation-type-label { display: flex; align-items: center; min-height: 43px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius); background: #101116; color: var(--text); font-weight: 650; }
.operation-type-label[data-type="deposit"] { color: var(--green); }
.operation-type-label[data-type="cashout"] { color: var(--red); }
.operation-type-label[data-type="transfer"] { color: var(--blue); }
.operation-source-fields { display: flex; align-items: center; gap: 8px; }
.operation-source-fields select { flex: 1; min-width: 0; }
.sources-modal { width: min(820px, calc(100vw - 28px)); }
.source-create-form { display: grid; grid-template-columns: 1fr 180px auto; gap: 12px; align-items: end; margin-bottom: 22px; }
.source-create-form .field { margin-bottom: 0; }
.source-manager-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 16px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line-soft); }
.source-manager-row div { display: flex; flex-direction: column; gap: 4px; }
.source-manager-row .source-manager-tools { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.source-manager-tools .text-btn { min-height: 34px; padding: 0 10px; font-size: 12px; }
.source-manager-row span { color: var(--muted); font-size: 13px; }
.source-manager-row.is-archived { opacity: .62; }
@media (max-width: 1000px) { .dashboard-overview { grid-template-columns: 1fr; } .top-action-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .day-editor-grid { grid-template-columns: minmax(310px, .8fr) minmax(280px, 1fr); } .day-note-column { grid-column: 1 / -1; padding-top: 0; } .day-note-column textarea { min-height: 120px; } }
@media (max-width: 860px) { .day-editor-grid { grid-template-columns: 1fr; } .day-middle-column, .day-note-column { grid-column: auto; padding-top: 0; } .day-status-panel { max-width: none; } }
@media (max-width: 720px) { .file-panel-wide, .source-create-form, .day-operation-row, .allocation-row, .operation-history-filters { grid-template-columns: 1fr; } .top-action-panels { grid-template-columns: 1fr; } .day-editor-modal { width: min(100%, calc(100vw - 20px)); } .day-editor-modal .report-head { padding: 14px 18px; } .day-editor-head .report-title { gap: 5px 8px; font-size: 20px; } .day-header-date { font-size: 17px; } .day-header-save { min-height: 36px; padding: 0 12px; } #dayEditorHost { padding: 18px; } .day-middle-column .row { grid-template-columns: 1fr; } .day-middle-column .row label { min-height: 0; } .bankroll-navigation-actions, .operation-history-summary { grid-template-columns: 1fr; } .day-operation-head { align-items: stretch; flex-direction: column; } .day-operation-tabs { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); } .source-manager-row { grid-template-columns: 1fr auto; } .source-manager-row button { grid-column: 1 / -1; } .allocation-existing { text-align: left; } }
