/* ==========================================================================
   MAYOR OF AGRO - COMPONENTS STYLESHEET
   ========================================================================== */

/* -------------------------------------------------------------
   Buttons
   ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
  filter: brightness(1.05);
}

.btn-gold {
  background: var(--gold-gradient);
  color: #1a1500;
  box-shadow: 0 4px 14px var(--gold-glow);
  font-weight: 700;
}
.btn-gold:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: var(--danger-bg);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}
.btn-icon-only:hover:not(:disabled) {
  color: var(--text-main);
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.1);
}

/* Disabled & Read-Only Buttons (for Viewer role) */
.btn:disabled,
.btn.disabled,
[data-requires-role].rbac-disabled {
  opacity: 0.45;
  cursor: not-allowed !important;
  pointer-events: none !important;
  filter: grayscale(0.5);
}

/* -------------------------------------------------------------
   KPI & Stat Cards
   ------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-normal), border-color var(--transition-normal);
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
}

.stat-card.gold-accent {
  border-color: rgba(245, 158, 11, 0.25);
}
.stat-card.gold-accent::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gold-gradient);
}

.stat-card.emerald-accent::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
}

.stat-card.danger-accent::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #ef4444, #f43f5e);
}

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

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-icon-wrap.primary {
  background: var(--primary-glow);
  color: var(--primary-light);
}
.stat-icon-wrap.gold {
  background: var(--gold-glow);
  color: var(--gold-light);
}
.stat-icon-wrap.danger {
  background: var(--danger-bg);
  color: #f87171;
}
.stat-icon-wrap.info {
  background: var(--info-bg);
  color: #60a5fa;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.2;
}

.stat-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.72rem;
}
.stat-badge.positive {
  background: var(--success-bg);
  color: var(--primary-light);
}
.stat-badge.negative {
  background: var(--danger-bg);
  color: #f87171;
}

/* -------------------------------------------------------------
   Panels, Cards & Content Sections
   ------------------------------------------------------------- */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* -------------------------------------------------------------
   Tables
   ------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

/* Ensure wide data tables in scrollable wrappers keep reasonable minimum width and don't crush cells */
.expenses-table {
  min-width: 1060px;
}

.sales-table {
  min-width: 1020px;
}

.store-sales-table {
  min-width: 980px;
}

.dashboard-recent-sales-table {
  min-width: 780px;
}

.data-table th {
  background: rgba(0, 0, 0, 0.35);
  padding: 13px 16px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  vertical-align: top;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* -------------------------------------------------------------
   Professional Item Note & Callout Component
   ------------------------------------------------------------- */
.item-note-wrap {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.75rem;
  line-height: 1.42;
  color: #cbd5e1;
  max-width: 100%;
  min-width: 0;
  width: fit-content;
  transition: all var(--transition-fast);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}

.item-note-wrap:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}

.item-note-icon {
  flex-shrink: 0;
  margin-top: 2px;
  opacity: 0.9;
}

.item-note-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1.35;
}

.item-note-body {
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
  color: #e2e8f0;
  font-weight: 400;
  flex: 1;
}

.item-note-toggle-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
  line-height: 1.35;
  transition: all var(--transition-fast);
}

.item-note-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

/* Tone Variants */
.item-note-expense {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.22);
}
.item-note-expense .item-note-icon {
  color: #fbbf24;
}
.item-note-expense .item-note-tag {
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.item-note-expense:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
}

.item-note-sale {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.22);
}
.item-note-sale .item-note-icon {
  color: #34d399;
}
.item-note-sale .item-note-tag {
  background: rgba(16, 185, 129, 0.18);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.item-note-sale:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.35);
}

.item-note-store {
  background: rgba(59, 130, 246, 0.06);
  border-color: rgba(59, 130, 246, 0.22);
}
.item-note-store .item-note-icon {
  color: #60a5fa;
}
.item-note-store .item-note-tag {
  background: rgba(59, 130, 246, 0.18);
  color: #bfdbfe;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.item-note-store:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.35);
}

.item-note-neutral {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.1);
}
.item-note-neutral .item-note-icon {
  color: #94a3b8;
}
.item-note-neutral .item-note-tag {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.item-note-neutral:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}

/* -------------------------------------------------------------
   Filters & Search Bars
   ------------------------------------------------------------- */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 1rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.search-input-wrap .form-input {
  padding-left: 40px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.02);
  cursor: not-allowed;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* -------------------------------------------------------------
   Badges & Pills
   ------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.badge-in-stock {
  background: var(--success-bg);
  color: var(--primary-light);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-low-stock {
  background: var(--warning-bg);
  color: var(--gold-light);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-out-of-stock {
  background: var(--danger-bg);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-paid {
  background: var(--success-bg);
  color: var(--primary-light);
}
.badge-partial {
  background: var(--warning-bg);
  color: var(--gold-light);
}
.badge-credit {
  background: var(--danger-bg);
  color: #f87171;
}

/* Flock & Broiler Stock Age Styles */
.flock-age-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--primary-light);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.stage-starter {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.stage-grower {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.stage-finisher {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.12);
}

.stage-overtarget {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.stage-neutral {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.batch-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition-fast);
}

.batch-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(16, 185, 129, 0.3);
}


/* -------------------------------------------------------------
   Products Grid
   ------------------------------------------------------------- */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 22px;
  margin-bottom: 30px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: all var(--transition-normal);
}

.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.product-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.product-category-chip {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.product-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.product-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.4;
  min-height: 38px;
}

.product-metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 12px;
  gap: 12px;
}

