/* ===== Belanja Harian — Apple-style modern UI ===== */
:root {
  --bg: #F2F2F7;                 /* iOS systemGroupedBackground */
  --card: #FFFFFF;
  --separator: #E5E5EA;
  --label: #000000;
  --secondary: #3C3C4399;        /* iOS secondaryLabel */
  --tertiary: #8E8E93;
  --accent: #34C759;             /* iOS green */
  --accent-dark: #248A3D;
  --warn: #FF9F0A;               /* iOS orange */
  --danger: #FF3B30;             /* iOS red */
  --radius: 16px;
  --tab-height: 78px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--label);
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; padding: 12px 16px calc(var(--tab-height) + 24px); }
.hidden { display: none !important; }

/* ===== Large title (iOS style) ===== */
.large-title { display: flex; align-items: flex-end; justify-content: space-between; padding: 14px 2px 18px; }
.large-title h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
.date-sub { color: var(--secondary); font-size: 14px; margin-top: 2px; font-weight: 500; }
.link-btn { border: none; background: none; color: var(--accent); font-size: 15px; font-weight: 600; padding: 6px; }

/* ===== Budget ring card ===== */
.budget-card {
  background: var(--card); border-radius: 20px; padding: 20px;
  display: flex; align-items: center; gap: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.05);
  margin-bottom: 14px;
}
.ring-wrap { position: relative; width: 116px; height: 116px; flex-shrink: 0; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: #E9E9EB; stroke-width: 11; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 11; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.3s ease;
}
.budget-card.warn .ring-fill { stroke: var(--warn); }
.budget-card.over .ring-fill { stroke: var(--danger); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-pct { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.ring-label { font-size: 11px; color: var(--tertiary); font-weight: 600; }

.budget-info { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.budget-row { display: flex; justify-content: space-between; align-items: baseline; }
.budget-label { font-size: 14px; color: var(--secondary); }
.budget-amount { font-size: 19px; font-weight: 800; }
.budget-baki { font-size: 19px; font-weight: 800; color: var(--accent); }
.budget-card.over .budget-baki { color: var(--danger); }
.budget-info .link-btn { align-self: flex-start; padding: 2px 0; }

/* ===== Capture card ===== */
.capture-card {
  width: 100%; background: var(--card); border: none; border-radius: 20px;
  padding: 22px 18px; display: flex; align-items: center; gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.05);
  cursor: pointer; text-align: left; margin-bottom: 26px;
  transition: transform 0.12s ease;
}
.capture-card:active { transform: scale(0.98); }
.capture-circle {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #34C759, #28A745);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; box-shadow: 0 4px 12px rgba(52,199,89,0.35);
}
.capture-text { font-size: 17px; font-weight: 700; display: block; }
.capture-sub { font-size: 13px; color: var(--secondary); display: block; margin-top: 2px; }

/* ===== Grouped list (iOS settings style) ===== */
.list-section { margin-bottom: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 10px; }
.section-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.grouped-list {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.05);
  margin-bottom: 14px;
}
.list-items { display: flex; flex-direction: column; }
.list-items > * + * { border-top: 0.5px solid var(--separator); }
.empty-hint { color: var(--secondary); text-align: center; padding: 26px 16px; font-size: 14px; line-height: 1.5; }

.entry-card { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; }
.entry-info { display: flex; flex-direction: column; gap: 3px; }
.entry-merchant { font-weight: 600; font-size: 15px; }
.entry-meta { font-size: 13px; color: var(--secondary); }
.entry-amount { font-weight: 700; font-size: 16px; }

/* ===== Process / review ===== */
.process-status { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 80px 0; }
.spinner {
  width: 44px; height: 44px; border: 3.5px solid #E9E9EB; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.process-status p { color: var(--secondary); font-size: 15px; text-align: center; padding: 0 30px; }

.receipt-preview-wrap { text-align: center; margin-bottom: 12px; }
.receipt-preview { max-width: 100%; max-height: 240px; border-radius: 14px; border: 1px solid var(--separator); }

.review-meta .field-input { border: none; width: 100%; padding: 15px 16px; font-size: 16px; background: transparent; }
.review-meta .field-input:focus { outline: none; }

.items-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.item-row {
  background: var(--card); border-radius: 14px; padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 18px rgba(0,0,0,0.05);
}
.item-name { flex: 1; border: none; font-size: 15px; padding: 7px; border-radius: 8px; background: transparent; min-width: 0; }
.item-name:focus { background: var(--bg); outline: none; }
.item-cat {
  border: 1px solid var(--separator); border-radius: 10px; padding: 7px 6px;
  font-size: 12px; background: var(--card); color: var(--label); max-width: 108px; flex-shrink: 0;
}
.item-amount {
  width: 88px; border: 1px solid var(--separator); border-radius: 10px; padding: 7px 8px;
  font-size: 15px; text-align: right; font-weight: 700;
}
.item-del {
  border: none; background: #FFEBEB; color: var(--danger); width: 34px; height: 34px;
  border-radius: 50%; font-size: 14px; cursor: pointer; flex-shrink: 0; font-weight: 700;
}

.total-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 18px rgba(0,0,0,0.05);
}
.total-label { font-weight: 700; font-size: 13px; color: var(--secondary); letter-spacing: 0.5px; }
.total-amount { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }

/* ===== Buttons ===== */
.btn {
  width: 100%; border: none; border-radius: 14px; padding: 16px; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(52,199,89,0.3); }
.btn.primary:active { transform: scale(0.98); }
.btn.primary:disabled { opacity: 0.5; }

/* ===== Settings ===== */
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; }
.setting-label { font-size: 15.5px; font-weight: 500; }
.setting-value { display: flex; align-items: center; gap: 6px; color: var(--secondary); }
.field-input.number { width: 80px; border: 1px solid var(--separator); border-radius: 10px; padding: 8px 10px; font-size: 16px; text-align: right; background: var(--bg); }
.row-btn { width: 100%; border: none; background: none; cursor: pointer; font-family: inherit; }
.chevron { color: var(--secondary); font-size: 14px; }
.info-card { padding: 16px; font-size: 14.5px; line-height: 1.55; }
.info-card ol { margin: 10px 0 8px 20px; display: flex; flex-direction: column; gap: 5px; }
.muted { color: var(--secondary); font-size: 13px; margin-top: 10px; }

/* ===== History ===== */
.history-day {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 18px rgba(0,0,0,0.05);
  margin-bottom: 14px;
}
.history-day-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 0.5px solid var(--separator);
}
.history-date { font-weight: 700; font-size: 15px; }
.history-day-total { font-weight: 800; font-size: 16px; color: var(--label); }
.history-receipt { padding: 10px 16px; }
.history-receipt + .history-receipt { border-top: 0.5px solid var(--separator); }
.history-receipt-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.history-merchant { font-weight: 600; font-size: 14px; }
.history-right { display: flex; align-items: center; gap: 10px; }
.history-rtotal { font-size: 14px; font-weight: 700; }
.history-del {
  border: none; background: #FFEBEB; color: var(--danger);
  width: 32px; height: 32px; border-radius: 50%; font-size: 14px;
  cursor: pointer; flex-shrink: 0;
}
.history-del:active { transform: scale(0.9); }
.history-item { display: flex; gap: 8px; padding: 3px 0; font-size: 14px; }
.h-item-name { flex: 1; color: var(--label); }
.h-item-cat { color: var(--tertiary); font-size: 12px; width: 80px; text-align: left; }
.h-item-amt { font-weight: 600; min-width: 64px; text-align: right; }

/* ===== Segmented control (iOS style) ===== */
.segmented {
  display: flex; background: var(--bg); border-radius: 9px; padding: 2px;
}
.seg-btn {
  border: none; background: transparent; color: var(--label);
  font-size: 14px; font-weight: 600; padding: 6px 18px; border-radius: 7px;
  cursor: pointer; transition: all 0.2s ease;
}
.seg-btn.active {
  background: var(--card); color: var(--label);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* ===== Tab bar (iOS style) ===== */
.tab-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: var(--tab-height);
  background: rgba(255,255,255,0.85);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
  display: flex; z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--tertiary);
}
.tab-icon { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: 0.75; transition: all 0.2s ease; }
.tab-label { font-size: 11px; font-weight: 600; }
.tab-item.active { color: var(--accent); }
.tab-item.active .tab-icon { filter: none; opacity: 1; transform: translateY(-1px); }

/* ===== Toast (iOS style pill) ===== */
.toast {
  position: fixed; bottom: calc(var(--tab-height) + 16px); left: 50%; transform: translateX(-50%);
  background: rgba(28,28,30,0.92);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  color: #fff; padding: 12px 22px; border-radius: 99px;
  font-size: 14px; font-weight: 500; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  max-width: 88%; text-align: center;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* View transition */
.view { animation: view-in 0.25s ease; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
