/* ============================================================
   EXPENSE TRACKER — Stylesheet
   ============================================================ */

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #F4F0E4;
  color: #2d3748;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}


/* ── Header ───────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #44A194 0%, #537D96 100%);
  color: white;
  padding: 28px 20px 20px;
  text-align: center;
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.6px;
  line-height: 1.2;
}

.app-header p {
  font-size: 0.82rem;
  font-weight: 400;
  opacity: 0.75;
  margin-top: 6px;
  letter-spacing: 0.02em;
}

/* ── Mobile Tip Banner ─────────────────────────────────── */
.tip-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #537D96;
  color: white;
  padding: 12px 16px;
  font-size: 0.8rem;
  line-height: 1.55;
}

.tip-banner small {
  opacity: 0.8;
}

.tip-close {
  background: none;
  border: none;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.7;
}

.tip-close:hover {
  opacity: 1;
}

/* ── Tab Navigation ───────────────────────────────────────── */
.tab-nav {
  display: flex;
  background: white;
  border-bottom: 2px solid #e5e0d4;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tab-btn {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #a0aec0;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  font-family: inherit;
}

.tab-btn.active {
  color: #44A194;
  border-bottom-color: #44A194;
}

.tab-btn:hover:not(.active) {
  color: #718096;
}


/* ── Sections ─────────────────────────────────────────────── */
.section {
  display: none;
  padding: 20px 16px;
  animation: fadeIn 0.2s ease;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 14px;
  padding: 22px 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  margin-bottom: 16px;
}

.card-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #a0aec0;
  margin-bottom: 18px;
}


/* ── Form Elements ────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #718096;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e5e0d4;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  color: #2d3748;
  background: #faf8f2;
  transition: border-color 0.2s, background 0.2s;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #44A194;
  background: white;
  box-shadow: 0 0 0 3px rgba(68, 161, 148, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* Amount input with $ prefix */
.amount-wrapper {
  position: relative;
}

.amount-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  font-weight: 700;
  color: #a0aec0;
  pointer-events: none;
}

.amount-wrapper .form-input {
  padding-left: 28px;
}


/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.15s;
}

.btn:active {
  transform: scale(0.98);
  opacity: 0.88;
}

