/* =============================================
   ITEMS PAGE — items.css
   Página de Itens / Estoque (Produtos, Serviços
   e Materiais). Inclui layout, header, tabela,
   badges, modal e campos de formulário.
   ============================================= */

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 0;
}

.page-subtitle {
  font-size: 0.875rem;
  color: #999;
  margin: 0;
}

body.dark .page-subtitle {
  color: #888;
}

/* Primary action button — overrides sistema.css for icon support */
.admin-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 8px;
  transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.admin-button:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 4px 14px rgba(29,78,216,0.4);
  background-color: #1554C8;
}

.admin-button:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ============================================
   ADMIN PANEL CARD
   ============================================ */

.admin-panel {
  border-radius: 14px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}

body.dark .admin-panel {
  background: var(--card-bg);
  border-color: var(--border);
}

/* ============================================
   TABLE CONTROLS BAR
   ============================================ */

.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.search-field {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-field .search-icon {
  position: absolute;
  left: 0.7rem;
  font-size: 1.1rem;
  color: #aaa;
  pointer-events: none;
  line-height: 1;
}

.search-field input {
  padding: 0.55rem 0.9rem 0.55rem 2.3rem;
  min-width: 280px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

body.dark .search-field input {
  background-color: #1A182A;
  border-color: var(--border);
  color: var(--text-color);
}

body.dark .search-field input::placeholder {
  color: #555;
}

/* ============================================
   TABLE
   ============================================ */

/* Override sistema.css gray thead — modern borderless header */
.admin-table thead {
  background-color: transparent;
}
body.dark .admin-table thead {
  background-color: transparent;
}

.admin-table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  color: #999;
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid #e8e8e8;
  white-space: nowrap;
  text-align: left;
}
body.dark .admin-table th {
  color: #666;
  border-bottom-color: #2e2f30;
}

.admin-table td {
  font-size: 0.875rem;
  padding: 0.7rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid #eeeeee;
}
body.dark .admin-table td {
  border-bottom-color: #2e2f30;
}
.admin-table tbody tr:nth-child(even)           { background-color: rgba(0,0,0,0.022); }
body.dark .admin-table tbody tr:nth-child(even) { background-color: rgba(255,255,255,0.022); }
.admin-table tbody tr:hover { background-color: rgba(29,78,216,0.1) !important; }
body.dark .admin-table tbody tr:hover { background-color: rgba(29,78,216,0.08) !important; }

.col-name {
  font-weight: 500;
}

.admin-table th.col-actions,
.admin-table td.col-actions {
  text-align: right;
  white-space: nowrap;
}

/* ============================================
   ICON ACTION BUTTONS
   ============================================ */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 1rem;
  background-color: transparent;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover {
  transform: scale(1.08);
}

.edit-btn {
  color: var(--primary-color);
}

.edit-btn:hover {
  background-color: rgba(29, 78, 216, 0.15);
}

.delete-btn {
  color: #cc4c4c;
}

.delete-btn:hover {
  background-color: rgba(204, 76, 76, 0.12);
}

body.dark .delete-btn {
  color: #ef9a9a;
}

body.dark .delete-btn:hover {
  background-color: rgba(239, 154, 154, 0.1);
}

/* ============================================
   SECONDARY / CANCEL BUTTON
   ============================================ */

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.55rem 1rem;
  background-color: transparent;
  color: var(--text-color);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-secondary:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border-color: #ccc;
}

body.dark .btn-secondary {
  border-color: #555;
  color: var(--text-color);
}

body.dark .btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: #666;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  color: #999;
}

.empty-state i {
  font-size: 3.2rem;
  margin-bottom: 0.85rem;
  opacity: 0.45;
  display: block;
}

.empty-state p {
  margin: 0;
  font-size: 0.95rem;
}

.empty-hint {
  font-size: 0.85rem;
  color: #bbb;
  margin-top: 0.4rem;
}

body.dark .empty-state {
  color: #666;
}

body.dark .empty-hint {
  color: #555;
}

/* ============================================
   TEXT HELPERS
   ============================================ */

.text-muted {
  color: #bbb;
  font-size: inherit;
}

body.dark .text-muted {
  color: #555;
}

/* ============================================
   STOCK STATUS BADGES
   ============================================ */

