:root {
  color-scheme: light dark;
  --sidebar-width: 240px;
  --font-sans: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-family: var(--font-sans);
  font-size: 14px;

  /* LIGHT THEME - Muted, soft palette */
  --bg: #fafbfc;
  --bg-gradient: none;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-soft: #f7f8f9;
  --surface-muted: #f2f3f5;

  --text: #5a6370;
  --text-strong: #3a4150;
  --muted: #8b95a5;
  --muted-strong: #6b7685;

  --line: #eef0f3;
  --line-strong: #e2e5ea;

  --primary: #3da58a;
  --primary-dark: #358f78;
  --primary-soft: #eef7f4;
  --income: #5cb89c;
  --expense: #d4865e;
  --warning: #c9a34e;
  --danger: #cd6060;
  --blue: #6b8cc9;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.06);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --transition-fast: 0.12s ease;
  --transition-normal: 0.2s ease;

  --scrollbar-track: transparent;
  --scrollbar-thumb: #dde0e4;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-gradient: none;
  --surface: #181b22;
  --surface-solid: #181b22;
  --surface-soft: #1e2129;
  --surface-muted: #22252e;

  --text: #9ca3af;
  --text-strong: #c8cdd5;
  --muted: #6b7280;
  --muted-strong: #9ca3af;

  --line: #262930;
  --line-strong: #32363f;

  --primary: #5cb89c;
  --primary-dark: #4ea68c;
  --primary-soft: rgba(92, 184, 156, 0.08);
  --income: #6bc4a8;
  --expense: #dba07a;
  --warning: #d4b164;
  --danger: #d47474;
  --blue: #7d9fd6;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.3);

  --scrollbar-track: transparent;
  --scrollbar-thumb: #32363f;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  transition: background var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

h1, h2, h3, p {
  margin: 0;
}

/* Buttons */
button {
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 450;
  line-height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

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

button:hover:not(:disabled) {
  opacity: 0.85;
}

button:active:not(:disabled) {
  opacity: 0.75;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 1.5px solid var(--primary);
  outline-offset: 1px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  color: var(--text-strong);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 400;
  transition: border-color var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(61, 165, 138, 0.08);
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 450;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  font-weight: 450;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-dark);
  opacity: 1;
}

.secondary-button {
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-weight: 400;
}

.secondary-button:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--muted);
  opacity: 1;
}

.danger-button {
  background: rgba(205, 96, 96, 0.06);
  border: 1px solid rgba(205, 96, 96, 0.15);
  color: var(--danger);
  font-weight: 400;
}

.danger-button:hover:not(:disabled) {
  background: rgba(205, 96, 96, 0.1);
  opacity: 1;
}

.icon-button {
  width: 30px;
  padding: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  min-height: 30px;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text-strong);
  opacity: 1;
}

.round-icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface-solid);
  color: var(--muted);
}

.round-icon-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--text);
  opacity: 1;
}

/* Theme Toggle */
#themeToggleButton .sun-icon {
  display: none;
}
#themeToggleButton .moon-icon {
  display: block;
}
[data-theme="dark"] #themeToggleButton .sun-icon {
  display: block;
}
[data-theme="dark"] #themeToggleButton .moon-icon {
  display: none;
}

.bell-icon {
  display: none;
}

.bell-icon::before {
  display: none;
}

.bell-icon::after {
  display: none;
}

/* Login */
.login-view {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 16px;
}

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

.brand-icon-large {
  width: 36px;
  height: 36px;
}

.login-brand h1 {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-strong);
}

.login-brand p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.login-error {
  color: var(--danger);
  font-size: 12px;
  font-weight: 400;
  min-height: 16px;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 56px;
  margin-left: var(--sidebar-width);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 251, 252, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--transition-normal);
}

[data-theme="dark"] .app-header {
  background: rgba(15, 17, 23, 0.85);
}



.menu-button {
  display: none;
}

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

