:root {
  --bg-primary: #f5f0e8;
  --bg-secondary: #ede6da;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-sidebar: rgba(255, 255, 255, 0.75);
  --text-primary: #3d2b1f;
  --text-secondary: #6b5a4a;
  --text-muted: #9a8a7a;
  --accent: #b8a48b;
  --accent-light: #d4c8b8;
  --success: #7fa87f;
  --danger: #c97a7a;
  --warning: #d4a86a;
  --border: #e0d8cc;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-sans: 'IBM Plex Sans', 'Noto Serif SC', system-ui, -apple-system, sans-serif;
  --font-serif: 'Noto Serif SC', 'IBM Plex Sans', Georgia, serif;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-blur: rgba(245, 240, 232, 0.85);
  --sidebar-width: 280px;
}

[data-theme="dark"] {
  --bg-primary: #1a2e2a;
  --bg-secondary: #1f3631;
  --bg-card: rgba(37, 52, 47, 0.92);
  --bg-sidebar: rgba(37, 52, 47, 0.88);
  --text-primary: #e8d5b7;
  --text-secondary: #c4b696;
  --text-muted: #8a7d67;
  --accent: #c4a97d;
  --accent-light: #8a7d67;
  --success: #7fa87f;
  --danger: #c97a7a;
  --warning: #d4a86a;
  --border: #2f4842;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 32px rgba(0, 0, 0, 0.35);
  --nav-blur: rgba(26, 46, 42, 0.9);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition), color var(--transition);
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--text-primary);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  list-style: none;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
  transition: background var(--transition);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Layout System ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  transition: background-color var(--transition), border-color var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.sidebar-brand h1 {
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  margin: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 16px;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
  transition: all var(--transition);
  text-decoration: none;
}

.sidebar-nav-link:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-nav-link.active {
  background: var(--accent-light);
  color: var(--text-primary);
}

.sidebar-user-actions {
  display: flex;
  gap: 8px;
}

.sidebar-nav svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.sidebar-user span {
  font-weight: 600;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px 40px;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 32px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-header h1 {
  margin: 0;
  letter-spacing: 0.02em;
}

.page-header .subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

/* ===== Card System ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-header h2, .card-header h3 {
  margin: 0;
}

.card-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== Grid System ===== */
.grid {
  display: grid;
  gap: 24px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ===== Typography & Spacing ===== */
.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.section-title {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

/* ===== Form System ===== */
.form-label {
  display: block;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 164, 139, 0.15);
}

.form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
  outline: none;
}

.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 164, 139, 0.15);
}

