/* ============================================
   家計簿アプリ - Design System
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Colors - Light Mode */
  --bg-primary: #f5f6fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f1f5;
  --bg-input: #f0f1f5;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --border-light: #f0f1f5;

  /* Accent Colors */
  --color-income: #10b981;
  --color-income-bg: rgba(16, 185, 129, 0.1);
  --color-income-light: #d1fae5;
  --color-expense: #f43f5e;
  --color-expense-bg: rgba(244, 63, 94, 0.1);
  --color-expense-light: #ffe4e6;
  --color-transfer: #3b82f6;
  --color-transfer-bg: rgba(59, 130, 246, 0.1);
  --color-transfer-light: #dbeafe;

  /* UI Colors */
  --color-accent: #6366f1;
  --color-accent-light: rgba(99, 102, 241, 0.1);
  --color-selected: #6366f1;
  --color-selected-bg: rgba(99, 102, 241, 0.12);
  --color-danger: #ef4444;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.15);

  /* Typography */
  --font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs: 0.7rem;
  --font-size-sm: 0.8rem;
  --font-size-base: 0.95rem;
  --font-size-lg: 1.15rem;
  --font-size-xl: 1.4rem;
  --font-size-2xl: 1.8rem;
  --font-size-3xl: 2.4rem;
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Borders */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --sidebar-width: 220px;
  --bottom-tab-height: 64px;
  --header-height: 56px;

  /* Premium Colors - Light */
  --premium-deep: #1a2a4d;
  --premium-mid: #2a4073;
  --premium-light: #3a538a;
  --premium-bg: #ffffff;
  --premium-text-on-dark: #ffffff;
  --premium-text-muted: rgba(255,255,255,0.7);
  --premium-card-bg: #ffffff;
  --premium-shadow: rgba(26, 42, 77, 0.2);
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #1e1e35;
    --bg-card-hover: #2a2a45;
    --bg-input: #252540;
    --text-primary: #e8e8f0;
    --text-secondary: #9ca3b8;
    --text-muted: #6b7290;
    --border-color: #2d2d4a;
    --border-light: #232340;
    --color-income-light: rgba(16, 185, 129, 0.15);
    --color-expense-light: rgba(244, 63, 94, 0.15);
    --color-transfer-light: rgba(59, 130, 246, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
  }
}

[data-theme="dark"] {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #1e1e35;
  --bg-card-hover: #2a2a45;
  --bg-input: #252540;
  --text-primary: #e8e8f0;
  --text-secondary: #9ca3b8;
  --text-muted: #6b7290;
  --border-color: #2d2d4a;
  --border-light: #232340;
  --color-income-light: rgba(16, 185, 129, 0.15);
  --color-expense-light: rgba(244, 63, 94, 0.15);
  --color-transfer-light: rgba(59, 130, 246, 0.15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);

  /* Premium Colors - Dark */
  --premium-deep: #0a0e1a;
  --premium-mid: #1a2a4d;
  --premium-light: #2a4073;
  --premium-bg: #1e1e35;
  --premium-text-on-dark: #e8e8f0;
  --premium-text-muted: rgba(232, 232, 240, 0.7);
  --premium-card-bg: #1e1e35;
  --premium-shadow: rgba(0, 0, 0, 0.4);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100dvh;
  width: 100%;
  overflow-x: hidden;
  position: relative;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  outline: none;
  transition: border-color var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-accent);
}

/* --- App Layout --- */
#app {
  display: flex;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* --- Sidebar (PC) --- */
.sidebar {
  display: none;
  width: var(--sidebar-width);
  height: 100dvh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  flex-direction: column;
  padding: var(--space-lg) 0;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-lg);
  margin-bottom: var(--space-xl);
}

.logo-icon {
  font-size: 1.8rem;
}

.logo-text {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: 0 var(--space-sm);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  padding: var(--space-md) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.nav-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-btn.active {
  background: var(--color-selected-bg);
  color: var(--color-selected);
  font-weight: var(--font-weight-semibold);
}

.nav-icon {
  font-size: 1.3rem;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  position: relative;
  overflow: hidden; /* Container itself shouldn't scroll */
}

.screen {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-md);
  padding-bottom: calc(var(--bottom-tab-height) + 16px);
  -webkit-overflow-scrolling: touch;
  background: var(--bg-primary);
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Bottom Tab (Mobile) --- */
.bottom-tab {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-tab-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  position: relative;
}

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

.tab-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 3px;
  background: var(--color-accent);
  border-radius: 0 0 3px 3px;
}

