@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --bg-body: #f3f4f6;
  --bg-panel: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-light: #e5e7eb;
  
  --purple-main: #8b5cf6;
  --teal-main: #14b8a6;
  --red-dot: #ef4444;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  min-height: 100vh;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px 20px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: #111827;
}

.inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

input[type="number"], input[type="text"], input[type="date"] {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s ease;
}

input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-container {
  display: flex;
  justify-content: center;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.primary-btn {
  background: #111827;
  color: white;
  padding: 12px 32px;
  font-size: 1rem;
}

.primary-btn:hover {
  background: #374151;
}

.black-btn {
  background: #111827;
}

.ghost-btn {
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: #4b5563;
  padding: 8px 16px;
  font-size: 0.9rem;
}

.ghost-btn:hover {
  background: #f9fafb;
}

.chart-container {
  position: relative;
  height: 480px;
  width: 100%;
  margin-bottom: 32px;
}

/* Custom Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.summary-card {
  padding: 20px 24px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-card.final-balance { background: #f5f3ff; }
.summary-card.final-balance .card-value { color: #6d28d9; }
.summary-card.final-balance .card-label { color: #6d28d9; font-weight: 700; }

.summary-card.cumulative-savings { background: #eff6ff; }
.summary-card.cumulative-savings .card-value { color: #1d4ed8; }
.summary-card.cumulative-savings .card-label { color: #1d4ed8; font-weight: 700; }

.summary-card.monthly-balance { background: #ecfdf5; }
.summary-card.monthly-balance .card-value { color: #047857; }
.summary-card.monthly-balance .card-label { color: #047857; font-weight: 700; }

.summary-card.savings-rate { background: #fff7ed; }
.summary-card.savings-rate .card-value { color: #c2410c; }
.summary-card.savings-rate .card-label { color: #c2410c; font-weight: 700; }

.card-label {
  font-size: 0.85rem;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Add expenses */
.add-expense-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.add-expense-form input {
  flex: 1;
  min-width: 180px;
}

.expense-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.expense-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}

.event-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-info strong {
  font-size: 1.05rem;
  color: #111827;
}

.event-info span {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.delete-btn {
  background: #fee2e2;
  color: #ef4444;
  padding: 8px 16px;
  font-size: 0.85rem;
}

.delete-btn:hover {
  background: #fca5a5;
  color: #b91c1c;
}

/* AI Chat Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.chat-container-panel {
  background: #ffffff;
  width: 90%;
  max-width: 500px;
  height: 600px;
  max-height: 90vh;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(0);
  transition: transform 0.3s ease;
}

.modal-overlay.hidden .chat-container-panel {
  transform: translateY(20px);
}

.chat-header {
  padding: 16px 20px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0 8px;
}
.close-btn:hover { color: #111827; }

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #ffffff;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.message.ai {
  background: #f3f4f6;
  color: #1f2937;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message.user {
  background: #111827;
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-input-area {
  padding: 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
  background: #ffffff;
}

.chat-input-area input {
  flex: 1;
  margin: 0;
}

.chat-input-area button {
  padding: 10px 20px;
}

/* Header Styles */
.main-header {
  text-align: center;
  margin-bottom: 48px;
  animation: fadeInDown 0.6s ease-out forwards;
}

.title-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.subtitle {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--teal-main);
  text-transform: uppercase;
}

.main-header h1 {
  font-size: 3rem;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, #111827 0%, #6d28d9 50%, #2563eb 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1.5px;
}

.main-header p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 600px;
  margin: 0 auto;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer */
.site-footer {
  text-align: center;
  margin-top: 40px;
  padding: 20px 0;
  border-top: 1px solid var(--border-light);
}

.site-footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
  line-height: 1.6;
}

/* Instructions */
.instructions-panel {
  background: linear-gradient(145deg, #ffffff, #f9fafb);
  border-left: 4px solid var(--purple-main);
}

.instructions-panel h2 {
  margin-bottom: 16px;
}

.instructions-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-main);
  line-height: 1.8;
  font-size: 0.95rem;
}

.instructions-list li {
  margin-bottom: 8px;
}

.instructions-list li:last-child {
  margin-bottom: 0;
}

/* Footer Links */
.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* Explanation Panel */
.explanation-panel {
  background: var(--bg-panel);
}

.explanation-content h3 {
  font-size: 1.1rem;
  color: #111827;
  margin-top: 24px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.explanation-content p {
  line-height: 1.8;
  color: var(--text-main);
  margin-bottom: 16px;
  font-size: 0.95rem;
}
