.open > .dropdown-menu {
  display: block;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bs-tertiary-bg);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--bs-secondary-color);
  border-radius: 4px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bs-body-color);
}

::-webkit-scrollbar-corner {
  background: var(--bs-tertiary-bg);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bs-secondary-color) var(--bs-tertiary-bg);
}

.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.item-list {
  flex: 1;
  overflow-y: auto;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.list-group-item {
  position: relative;
  padding: 0.6rem 1rem;
  transition: background-color 0.2s ease;
  border-bottom: none;
}

.list-group-item.has-divider {
  border-top: 1px solid var(--bs-border-color);
  margin-top: 0.5rem;
  padding-top: 0.8rem;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

.btn-sm i {
  font-size: 1rem;
}

.list-group-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.list-group-item.focused,
.list-group-item:focus {
  outline: 2px solid var(--bs-focus-color);
  outline-offset: -2px;
  background-color: rgba(255, 255, 255, 0.08);
}

/* Month Selector */
.month-selector {
  font-size: 1.3rem;
  font-weight: 600;
  align-items: center;
}

.month-selector .btn-link {
  color: var(--bs-body-color);
  font-weight: 600;
  font-size: 1.3rem;
  position: relative;
}

.month-selector .btn-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bs-primary);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.month-selector .btn-link:hover::after {
  transform: scaleX(1);
}

.month-selector .btn-outline-secondary {
  border: none;
  padding: 0.25rem 0.5rem;
  font-size: 1.3rem;
  background: transparent !important;
}

.month-selector .btn-outline-secondary i {
  font-size: 1.5rem;
}

.month-selector .btn-outline-secondary:hover i {
  font-weight: bold;
}

/* Finance Item Layout */
.finance-item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.list-group-item.selected {
  background-color: rgba(var(--bs-primary-rgb), 0.15) !important;
  border-color: var(--bs-primary) !important;
}

.item-day {
  font-weight: 600;
  min-width: 2rem;
  text-align: center;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--bs-border-color);
  border-radius: 0.375rem;
}

.item-day-placeholder {
  min-width: 2rem;
  width: 2rem;
  height: 2rem;
}

.item-date {
  font-weight: 600;
  min-width: 4rem;
  text-align: center;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border: 2px solid var(--bs-border-color);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.item-date:hover {
  background: var(--bs-tertiary-bg);
  border-color: var(--bs-primary);
}

.item-amount {
  font-weight: 600;
  min-width: 4.5rem;
  text-align: right;
  font-size: 0.95rem;
  align-self: center;
}

.item-amount.positive {
  color: #4caf50;
}

.item-amount.negative {
  color: white;
}

.item-description {
  min-width: 0;
  word-break: break-word;
  font-size: 0.95rem;
  align-self: center;
  margin-left: 0.75rem;
}

.item-category {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.item-period {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  cursor: help;
  font-family: monospace;
  display: flex;
  align-items: center;
  gap: 0.1rem;
  margin-left: 0.5rem;
}

.item-actions {
  display: flex;
  gap: 0.15rem;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  min-width: 4rem;
  visibility: hidden;
}

.item-actions:not(:empty) {
  visibility: visible;
}

.spacer {
  flex: 1;
}

.list-group-item:hover .item-actions,
.list-group-item:focus-within .item-actions {
  opacity: 1;
  pointer-events: auto;
}

.item-actions button {
  padding: 0.35rem 0.45rem;
  font-size: 0.95rem;
  line-height: 1;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: background-color 0.15s ease;
}

.item-actions button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.item-actions button:focus {
  outline: 1px solid var(--bs-focus-color);
}

/* FAB */
.fab-container {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1001;
}

/* Bulk Action Bar */
.bulk-action-bar {
  position: relative;
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  z-index: 999;
  padding: 1rem;
}

.bulk-action-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.fab {
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 50%;
  font-size: 1.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.fab-secondary {
  font-size: 1.25rem;
}

/* Stats Pane */
.stats-pane {
  position: relative;
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  max-height: 2.5rem;
  overflow: hidden;
  transition: max-height 0.3s ease;
  z-index: 999;
}

.stats-pane.open {
  max-height: 50vh;
}

.stats-pane.open {
  transform: translateY(0);
}

.stats-handle {
  height: 2.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid var(--bs-border-color);
}

.handle-bar {
  width: 3rem;
  height: 0.3rem;
  background: var(--bs-secondary-color);
  border-radius: 2px;
}

.stats-content {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Stats Overview Cards */
.stats-overview {
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bs-secondary-color);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--bs-body-color);
}

.stat-income .stat-value {
  color: #4caf50;
}

.stat-expenses .stat-value {
  color: #e89892;
}

.stat-positive .stat-value {
  color: #4caf50;
}

.stat-negative .stat-value {
  color: #e89892;
}

.stat-transactions .stat-value {
  color: var(--bs-primary);
}

.stat-sublabel {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--bs-secondary-color);
}

/* Category Breakdown */
.category-breakdown h6,
.top-categories h6,
.trends-chart h6,
.monthly-comparison h6 {
  font-weight: 600;
  color: var(--bs-body-color);
  border-bottom: 1px solid var(--bs-border-color);
  padding-bottom: 0.5rem;
}

.category-bar {
  margin-bottom: 1rem;
}

.category-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.category-name .bi-arrow-repeat {
  font-size: 0.75rem;
  opacity: 0.7;
}

.category-amount {
  font-weight: 600;
  font-size: 0.9rem;
}

.category-bars .progress {
  background-color: var(--bs-border-color);
  border-radius: 0.25rem;
}

.category-bars .progress-bar {
  transition: width 0.5s ease;
}

/* Monthly Comparison */
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.comparison-item {
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 1rem;
}

.comparison-label {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
  margin-bottom: 0.5rem;
}

.comparison-values {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.comparison-current {
  font-weight: 600;
  font-size: 1.1rem;
}

.comparison-arrow {
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Top Categories */
.top-category-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.top-category-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  border-left: 4px solid;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  transition: transform 0.15s ease;
}

.top-category-item:hover {
  transform: translateX(4px);
}

.top-category-rank {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--bs-border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--bs-secondary-color);
  flex-shrink: 0;
}

.top-category-info {
  flex: 1;
  min-width: 0;
}

.top-category-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.top-category-name .bi-arrow-repeat {
  font-size: 0.75rem;
  opacity: 0.7;
}

.top-category-details {
  display: flex;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}

.top-category-amount {
  font-weight: 600;
  color: var(--bs-body-color);
}

.top-category-percent {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--bs-primary);
  flex-shrink: 0;
}