.user-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface-solid);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 400;
}

.user-avatar {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 450;
}

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 30;
  transition: background var(--transition-normal), border-color var(--transition-normal);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px;
  cursor: default;
}

.brand-icon {
  width: 28px;
  height: 28px;
  transition: transform var(--transition-normal);
}

.sidebar-brand:hover .brand-icon {
  transform: rotate(5deg) scale(1.02);
}

.sidebar-brand strong {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-strong);
}

.sidebar-brand span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 1px;
}

.sidebar-brand div {
  display: flex;
  flex-direction: column;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-button {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-strong);
  font-weight: 400;
  font-size: 13px;
  position: relative;
}

.nav-button:hover {
  background: var(--surface-soft);
  color: var(--text-strong);
  opacity: 1;
}

.nav-button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-button.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-icon {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  flex: 0 0 auto;
  transition: all var(--transition-fast);
  color: var(--muted);
}

.nav-button:hover .nav-icon {
  color: var(--muted-strong);
}

.nav-button.active .nav-icon {
  background: var(--primary);
  color: #fff;
}

.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.nav-icon-bills::before {
  width: 10px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}

.nav-icon-bills::after {
  width: 5px;
  height: 1.5px;
  background: currentColor;
  box-shadow: 0 3px 0 currentColor;
}

.nav-icon-report::before {
  width: 12px;
  height: 12px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translate(-60%, -40%);
}

.nav-icon-report::after {
  width: 10px;
  height: 7px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: translate(-30%, -60%) rotate(-35deg);
}

