body {
  margin: 0;
  font-family: Inter, sans-serif;
  background: #f8fafc;
  color: #0f172a;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

@media (min-width: 768px) {
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.site-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.brand {
  font-weight: 700;
  font-size: 1.2rem;
}

.site-header .nav-link {
  color: #475569;
}

.site-header .nav-link:hover,
.site-header .nav-link.active {
  color: #0f172a;
  background: #f8fafc;
}

.logo-icon {
  width: auto;
  height: auto;
  max-height: 38px;
  display: inline-block;
}

.site-header .dropdown-menu {
  min-width: 180px;
}

.menu-button {
  white-space: nowrap;
}

.card {
  border-radius: 1.25rem;
}

.form-control,
.form-select,
textarea {
  border-radius: 1rem;
}

.table-responsive {
  overflow-x: auto;
}

.errors,
.flash-message {
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.flash-message {
  background: #eff6ff;
  border: 1px solid #bae6fd;
  color: #0c4a6e;
}

.flash-notification {
  position: fixed;
  top: 1rem;
  left: 50%;
  right: auto;
  transform: translateX(-50%) translateY(-0.6rem) scale(0.995);
  z-index: 1050;
  max-width: 280px;
  padding: 0.6rem 0.9rem;
  background: rgba(13, 110, 253, 0.95);
  color: #ffffff;
  border-radius: 0.75rem;
  box-shadow: 0 0.5rem 1rem rgba(15, 23, 42, 0.18);
  font-size: 0.86rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  opacity: 0.999; /* visible by default when JS disabled */
  transition: opacity 260ms ease, transform 260ms cubic-bezier(.2,.9,.2,1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap; /* do not wrap text */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* entrance animation when JS adds .show */
.flash-notification.show {
  animation: flashEnter 260ms cubic-bezier(.2,.9,.2,1) both;
}

.flash-notification.hide {
  /* use exit animation to fade/slide up */
  animation: flashExit 260ms cubic-bezier(.2,.9,.2,1) both;
  pointer-events: none;
}

@keyframes flashEnter {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-0.9rem) scale(0.98);
  }
  60% {
    transform: translateX(-50%) translateY(0.18rem) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes flashExit {
  0% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-0.6rem) scale(0.98);
  }
}

/* icon is rendered via inline <i class="bi ..."> element; remove ::before glyph */

.empty {
  text-align: center;
  color: #64748b;
}

.site-footer {
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

.tab-toggle-button {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.tab-toggle-button.active.btn-outline-success {
  background-color: #198754;
  border-color: #198754;
  color: #ffffff;
}

.tab-toggle-button.active.btn-outline-danger {
  background-color: #dc3545;
  border-color: #dc3545;
  color: #ffffff;
}

.tab-toggle-button:not(.active) {
  background-color: transparent;
}

.tab-toggle-button.btn-outline-success:hover:not(.active),
.tab-toggle-button.btn-outline-success:focus-visible:not(.active) {
  color: #198754;
  background-color: rgba(25, 135, 84, 0.08);
  border-color: #198754;
}

.tab-toggle-button.btn-outline-danger:hover:not(.active),
.tab-toggle-button.btn-outline-danger:focus-visible:not(.active) {
  color: #dc3545;
  background-color: rgba(220, 53, 69, 0.08);
  border-color: #dc3545;
}

.currency-select {
  max-width: 91px;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-color: #d1d5db;
  color: #495057;
}

.currency-select:focus {
  box-shadow: 0 0 0 0.15rem rgba(148, 163, 184, 0.25);
}

.form-row-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-row-inline .form-label {
  min-width: 70px;
  width: 70px;
  flex-shrink: 0;
}

.form-row-inline .form-control,
.form-row-inline .form-select,
.form-row-inline .input-group {
  flex: 1;
}

.btn-pill {
  border-radius: 50px !important;
}

.btn {
  border-radius: 50px !important;
}

.checkbox-label {
  align-items: center;
  display: flex;
  gap: 10px;
  color: #334155;
}

.site-footer {
  margin-top: 40px;
  padding: 24px 0;
  color: #475569;
  text-align: center;
}

/* Compact accordion styling for main incomes list */
.compact-accordion .accordion-item {
  border: none; /* remove default item border */
  padding: 0.85rem 0; /* vertical breathing inside each item */
}
.compact-accordion .accordion-item + .accordion-item {
  border-top: 1px solid #eef2f6; /* thin subtle separator between items */
  margin-top: 0; /* small gap between items */
}
/* Hide separator when previous item is expanded (JS will add .expanded class) */
.compact-accordion .accordion-item.expanded + .accordion-item {
  border-top: none;
}

/* Remove any border/line below the header when the item is expanded */
.compact-accordion .accordion-item.expanded > .accordion-header,
.compact-accordion .accordion-item.expanded > .accordion-header .accordion-button {
  border-bottom: none !important;
  box-shadow: none !important;
}

/* Ensure collapse body doesn't draw a top border */
.compact-accordion .accordion-item .accordion-collapse {
  border-top: none !important;
}

/* Prevent focus outlines from showing a hairline under header */
.compact-accordion .accordion-button:focus {
  outline: none !important;
  box-shadow: none !important;
}
/* no bottom border on items; separators appear only between items above */
.compact-accordion .accordion-button {
  padding: 0.45rem 0; /* vertical spacing; left/right zero */
  padding-left: 0; /* align date to edge */
  padding-right: 0; /* let chevron sit at the very edge */
  border: none;
}
.compact-accordion .accordion-button:focus {
  box-shadow: none;
}
.compact-accordion .accordion-date {
  display: inline-block;
  padding-left: 0.5rem;
  color: #ababab;
}
.compact-accordion .accordion-right {
  margin-left: auto;
  padding-right: 0.5rem;
}
.compact-accordion .accordion-button .amount {
  white-space: nowrap;
}

/* Make the accordion chevron size match compact select arrows */
.compact-accordion .accordion-button::after {
  /* explicit size for Bootstrap accordion chevron (SVG background) - font-size doesn't affect it */
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background-size: 1rem 1rem;
  background-repeat: no-repeat;
  background-position: center;
  font-size: 0.8rem; /* keep for cases where icon is text-based */
  margin-left: 0.5rem !important;
  line-height: 1;
}

/* Make payment-type icon slightly smaller and align with amount */
.compact-accordion .accordion-right .bi,
.compact-accordion .accordion-button .bi {
  font-size: 0.95rem;
  line-height: 1;
}

/* Appearance: remove bold formatting for amount and date */
.compact-accordion .amount,
.compact-accordion .accordion-date {
  font-weight: 400;
}

/* Place date adjacent to the accordion chevron */
.compact-accordion .accordion-date {
  margin-left: auto;
  padding-right: 0.25rem;
}

/* Keep header appearance identical when expanded */
.compact-accordion .accordion-button,
.compact-accordion .accordion-button:not(.collapsed) {
  background-color: transparent !important;
  color: inherit !important;
}

/* Match accordion body padding to header paddings */
.compact-accordion .accordion-body {
  padding: 1rem 0; /* same vertical/horizontal as header */
  background-color: transparent;
}

/* Make modals approximately match the site's container width and padding */
.modal-dialog.modal-match-container {
  width: calc(100% - 3rem);
  max-width: 1000px;
  margin: 0.5rem auto;
}
@media (min-width: 1200px) {
  .modal-dialog.modal-match-container {
    max-width: 1140px; /* align with common container max width */
  }
}

/* Full-width section divider that extends to container edges */
.section-divider {
  border: 0;
  border-top: 1px solid var(--bs-green);
  margin: 0.5rem 0 1rem;
  /* extend beyond card padding to align with page container */
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  width: calc(100% + 3rem);
}
@media (min-width: 768px) {
  .section-divider {
    margin-left: -2rem;
    margin-right: -2rem;
    width: calc(100% + 4rem);
  }
}

/* Reduce heavy animations/effects on mobile (improves iOS FPS) */
@media (max-width: 768px) {
  .compact-accordion .accordion-button,
  .compact-accordion .accordion-collapse {
    transition: none !important;
  }
  .flash-notification {
    backdrop-filter: none !important;
    box-shadow: 0 0.25rem 0.5rem rgba(15,23,42,0.08) !important;
  }
  .modal-dialog.modal-match-container {
    transition: none !important;
  }
}

/* Ensure photo lightbox modal displays above the backdrop (fix stacking issues) */
#photoLightboxModal.modal {
  z-index: 2005 !important;
}
#photoLightboxModal .modal-dialog {
  z-index: 2006 !important;
}

/* Photo thumbnail: make image fill the box with cover effect */
.photo-thumb {
  width: 80px;
  height: 80px;
  display: inline-block;
  overflow: hidden;
  border-radius: 6px;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* Lightbox side nav buttons placed outside image area */
.lightbox-inner {
  display: inline-block;
  max-width: calc(100% - 160px); /* leave space for side nav */
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
}
.lightbox-nav.left { left: 8px; }
.lightbox-nav.right { right: 8px; }
.lightbox-nav .btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* For iOS Safari specifically, turn off backdrop-filter and transitions */
@supports (-webkit-overflow-scrolling: touch) {
  .compact-accordion .accordion-button,
  .compact-accordion .accordion-collapse {
    transition: none !important;
    will-change: auto !important;
  }
  .flash-notification {
    backdrop-filter: none !important;
  }
}

.form-title {
  text-transform: uppercase;
}

.form-title.text-success {
  background-color: var(--bs-success);
  color: #ffffff!important;
  padding: 15px;
  border-radius: 15px;
  text-align: center;
}

.form-title.text-danger {
  background-color: var(--bs-danger);
  color: #ffffff!important;
  padding: 15px;
  border-radius: 15px;
  text-align: center;
}

/* tighter textarea used in expense form */
.textarea-tight {
  line-height: 1.15;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

/* Uniform textarea height across the app */
:root {
  --textarea-height: 4.2rem;
}

textarea.form-control {
  height: var(--textarea-height);
  min-height: var(--textarea-height);
  line-height: 1.15;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  resize: vertical;
}

.menu-button {
  padding: 0 10px;
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 0.5rem;
}

.icon-choice-btn {
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  background: #fff;
  min-height: 52px;
}

.icon-choice-btn .bi {
  font-size: 1.2rem;
}

.icon-choice-btn.active,
.icon-choice-btn:hover {
  border-color: #0d6efd;
  background: #eff6ff;
}

.article-item.dragging {
  opacity: 0.6;
}

.drag-handle {
  cursor: grab;
}

.article-icon-trigger .bi {
  font-size: 1.1rem;
}

/* Photo input / preview styles */
.photo-input-wrapper .visually-hidden { display: none !important; }
.photo-input-wrapper #expensePhotosPreview { min-height: 0; flex: 1 1 auto; display: flex; gap: 0.5rem; align-items: center; }
.photo-thumb {
  width: 80px;
  height: 80px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #e6eef6;
}
.photo-thumb img { max-width: 100%; max-height: 100%; display: block; }
.photo-input-wrapper .btn { height: 40px; width: 40px; padding: 0.5rem; display: inline-flex; align-items: center; justify-content: center; }