/* Pie Chart */
.pie-chart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
}

.pie-chart-container canvas {
  max-width: 300px;
  height: auto;
  max-height: 300px;
}

/* Trends Chart */
.trends-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
}

.trends-chart canvas {
  max-width: 100%;
  height: auto;
  max-height: 300px;
  background: var(--bs-tertiary-bg);
  border-radius: 0.5rem;
  padding: 0.5rem;
}

/* Monthly Grid */
.monthly-grid .table {
  font-size: 0.9rem;
}

.monthly-grid .table th {
  font-weight: 600;
  color: var(--bs-secondary-color);
  border-bottom: 2px solid var(--bs-border-color);
}

.monthly-grid .table td {
  vertical-align: middle;
}

/* Date Range */
.date-range {
  padding: 0.75rem;
  background: var(--bs-tertiary-bg);
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
}

/* Tab Styling */
.stats-content .nav-tabs {
  border-bottom: 2px solid var(--bs-border-color);
}

.stats-content .nav-link {
  color: var(--bs-secondary-color);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.stats-content .nav-link:hover {
  color: var(--bs-body-color);
  border-bottom-color: var(--bs-border-color);
}

.stats-content .nav-link.active {
  color: var(--bs-primary);
  border-bottom-color: var(--bs-primary);
  background: transparent;
}

.stats-content .tab-content {
  padding-top: 1rem;
}

/* Stats pane expand state */
.stats-pane.open {
  max-height: 85vh;
}

.stats-pane.open .stats-content {
  max-height: calc(85vh - 2.5rem);
}

/* Category Filter */
.category-filter {
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

.category-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-filter-pill {
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--bs-border-color);
  color: var(--bs-secondary-color);
  background: var(--bs-body-bg);
  transition: all 0.15s ease;
}

.category-filter-pill:hover {
  opacity: 0.8;
}

.category-filter-pill.active {
  font-weight: 600;
  border-color: transparent;
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Calendar Grid */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
}

.calendar-day {
  height: 2.25rem;
  font-size: 0.9rem;
  padding: 0;
  transition: all 0.15s ease;
}

.calendar-day:hover:not(.btn-primary) {
  background: var(--bs-tertiary-bg);
}

.calendar-day.btn-primary {
  color: #333;
  transform: scale(1.05);
}

.calendar-day:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Category Pills */
.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.category-pill {
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  border: none;
  color: var(--bs-body-color);
  background: var(--bs-tertiary-bg);
  transition: all 0.15s ease;
}

.category-pill:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.category-pill.selected {
  font-weight: 600;
  color: #333;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Category Box */
.category-box {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 1rem;
  background: transparent;
}

/* Date Box */
.date-box {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 1rem;
  background: transparent;
}

.quick-add-format {
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
  margin-bottom: 0.5rem;
  text-align: center;
}

.quick-add-format + .validation-status {
  margin-top: 0.5rem;
}

/* Date Chevrons */
.date-chevron {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--bs-body-color);
  font-size: 1.5rem;
  line-height: 1;
}

.date-chevron:hover {
  background: transparent;
  color: var(--bs-body-color);
}

/* Modal improvements */
.modal-content {
  border-radius: 0.75rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

/* Search input group fix */
.input-group {
  flex-wrap: nowrap;
}

.input-group > .form-control {
  border-radius: 0.5rem 0 0 0.5rem !important;
}

.input-group > .btn {
  border-left: none;
  border-radius: 0 0.5rem 0.5rem 0 !important;
}

.input-group > .btn.btn-primary {
  color: #333 !important;
}

/* Sort button active state */
.navbar-collapse .btn:active {
  background-color: var(--bs-tertiary-bg);
}

/* Selection mode button icon color when active */
.navbar-collapse .btn-primary {
  color: #333 !important;
}

.modal-header {
  border-bottom: 1px solid var(--bs-border-color);
  padding: 1rem 1.25rem;
}

.modal-header.bg-success-subtle {
  background-color: #0a3d1e !important;
  color: #fff !important;
}

.modal-body {
  padding: 1.25rem;
}

.modal-body .input-group {
  flex-wrap: nowrap;
}

.modal-body .input-group .form-control {
  border-radius: 0 0.5rem 0.5rem 0 !important;
}

.modal-body .input-group .btn {
  border-left: 1px solid var(--bs-border-color);
  border-radius: 0.5rem 0 0 0.5rem !important;
}

/* Border label */
.border-label-wrapper {
  position: relative;
}

.border-label-wrapper .form-control {
  padding-top: 0.75rem;
}

.border-label {
  position: absolute;
  top: 0;
  left: 0.75rem;
  transform: translateY(-50%);
  background: var(--bs-body-bg);
  padding: 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--bs-secondary-color);
  pointer-events: none;
  border-radius: 0.25rem;
}

.border-label-group .border-label-wrapper {
  flex: 1;
}

.border-label-group .border-label {
  left: 1rem;
}

.modal-footer {
  border-top: 1px solid var(--bs-border-color);
  padding: 1rem 1.25rem;
}

.modal-footer.bg-success-subtle {
  background-color: #0a3d1e !important;
}

.modal-content.bg-success-subtle {
  background-color: #0a2a15 !important;
}

.modal-content.bg-success-subtle .form-control {
  color: #fff !important;
  background: transparent !important;
  border-color: rgba(255,255,255,0.3) !important;
}

.modal-content.bg-success-subtle .border-label {
  background: #0a2a15;
  color: #fff;
}

.modal-content.bg-success-subtle .category-box,
.modal-content.bg-success-subtle .date-box {
  background: transparent;
  border-color: rgba(255,255,255,0.3);
}

.text-success {
  color: #4caf50 !important;
}

.form-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.form-control {
  border-radius: 0.5rem;
}

.input-group .btn {
  border-radius: 0.5rem 0 0 0.5rem;
}

.input-group .form-control {
  border-radius: 0 0.5rem 0.5rem 0;
}

/* Validation Status */
.validation-status {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  background: var(--bs-tertiary-bg);
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
}

/* Month Dropdown */
.month-dropdown {
  width: 280px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  border: 1px solid var(--bs-border-color);
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

#copyModal .month-grid {
  margin-top: 1rem;
}

/* Navbar Toggler */
.navbar-toggler {
  position: absolute !important;
  right: 1rem;
  top: 0.5rem;
  z-index: 1000;
}

.month-dropdown-content {
  width: 100%;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.month-grid-item {
  padding: 0.5rem;
  font-size: 0.85rem;
}

.month-grid-item.btn-primary {
  color: #333;
}

.empty-state,
.loading-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--bs-secondary-color);
  font-size: 1rem;
}

