/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: #f2f2f7;
  color: #1c1c1e;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
  margin-top: 50px;
}

/* ===== HEADER (iOS Style) ===== */
.site-header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: 12px 0 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  position: fixed;
  width: 100%;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1c1c1e;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo i {
  font-size: 1.4rem;
  color: #007aff;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f2f2f7;
  padding: 4px 12px 4px 8px;
  border-radius: 20px;
}
.user-badge i {
  color: #007aff;
  font-size: 0.9rem;
}
.user-badge span {
  font-size: 0.75rem;
  font-weight: 500;
  color: #1c1c1e;
}

/* ===== iOS HOME SCREEN GRID ===== */
.home-screen {
  padding: 16px 0 20px;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #8e8e93;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 4px 6px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  padding: 12px 4px;
  border-radius: 16px;
  transition: transform 0.15s ease;
  background: transparent;
}
.app-icon:active {
  transform: scale(0.92);
}

.app-icon .icon-wrapper {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  margin-bottom: 6px;
  transition: all 0.2s;
}

/* App Icon Colors */
.app-icon .icon-dashboard { background: linear-gradient(135deg, #007aff, #0055d4); }
.app-icon .icon-income { background: linear-gradient(135deg, #34c759, #28a745); }
.app-icon .icon-expenses { background: linear-gradient(135deg, #ff3b30, #d63031); }
.app-icon .icon-debts { background: linear-gradient(135deg, #ff9500, #e67e22); }
.app-icon .icon-credits { background: linear-gradient(135deg, #af52de, #8e44ad); }
.app-icon .icon-reports { background: linear-gradient(135deg, #5856d6, #6c5ce7); }
.app-icon .icon-transactions { background: linear-gradient(135deg, #00c7be, #00b894); }
.app-icon .icon-settings { background: linear-gradient(135deg, #8e8e93, #636366); }

.app-icon .app-label {
  font-size: 0.6rem;
  font-weight: 500;
  color: #1c1c1e;
  text-align: center;
  line-height: 1.2;
  max-width: 64px;
}

/* ===== BOTTOM TAB BAR (iOS Style) ===== */
.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  padding: 6px 0 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 100;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #8e8e93;
  font-size: 0.5rem;
  font-weight: 500;
  gap: 2px;
  padding: 4px 0;
  transition: color 0.2s;
  position: relative;
}
.tab-item i {
  font-size: 1.3rem;
}
.tab-item.active {
  color: #007aff;
}
.tab-item .badge {
  position: absolute;
  top: 2px;
  right: 50%;
  transform: translateX(calc(50% + 16px));
  background: #ff3b30;
  color: white;
  font-size: 0.5rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

/* ===== PAGE CONTENT ===== */
.page-content {
  flex: 1;
  padding: 12px 0 80px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1c1c1e;
  margin-bottom: 2px;
}
.subtitle {
  font-size: 0.8rem;
  color: #8e8e93;
  margin-bottom: 16px;
}

/* ===== STATS CARDS (iOS Style) ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: white;
  border-radius: 14px;
  padding: 14px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.stat-card .label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8e8e93;
  font-weight: 600;
}
.stat-card .value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1c1c1e;
  margin-top: 2px;
}
.stat-card .change {
  font-size: 0.65rem;
  margin-top: 2px;
}
.change.positive { color: #34c759; }
.change.negative { color: #ff3b30; }

.stat-card.highlight {
  background: linear-gradient(135deg, #007aff, #0055d4);
  border-color: transparent;
}
.stat-card.highlight .label {
  color: rgba(255, 255, 255, 0.7);
}
.stat-card.highlight .value {
  color: white;
}

/* ===== CARDS ===== */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.card {
  background: white;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.card h4 {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: #8e8e93;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.card .amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1c1c1e;
}
.card .amount.income { color: #34c759; }
.card .amount.expense { color: #ff3b30; }

/* ===== SECTION CONTAINERS ===== */
.section-container {
  background: white;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.section-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1c1c1e;
}
.section-header a {
  font-size: 0.7rem;
  color: #007aff;
  text-decoration: none;
  font-weight: 500;
}

/* ===== TRANSACTION ITEMS ===== */
.tx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f2f2f7;
}
.tx-item:last-child {
  border-bottom: none;
}
.tx-left .tx-title {
  font-weight: 500;
  font-size: 0.85rem;
  color: #1c1c1e;
}
.tx-left .tx-meta {
  font-size: 0.65rem;
  color: #8e8e93;
  display: flex;
  gap: 6px;
  margin-top: 1px;
}
.tx-right {
  font-weight: 600;
  font-size: 0.9rem;
}
.tx-right.income { color: #34c759; }
.tx-right.expense { color: #ff3b30; }

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #1c1c1e;
  margin-bottom: 4px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #f8f8fa;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: #007aff;
  background: white;
}
.form-group textarea {
  min-height: 60px;
  resize: vertical;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}
.btn-primary {
  background: #007aff;
  color: white;
}
.btn-primary:hover {
  background: #0055d4;
}
.btn-success {
  background: #34c759;
  color: white;
}
.btn-success:hover {
  background: #28a745;
}
.btn-danger {
  background: #ff3b30;
  color: white;
}
.btn-danger:hover {
  background: #d63031;
}
.btn-outline {
  background: transparent;
  color: #007aff;
  border: 1px solid #007aff;
}
.btn-outline:hover {
  background: #f0f7ff;
}
.btn-sm {
  padding: 6px 14px;
  font-size: 0.7rem;
}
.btn-block {
  width: 100%;
}

/* ===== DEBT/CREDIT ITEMS ===== */
.debt-item, .credit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f2f2f7;
}
.debt-item:last-child, .credit-item:last-child {
  border-bottom: none;
}
.debt-info .debt-title {
  font-weight: 500;
  font-size: 0.85rem;
}
.debt-info .debt-meta {
  font-size: 0.65rem;
  color: #8e8e93;
}
.debt-amount {
  text-align: right;
}
.debt-amount .total {
  font-weight: 600;
}
.debt-amount .remaining {
  font-size: 0.7rem;
  color: #8e8e93;
}
.debt-amount .paid {
  font-size: 0.7rem;
  color: #34c759;
}
.progress-bar {
  width: 100%;
  height: 4px;
  background: #e5e5ea;
  border-radius: 4px;
  margin-top: 4px;
  overflow: hidden;
}
.progress-bar .progress {
  height: 100%;
  background: #34c759;
  border-radius: 4px;
  transition: width 0.3s;
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: white;
  border-radius: 20px 20px 0 0;
  max-width: 440px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 20px 30px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-handle {
  width: 36px;
  height: 4px;
  background: #e5e5ea;
  border-radius: 4px;
  margin: -8px auto 16px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #8e8e93;
  padding: 4px 8px;
}

/* ===== FOOTER ===== */
.site-footer {
  background: transparent;
  padding: 12px 0 80px;
  margin-top: 0;
}
.footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}
.footer-inner span {
  font-size: 0.6rem;
  color: #8e8e93;
}
.footer-links {
  display: flex;
  gap: 12px;
}
.footer-links a {
  font-size: 0.6rem;
  color: #8e8e93;
  text-decoration: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 380px) {
  .app-grid { gap: 8px; }
  .app-icon .icon-wrapper { width: 50px; height: 50px; font-size: 1.5rem; }
  .app-icon .app-label { font-size: 0.5rem; }
}

@media (min-width: 600px) {
  .container { max-width: 560px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .card-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== UTILITY ===== */
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }
.text-center { text-align: center; }
.text-muted { color: #8e8e93; }
.text-success { color: #34c759; }
.text-danger { color: #ff3b30; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }