* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 10px;
}

@media (min-width: 768px) {
  body {
    padding: 20px;
  }
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  overflow-x: hidden;
}

/* Auth Styles */
.auth-box {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  max-width: 400px;
  margin: 20px auto;
}

@media (min-width: 768px) {
  .auth-box {
    padding: 40px;
    margin: 100px auto;
  }
}

.auth-box h1 {
  text-align: center;
  color: #667eea;
  margin-bottom: 20px;
  font-size: 24px;
}

@media (min-width: 768px) {
  .auth-box h1 {
    margin-bottom: 30px;
    font-size: 32px;
  }
}

.form-container h2 {
  margin-bottom: 20px;
  color: #333;
}

.form-container input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.form-container button {
  width: 100%;
  padding: 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
}

.form-container button:hover {
  background: #5568d3;
}

.form-container p {
  text-align: center;
  margin-top: 15px;
  color: #666;
}

.form-container a {
  color: #667eea;
  text-decoration: none;
}

/* App Styles */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.header h1 {
  color: #667eea;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  .header {
    padding: 20px;
    margin-bottom: 20px;
  }
  
  .header h1 {
    font-size: 28px;
  }
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-shrink: 0;
}

.user-info span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.btn-secondary {
  padding: 6px 12px;
  background: #f0f0f0;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
  font-size: 13px;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .user-info {
    gap: 15px;
    font-size: 16px;
  }
  
  .user-info span {
    max-width: none;
  }
  
  .btn-secondary {
    padding: 8px 16px;
    font-size: 14px;
  }
}

.btn-secondary:hover {
  background: #e0e0e0;
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 480px) {
  .summary-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .summary-cards {
    gap: 20px;
    margin-bottom: 20px;
  }
}

.card {
  background: white;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

@media (min-width: 768px) {
  .card {
    padding: 20px;
  }
}

.card.income {
  border-left: 4px solid #10b981;
}

.card.expense {
  border-left: 4px solid #ef4444;
}

.card.balance {
  border-left: 4px solid #667eea;
}

.card h3 {
  color: #666;
  font-size: 12px;
  margin-bottom: 8px;
}

.card .amount {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

@media (min-width: 768px) {
  .card h3 {
    font-size: 14px;
    margin-bottom: 10px;
  }
  
  .card .amount {
    font-size: 24px;
  }
}

/* Form Styles */
form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 480px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 768px) {
  form {
    gap: 15px;
  }
  
  .form-row {
    gap: 15px;
  }
}

input, select, textarea {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
}

@media (min-width: 768px) {
  input, select, textarea {
    font-size: 14px;
  }
}

button[type="submit"] {
  padding: 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
}

button[type="submit"]:hover {
  background: #5568d3;
}

/* Transactions */
.transactions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.transactions-header h2 {
  margin: 0;
}

.transaction-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 8px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s;
  gap: 8px;
}

@media (min-width: 768px) {
  .transaction-item {
    align-items: center;
    padding: 15px;
    gap: 0;
  }
}

.transaction-item:hover {
  background: #f9f9f9;
}

.transaction-info {
  flex: 1;
}

.transaction-category {
  font-weight: bold;
  color: #333;
  font-size: 14px;
}

.transaction-description {
  color: #666;
  font-size: 12px;
  margin-top: 2px;
}

.transaction-date {
  color: #999;
  font-size: 11px;
  margin-top: 2px;
}

.transaction-amount {
  font-size: 16px;
  font-weight: bold;
  margin-right: 8px;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .transaction-category {
    font-size: 16px;
  }
  
  .transaction-description {
    font-size: 14px;
    margin-top: 4px;
  }
  
  .transaction-date {
    font-size: 12px;
    margin-top: 4px;
  }
  
  .transaction-amount {
    font-size: 18px;
    margin-right: 15px;
  }
}

.transaction-amount.income {
  color: #10b981;
}

.transaction-amount.expense {
  color: #ef4444;
}

.transaction-actions {
  display: flex;
  gap: 10px;
}

.btn-delete {
  padding: 6px 10px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .btn-delete {
    padding: 6px 12px;
    font-size: 12px;
  }
}

.btn-delete:hover {
  background: #dc2626;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
}

/* Tambahan untuk mobile */
.card h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

@media (min-width: 768px) {
  .card h2 {
    font-size: 22px;
    margin-bottom: 20px;
  }
}

/* Touch-friendly buttons */
button, .btn-delete, .btn-secondary {
  min-height: 44px;
  touch-action: manipulation;
}

@media (min-width: 768px) {
  button, .btn-delete, .btn-secondary {
    min-height: auto;
  }
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 767px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Category Management */
.form-row-category {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.form-row-category select {
  flex: 1;
}

.btn-icon {
  padding: 12px 16px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.3s;
  white-space: nowrap;
}

.btn-icon:hover {
  background: #5568d3;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  overflow-y: auto;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  min-height: auto;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
}

.modal-body h3 {
  margin-bottom: 12px;
  font-size: 16px;
  color: #333;
}

.categories-section {
  margin-top: 24px;
}

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 6px;
  transition: background 0.2s;
}

.category-item:hover {
  background: #f0f0f0;
}

.category-name {
  font-weight: 500;
  color: #333;
}

.btn-delete-category {
  padding: 6px 12px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.3s;
}

.btn-delete-category:hover {
  background: #dc2626;
}

.empty-categories {
  text-align: center;
  padding: 20px;
  color: #999;
  font-size: 14px;
}


/* Custom Toast Notification */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2000;
  animation: slideIn 0.3s ease-out;
  max-width: 90%;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

.toast.hiding {
  animation: slideOut 0.3s ease-out;
}

.toast-icon {
  font-size: 24px;
  line-height: 1;
}

.toast-message {
  flex: 1;
  color: #333;
  font-size: 14px;
}

.toast-close {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  width: 20px;
  height: 20px;
  min-height: auto;
}

.toast-close:hover {
  color: #333;
}

.toast.success {
  border-left: 4px solid #10b981;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.warning {
  border-left: 4px solid #f59e0b;
}

.toast.info {
  border-left: 4px solid #3b82f6;
}

/* Custom Confirm Dialog */
.confirm-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

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

.confirm-dialog-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.confirm-dialog-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 16px;
}