.loading-state .spinner-border {
  width: 2.5rem;
  height: 2.5rem;
}

@media (max-width: 576px) {
  .item-actions {
    display: none;
  }

  .month-selector {
    font-size: 1rem;
  }

  .list-group-item {
    padding: 0.75rem 0.75rem;
  }

  .finance-item-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .item-day {
    min-width: 1.75rem;
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.85rem;
  }

  .item-day-placeholder {
    min-width: 1.75rem;
    width: 1.75rem;
    height: 1.75rem;
  }

  .item-date {
    min-width: 3.5rem;
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
  }

  .item-amount {
    min-width: 3rem;
    font-size: 0.9rem;
  }

  .item-description {
    min-width: 0;
    font-size: 0.9rem;
    order: 2;
  }

  .item-period {
    order: 3;
  }

  .item-category {
    font-size: 0.75rem;
    order: 4;
    margin-left: auto;
  }

  .spacer {
    display: none;
  }

  .fab-container {
    bottom: 4.5rem;
    right: 1rem;
  }

  .fab {
    width: 3.25rem;
    height: 3.25rem;
    font-size: 1.25rem;
  }

  .navbar-collapse .form-control {
    flex: 1;
    min-width: 0;
  }

  .navbar-collapse {
    width: 100%;
  }

  .navbar-collapse > div {
    width: 100%;
  }

  .category-pills {
    gap: 0.4rem;
  }

  .category-pill {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }

  .calendar-grid {
    gap: 0.25rem;
  }

  .calendar-day {
    height: 2rem;
    font-size: 0.85rem;
  }
}

@media (min-width: 992px) {
  .navbar-collapse .form-control {
    width: auto !important;
  }
}
