:root {
  color-scheme: light;
  --bg-app: #f4f7f9;
  --bg-card: #ffffff;
  --bg-sidebar: #101d2a;
  --primary: #007f73;
  --primary-dark: #00675d;
  --green: #0f9d58;
  --red: #dc3545;
  --blue: #2563eb;
  --orange: #f59e0b;
  --border-soft: #dbe4ea;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #1e2933;
  --muted: #64748b;
  --line: #d8e0e7;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b42318;
  --ok: #137333;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

body.theme-night {
  color-scheme: dark;
  --bg-app: #08111c;
  --bg-card: #111c28;
  --bg-sidebar: #07111d;
  --primary: #14b8a6;
  --primary-dark: #0f766e;
  --green: #22c55e;
  --red: #f87171;
  --blue: #60a5fa;
  --orange: #fbbf24;
  --border-soft: #263445;
  --bg: #08111c;
  --surface: #111c28;
  --surface-2: #172536;
  --text: #e5edf5;
  --muted: #9fb0c3;
  --line: #263445;
  --accent: #14b8a6;
  --accent-2: #60a5fa;
  --danger: #f87171;
  --ok: #22c55e;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg-app);
}

body.auth-locked {
  display: block;
}

body.auth-locked .sidebar,
body.auth-locked .app {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--bg-app);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 26px;
}

.auth-brand {
  margin-bottom: 22px;
  color: var(--text);
}

.auth-brand .brand-mark {
  color: #fff;
}

.auth-brand p {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  color: var(--muted);
}

.auth-form button {
  min-height: 44px;
  border-radius: 10px;
  font-weight: 800;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 9px 13px;
  border-radius: 6px;
  cursor: pointer;
}

a.button-link {
  display: inline-block;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  padding: 9px 13px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.96);
}

button.secondary {
  background: var(--surface);
  color: var(--accent);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}

input[type="checkbox"] {
  width: auto;
}

.sidebar {
  min-height: 100vh;
  background: var(--bg-sidebar);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand p {
  margin: 4px 0 0;
  color: #b7c4d1;
  font-size: 13px;
}

.tabs {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
}

.nav-label {
  margin: 10px 0 0;
  padding: 9px 13px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-spacer {
  flex: 1;
  min-height: 18px;
}

.tab {
  width: 100%;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: #dbe6ef;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tab.subtab {
  padding-left: 28px;
  color: #b7c4d1;
  font-size: 14px;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: currentColor;
}

.nav-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.active {
  background: var(--primary-dark);
  border-color: var(--primary);
}

.app {
  padding: 28px;
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.view-header h2 {
  margin: 0;
  font-size: 26px;
}

.view-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar input,
.toolbar select,
.compact-select {
  width: auto;
  min-width: 120px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.panel-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-header {
  align-items: center;
}

.dashboard-toolbar {
  align-items: end;
}

.dashboard-toolbar label {
  min-width: 110px;
}

.dashboard-toolbar #open-register {
  min-height: 39px;
  margin-bottom: 0;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 39px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  min-width: auto;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-slider {
  width: 42px;
  height: 23px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  transition: background 0.18s ease;
}

.toggle-slider::before {
  content: "";
  display: block;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  transition: transform 0.18s ease;
}

.theme-toggle input:checked + .toggle-slider {
  background: var(--primary);
}

.theme-toggle input:checked + .toggle-slider::before {
  transform: translateX(19px);
}

.dashboard-layout {
  display: grid;
  gap: 18px;
}

.dashboard-top {
  display: grid;
  grid-template-columns: 1.55fr 1fr 1fr 1fr;
  gap: 18px;
}

.dashboard-total-card,
.dashboard-stat-card,
.indicator-card,
.dashboard-card {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.dashboard-total-card {
  min-height: 190px;
  padding: 28px 30px;
  background:
    linear-gradient(135deg, rgba(0, 127, 115, 0.98), rgba(0, 103, 93, 0.92));
  color: #fff;
  display: grid;
  align-content: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.dashboard-total-card::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -55px;
  width: 280px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.dashboard-total-card span,
.dashboard-stat-card span,
.indicator-card span {
  color: inherit;
  font-size: 14px;
  font-weight: 700;
}

.dashboard-total-card strong {
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

.dashboard-total-card p,
.indicator-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-total-card p {
  color: rgba(255, 255, 255, 0.86);
}

.source-mini-list {
  display: grid;
  gap: 8px;
  max-width: 360px;
}

.source-mini-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
}

.source-mini-list b {
  color: #fff;
  font-size: 13px;
}

.dashboard-stat-card {
  min-height: 190px;
  padding: 22px;
  background: var(--bg-card);
}

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

.dashboard-stat-head strong {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
}

.dashboard-stat-head svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dashboard-stat-card.income .dashboard-stat-head strong {
  color: var(--green);
  background: rgba(15, 157, 88, 0.12);
}

.dashboard-stat-card.expense .dashboard-stat-head strong {
  color: var(--red);
  background: rgba(220, 53, 69, 0.12);
}

.dashboard-stat-card.balance .dashboard-stat-head strong {
  color: var(--primary);
  background: rgba(0, 127, 115, 0.12);
}

.dashboard-stat-card b {
  display: block;
  margin-bottom: 18px;
  color: var(--primary);
  font-size: 28px;
}

.dashboard-stat-card.expense b {
  color: var(--red);
}

.dashboard-metric-list {
  display: grid;
  gap: 8px;
}

.dashboard-metric-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-metric-list strong {
  color: var(--text);
}

.dashboard-indicators {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.indicator-card {
  min-height: 130px;
  padding: 20px;
  background: var(--bg-card);
  display: grid;
  gap: 8px;
}

.circle-card {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
}

.indicator-card strong {
  font-size: 26px;
}

.circle-progress {
  --pct: 0;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--bg-card) 57%, transparent 58%),
    conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--surface-2) 0);
}

.circle-progress.blue {
  background:
    radial-gradient(circle at center, var(--bg-card) 57%, transparent 58%),
    conic-gradient(var(--blue) calc(var(--pct) * 1%), var(--surface-2) 0);
}

.circle-progress span {
  color: var(--primary);
  font-size: 20px;
  font-weight: 800;
}

.circle-progress.blue span {
  color: var(--blue);
}

.indicator-card em {
  justify-self: start;
  border-radius: 6px;
  padding: 4px 10px;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.progress-fill.blue {
  background: var(--blue);
}

.progress-fill.teal {
  background: var(--primary);
}

.dashboard-deadline-card {
  grid-column: span 2;
  min-height: 130px;
  padding: 20px;
}

.ok-badge {
  color: var(--green);
  background: rgba(15, 157, 88, 0.12);
}

.neutral-badge {
  color: var(--blue);
  background: rgba(37, 99, 235, 0.12);
}

.warn-badge {
  color: var(--orange);
  background: rgba(245, 158, 11, 0.14);
}

.danger-badge {
  color: var(--red);
  background: rgba(220, 53, 69, 0.14);
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: 1.45fr 1.1fr 1.15fr;
  gap: 18px;
}

.dashboard-bottom-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
}

.dashboard-card {
  margin-bottom: 0;
  background: var(--bg-card);
  border-radius: 16px;
}

.dashboard-chart-card {
  display: grid;
  gap: 12px;
}

.line-chart {
  min-height: 250px;
}

.line-chart svg {
  width: 100%;
  height: 250px;
}

.line-chart line {
  stroke: var(--line);
  stroke-width: 1;
}

.axis-tick line {
  stroke: var(--line);
  stroke-width: 0.7;
  opacity: 0.65;
}

.axis-tick text {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: end;
}

.line-chart polyline {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-expected {
  stroke: var(--blue);
  stroke-dasharray: 8 7;
}

.line-actual {
  stroke: var(--primary);
}

.line-area {
  fill: rgba(0, 127, 115, 0.14);
}

.line-dots circle {
  fill: var(--bg-card);
  stroke: var(--primary);
  stroke-width: 2;
}

.chart-legend {
  display: flex;
  gap: 18px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
}

.dot.blue {
  background: var(--blue);
}

.dot.teal {
  background: var(--primary);
}

.dashboard-list {
  display: grid;
  gap: 10px;
}

.alert-row,
.deadline-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.alert-row span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--orange);
  background: rgba(245, 158, 11, 0.14);
  font-weight: 900;
}

.deadline-row {
  grid-template-columns: 72px 1fr auto auto;
}

.deadline-row em {
  border-radius: 6px;
  padding: 3px 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-style: normal;
}

.top-category-list {
  display: grid;
  gap: 9px;
}

.top-category-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(90px, 1fr) auto 36px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.mini-bar {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}

.mini-bar div {
  height: 100%;
  border-radius: inherit;
  background: var(--red);
}

.link-button {
  justify-self: end;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
  padding-inline: 0;
}

.ytd-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ytd-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface);
}