.stock-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.stock-normal {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.stock-low {
  background-color: #fff3e0;
  color: #e65100;
}

.stock-critical {
  background-color: #ffebee;
  color: #c62828;
}

body.dark .stock-normal {
  background-color: rgba(46, 125, 50, 0.2);
  color: #81c784;
}

body.dark .stock-low {
  background-color: rgba(230, 81, 0, 0.2);
  color: #ffb74d;
}

body.dark .stock-critical {
  background-color: rgba(198, 40, 40, 0.2);
  color: #ef9a9a;
}

/* Service or non-stock-controlled items */
.stock-service {
  background-color: rgba(100, 100, 100, 0.08);
  color: #999;
  font-style: italic;
}

body.dark .stock-service {
  background-color: rgba(255, 255, 255, 0.05);
  color: #555;
}

/* Service or non-stock-controlled items */
.stock-service {
  background-color: rgba(100, 100, 100, 0.08);
  color: #888;
  font-style: italic;
}

body.dark .stock-service {
  background-color: rgba(255, 255, 255, 0.06);
  color: #666;
}

/* ============================================
   ITEM TYPE BADGES
   ============================================ */

.type-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.type-produto {
  background-color: #e3f2fd;
  color: #1565c0;
}

.type-servico {
  background-color: #f3e5f5;
  color: #6a1b9a;
}

.type-material {
  background-color: #e8f5e9;
  color: #1b5e20;
}

body.dark .type-produto {
  background-color: rgba(21, 101, 192, 0.2);
  color: #90caf9;
}

body.dark .type-servico {
  background-color: rgba(106, 27, 154, 0.2);
  color: #ce93d8;
}

body.dark .type-material {
  background-color: rgba(27, 94, 32, 0.2);
  color: #a5d6a7;
}

/* ============================================
   ITEM MODAL — OVERLAY
   ============================================ */

.item-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  backdrop-filter: blur(3px);
}

.item-modal-overlay .item-modal {
  margin: auto;
}

.item-modal-overlay.hidden {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

/* ============================================
   ITEM MODAL — CONTAINER
   ============================================ */

.item-modal {
  width: min(100%, 520px);
  background: var(--sidebar-color);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: slideInModal 0.22s ease-out;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
}

body.dark .item-modal {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

@keyframes slideInModal {
  from {
    transform: scale(0.96) translateY(-16px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.item-modal form {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* ============================================
   ITEM MODAL — HEADER
   ============================================ */

.item-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(
    135deg,
    rgba(29, 78, 216, 0.08) 0%,
    rgba(29, 78, 216, 0.02) 100%
  );
}

body.dark .item-modal-header {
  background: linear-gradient(
    135deg,
    rgba(29, 78, 216, 0.1) 0%,
    rgba(29, 78, 216, 0.03) 100%
  );
  border-bottom-color: var(--border);
}

.item-modal-header h2 {
  margin: 0 0 0.1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-color);
}

.item-modal-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: #999;
}

body.dark .item-modal-subtitle {
  color: #888;
}

/* ============================================
   ITEM MODAL — CLOSE BUTTON
   ============================================ */

.modal-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  background-color: transparent;
  color: var(--text-color);
  font-size: 1.4rem;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 0.1rem;
}

.modal-close-btn:hover {
  background-color: rgba(0, 0, 0, 0.07);
  color: #cc4c4c;
}

body.dark .modal-close-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #ef9a9a;
}

/* ============================================
   ITEM MODAL — SCROLLABLE BODY
   ============================================ */

.item-modal .modal-body {
  padding: 1.35rem 1.35rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex: 1;
}

/* ============================================
   FORM SECTION DIVIDER
   ============================================ */

.form-section-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.85rem 0 0.7rem;
}

.form-section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.form-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #aaa;
  white-space: nowrap;
}

body.dark .form-section-label {
  color: #666;
}

/* ============================================
   ITEM MODAL — FORM FIELDS
   ============================================ */

.item-modal .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}

.item-modal .form-field:last-child {
  margin-bottom: 0;
}

.item-modal .form-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-color);
  letter-spacing: 0.1px;
}

.item-modal .form-field input,
.item-modal .form-field select,
.item-modal .form-field textarea {
  width: 100%;
  padding: 0.58rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--sidebar-color);
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

