/* ===========================
   CSS Variables & Reset
   =========================== */
:root {
  --navy: #1a3a5c;
  --navy-dark: #122a44;
  --navy-light: #2a5080;
  --gold: #f5c518;
  --gold-dark: #d4a800;
  --gold-light: #fdd84e;
  --white: #ffffff;
  --light-blue: #e8f0f8;
  --light-blue2: #d0e4f7;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --red: #c0392b;
  --red-light: #fdecea;
  --green: #27ae60;
  --green-light: #e8f8f0;
  --shadow: 0 2px 8px rgba(26, 58, 92, 0.15);
  --shadow-lg: 0 4px 20px rgba(26, 58, 92, 0.2);
  --radius: 6px;
  --radius-lg: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--light-blue);
  color: var(--gray-800);
  min-height: 100vh;
}

/* ===========================
   Header
   =========================== */
.app-header {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, var(--navy-light) 100%);
  color: var(--white);
  padding: 0;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 1.8rem;
}

.header-logo h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--gold-light);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ===========================
   Tab Navigation
   =========================== */
.tab-nav {
  background: var(--navy);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.tab-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--gray-300);
  padding: 14px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  letter-spacing: 0.3px;
}

.tab-btn:hover {
  color: var(--gold-light);
  background: rgba(255,255,255,0.07);
}

.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: rgba(245, 197, 24, 0.1);
}

/* ===========================
   Main Content
   =========================== */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.tab-panel {
  display: none;
}

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

/* ===========================
   Cards / Sections
   =========================== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  background: var(--navy);
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.card-header .header-icon {
  font-size: 1.2rem;
}

.card-body {
  padding: 20px;
}

/* ===========================
   Forms
   =========================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  align-items: end;
}

.form-grid-wide {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.2px;
}

.form-group input,
.form-group select,
.form-group textarea {
  border: 2px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.12);
}

.form-group input.input-error,
.form-group select.input-error {
  border-color: var(--red);
}

.form-group input:disabled,
.form-group select:disabled {
  background: var(--gray-100);
  color: var(--gray-600);
  cursor: default;
  border-color: var(--gray-200);
}

.form-submit-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

/* ===========================
   Buttons
   =========================== */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background: var(--navy-light);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.btn-view-note {
  background: none;
  border: none;
  color: var(--navy-light);
  padding: 0;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-view-note:hover:not(:disabled) {
  color: var(--navy);
  background: none;
  text-decoration: underline;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-300);
}

.btn-danger {
  background: var(--red);
  color: var(--white);
}

.btn-danger:hover:not(:disabled) {
  background: #a93226;
}

.btn-gold {
  background: var(--gold);
  color: var(--navy-dark);
}

.btn-gold:hover:not(:disabled) {
  background: var(--gold-dark);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 5px 8px;
  font-size: 0.85rem;
  border-radius: var(--radius);
}

/* ===========================
   Error & Success Messages
   =========================== */
@keyframes error-fadeout {
  0%   { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

.error-message {
  color: var(--red);
  background: var(--red-light);
  border: 1px solid #f5c6cb;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-top: 16px;
  font-weight: 500;
}

.error-message.error-fading {
  animation: error-fadeout 4s forwards;
}

.success-message {
  color: var(--green);
  background: var(--green-light);
  border: 1px solid #b2dfdb;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-top: 10px;
}

/* ===========================
   Filters Section
   =========================== */
.filters-section {
  background: var(--light-blue);
  border: 1px solid var(--light-blue2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.filters-section h3 {
  font-size: 0.9rem;
  color: var(--navy);
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.filters-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.filter-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy);
}

.filter-group input,
.filter-group select {
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 0.88rem;
  font-family: var(--font);
  background: var(--white);
  color: var(--gray-800);
  transition: border-color 0.2s;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--navy-light);
}

.filter-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.filter-input-row input {
  flex: 1;
}

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

.pill {
  padding: 5px 12px;
  border-radius: 20px;
  border: 2px solid var(--navy);
  background: var(--white);
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.pill:hover {
  background: var(--light-blue2);
}

.pill.active {
  background: var(--navy);
  color: var(--white);
}

.pill.pill-pending {
  border-color: #e67e22;
  color: #e67e22;
}

.pill.pill-pending.active {
  background: #e67e22;
  color: var(--white);
}

.pill.pill-paid {
  border-color: #1a7a42;
  color: #1a7a42;
}

.pill.pill-paid.active {
  background: #1a7a42;
  color: var(--white);
}

.pill.pill-notes {
  border-color: var(--navy-light);
  color: var(--navy-light);
}

.pill.pill-notes.active {
  background: var(--navy-light);
  color: var(--white);
}

/* ===========================
   Tables
   =========================== */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead tr {
  background: var(--navy);
  color: var(--white);
}

thead th {
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:hover {
  background: var(--navy-light);
}

thead th .sort-icon {
  margin-left: 5px;
  font-size: 0.8rem;
  opacity: 0.7;
}

thead th .sort-icon:empty {
  display: none;
}

.cell-dash {
  color: var(--gray-500);
  font-family: var(--font);
  font-weight: normal;
}

thead th.sort-active .sort-icon {
  opacity: 1;
  color: var(--gold);
}

tbody tr {
  border-bottom: 1px solid var(--gray-200);
  transition: background 0.15s;
}

tbody tr:nth-child(even) {
  background: var(--gray-100);
}

tbody tr:hover {
  background: var(--light-blue);
}

tbody td {
  padding: 10px 14px;
  vertical-align: middle;
}

.table-empty {
  text-align: center;
  padding: 30px;
  color: var(--gray-500);
  font-style: italic;
}

/* ===========================
   Status Badges
   =========================== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-pending {
  background: transparent;
  color: #e67e22;
  border: 2px solid #e67e22;
}

.badge-paid {
  background: transparent;
  color: #1a7a42;
  border: 2px solid #1a7a42;
}

/* ===========================
   Table Footer
   =========================== */
.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-top: 2px solid var(--gray-200);
  margin-top: 4px;
  flex-wrap: wrap;
  gap: 10px;
}

.table-total {
  font-weight: 700;
  color: var(--navy);
  font-size: 1rem;
}

.table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===========================
   Checkbox
   =========================== */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--navy);
}

.checkbox-cell {
  width: 40px;
  text-align: center;
}

/* ===========================
   Action Buttons in Table
   =========================== */
.action-btns {
  display: flex;
  gap: 5px;
  white-space: nowrap;
}

/* ===========================
   Modals
   =========================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 900;
}

.modal-overlay.active {
  display: block;
}

.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal.active {
  display: block;
}

.modal-sm {
  max-width: 380px;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  background: var(--navy);
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--gray-300);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--white);
}

.modal-body {
  padding: 20px;
}

.modal-body p {
  margin-bottom: 14px;
  color: var(--gray-700);
  font-size: 0.95rem;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal .form-actions {
  justify-content: flex-end;
}

.modal .form-grid {
  gap: 16px;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===========================
   Cashout Summary
   =========================== */
.cashout-list {
  list-style: none;
  margin: 10px 0;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}

.cashout-list li {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--gray-200);
}

.cashout-list li:last-child {
  border-bottom: none;
}

.cashout-list li:nth-child(even) {
  background: var(--gray-100);
}

.cashout-action {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.cashout-action.create {
  background: var(--green-light);
  color: var(--green);
}

.cashout-action.update {
  background: #e3f2fd;
  color: #1565c0;
}

/* ===========================
   Loading State
   =========================== */
.loading {
  text-align: center;
  padding: 30px;
  color: var(--gray-500);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--gray-300);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
  .main-content {
    padding: 16px;
  }

  .tab-btn {
    padding: 12px 14px;
    font-size: 0.85rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters-grid {
    flex-direction: column;
  }

  .filter-group {
    min-width: unset;
    width: 100%;
  }

  .table-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ===========================
   Amount formatting
   =========================== */
.amount {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  text-align: right;
}

thead th.amount-header {
  text-align: right;
}

/* ===========================
   Notes cell
   =========================== */
.notes-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gray-600);
  font-style: italic;
  font-size: 0.85rem;
}

/* ===========================
   Select all checkbox header
   =========================== */
#select-all-vouchers {
  cursor: pointer;
}

/* ===========================
   Filter count labels
   =========================== */
.filter-label {
  font-size: 0.8rem;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 4px;
}