.ytd-item span {
  color: var(--muted);
  font-size: 13px;
}

.ytd-item strong {
  font-size: 21px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.import-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.import-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.secondary-link {
  background: var(--surface);
  font-size: 13px;
  padding: 9px 11px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 14px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

label input,
label select {
  color: var(--text);
  font-size: 14px;
}

.span-3 {
  grid-column: span 3;
}

.span-2 {
  grid-column: span 2;
}

.form-break {
  grid-column: 1 / -1;
  height: 0;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.message {
  color: var(--muted);
  margin: 0;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--ok);
}

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

.table-header h3 {
  margin: 0;
}

.bulk-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.bulk-edit-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.bulk-actions select {
  width: auto;
  min-width: 130px;
}

.bulk-edit-tools input {
  width: auto;
  min-width: 150px;
}

#toggle-search-edit[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e8f2ff;
  color: var(--accent-2);
}

table.read-only .edit-only {
  display: none;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap:has(#search-results-table) {
  overflow-x: auto;
}

#search-results-table {
  min-width: 1320px;
}

#search-results-table:not(.read-only) {
  min-width: 1700px;
}

#search-results-table .edit-value {
  min-width: 130px;
}

#search-results-table input.edit-value[name="description"] {
  min-width: 240px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.compact-table {
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
}

th {
  background: var(--surface-2);
  color: #334155;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

.num {
  text-align: right;
}

.delete-btn {
  border-color: #e5b8b2;
  background: var(--surface);
  color: var(--danger);
  padding: 6px 8px;
}

.edit-btn {
  border-color: #bfdbfe;
  background: var(--surface);
  color: var(--accent-2);
  padding: 6px 8px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.editing-row input,
.editing-row select {
  min-width: 110px;
  padding: 6px 7px;
  font-size: 12px;
}

.editing-row input[name="description"] {
  min-width: 190px;
}

.sort-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-weight: 600;
}

.search-sort-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-weight: 600;
}

.search-sort-btn.active {
  color: var(--accent);
}

.sort-btn.active {
  color: var(--accent);
}

.movement-badge,
.category-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.movement-badge span,
.category-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
}

.movement-badge.income span {
  background: #dcfce7;
  color: var(--ok);
}

.movement-badge.expense span {
  background: #fee2e2;
  color: var(--danger);
}

.movement-badge.neutral span {
  background: #e5e7eb;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.status-prevista {
  background: #dbeafe;
  color: var(--accent-2);
}

.status-pagata {
  background: #dcfce7;
  color: var(--ok);
}

.status-annullata {
  background: #fee2e2;
  color: var(--danger);
}

.category-icon {
  background: #eef2f5;
  color: var(--accent);
  font-size: 12px;
}

.category-icon::before {
  content: "•";
}

.category-icon-home::before {
  content: "⌂";
}

.category-icon-car::before {
  content: "A";
}

.category-icon-food::before {
  content: "F";
}

.category-icon-travel::before {
  content: "↗";
}

.category-icon-shop::before {
  content: "S";
}

.category-icon-subscription::before {
  content: "▶";
}

.category-icon-money::before {
  content: "€";
}

.category-icon-transfer::before {
  content: "↔";
}

.category-icon-income::before {
  content: "+";
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 12px;
  flex-wrap: wrap;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.search-total-info {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.search-total-info strong {
  color: var(--text);
}

.budget-table input {
  width: 100%;
  min-width: 0;
  padding: 5px 4px;
  text-align: right;
  font-size: 12px;
}

.budget-table tfoot td {
  font-weight: 700;
  background: #f8fafc;
}

.budget-wrap {
  overflow-x: hidden;
}

.budget-table {
  table-layout: fixed;
  min-width: 0;
}

.budget-table th,
.budget-table td {
  padding: 6px 4px;
  font-size: 12px;
}

.budget-table th:first-child,
.budget-table td:first-child {
  width: 150px;
  white-space: normal;
}

.budget-table th:not(:first-child),
.budget-table td:not(:first-child) {
  width: calc((100% - 150px) / 13);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  display: block;
  font-size: 30px;
}

.kpi-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.fuel-gauge {
  position: relative;
  flex: 0 0 auto;
  width: 108px;
  height: 72px;
}

.fuel-arc {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 54px;
  border-radius: 108px 108px 0 0;
  background: #d8e0e7;
  overflow: hidden;
}

.fuel-arc::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 0;
  height: 43px;
  border-radius: 86px 86px 0 0;
  background: var(--surface);
}

.fuel-needle {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 43px;
  height: 3px;
  border-radius: 999px;
  background: var(--text);
  transform-origin: 0 50%;
  transform: rotate(calc(-180deg + (var(--pct) * 180deg)));
}

.fuel-needle::after {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text);
}