.confirm-dialog-title {
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 12px;
  color: #333;
}

.confirm-dialog-message {
  text-align: center;
  color: #666;
  margin-bottom: 24px;
  font-size: 14px;
}

.confirm-dialog-buttons {
  display: flex;
  gap: 12px;
}

.confirm-dialog-buttons button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
}

.confirm-btn-cancel {
  background: #f0f0f0;
  color: #333;
}

.confirm-btn-cancel:hover {
  background: #e0e0e0;
}

.confirm-btn-confirm {
  background: #667eea;
  color: white;
}

.confirm-btn-confirm:hover {
  background: #5568d3;
}

.confirm-btn-confirm.danger {
  background: #ef4444;
}

.confirm-btn-confirm.danger:hover {
  background: #dc2626;
}

@media (max-width: 480px) {
  .toast {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
}


/* Input Group with Icons */
.input-group {
  position: relative;
  margin-bottom: 15px;
}

.input-group i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 16px;
}

.input-group input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 0;
}

.form-container input:not(.input-group input) {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

/* Icon spacing in buttons and headers */
button i, h1 i, h2 i, h3 i {
  margin-right: 6px;
}

.user-info i {
  margin-right: 4px;
}


/* Mobile App Layout */
.app-container {
  max-width: 100%;
  margin: 0;
  padding: 0;
  padding-bottom: 70px; /* Space for bottom nav */
  overflow-x: hidden;
}

.app-container .header {
  margin: 0;
  border-radius: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Tab System */
.tab-content {
  padding: 10px;
  overflow-x: hidden;
}

.tab-pane {
  display: none;
  overflow-x: hidden;
}

.tab-pane.active {
  display: block;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  z-index: 1000;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: #999;
  transition: all 0.3s;
  min-height: auto;
}

.nav-item i {
  font-size: 20px;
  margin: 0;
}

.nav-item span {
  font-size: 11px;
}

.nav-item.active {
  color: #667eea;
}

.nav-item:active {
  transform: scale(0.95);
}

/* Report Styles */
.report-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  width: 100%;
}

.report-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  width: 100%;
  box-sizing: border-box;
}

.report-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
}

.report-label i {
  flex-shrink: 0;
}

.report-value {
  font-size: 20px;
  font-weight: bold;
  text-align: left;
}

@media (min-width: 480px) {
  .report-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  
  .report-label {
    font-size: 14px;
  }
  
  .report-value {
    font-size: 18px;
    text-align: right;
  }
}

.report-value.income {
  color: #10b981;
}

.report-value.expense {
  color: #ef4444;
}

.report-value.balance {
  color: #667eea;
}

.category-breakdown {
  margin-top: 24px;
  width: 100%;
  overflow-x: hidden;
}

.category-breakdown h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

.category-item-report {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
  width: 100%;
  box-sizing: border-box;
}

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

.category-item-report > div {
  width: 100%;
  min-width: 0;
}

.category-name-report {
  font-size: 13px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-amount-report {
  font-size: 14px;
  font-weight: bold;
  color: #ef4444;
  white-space: nowrap;
  margin-left: 8px;
}

@media (min-width: 480px) {
  .category-name-report {
    font-size: 14px;
  }
  
  .category-amount-report {
    font-size: 16px;
  }
}

.category-bar {
  width: 100%;
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #dc2626);
  border-radius: 4px;
  transition: width 0.3s;
}

@media (min-width: 768px) {
  .app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 90px;
  }
  
  .app-container .header {
    border-radius: 12px;
    position: relative;
  }
  
  .tab-content {
    padding: 0;
  }
  
  .bottom-nav {
    max-width: 1000px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 12px 12px 0 0;
  }
  
  .nav-item i {
    font-size: 24px;
  }
  
  .nav-item span {
    font-size: 12px;
  }
}


/* Force prevent horizontal scroll */
.app-container, .tab-content, .tab-pane, .card, .report-summary, .category-breakdown {
  max-width: 100%;
  overflow-x: hidden !important;
}

.report-item, .category-item-report {
  max-width: 100%;
  overflow: hidden;
}

/* Ensure all text can wrap or truncate */
.report-label, .category-name-report, .category-amount-report, .report-value {
  word-wrap: break-word;
  overflow-wrap: break-word;
}


/* Filter Section */
.filter-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.filter-section select {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

@media (min-width: 480px) {
  .filter-section {
    flex-direction: row;
    align-items: center;
  }
  
  .filter-row {
    flex: 1;
  }
  
  .filter-section > select {
    width: auto;
    min-width: 150px;
  }
}


/* Filters */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.filters select {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

@media (min-width: 768px) {
  .filters {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* Icon Picker */
.icon-picker {
  margin-bottom: 16px;
}

.icon-picker label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.icon-option {
  width: 45px;
  height: 45px;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #666;
  transition: all 0.3s;
  min-height: auto;
  padding: 0;
}

.icon-option:hover {
  border-color: #667eea;
  color: #667eea;
  transform: scale(1.1);
}

.icon-option.active {
  border-color: #667eea;
  background: #667eea;
  color: white;
}

.icon-option i {
  margin: 0;
}