.item-modal .form-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='%23999' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 16px;
  padding-right: 2.2rem;
  cursor: pointer;
}

.item-modal .form-field textarea {
  resize: vertical;
  min-height: 68px;
  line-height: 1.5;
}

.item-modal .form-field input:focus,
.item-modal .form-field select:focus,
.item-modal .form-field textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

body.dark .item-modal .form-field input,
body.dark .item-modal .form-field select,
body.dark .item-modal .form-field textarea {
  background-color: #2a2b2c;
  border-color: #3a3b3c;
  color: var(--text-color);
}

body.dark .item-modal .form-field input::placeholder,
body.dark .item-modal .form-field textarea::placeholder {
  color: #555;
}

body.dark .item-modal .form-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='%23666' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

body.dark .item-modal .form-field input:focus,
body.dark .item-modal .form-field select:focus,
body.dark .item-modal .form-field textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

/* ============================================
   ITEM MODAL — 2-COLUMN GRID
   ============================================ */

.item-modal .form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.8rem;
}

@media (max-width: 440px) {
  .item-modal .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   TOGGLE SWITCH — controlsStock
   ============================================ */

.form-field-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.9rem;
  background: rgba(29, 78, 216, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.8rem;
}

body.dark .form-field-inline {
  background: rgba(29, 78, 216, 0.05);
  border-color: #3a3b3c;
}

.form-field-inline-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.toggle-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-color);
  cursor: default;
}

.toggle-hint {
  font-size: 0.76rem;
  color: #aaa;
  line-height: 1.4;
}

/* ============================================
   CLICKABLE STOCK BADGE (inline adjust)
   ============================================ */

.stock-status-badge {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.stock-status-badge:hover {
  filter: brightness(0.92);
  box-shadow: 0 0 0 1.5px currentColor;
}

.stock-status-badge .status-badge-chevron {
  font-size: 0.72rem;
  opacity: 0.6;
  transition: opacity 0.15s ease, transform 0.15s ease;
  line-height: 1;
  flex-shrink: 0;
}

.stock-status-badge:hover .status-badge-chevron {
  opacity: 1;
  transform: translateY(1px);
}

/* ============================================
   STOCK ADJUST POPOVER
   ============================================ */

.stock-adjust-pop {
  position: absolute;
  z-index: 9000;
  width: 210px;
  background: var(--sidebar-color, #fff);
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  padding: 0.85rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  animation: sapPop 0.15s ease-out;
}

body.dark .stock-adjust-pop {
  border-color: #333;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

@keyframes sapPop {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

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

.sap-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #888;
}

.sap-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
}

.sap-close:hover { color: var(--text-color); }

.sap-current {
  font-size: 0.85rem;
  color: var(--text-color);
}

.sap-current strong {
  color: var(--primary-color, #1D4ED8);
}

.sap-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sap-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  background: transparent;
  color: var(--text-color);
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.sap-btn:hover { background-color: rgba(0, 0, 0, 0.06); }
body.dark .sap-btn:hover { background-color: rgba(255, 255, 255, 0.08); }

.sap-input {
  flex: 1;
  text-align: center;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  background: transparent;
  color: var(--text-color);
  font-size: 0.9rem;
  font-family: inherit;
  width: 0;
}

.sap-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.18);
}

.sap-type-row {
  display: flex;
  gap: 0.75rem;
}

.sap-radio {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.83rem;
  color: var(--text-color);
  cursor: pointer;
}

.sap-confirm {
  width: 100%;
  justify-content: center;
  padding: 0.5rem;
  font-size: 0.85rem;
}

/* ============================================
   APP TOAST (shared with other modules)
   ============================================ */

.app-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.1rem;
  background: #1E1E1E;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  font-size: 0.88rem;
  font-weight: 500;
  animation: toastSlideUp 0.22s ease-out;
  max-width: 360px;
}

.app-toast.app-toast-error {
  background: #3B1C1C;
  border-left: 3px solid #EF5350;
}

.app-toast-icon {
  font-size: 1.15rem;
  color: #81C784;
  flex-shrink: 0;
}