.nav-icon-subscription::before {
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.nav-icon-subscription::after {
  width: 5px;
  height: 5px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: translate(-40%, -50%) rotate(45deg);
}

.nav-icon-settings::before {
  width: 11px;
  height: 11px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.nav-icon-settings::after {
  width: 2px;
  height: 15px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

/* Sidebar Insight Card - hidden by default, removed per user request */
.sidebar-insight-card {
  display: none !important;
}

.insight-title,
.insight-text,
.insight-value,
.insight-progress-bar,
.insight-progress-fill {
  display: none;
}

/* App Main */
.app-shell {
  margin-left: var(--sidebar-width);
  padding: 20px 28px 36px;
  transition: margin var(--transition-normal);
}

.page-host {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.app-page {
  display: grid;
  gap: 18px;
  min-width: 0;
}

/* Summary Cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.summary-item,
.content-band,
.chart-card,
.filter-card,
.empty-inline,
.manage-item,
.pill {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  transition: border-color var(--transition-fast);
}

.summary-item,
.chart-card,
.filter-card,
.content-band {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-fast);
}

.summary-item:hover,
.chart-card:hover,
.filter-card:hover,
.content-band:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.summary-item {
  min-height: 84px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}

.summary-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.summary-content span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.summary-content strong {
  display: block;
  color: var(--text-strong);
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
}

.summary-content small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
}

.compare-good {
  color: var(--income);
}

.compare-bad {
  color: var(--danger);
}

.compare-neutral {
  color: var(--muted);
}

.summary-icon {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex: 0 0 auto;
}

.summary-income .summary-icon {
  background: rgba(92, 184, 156, 0.08);
  color: var(--income);
}

.summary-expense .summary-icon {
  background: rgba(107, 140, 201, 0.08);
  color: var(--blue);
}

.summary-balance .summary-icon {
  background: rgba(92, 184, 156, 0.08);
  color: var(--income);
}

.summary-subscription .summary-icon {
  background: rgba(107, 140, 201, 0.08);
  color: var(--blue);
}

.summary-icon::before,
.summary-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
}

.summary-income .summary-icon::before {
  width: 16px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  transform: translate(-50%, -50%);
}

.summary-income .summary-icon::after {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(2px, -2px);
}

.summary-expense .summary-icon::before {
  width: 1.5px;
  height: 14px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.summary-expense .summary-icon::after {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translate(-50%, -10%) rotate(45deg);
}

.summary-balance .summary-icon::before {
  width: 12px;
  height: 12px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translate(-50%, -50%);
}

.summary-balance .summary-icon::after {
  width: 1.5px;
  height: 10px;
  background: currentColor;
  transform: translate(0px, -5px);
  box-shadow: -3px 3px 0 currentColor, 3px 1.5px 0 currentColor;
}

.summary-subscription .summary-icon::before {
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.summary-subscription .summary-icon::after {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 6px solid currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

/* Middle Grid */
.middle-grid {
  display: grid;
  grid-template-columns: 5.5fr 4.5fr;
  gap: 14px;
}

.chart-card {
  min-width: 0;
  padding: 20px 22px 18px;
  position: relative;
}

.filter-card {
  min-width: 0;
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: auto;
}

.filter-actions button {
  flex: 1;
  max-width: 120px;
}

/* Horizontal filter bar */
.filter-bar {
  padding: 14px 22px;
}

.filter-bar-inner {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.filter-bar-inner label {
  flex: 1;
  min-width: 120px;
}

.filter-bar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.card-header,
.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.card-header {
  margin-bottom: 14px;
}

.card-header h2,
.section-header h2 {
  color: var(--text-strong);
  font-size: 16px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card-header p,
.section-header p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.chart-period {
  display: none;
}

.expense-chart {
  min-height: 360px;
  position: relative;
}

/* Table Card */
.content-band {
  min-width: 0;
  padding: 24px 26px;
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.content-band:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.table-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.table-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.report-band {
  margin-bottom: 18px;
}

.section-header {
  margin-bottom: 14px;
}

.section-header.compact {
  align-items: center;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: transparent;
}

th, td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 450;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

tbody tr {
  transition: background-color var(--transition-fast);
}

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

tbody tr:hover td {
  background: var(--primary-soft);
}

[data-theme="dark"] tbody tr:hover td {
  background: var(--surface-muted);
}

.amount-income {
  color: var(--income);
  font-weight: 450;
}

.amount-expense {
  color: var(--expense);
  font-weight: 450;
}

/* Table Cells */
.table-datetime {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.3;
}

.table-datetime .date-time {
  color: var(--text-strong);
  font-weight: 400;
}

.table-datetime .weekday {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.cell-category,
.cell-account {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 400;
  color: var(--text-strong);
}

.category-icon {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.account-icon {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-muted);
  color: var(--muted);
  flex-shrink: 0;
}

.category-icon-svg,
.account-icon-svg {
  stroke-width: 2px;
}

.row-actions-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.action-btn-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0;
  min-height: auto;
  transition: all var(--transition-fast);
}

.action-btn-icon:hover {
  background: var(--surface-muted);
  color: var(--text-strong);
  border-color: var(--line);
  opacity: 1;
}

.action-btn-icon.delete-btn {
  color: var(--muted);
}

.action-btn-icon.delete-btn:hover {
  background: rgba(205, 96, 96, 0.06);
  border-color: rgba(205, 96, 96, 0.12);
  color: var(--danger);
  opacity: 1;
}

/* Tags */
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: var(--radius-full);
  padding: 2px 8px;
  background: var(--surface-muted);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}

.tag-confirmed {
  background: rgba(92, 184, 156, 0.08);
  color: var(--income);
}

.tag-rejected,
.tag-ignored {
  background: var(--surface-muted);
  color: var(--muted);
}

.tag-fixed_expense {
  background: rgba(107, 140, 201, 0.08);
  color: var(--blue);
}

.tag-candidate,
.tag-duplicate {
  background: rgba(201, 163, 78, 0.08);
  color: var(--warning);
}

/* Subscription status tags - soft red/green */
.tag-active {
  background: rgba(92, 184, 156, 0.1);
  color: #5aab8e;
}

.tag-inactive {
  background: rgba(195, 110, 110, 0.08);
  color: #c07070;
}

.tag-deleted {
  background: var(--surface-muted);
  color: var(--muted);
  text-decoration: line-through;
}

.actions-cell {
  width: 110px;
}

.empty-state,
.empty-inline {
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: var(--radius-md);
}

.empty-state {
  padding: 32px;
  text-align: center;
  font-weight: 400;
  font-size: 13px;
  border: 1px dashed var(--line-strong);
}

.empty-inline {
  min-height: 44px;
  display: grid;
  place-items: center start;
  padding: 10px 14px;
  font-size: 12px;
}

/* Tabs */
.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 14px;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.tab-button {
  min-height: 30px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
  font-weight: 400;
  font-size: 12px;
}

.tab-button:hover {
  background: rgba(255, 255, 255, 0.4);
  color: var(--text-strong);
  opacity: 1;
}

[data-theme="dark"] .tab-button:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tab-button.active {
  background: var(--surface-solid);
  color: var(--primary);
  box-shadow: var(--shadow);
}

.tab-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

/* Report */
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.report-grid > div {
  min-width: 0;
}

.report-grid h3,
.content-band h3,
.trend-section h3,
.budget-manager h3,
.llm-report-panel h3 {
  margin: 0 0 10px;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.rank-list,
.alert-list,
.trend-list {
  display: grid;
  gap: 6px;
}

.rank-item,
.trend-item,
.budget-status-item {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  transition: background-color var(--transition-fast);
}

.rank-item:last-child,
.trend-item:last-child,
.budget-status-item:last-child {
  border-bottom: none;
}

.rank-item:hover,
.trend-item:hover,
.budget-status-item:hover {
  background: var(--surface-soft);
}

.rank-item strong,
.alert-item strong,
.trend-item strong,
.budget-status-item strong {
  display: block;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 450;
  overflow-wrap: anywhere;
}

.rank-item span,
.alert-item span,
.trend-item span,
.budget-status-item span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.rank-item b,
.budget-status-item b {
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

/* Trend Badges */
.trend-change {
  display: flex;
  align-items: center;
  gap: 6px;
}

.trend-change b {
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.trend-item .trend-change span {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-muted);
  color: var(--text-strong);
}

.trend-item .trend-change span.trend-positive {
  background: rgba(92, 184, 156, 0.15); /* income / positive */
  color: var(--income);
}

.trend-item .trend-change span.trend-negative {
  background: rgba(212, 134, 94, 0.15); /* expense / negative */
  color: var(--expense);
}

.budget-status-item {
  border-left: 4px solid var(--line-strong);
}

.budget-over {
  border-left-color: var(--danger);
  background: rgba(205, 96, 96, 0.04);
}

.budget-over:hover {
  background: rgba(205, 96, 96, 0.08);
}

.alert-item {
  min-height: 44px;
  display: grid;
  gap: 3px;
  padding: 12px 14px 12px 34px;
  border-radius: var(--radius-md);
  border-bottom: none;
  position: relative;
  transition: transform var(--transition-fast);
}

.alert-item:hover {
  transform: translateX(2px);
}

.alert-item::before {
  content: "⚠️";
  position: absolute;
  left: 10px;
  top: 12px;
  font-size: 14px;
}

.alert-high {
  background: rgba(205, 96, 96, 0.08);
  border-left: 3px solid var(--danger);
}

.alert-medium {
  background: rgba(201, 163, 78, 0.08);
  border-left: 3px solid var(--warning);
}

.trend-section,
.budget-manager,
.llm-report-panel {
  margin-top: 14px;
}

.budget-list,
.pill-list,
.manage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.pill,
.manage-item {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
}

.marker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.duplicate-check {
  border: 1px solid rgba(201, 163, 78, 0.2);
  border-radius: var(--radius-md);
  background: rgba(201, 163, 78, 0.03);
  color: var(--warning);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}

[data-theme="dark"] .duplicate-check {
  color: #d4b164;
}

.duplicate-check strong {
  display: block;
  color: var(--text-strong);
  font-weight: 500;
  margin-bottom: 3px;
}

.duplicate-check ul {
  margin: 4px 0 0;
  padding-left: 16px;
}

.muted-inline {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.trend-change {
  display: grid;
  gap: 2px;
  justify-items: end;
  text-align: right;
}

/* LLM Report */
.llm-report-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.llm-report-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #8b8ec9, #b089c9, #c98ba0);
  opacity: 0.6;
}

.markdown-content {
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.markdown-content > :first-child {
  margin-top: 0;
}

.markdown-content > :last-child {
  margin-bottom: 0;
}

.markdown-content p,
.markdown-content ul,
.markdown-content ol,
.markdown-content blockquote {
  margin: 0 0 10px;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
  margin: 12px 0 8px;
  line-height: 1.35;
  color: var(--text-strong);
  font-weight: 500;
}

.markdown-content h1 { font-size: 15px; }
.markdown-content h2 { font-size: 14px; }
.markdown-content h3 { font-size: 13px; }

.markdown-content ul,
.markdown-content ol {
  padding-left: 18px;
}

.markdown-content li + li {
  margin-top: 3px;
}

.markdown-content code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--expense);
  font-size: 12px;
  font-family: monospace;
}

.markdown-content strong {
  font-weight: 500;
  color: var(--text-strong);
}

.markdown-content em {
  font-style: italic;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.pagination-bar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.subscriptions-band,
.classification-rules-band,
.subscription-matches-band,
.recurring-band {
  margin-top: 14px;
}

.color-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex: 0 0 auto;
}

.checkbox-label {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input {
  width: auto;
  min-height: auto;
  cursor: pointer;
}

/* Report Controls */
.report-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.report-controls select,
.report-controls input {
  width: auto;
  min-width: 120px;
}

/* Dialog */
dialog {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: var(--shadow-soft);
  background: var(--surface-solid);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.97) translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

dialog[open] {
  opacity: 1;
  transform: scale(1) translateY(0);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.15s ease;
}

dialog[open]::backdrop {
  opacity: 1;
}

dialog form {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.dialog-header,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 2px;
}

.dialog-header h2 {
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 500;
}

.dialog-actions {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
  justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: min(380px, calc(100vw - 40px));
  background: var(--text-strong);
  color: var(--surface-solid);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  box-shadow: var(--shadow-soft);
  font-weight: 400;
  font-size: 13px;
  border-left: 3px solid var(--primary);
  animation: toast-fade-in 0.15s ease;
}

@keyframes toast-fade-in {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .middle-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  :root {
    --sidebar-width: 0px;
  }

  .app-sidebar {
    position: static;
    width: auto;
    margin: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
  }

  .app-nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 2px;
  }

  .nav-button {
    flex: 0 0 auto;
    width: auto;
    min-width: 100px;
    justify-content: center;
  }

  .nav-button.active::before {
    display: none;
  }

  .sidebar-insight-card {
    display: none !important;
  }

  .app-header {
    margin-left: 0;
    padding: 12px 16px;
  }

  .app-shell {
    margin-left: 0;
    padding: 0 16px 24px;
  }


  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .section-header,
  .card-header {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .toolbar-stack {
    justify-items: stretch;
  }

  .filters,
  .report-controls {
    justify-content: stretch;
  }

  .filters input,
  .filters select,
  .report-controls input,
  .report-controls select {
    width: 100%;
  }

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

@media (max-width: 640px) {
  .app-header {
    position: static;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    min-height: auto;
    padding: 16px;
  }


  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .round-icon-button,
  .user-pill {
    display: none;
  }

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

  .summary-item {
    min-height: 72px;
  }

  .content-band,
  .chart-card,
  .filter-card,
  .table-card {
    padding: 16px;
  }

  .tab-list {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .tab-button {
    flex: 0 0 auto;
  }
}