.form-group {
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group-flex {
  flex: 1;
}

/* ===== Button System ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(184, 164, 139, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  filter: brightness(1.05);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ===== Button Group System ===== */
.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-group-btn {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.button-group-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.button-group-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.stat-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-value {
  display: block;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-positive { color: var(--success); }
.stat-negative { color: var(--danger); }

/* ===== Category Grid (Button Group) ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.category-item {
  position: relative;
  display: block;
  cursor: pointer;
}

.category-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.category-name {
  display: block;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  transition: all var(--transition);
}

.category-radio:checked + .category-name {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.category-item:hover .category-name {
  border-color: var(--accent);
  color: var(--text-primary);
}

.category-item.category-pinned .category-name {
  border-style: dashed;
  border-color: var(--accent);
}

.category-item.category-pinned .category-radio:checked + .category-name {
  border-style: solid;
}

/* ===== Amount Input ===== */
.amount-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  overflow: hidden;
}

.amount-prefix {
  padding: 0 14px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
}

.amount-input {
  flex: 1;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 1.2rem;
  font-family: var(--font-serif);
  font-weight: 600;
}

/* ===== Type Tabs ===== */
.entry-tabs {
  display: inline-flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
  margin-bottom: 20px;
}

.entry-tab {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.entry-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.entry-tab[data-type="income"].active {
  color: var(--success);
}

.entry-tab[data-type="expense"].active {
  color: var(--danger);
}

/* ===== Backfill Notice ===== */
.backfill-notice {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  margin-bottom: 16px;
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Timeline ===== */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 80px 40px 1fr;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
}

.timeline-item:hover {
  box-shadow: var(--shadow);
}

.timeline-time {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.timeline-icon-wrap {
  display: flex;
  justify-content: center;
}

.timeline-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.timeline-icon.icon-expense {
  background: rgba(201, 122, 122, 0.15);
  color: var(--danger);
}

.timeline-icon.icon-income {
  background: rgba(127, 168, 127, 0.15);
  color: var(--success);
}

.timeline-body {
  flex: 1;
}

.timeline-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.timeline-category {
  font-weight: 600;
}

.timeline-amount {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
}

.amount-expense { color: var(--danger); }
.amount-income { color: var(--success); }

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.meta-tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-note {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== Filter Bar ===== */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.filter-group {
  flex: 1;
  min-width: 160px;
}

.filter-label {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.filter-select, .filter-input {
  width: 100%;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

/* ===== Transaction Table ===== */
.txn-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.txn-table thead {
  background: var(--bg-secondary);
}

.txn-table th {
  padding: 14px 16px;
  text-align: left;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.txn-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.txn-table tbody tr:last-child td {
  border-bottom: none;
}

.txn-table tbody tr {
  transition: background var(--transition);
}

.txn-table tbody tr:hover {
  background: var(--bg-secondary);
}

.txn-amount {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.05rem;
}

.txn-type-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
}

.txn-badge-expense {
  background: rgba(201, 122, 122, 0.15);
  color: var(--danger);
}

.txn-badge-income {
  background: rgba(127, 168, 127, 0.15);
  color: var(--success);
}

.txn-actions {
  display: flex;
  gap: 6px;
}

.txn-list-mobile {
  display: none;
}

/* ===== Chart Container ===== */
.chart-container {
  position: relative;
  max-width: 320px;
  margin: 0 auto;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  opacity: 0.5;
}

.empty-text {
  font-size: 1.1rem;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.empty-hint {
  font-size: 0.9rem;
}

/* ===== Flash Messages ===== */
.flash-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.flash-message {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.flash-success { border-left: 4px solid var(--success); }
.flash-error { border-left: 4px solid var(--danger); }
.flash-info { border-left: 4px solid var(--accent); }

.flash-text { font-weight: 500; }

.flash-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.flash-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ===== Dashboard Layout ===== */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 28px;
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.dashboard-sidebar {
  position: sticky;
  top: 32px;
  align-self: flex-start;
}

.dash-greeting {
  margin-bottom: 8px;
}

.greeting-text {
  font-size: 1.75rem;
  margin-bottom: 4px;
}

.greeting-date {
  font-size: 1rem;
  color: var(--text-muted);
}

.quick-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.today-timeline {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.dash-cards {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.summary-card .card-title {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.summary-card .card-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.summary-card .stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-card .stat-label {
  font-size: 0.8rem;
}

.summary-card .stat-value {
  font-size: 1.5rem;
}

/* ===== Reports Page ===== */
.report-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.report-tabs {
  display: inline-flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.report-tab {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.report-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.report-date-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.date-nav-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.date-nav-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.report-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.report-stat {
  text-align: center;
}

.report-stat .stat-label {
  font-size: 0.85rem;
}

.report-stat .stat-value {
  font-size: 1.75rem;
}

.report-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.report-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.report-txn-item {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.report-txn-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.report-txn-item:first-child {
  padding-top: 0;
}

.report-txn-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.report-txn-date {
  font-weight: 600;
  font-family: var(--font-serif);
}

.report-txn-time {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.report-txn-center {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.report-txn-category {
  font-weight: 600;
}

.report-txn-note {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.report-txn-right {
  text-align: right;
}

.report-txn-amount {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
}

.txn-amount-expense { color: var(--danger); }
.txn-amount-income { color: var(--success); }

/* ===== Settings Page ===== */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.settings-tab {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.settings-tab:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.settings-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-panel .panel-title {
  font-size: 1.15rem;
  margin-bottom: 20px;
}

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.cat-item[data-pinned="1"] {
  border-style: dashed;
  border-color: var(--accent);
}

.cat-item-ghost {
  opacity: 0.4;
  background: var(--accent-light) !important;
}

.cat-name {
  font-weight: 500;
}

.cat-actions {
  display: flex;
  gap: 8px;
}

.add-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.add-form .form-input {
  flex: 1;
}

.settings-form {
  max-width: 500px;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.theme-option {
  display: flex;
  flex-direction: column;
}

.theme-option input[type="radio"] {
  position: absolute;
  opacity: 0;
}

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition);
}

.theme-card:hover {
  border-color: var(--accent);
}

.theme-option input[type="radio"]:checked + .theme-card {
  border-color: var(--accent);
  background: var(--accent-light);
}

.admin-link-wrap {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ===== Auth Pages ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-title {
  font-size: 1.75rem;
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--text-muted);
}

.auth-form {
  margin-bottom: 20px;
}

.auth-footer {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.auth-link {
  font-weight: 600;
  color: var(--accent);
}

.auth-link:hover {
  color: var(--text-primary);
}

/* ===== Admin Page ===== */
.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.admin-form {
  max-width: 400px;
}

.code-list {
  margin-top: 20px;
}

.code-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-table th, .code-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.code-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-value {
  font-family: 'Courier New', monospace;
  font-weight: 700;
}

.code-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
}

.status-valid {
  background: rgba(127, 168, 127, 0.15);
  color: var(--success);
}

.status-invalid {
  background: rgba(201, 122, 122, 0.15);
  color: var(--danger);
}

/* ===== AI Analysis Page ===== */
.ai-page {
  max-width: 800px;
  margin: 0 auto;
}

.ai-period-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.ai-custom-range {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.ai-custom-range input[type="date"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
}

.ai-result-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-height: 100px;
  line-height: 1.8;
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-result-content h3 {
  font-size: 1.1rem;
  margin: 16px 0 8px;
  color: var(--accent);
}

.ai-result-content h3:first-child {
  margin-top: 0;
}

.ai-result-content ul {
  list-style: disc;
  padding-left: 20px;
  margin: 8px 0;
}

.ai-result-content li {
  margin-bottom: 4px;
}

.ai-result-content strong {
  color: var(--text-primary);
}

.ai-loading {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.ai-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ai-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.ai-export-btn {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  font-size: 1.4rem;
  line-height: 1;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== Mobile Menu Button ===== */
.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.mobile-menu-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ===== Sidebar Overlay ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
  animation: fadeIn 0.2s ease;
}

/* ===== Drag Handle ===== */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  cursor: grab;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 8px;
  transition: color var(--transition);
}

.drag-handle:hover {
  color: var(--accent);
}

.drag-handle:active {
  cursor: grabbing;
}

/* ===== FAB (Floating Action Button) ===== */
.fab {
  display: none;
  position: fixed;
  bottom: 88px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 300;
  line-height: 1;
  border: none;
  box-shadow: 0 4px 16px rgba(184, 164, 139, 0.35);
  cursor: pointer;
  z-index: 90;
  text-decoration: none;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(184, 164, 139, 0.45);
}

.fab:active {
  transform: translateY(0);
}

/* ===== Bottom Nav (Mobile Only) ===== */
.bottom-nav {
  display: none;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 960px) {
  .sidebar {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
    padding: 20px 16px 90px;
  }
  
  .container {
    max-width: 100%;
  }
  
  .dashboard {
    grid-template-columns: 1fr;
  }
  
  .dashboard-sidebar {
    position: static;
    order: -1;
  }
  
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 8px 16px;
    z-index: 100;
    justify-content: space-around;
  }
  
  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition);
  }
  
  .bottom-nav a.active {
    color: var(--accent);
  }
  
  .bottom-nav svg {
    width: 24px;
    height: 24px;
  }
  
  .txn-list-desktop {
    display: none;
  }
  
  .txn-list-mobile {
    display: block;
  }
  
  .txn-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
  }
  
  .txn-card-main {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
  }
  
  .txn-card-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 70px;
  }
  
  .txn-card-date {
    font-weight: 600;
    font-family: var(--font-serif);
  }
  
  .txn-card-time {
    color: var(--text-muted);
    font-size: 0.85rem;
  }
  
  .txn-card-center {
    flex: 1;
  }
  
  .txn-card-category {
    font-weight: 600;
    margin-bottom: 4px;
  }
  
  .txn-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .txn-card-pm {
    color: var(--text-muted);
    font-size: 0.85rem;
  }
  
  .txn-card-note {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
  }
  
  .txn-card-right {
    text-align: right;
  }
  
  .txn-card-amount {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
  }
  
  .txn-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  
  .txn-card-actions .btn-sm {
    flex: 1;
  }
  
  .filter-form {
    flex-direction: column;
  }
  
  .filter-group {
    width: 100%;
  }
  
  .report-stats {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .theme-options {
    grid-template-columns: 1fr;
  }
  
  .report-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .flash-container {
    left: 16px;
    right: 16px;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .sidebar.open {
    display: flex;
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .fab {
    display: flex;
  }
}

/* ===== Tablet Responsive (max-width: 768px) ===== */
@media (max-width: 768px) {
  .main-content {
    padding: 16px 12px 90px;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .stats-grid {
    gap: 12px;
  }

  .stat-card {
    padding: 14px 16px;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .card {
    padding: 16px;
  }
}

/* ===== Phone Responsive (max-width: 480px) ===== */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  body {
    font-size: 0.9rem;
  }

  .main-content {
    padding: 12px 10px 80px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 20px;
  }

  .page-header h1 {
    font-size: 1.35rem;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 12px 14px;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .card {
    padding: 14px;
    border-radius: var(--radius-md);
  }

  .timeline-item {
    grid-template-columns: 60px 32px 1fr;
    gap: 10px;
    padding: 12px 14px;
  }

  .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
  }

  .category-name {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  .fab {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
    bottom: 80px;
    right: 16px;
  }

  .bottom-nav {
    padding: 6px 10px;
  }

  .bottom-nav a {
    padding: 6px 8px;
    font-size: 0.7rem;
  }

  .bottom-nav svg {
    width: 20px;
    height: 20px;
  }

  .btn {
    padding: 10px 18px;
    font-size: 0.9rem;
  }

  .settings-tab {
    padding: 8px 14px;
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