.app-toast-error-icon { color: #EF5350; }

@keyframes toastSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

body.dark .toggle-hint {
  color: #666;
}

/* Toggle switch component */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle input[type='checkbox'] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.toggle-track {
  width: 40px;
  height: 22px;
  background-color: #d0d0d0;
  border-radius: 11px;
  transition: background-color 0.25s ease;
  position: relative;
}

body.dark .toggle-track {
  background-color: #444;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.toggle input:checked ~ .toggle-track {
  background-color: var(--primary-color);
}

.toggle input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(18px);
}

.toggle input:focus ~ .toggle-track {
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.25);
}

/* ============================================
   STOCK SECTION (conditional)
   ============================================ */

#item-stock-section {
  /* no overflow:hidden or max-height — let content flow naturally */
}

#item-stock-section.collapsed {
  display: none;
}

/* ============================================
   TABLE LOADING STATE
   ============================================ */

.table-loading-row td {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #bbb;
  font-size: 0.88rem;
  border-bottom: none;
}

body.dark .table-loading-row td {
  color: #444;
}

.loading-dots::after {
  content: '';
  animation: loadingDots 1.2s steps(3, end) infinite;
}

@keyframes loadingDots {
  0%   { content: ''; }
  33%  { content: '.'; }
  66%  { content: '..'; }
  100% { content: '...'; }
}

/* ============================================
   REQUIRED ASTERISK
   ============================================ */

.required {
  color: var(--primary-color);
}

/* ============================================
   FORM ERROR
   ============================================ */

.item-modal .form-error {
  color: #c62828;
  font-size: 0.82rem;
  margin-top: 0.5rem;
  padding: 0.6rem 0.85rem;
  background-color: rgba(198, 40, 40, 0.08);
  border-radius: 8px;
  border-left: 3px solid #c62828;
}

body.dark .item-modal .form-error {
  background-color: rgba(198, 40, 40, 0.18);
  color: #ef9a9a;
  border-left-color: #ef9a9a;
}

/* ============================================
   ITEM MODAL — FOOTER
   ============================================ */

.item-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border);
  background-color: var(--sidebar-color);
  flex-shrink: 0;
}

/* ============================================
   RESPONSIVE — MOBILE (≤ 768px)
   ============================================ */

@media (max-width: 768px) {
  /* Page header: stack vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  /* Button group in header: full width, buttons stretch equally */
  .page-header > div:last-child {
    width: 100%;
  }
  .page-header > div:last-child > .admin-button,
  .page-header > div:last-child > .admin-button-outline {
    flex: 1;
    justify-content: center;
  }

  /* Table controls: stack vertically and stretch children */
  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }

  /* Search field: full width */
  .search-field {
    display: flex;
    width: 100%;
  }
  .search-field input {
    min-width: 0;
    width: 100%;
  }

  /* Filter chip rows: wrap, full width */
  .filter-chips {
    width: 100%;
  }

  /* Modal footer: buttons take equal space */
  .item-modal .modal-footer {
    flex-wrap: wrap;
  }
  .item-modal .modal-footer .admin-button,
  .item-modal .modal-footer .btn-secondary {
    flex: 1;
    justify-content: center;
  }
}


/* -- Pagination ----------------------------------------------- */
.finance-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 0.25rem 0;
  margin-top: 0.6rem;
  border-top: 1px solid var(--border, #eeeeee);
}
body.dark .finance-pagination { border-top-color: #2e2f30; }
.pagination-info { font-size: 0.8rem; color: #aaa; }
body.dark .pagination-info { color: #666; }
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.pagination-perpage {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #aaa;
}
body.dark .pagination-perpage { color: #666; }
.pagination-perpage select {
  padding: 0.28rem 0.5rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-color);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.pagination-perpage select:focus { outline: none; border-color: var(--primary-color); }
body.dark .pagination-perpage select { background: #2a2b2c; border-color: #3a3b3c; color: var(--text-color); }
.pagination-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.pagination-pages span {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-color);
  min-width: 48px;
  text-align: center;
}
.page-prev, .page-next { width: 30px; height: 30px; font-size: 1.2rem; color: var(--text-color); }
.page-prev:disabled, .page-next:disabled { opacity: 0.3; cursor: not-allowed; }
.page-prev:not(:disabled):hover, .page-next:not(:disabled):hover {
  background-color: rgba(29,78,216,0.14);
  color: var(--primary-color);
  border-radius: 6px;
}