.product-metric-col {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.metric-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.product-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* -------------------------------------------------------------
   Modal Dialogs
   ------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

/* Stacked sub-modals (e.g. editing a flock from within the flock registry modal, or recording mortality) */
#editLayerFlockModal,
#flockMortalityModal,
.modal-backdrop.modal-stacked {
  z-index: 1100;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 580px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-backdrop.open .modal-dialog {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close-btn:hover {
  color: #ffffff;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
  flex-shrink: 0;
}

/* -------------------------------------------------------------
   Toasts Notification
   ------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 150;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #111e18;
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #ffffff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 420px;
  transform: translateY(20px);
  opacity: 0;
  transition: all var(--transition-normal);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  background: #1e1112;
}

.toast.warning {
  border-color: rgba(245, 158, 11, 0.4);
  background: #1e1910;
}

/* -------------------------------------------------------------
   Financial Statement Grid
   ------------------------------------------------------------- */
.pnl-statement-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 28px;
}

.pnl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.pnl-row.header {
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
  border-bottom: 2px solid var(--border-color);
}

.pnl-row.sub-item {
  padding-left: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pnl-row.total {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
  border-top: 2px solid rgba(16, 185, 129, 0.4);
  border-bottom: none;
  margin-top: 10px;
  padding-top: 18px;
}

/* -------------------------------------------------------------
   Role Permission Matrix Table
   ------------------------------------------------------------- */
.rbac-matrix-table td {
  text-align: center;
}
.rbac-matrix-table td:first-child {
  text-align: left;
  font-weight: 600;
}
.check-icon {
  color: var(--primary-light);
  font-weight: 700;
}
.cross-icon {
  color: #f87171;
  font-weight: 700;
}

/* -------------------------------------------------------------
   Mobile Responsive Rules for Components & Modals
   ------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Form Inputs on Mobile: 16px font-size prevents iOS Safari zoom */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px;
    min-height: 44px;
  }

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

  /* Filter Toolbar on Mobile */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-input-wrap {
    min-width: 100%;
    width: 100%;
  }

  .filter-bar .form-select {
    width: 100% !important;
  }

  /* Products Grid on Mobile */
  .products-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .product-card {
    padding: 18px 16px;
  }

  .product-card-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .product-card-actions .btn:not(.btn-icon-only):not([title*="Delete"]):not([title*="delete"]) {
    flex: 1;
    min-width: 90px;
    justify-content: center;
    padding: 8px 10px;
  }

  .product-card-actions .btn.btn-icon-only,
  .product-card-actions .btn[title*="Delete"],
  .product-card-actions .btn[title*="delete"] {
    flex: 0 0 38px !important;
    min-width: 38px !important;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Tables & Responsive Containers */
  .card-panel {
    padding: 16px 14px;
  }

  .table-responsive {
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* Modals on Mobile: Thumb-friendly bottom-sheet */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal-dialog {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 92dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
    margin: 0;
    border-bottom: none;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .modal-dialog form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-title {
    font-size: 1.15rem;
  }

  .modal-body {
    padding: 16px;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 12px 16px max(16px, env(safe-area-inset-bottom)) 16px;
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
    font-size: 0.92rem;
  }

  /* Toasts on Mobile */
  .toast-container {
    left: 14px;
    right: 14px;
    bottom: 16px;
  }

  .toast {
    min-width: unset;
    width: 100%;
    max-width: 100%;
    padding: 12px 16px;
    font-size: 0.84rem;
  }

  /* P&L Statement Card */
  .pnl-statement-card {
    padding: 18px 14px;
  }

  .pnl-row {
    padding: 10px 0;
    font-size: 0.82rem;
  }

  .pnl-row.sub-item {
    padding-left: 10px;
  }

  .pnl-row.total {
    font-size: 1.15rem;
  }
}

/* ===================================================
   Expense Category Breakdown & Period Filter Styles
   =================================================== */
.period-selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 20px;
}

.period-pills-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.period-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.period-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.period-pill.active {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.2) 0%, rgba(245, 158, 11, 0.28) 100%);
  color: #fbbf24;
  border-color: var(--gold);
  font-weight: 700;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}

.category-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.category-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.category-card.selected {
  border-color: var(--gold);
  background: rgba(234, 179, 8, 0.08);
  box-shadow: 0 0 16px rgba(234, 179, 8, 0.18);
}

.category-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  transition: width 0.4s ease;
}

.flock-tab-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.flock-tab-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.flock-tab-pill.active {
  background: rgba(234, 179, 8, 0.18);
  color: var(--gold);
  border-color: rgba(234, 179, 8, 0.4);
  font-weight: 700;
}

@media (max-width: 768px) {
  .period-selector-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 14px;
  }

  .period-pills-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .period-pills-wrap::-webkit-scrollbar {
    display: none;
  }

  .period-pill {
    flex-shrink: 0;
    padding: 7px 14px;
  }

  .category-breakdown-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .flock-tabs-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .flock-tabs-wrap::-webkit-scrollbar {
    display: none;
  }

  .flock-tab-pill {
    flex-shrink: 0;
    padding: 6px 14px;
  }

  .flocks-card-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}