.tab-icon {
  font-size: 1.4rem;
}

.tab-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

/* --- Input Screen --- */
.input-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* Type Toggle */
.type-toggle {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-md) var(--space-md) var(--space-sm);
  background: var(--bg-primary);
  overflow-x: hidden;
  width: 100%;
}

.type-btn {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}

.type-btn[data-type="expense"] {
  color: var(--color-expense);
  border-color: var(--color-expense);
}

.type-btn[data-type="expense"].active {
  background: var(--color-expense);
  color: white;
}

.type-btn[data-type="income"] {
  color: var(--color-income);
  border-color: var(--color-income);
}

.type-btn[data-type="income"].active {
  background: var(--color-income);
  color: white;
}

.type-btn[data-type="transfer"] {
  color: var(--color-transfer);
  border-color: var(--color-transfer);
}

.type-btn[data-type="transfer"].active {
  background: var(--color-transfer);
  color: white;
}

/* Amount Display */
.amount-display {
  text-align: center;
  padding: var(--space-md) var(--space-md) var(--space-sm);
  background: var(--bg-primary);
}

.amount-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: -1px;
  transition: color var(--transition-fast);
  font-variant-numeric: tabular-nums;
}

.amount-value.expense {
  color: var(--color-expense);
}

.amount-value.income {
  color: var(--color-income);
}

.amount-value.transfer {
  color: var(--color-transfer);
}

/* Scrollable Middle Section */
.input-fields {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background: var(--bg-primary);
  width: 100%;
}

/* Selector Sections */
.selector-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  border: 1px solid var(--border-color);
}

@media (max-width: 767px) {
  .selector-section {
    padding: var(--space-sm) var(--space-md);
    margin-bottom: 2px;
  }
  .selector-header {
    margin-bottom: 0;
  }
}

.selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.selector-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
}

.selected-summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-selected-bg);
  color: var(--color-selected);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  margin-left: 8px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  border: 1px solid rgba(99, 102, 241, 0.15);
  animation: fadeIn 0.2s ease;
}

.selector-expand {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  font-weight: var(--font-weight-medium);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.selector-expand:hover {
  background: var(--color-accent-light);
}

/* Icon Grid */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
  width: 100%;
}

.icon-grid.expanded {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-md) var(--space-xs);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  min-height: 80px;
  justify-content: center;
  border: 2px solid transparent;
  user-select: none;
  -webkit-user-select: none;
}

.icon-item:active {
  transform: scale(0.92);
}

.icon-item.selected {
  border-color: var(--color-selected);
  background: var(--color-selected-bg);
}

.icon-item.selected .icon-emoji {
  animation: iconBounce 0.3s ease;
}

@keyframes iconBounce {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.3);
  }

  70% {
    transform: scale(0.95);
  }

  100% {
    transform: scale(1);
  }
}

.icon-emoji {
  font-size: 1.8rem;
  line-height: 1;
}

@media (min-width: 768px) {
  .icon-emoji {
    font-size: 2rem;
  }
}

.icon-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-item.selected .icon-label {
  color: var(--color-selected);
  font-weight: var(--font-weight-semibold);
}

/* Hidden items (collapsed) */
.icon-grid:not(.expanded) .icon-item.extra {
  display: none;
}

/* Date & Memo Row */
.meta-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.meta-row input {
  flex: 1;
  height: 44px;
  font-size: var(--font-size-sm);
}

.date-input {
  max-width: 160px;
  flex: none !important;
}

/* Date Row with shortcuts */
.date-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

.date-shortcut-btn {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  background: transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.date-shortcut-btn:hover:not(:disabled) {
  background: var(--color-accent);
  color: white;
}

.date-shortcut-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Amount Input Field */
.amount-input-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  border: 1px solid var(--border-color);
}

.amount-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.amount-yen {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-secondary);
}

.amount-field {
  flex: 1;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  border: none;
  background: transparent;
  padding: var(--space-sm) 0;
  -moz-appearance: textfield;
  appearance: textfield;
}

.amount-field::-webkit-outer-spin-button,
.amount-field::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.amount-field:focus {
  border: none;
}

/* Submit Button */
.submit-btn {
  width: 100%;
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: white;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: var(--space-sm);
}

.submit-btn.expense-mode {
  background: var(--color-expense);
}

.submit-btn.expense-mode:hover {
  background: #e11d48;
}