.fuel-expected {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 47px;
  height: 2px;
  transform-origin: 0 50%;
  transform: rotate(calc(-180deg + (var(--expected) * 180deg)));
}

.fuel-expected::after {
  content: "";
  position: absolute;
  right: -3px;
  top: -5px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 7px solid var(--accent-2);
}

.fuel-percent {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.fuel-scale {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.fuel-scale span {
  display: inline;
  color: inherit;
  font-size: inherit;
}

.danger-action {
  border-color: var(--danger);
  color: var(--danger);
}

.budget-comparison-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.mini-budget-table {
  min-width: 0;
  table-layout: fixed;
}

.mini-budget-table th,
.mini-budget-table td {
  text-align: center;
}

.mini-budget-table th:first-child,
.mini-budget-table td:first-child {
  text-align: left;
}

.mini-budget-table thead tr:first-child th {
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 15px;
}

.mini-budget-table .total-row td {
  font-weight: 700;
  background: #f8fafc;
}

.analysis-matrix {
  min-width: 1120px;
  table-layout: fixed;
}

.analysis-matrix th:first-child {
  width: 220px;
}

.analysis-matrix th,
.analysis-matrix td {
  font-size: 12px;
  white-space: nowrap;
}

.analysis-matrix tbody th {
  background: #f8fafc;
  font-weight: 600;
}

.analysis-matrix tfoot th,
.analysis-matrix tfoot td,
.analysis-matrix .total-cell {
  background: #eef2f5;
  font-weight: 700;
}

.budget-analysis-matrix {
  min-width: 3300px;
}

.budget-analysis-matrix thead tr:first-child > th:first-child {
  width: 45px;
  position: sticky;
  left: 0;
  z-index: 4;
}

.budget-analysis-matrix tbody th,
.budget-analysis-matrix tfoot th {
  width: 45px;
  max-width: 45px;
  position: sticky;
  left: 0;
  z-index: 3;
  background: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
}

.budget-analysis-matrix th,
.budget-analysis-matrix td {
  width: 78px;
  padding: 6px 5px;
  text-align: right;
  font-size: 11px;
}

.budget-analysis-matrix .month-group {
  text-align: center;
  background: #e8f4f2;
  color: var(--primary-dark);
  border-left: 2px solid var(--line);
}

.budget-analysis-matrix .subcol {
  font-size: 10px;
  white-space: normal;
  line-height: 1.15;
}

.budget-analysis-matrix .planned-col {
  background: rgba(37, 99, 235, 0.06);
}

.budget-analysis-matrix .actual-col {
  background: rgba(15, 157, 88, 0.06);
}

.budget-analysis-matrix .variance-col {
  background: rgba(245, 158, 11, 0.07);
  border-right: 2px solid var(--line);
}

.budget-analysis-matrix .total-cell {
  background: #eef2f5;
}

body.theme-night .budget-analysis-matrix .month-group {
  background: rgba(20, 184, 166, 0.14);
}

body.theme-night .budget-analysis-matrix .planned-col {
  background: rgba(96, 165, 250, 0.1);
}

body.theme-night .budget-analysis-matrix .actual-col {
  background: rgba(34, 197, 94, 0.1);
}

body.theme-night .budget-analysis-matrix .variance-col {
  background: rgba(251, 191, 36, 0.1);
}

.bar-chart {
  min-height: 260px;
  display: grid;
  grid-template-columns: repeat(12, minmax(42px, 1fr));
  gap: 7px;
  align-items: end;
}

.bar-column {
  min-width: 0;
  display: grid;
  gap: 6px;
  justify-items: center;
  align-items: end;
}

.bar-value {
  min-height: 28px;
  width: 100%;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.paired-value {
  display: grid;
  gap: 2px;
}

.bar-track {
  width: 18px;
  height: 150px;
  display: flex;
  align-items: end;
  justify-content: center;
  border-radius: 999px;
  background: #eef2f5;
  overflow: hidden;
}

.bar-track.paired {
  width: 34px;
  flex-direction: row;
  gap: 3px;
  padding: 0 4px;
}

.bar-fill {
  width: 100%;
  border-radius: 999px 999px 0 0;
  background: var(--accent);
}

.bar-fill.planned {
  width: 10px;
  background: #94a3b8;
}

.bar-fill.actual {
  width: 10px;
  background: var(--accent);
}

.bar-label {
  color: var(--muted);
  font-size: 12px;
}

.grouped-chart {
  min-height: 360px;
}

.budget-chart-panel {
  margin-top: 18px;
}

.rank-chart {
  display: grid;
  gap: 12px;
}

.rank-row {
  display: grid;
  gap: 5px;
}

.rank-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rank-head > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-track {
  height: 9px;
  border-radius: 999px;
  background: #eef2f5;
  overflow: hidden;
}

.rank-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.rank-fill.negative-bar {
  background: var(--danger);
}

.empty-chart {
  color: var(--muted);
  padding: 14px 0;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.mini-row:last-child {
  border-bottom: 0;
}

.line-chart-wrap {
  display: grid;
  gap: 10px;
}

.line-chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-axis {
  stroke: #cbd5e1;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.income-line {
  stroke: var(--ok);
}

.expense-line {
  stroke: var(--danger);
}

.balance-line {
  stroke: var(--accent-2);
}

.chart-point {
  fill: var(--surface);
  stroke-width: 3;
}

.chart-point.income-line {
  stroke: var(--ok);
}

.chart-point.expense-line {
  stroke: var(--danger);
}

.chart-point.balance-line {
  stroke: var(--accent-2);
}

.chart-value,
.chart-months text {
  fill: var(--muted);
  font-size: 12px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  display: inline-block;
}

.legend-income {
  background: var(--ok);
}

.legend-expense {
  background: var(--danger);
}

.legend-balance {
  background: var(--accent-2);
}

.source-balance-chart {
  display: grid;
  gap: 12px;
}

.source-balance-row {
  display: grid;
  gap: 5px;
}

.source-balance-head,
.source-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.source-balance-head span,
.source-total span {
  color: var(--muted);
}

.source-balance-track {
  height: 9px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.source-balance-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--ok);
}

.source-balance-bar.negative-bar {
  background: var(--danger);
}

.source-total {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

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

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

.balance-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 150px;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  justify-content: start;
}

.balance-row input {
  max-width: 150px;
}

.inline-add-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-add-row input {
  max-width: 280px;
}

.category-settings {
  display: grid;
  gap: 22px;
}

.category-edit-section h4 {
  margin: 0 0 10px;
}

.category-matrix-wrap {
  max-height: 520px;
  overflow-x: hidden;
}

.category-matrix {
  table-layout: fixed;
  min-width: 0;
  width: 100%;
}

.category-matrix th,
.category-matrix td {
  min-width: 0;
  padding: 3px;
  text-align: center;
}

.category-matrix th {
  background: #ea6a2a;
}

.category-edit-section:nth-child(2) .category-matrix th {
  background: #0f7a3a;
}

.category-matrix input {
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 5px 4px;
  text-align: center;
  background: transparent;
  font-size: 12px;
}

.category-matrix th input {
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}

.category-matrix td input {
  background: #fff7ed;
}

.category-edit-section:nth-child(2) .category-matrix td input {
  background: #ecfdf3;
}

.page-title-with-icon {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(20, 184, 166, 0.16);
  color: var(--primary);
}

.page-title-icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.transaction-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.transaction-step {
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.transaction-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: stretch;
}

.transaction-main-column {
  min-width: 0;
}

.transaction-type-panel {
  padding-block: 14px;
}

.transaction-actions-panel {
  position: sticky;
  top: 20px;
  border-radius: 16px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
}

.action-status {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
}

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

.step-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.step-heading.compact {
  margin-bottom: 0;
}

.step-heading h3 {
  margin: 0;
}

.step-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

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

.movement-type-card {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-color: var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
}

.movement-type-card.active.expense {
  border-color: var(--red);
  background: rgba(220, 53, 69, 0.08);
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.08);
}

.movement-type-card.active.income {
  border-color: var(--green);
  background: rgba(15, 157, 88, 0.08);
  box-shadow: 0 0 0 2px rgba(15, 157, 88, 0.08);
}

.movement-type-card.active.transfer {
  border-color: var(--blue);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

.type-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--primary);
}

.movement-type-card.income .type-icon {
  color: var(--green);
  background: rgba(15, 157, 88, 0.14);
}

.movement-type-card.expense .type-icon {
  color: var(--red);
  background: rgba(220, 53, 69, 0.14);
}

.movement-type-card.transfer .type-icon {
  color: var(--blue);
  background: rgba(37, 99, 235, 0.14);
}

.type-icon svg,
.field-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.transaction-form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

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

.tx-field {
  gap: 6px;
  grid-column: span 4;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
}

.tx-field.wide {
  grid-column: span 3;
}

.amount-field {
  grid-column: span 4;
}

.description-field {
  grid-column: span 8;
}

.field-shell {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 0 10px;
}

.field-shell input,
.field-shell select {
  border: 0;
  background: transparent;
  padding-inline: 0;
  min-width: 0;
  min-height: 38px;
}

.field-shell input:focus,
.field-shell select:focus {
  outline: none;
}

.field-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--accent-2);
}