.btn-primary {
  background: linear-gradient(135deg, #44A194, #537D96);
  color: white;
}

.btn-success {
  background: #44A194;
  color: white;
}

.btn-danger {
  background: #EC8F8D;
  color: white;
}

.btn + .btn {
  margin-top: 10px;
}


/* ── Summary Stats Bar ────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.stat-card .stat-value {
  font-size: 1.15rem;
  font-weight: 900;
  color: #44A194;
  line-height: 1;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
  font-size: 0.65rem;
  color: #a0aec0;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 6px;
}


/* ── Filter Row ───────────────────────────────────────────── */
.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-row .form-select {
  flex: 1;
  font-size: 0.875rem;
  padding: 10px 12px;
}


/* ── Expense List ─────────────────────────────────────────── */
.expense-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.expense-item {
  background: white;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  border-left: 4px solid #44A194;
}

/* Category color accents */
.expense-item[data-category="Food"]          { border-left-color: #EC8F8D; }
.expense-item[data-category="Transport"]     { border-left-color: #44A194; }
.expense-item[data-category="Bills"]         { border-left-color: #537D96; }
.expense-item[data-category="Health"]        { border-left-color: #76c4b8; }
.expense-item[data-category="Entertainment"] { border-left-color: #d4a49e; }
.expense-item[data-category="Shopping"]      { border-left-color: #e0b4a0; }
.expense-item[data-category="Service"]       { border-left-color: #7fb3a8; }
.expense-item[data-category="Other"]         { border-left-color: #b8b0a0; }

.expense-info .expense-category {
  font-weight: 800;
  font-size: 0.92rem;
  color: #2d3748;
  letter-spacing: -0.2px;
}

.expense-info .expense-meta {
  font-size: 0.72rem;
  font-weight: 500;
  color: #a0aec0;
  margin-top: 3px;
  letter-spacing: 0.02em;
}

.expense-info .expense-note {
  font-size: 0.78rem;
  font-weight: 400;
  color: #718096;
  margin-top: 5px;
  font-style: italic;
  line-height: 1.5;
}

.expense-right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.expense-right .expense-amount {
  font-size: 1.08rem;
  font-weight: 900;
  color: #2d3748;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}

.expense-right .delete-btn {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #EC8F8D;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.expense-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

.edit-btn {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #44A194;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.edit-btn:hover {
  color: #3a8d81;
}

.delete-btn:hover {
  color: #d4706e;
}

/* ── Inline Edit Amount ───────────────────────────────────── */
.edit-amount-input {
  width: 80px;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: right;
  border: 1.5px solid #44A194;
  border-radius: 6px;
  padding: 3px 6px;
  outline: none;
  font-family: inherit;
  color: #2d3748;
  font-variant-numeric: tabular-nums;
}

.edit-amount-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 4px;
}

.edit-save-btn,
.edit-cancel-btn {
  font-size: 0.8rem;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  font-family: inherit;
  font-weight: 600;
}

.edit-save-btn {
  background: #44A194;
  color: white;
}

.edit-save-btn:hover {
  background: #3a8d81;
}

.edit-cancel-btn {
  background: #e5e0d4;
  color: #718096;
}

.edit-cancel-btn:hover {
  background: #d8d2c4;
}


/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: #a0aec0;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

.empty-state p {
  font-size: 0.9rem;
  line-height: 1.6;
}


/* ── Export Section ───────────────────────────────────────── */
.info-box {
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.83rem;
  line-height: 1.65;
  margin-bottom: 14px;
}

.info-box.blue {
  background: #e8f4f2;
  color: #2d7a6f;
}

.info-box.yellow {
  background: #fdf0ef;
  color: #8b5a59;
}

.export-summary {
  font-size: 0.9rem;
  color: #4a5568;
  line-height: 2;
}

.export-summary hr {
  border: none;
  border-top: 1px solid #e5e0d4;
  margin: 8px 0;
}


/* ── Toast Notification ───────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #2d3748;
  color: white;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.3s ease;
  z-index: 999;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

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


/* ── Receipt Scanner ──────────────────────────────────────── */

.scan-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border: 2px dashed #44A194;
  border-radius: 10px;
  background: #ecf5f3;
  color: #44A194;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s;
  margin-bottom: 16px;
}

.scan-btn:hover {
  background: #dff0ed;
}

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

/* Scanner modal overlay */
.scanner-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 500;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 0;
}

.scanner-overlay.open {
  display: flex;
}

.scanner-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  color: white;
}

.scanner-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.scanner-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-viewfinder {
  position: relative;
  width: 100%;
  flex: 1;
  overflow: hidden;
  background: black;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Animated scan line */
.scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #44A194, transparent);
  animation: scanMove 2s ease-in-out infinite;
  border-radius: 2px;
}

@keyframes scanMove {
  0%   { top: 20%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 80%; opacity: 0; }
}

/* Corner markers */
.scan-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: #44A194;
  border-style: solid;
  border-width: 0;
}
.scan-corner.tl { top: 15%; left: 8%;  border-top-width: 3px; border-left-width: 3px;  border-radius: 4px 0 0 0; }
.scan-corner.tr { top: 15%; right: 8%; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.scan-corner.bl { bottom: 15%; left: 8%;  border-bottom-width: 3px; border-left-width: 3px;  border-radius: 0 0 0 4px; }
.scan-corner.br { bottom: 15%; right: 8%; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }

.scanner-footer {
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.capture-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: white;
  border: 4px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.capture-btn:active {
  transform: scale(0.92);
  background: #e5e0d4;
}

.scanner-hint {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.78rem;
  text-align: center;
}

/* OCR processing state */
.scanner-status {
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  min-height: 20px;
  padding: 0 20px;
}

/* Hidden canvas for capture */
#scanner-canvas {
  display: none;
}


/* ── Pie Chart ────────────────────────────────────────────── */

.chart-card {
  padding-bottom: 16px;
}

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

.chart-month-select {
  flex: 0 0 auto;
  width: auto;
  font-size: 0.8rem;
  padding: 7px 10px;
}

.chart-container {
  width: 100%;
  max-width: 240px;
  margin: 0 auto 16px;
  position: relative;
}

.chart-empty {
  text-align: center;
  color: #a0aec0;
  font-size: 0.85rem;
  padding: 20px 0;
}

/* Legend rows */
.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  color: #4a5568;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.legend-amount {
  font-weight: 800;
  color: #2d3748;
  font-variant-numeric: tabular-nums;
}

.legend-pct {
  color: #a0aec0;
  font-size: 0.75rem;
  font-weight: 500;
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}


/* ── Loans Category ───────────────────────────────────────── */

.expense-item[data-category="Loans"] { border-left-color: #c4a96a; }


/* ── Dropbox Section ──────────────────────────────────────── */

.btn-dropbox {
  background: #0061FF;
  color: white;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.15s;
}

.btn-dropbox:active {
  transform: scale(0.98);
  opacity: 0.88;
}

.dropbox-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Connected status row */
.dropbox-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ecf5f3;
  border: 1px solid #b3dad3;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.dropbox-status-icon {\n  font-size: 1.1rem;\n  flex-shrink: 0;\n  line-height: 1;\n}\n\n.dropbox-status span {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2d7a6f;
  letter-spacing: 0.01em;
}

.dropbox-disconnect {
  font-size: 0.75rem;
  color: #EC8F8D;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.dropbox-disconnect:hover {
  color: #d4706e;
}

code {
  background: #ebe7db;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.78rem;
}