.submit-btn.income-mode {
  background: var(--color-income);
}

.submit-btn.income-mode:hover {
  background: #059669;
}

.submit-btn.transfer-mode {
  background: var(--color-transfer);
}

.submit-btn.transfer-mode:hover {
  background: #2563eb;
}

.submit-btn:active {
  transform: scale(0.98);
}

/* Shortcuts */
.shortcuts-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  border: 1px solid var(--border-color);
}

.shortcuts-scroll {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.shortcuts-scroll::-webkit-scrollbar {
  display: none;
}

.shortcut-chip {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-full);
  white-space: nowrap;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-fast);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.shortcut-chip:hover {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
}

.shortcut-chip:active {
  transform: scale(0.95);
}

/* Bulk Input Table (PC only) */
.bulk-input-section {
  padding-bottom: var(--space-lg);
}

.bulk-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.bulk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.bulk-table th {
  padding: var(--space-sm) var(--space-xs);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.bulk-table td {
  padding: var(--space-xs);
  border-bottom: 1px solid var(--border-light);
}

.bulk-input {
  width: 100%;
  height: 36px;
  font-size: var(--font-size-sm);
  padding: var(--space-xs) var(--space-sm);
  min-width: 80px;
}

.bulk-input[type="date"] {
  min-width: 130px;
}

.bulk-input[type="number"] {
  min-width: 90px;
}

.bulk-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-danger);
  font-size: var(--font-size-sm);
  transition: background var(--transition-fast);
}

.bulk-delete-btn:hover {
  background: var(--color-expense-bg);
}

.bulk-toggle {
  max-width: 120px;
}


/* ============================================
   Dashboard Screen
   ============================================ */
.dashboard-screen {
  padding: var(--space-md);
  max-width: 800px;
  margin: 0 auto;
}

.dashboard-header {
  text-align: center;
  padding: var(--space-lg) 0;
}

.total-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.total-amount {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  margin-top: var(--space-xs);
  font-variant-numeric: tabular-nums;
}

.total-amount.positive {
  color: var(--color-income);
}

.sortable-ghost {
  opacity: 0.15;
  background: var(--bg-secondary) !important;
  border: 1px dashed var(--color-accent);
}

.sortable-drag {
  background: var(--bg-card) !important;
  box-shadow: 0 12px 32px rgba(0,0,0,0.2), 0 4px 8px rgba(0,0,0,0.1);
  opacity: 1 !important;
  transform: scale(1.02);
  cursor: grabbing;
  z-index: 9999;
}

/* While chosen but not dragging yet */
.sortable-chosen {
  background: var(--bg-card-hover) !important;
}

.total-amount.negative {
  color: var(--color-expense);
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  border: 1px solid var(--border-color);
}

.chart-card-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-sm);
}

.chart-period-toggle {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.period-btn {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.period-btn.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.chart-container {
  position: relative;
  height: 220px;
}

/* Account Balance Cards */
.account-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-sm);
}

.account-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: all var(--transition-fast);
}

.account-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.account-card-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.account-card-info {
  flex: 1;
  min-width: 0;
}

.account-card-name {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-card-balance {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
}

/* Drag and Drop Transfer Styles */
.account-card.sortable-ghost {
  opacity: 0.3;
  background: var(--color-selected-bg) !important;
  border: 2px dashed var(--color-selected);
}

.account-card.drag-over {
  transform: scale(1.05);
  border-color: var(--color-income) !important;
  background: var(--color-income-light) !important;
  box-shadow: 0 0 15px var(--color-income-bg);
  z-index: 10;
}

/* Quick Transfer Modal Specifics */
.quick-transfer-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
}

.transfer-arrow {
  color: var(--color-transfer);
  font-size: 1.5rem;
}


/* ============================================
   History Screen
   ============================================ */
.history-screen {
  max-width: 600px;
  margin: 0 auto;
}

.history-header {
  padding: var(--space-md);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.history-header-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.history-title-group {
  display: flex;
  flex-direction: column;
}

.history-current-date {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
}

.history-asset-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-asset-amount {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--premium-deep);
}

.history-filters {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.filter-card {
  flex: 1;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.filter-card:focus-within {
  border-color: #4a5568;
  box-shadow: 0 0 0 2px rgba(74, 85, 104, 0.1);
}

.filter-label {
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  color: var(--text-muted);
  text-transform: uppercase;
}

.filter-card input,
.filter-card select {
  border: none;
  background: transparent;
  padding: 0;
  height: 24px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  width: 100%;
}

.filter-card input[type="date"] {
  min-width: 0;
}

@media (max-width: 480px) {
  .filter-card {
    min-width: calc(50% - var(--space-sm) / 2);
  }
}

.history-list {
  padding: 0 var(--space-md);
}

.history-date-group {
  padding-top: var(--space-md);
}

.history-date-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: var(--space-xs);
}

.history-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:active {
  background: var(--bg-card-hover);
}

.history-item-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.history-item-icon.expense {
  background: var(--color-expense-bg);
}

.history-item-icon.income {
  background: var(--color-income-bg);
}

.history-item-icon.transfer {
  background: var(--color-transfer-bg);
}

.history-item-info {
  flex: 1;
  min-width: 0;
}

.history-item-category {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.history-item-account {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.history-item-amount {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.history-item-amount.expense {
  color: var(--color-expense);
}

.history-item-amount.income {
  color: var(--color-income);
}

.history-item-amount.transfer {
  color: var(--color-transfer);
}

.history-empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

.history-empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}


/* ============================================
   Settings Screen
   ============================================ */
.settings-screen {
  padding: var(--space-md);
  max-width: 600px;
  margin: 0 auto;
}

.settings-section {
  margin-bottom: var(--space-lg);
}

.settings-section-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-sm);
  padding-left: var(--space-xs);
}

.settings-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item:hover {
  background: var(--bg-card-hover);
}

.settings-item-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.settings-item-icon {
  font-size: 1.3rem;
}

.settings-item-label {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
}

.settings-item-arrow {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-switch.active {
  background: var(--color-accent);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.toggle-switch.active::after {
  transform: translateX(20px);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--space-xs);
  margin-top: var(--space-md);
  max-height: 200px;
  overflow-y: auto;
  padding: var(--space-sm);
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.emoji-option {
  font-size: 1.5rem;
  text-align: center;
  padding: 5px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), transform 0.1s ease;
}

.emoji-option:hover {
  background: var(--bg-card);
  transform: scale(1.2);
}
.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 480px;
  padding: var(--space-lg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 2100;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-lg);
  overflow-y: auto;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  transition: background var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-card-hover);
}

/* Form */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-input {
  width: 100%;
  height: 44px;
}