.field-icon.danger {
  color: var(--red);
}

.field-prefix {
  color: var(--text);
  font-weight: 800;
}

.transaction-message {
  margin-top: 12px;
}

.transaction-action-bar {
  display: grid;
  grid-template-columns: minmax(190px, auto) minmax(150px, auto) minmax(120px, auto) minmax(280px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
}

.transaction-actions-panel .transaction-action-bar {
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 12px;
}

.transaction-action-bar > button {
  min-height: 44px;
  border-radius: 10px;
  font-weight: 800;
}

.transaction-actions-panel #transaction-submit {
  min-height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary-dark);
}

.transaction-save-panel {
  margin-bottom: 18px;
}

.transaction-save-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.transaction-save-actions button {
  min-height: 44px;
  border-radius: 10px;
  font-weight: 800;
}

.transaction-save-actions #transaction-submit {
  min-width: 190px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary-dark);
}

.transaction-import-panel .step-heading {
  margin-bottom: 10px;
}

.transaction-import-inline {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.transaction-actions-panel .transaction-import-inline {
  grid-template-columns: 1fr;
  margin-top: 2px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.transaction-import-inline input {
  min-height: 42px;
}

.transaction-import-inline button,
.transaction-import-inline a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-filter-panel .search-grid,
.matrix-panel {
  margin-top: 0;
}

.search-filter-panel label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

@media (max-width: 1300px) and (min-width: 1001px) {
  .dashboard-top,
  .dashboard-indicators {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-main-grid,
  .dashboard-bottom-grid {
    grid-template-columns: 1fr;
  }

  .transaction-workspace {
    grid-template-columns: 1fr;
  }

  .transaction-actions-panel {
    position: static;
  }

  .transaction-actions-panel .transaction-action-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .transaction-actions-panel .transaction-import-inline {
    grid-column: span 2;
    grid-template-columns: minmax(180px, 1fr) auto auto;
  }
}

@media (max-width: 1000px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .nav-label,
  .nav-spacer {
    display: none;
  }

  .form-grid,
  .search-grid,
  .analysis-grid,
  .import-row,
  .two-col,
  .kpi-grid,
  .budget-comparison-grid,
  .dashboard-top,
  .dashboard-indicators,
  .dashboard-main-grid,
  .dashboard-bottom-grid,
  .ytd-grid,
  .transaction-workspace,
  .movement-type-grid,
  .transaction-form-grid,
  .transaction-action-bar,
  .transaction-import-inline {
    grid-template-columns: 1fr;
  }

  .transaction-actions-panel {
    position: static;
  }

  .tx-field,
  .tx-field.wide,
  .amount-field,
  .description-field {
    grid-column: span 1;
  }

  .dashboard-toolbar {
    justify-content: flex-start;
  }

  .dashboard-toolbar label,
  .dashboard-toolbar button {
    width: 100%;
  }

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

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

  .span-3 {
    grid-column: span 1;
  }

  .span-2 {
    grid-column: span 1;
  }

  .view-header {
    flex-direction: column;
  }

  .bar-chart {
    overflow-x: auto;
    grid-template-columns: repeat(12, 58px);
  }
}