.form-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.btn {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover {
  background: #4f46e5;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
  z-index: 300;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}



/* ============================================
   Analysis Screen (Premium Redesign)
   ============================================ */

.analysis-screen {
  background-color: #f8f9fa;
  min-height: 100%;
}

/* Summary Master Card */
.total-summary-card {
  background: linear-gradient(135deg, var(--premium-mid) 0%, var(--premium-deep) 100%);
  padding: 32px var(--space-lg);
  color: var(--premium-text-on-dark);
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 25px var(--premium-shadow);
  margin-bottom: var(--space-md);
}

.total-summary-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.total-amount {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: -1px;
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.total-amount.expense { color: #ffffff; }
.total-amount.income { color: #ffffff; }

/* Segmented Control (iOS style) */
.analysis-segmented-control {
  display: flex;
  background: rgba(0,0,0,0.05);
  padding: 2px;
  border-radius: 9px;
  margin: 0 var(--space-md) var(--space-md);
}

.segmented-item {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  border-radius: 7px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.segmented-item.active {
  background: white;
  color: var(--premium-deep);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Period Navigation */
.period-nav-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--space-md) var(--space-md);
}

.period-display {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--text-secondary);
}

.nav-round-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: white;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #1a2a4d;
  font-weight: bold;
}

/* Premium Card (Charts, Lists) */
.premium-card-v3 {
  background: white;
  border-radius: var(--radius-xl);
  margin: 0 var(--space-md) var(--space-md);
  padding: var(--space-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.02);
}

/* Category List */
.category-item-v3 {
  display: flex;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid #f0f0f0;
}

.category-item-v3:last-child {
  border-bottom: none;
}

.cat-icon-frame {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-right: var(--space-sm);
}

.cat-info-v3 {
  flex: 1;
}

.cat-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.cat-name-v3 {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.cat-amount-v3 {
  font-weight: 800;
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
  color: #1a2a4d;
}

.cat-progress-v3 {
  height: 6px;
  background: #f0f2f5;
  border-radius: 3px;
  overflow: hidden;
}

.cat-progress-bar {
  height: 100%;
  background: #2a4073;
  transition: width 0.6s ease;
}

/* Main Navigation Tabs (Segmented) */
.analysis-main-nav-container {
  background: var(--bg-secondary);
  padding: var(--space-md) 0 var(--space-sm);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.analysis-segmented-control.main-nav {
  margin: 0 auto;
  max-width: var(--nav-max-width, 280px);
  background: rgba(0,0,0,0.04);
}

[data-theme="dark"] .analysis-segmented-control.main-nav {
  background: rgba(255,255,255,0.08);
}

.analysis-segmented-control.main-nav .segmented-item {
  padding: 8px;
  font-size: var(--font-size-sm);
}

/* Accessibility: focus states */
.segmented-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* Responsive Analysis Nav */
@media (max-width: 480px) {
  .analysis-segmented-control.main-nav {
    max-width: calc(100% - 32px);
    margin: 0 var(--space-md);
  }
}

@media (min-width: 768px) {
  .sidebar {
    display: flex;
  }

  .bottom-tab {
    display: none;
  }

  .screen {
    padding-bottom: var(--space-md);
  }

  .icon-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .icon-grid.expanded {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .input-screen {
    max-width: 600px;
    padding-top: var(--space-md);
  }

  .icon-emoji {
    font-size: 1.8rem;
  }

  .icon-label {
    font-size: var(--font-size-xs);
  }

  .icon-item {
    min-height: 65px;
    padding: var(--space-sm) var(--space-xs);
  }

  .modal-content {
    border-radius: var(--radius-xl);
    margin: auto;
  }

  .modal-overlay {
    align-items: center;
  }

  .account-cards {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (min-width: 1024px) {
  .icon-grid.expanded {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .account-cards {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}
/* ============================================
   Premium Modal Sheet (Bottom Sheet style)
   ============================================ */
.premium-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.premium-modal-sheet {
  background: var(--bg-secondary);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-lg) var(--space-lg) calc(var(--space-lg) + 20px);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
  position: relative;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-drag-handle {
  width: 36px;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  margin: 0 auto var(--space-md);
  opacity: 0.6;
}

.modal-header-v3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
}

.modal-title-v3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.5px;
}

.modal-close-v3 {
  font-size: 1.8rem;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
  margin-right: -8px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.modal-close-v3:active { transform: scale(0.9); }

.modal-body-v3 {
  margin-bottom: var(--space-xl);
}

.date-row-v3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.date-field-v3 {
  flex: 1;
}

.date-field-v3 label {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.date-field-v3 input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  padding: 14px 12px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: border-color 0.2s ease;
}

.date-field-v3 input:focus {
  border-color: var(--color-accent);
}

.date-arrow-v3 {
  color: var(--text-muted);
  font-weight: 900;
  padding-top: 18px;
  font-size: 1.2rem;
  opacity: 0.5;
}

.modal-footer-v3 {
  margin-top: var(--space-md);
}

.modal-apply-btn-v3 {
  width: 100%;
  background: linear-gradient(135deg, var(--premium-mid) 0%, var(--premium-deep) 100%);
  color: white;
  padding: 16px;
  border-radius: 18px;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: 0 8px 20px var(--premium-shadow);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.modal-apply-btn-v3:active {
  transform: scale(0.97);
  box-shadow: 0 4px 10px var(--premium-shadow);
}

/* Animations */
.slideUp {
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.fadeIn {
  animation: fadeIn 0.3s ease-out;
}

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

[data-theme="dark"] .premium-modal-sheet {
  background: var(--bg-card);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
}

/* Premium Select (stylish buttons) */
.select-v3 {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-light);
  padding: 8px 28px 8px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--premium-deep);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231a2a4d' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all 0.2s ease;
  min-width: 0;
  width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.select-v3:focus {
  outline: none;
  border-color: var(--premium-mid);
  box-shadow: 0 0 0 3px rgba(42, 64, 115, 0.1);
}

[data-theme="dark"] .select-v3 {
  background-color: rgba(255,255,255,0.05);
  color: white;
  stroke: white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
}

/* Date Header Badge */
.date-header-v3 {
  margin: 32px var(--space-md) 12px;
  display: flex;
  align-items: center;
}

.date-badge-v3 {
  background: white;
  color: var(--premium-deep);
  font-size: 0.75rem;
  font-weight: 900;
  padding: 4px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--premium-mid);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  letter-spacing: 0.5px;
}

[data-theme="dark"] .date-badge-v3 {
  background: var(--bg-card);
  color: white;
  border-color: rgba(255,255,255,0.2);
}
