/* ─── Finance Admin Page ─── */
/* Matches Reservations page design patterns */

/* ===== PAGE HEADER ===== */
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-heading {
  font-size: 27px;
  font-weight: 800;
  color: #002e56;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
  letter-spacing: -0.01em;
}

/* Date Range */
.ns-date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ns-date-input {
  padding: 7px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-family: "Inter", sans-serif;
  width: 120px;
  background: #fff;
  color: #1e293b;
}

.ns-date-input:focus {
  outline: none;
  border-color: #2b6cb0;
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.15);
}

.ns-date-sep {
  color: #94a3b8;
  font-size: 13px;
}

.btn-load {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 8px;
  background: #2b6cb0;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  font-family: "Inter", sans-serif;
}

.btn-load:hover {
  background: #2563eb;
}

.btn-load .material-icons {
  font-size: 16px;
}

.btn-sync {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 8px;
  background: #059669;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  font-family: "Inter", sans-serif;
}

.btn-sync:hover {
  background: #047857;
}

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

.btn-sync .material-icons {
  font-size: 16px;
}

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

.spin {
  animation: spin 1s linear infinite;
}

/* ===== SUMMARY CARDS ===== */
.ns-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.ns-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
  transition: box-shadow 0.15s;
}

.ns-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ns-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #edf2f7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ns-card-icon .material-icons {
  font-size: 20px;
  color: #64748b;
}

.ns-card-icon-ok { background: #dcfce7; }
.ns-card-icon-ok .material-icons { color: #166534; }

.ns-card-icon-warn { background: #fee2e2; }
.ns-card-icon-warn .material-icons { color: #dc2626; }

.ns-card-icon-balance { background: #dbeafe; }
.ns-card-icon-balance .material-icons { color: #1e40af; }

.ns-card-balance {
  border-color: #93c5fd;
  background: linear-gradient(135deg, #eff6ff 0%, #fff 100%);
}

.ns-card-warn-active {
  border-color: #fca5a5;
  background: linear-gradient(135deg, #fef2f2 0%, #fff 100%);
}

.ns-card-body { min-width: 0; }

.ns-card-value {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
}

.ns-card-label {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 8px;
  flex-wrap: wrap;
}

.type-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  font-family: "Inter", sans-serif;
  white-space: nowrap;
}

.type-chip:hover {
  border-color: #cbd5e1;
  color: #334155;
  background: #f8fafc;
}

.type-chip.active {
  background: #1e293b;
  color: #fff;
  border-color: #1e293b;
  font-weight: 600;
}

.type-chip.active .chip-count {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.chip-count {
  font-size: 11px;
  font-weight: 700;
  background: #e2e8f0;
  color: #475569;
  padding: 1px 6px;
  border-radius: 4px;
  min-width: 20px;
  text-align: center;
  line-height: 1.4;
}

.chip-count:empty {
  display: none;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ns-select {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-family: "Inter", sans-serif;
  background: #fff;
  color: #334155;
  min-width: 140px;
}

.ns-select:focus {
  outline: none;
  border-color: #2b6cb0;
}

.ns-search {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-family: "Inter", sans-serif;
  width: 240px;
  background: #fff;
  color: #334155;
}

.ns-search:focus {
  outline: none;
  border-color: #2b6cb0;
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.15);
}

.btn-csv {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  font-family: "Inter", sans-serif;
}

.btn-csv:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}

.btn-csv .material-icons {
  font-size: 16px;
}

/* ===== RESULT COUNT ===== */
.result-count {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
  padding: 0 2px 6px;
}

.result-count:empty {
  display: none;
}

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.res-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: "Inter", sans-serif;
}

.res-table th {
  text-align: left;
  font-weight: 600;
  color: #64748b;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  font-family: "Inter", sans-serif;
}

.res-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
  font-family: "Inter", sans-serif;
}

.res-table tbody tr {
  cursor: pointer;
  transition: background 0.1s ease;
}

.res-table tbody tr:hover {
  background: #f0f7ff;
}

.col-right {
  text-align: right !important;
}

.loading-cell {
  text-align: center;
  color: #94a3b8;
  padding: 32px 16px !important;
  font-size: 13px;
}

/* ===== SORTABLE HEADERS ===== */
th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

th.sortable:hover {
  color: #1e293b;
}

.sort-arrow {
  font-size: 14px;
  vertical-align: middle;
  margin-left: 2px;
  opacity: 0.3;
  transition: opacity 0.15s;
}

th.sort-active .sort-arrow {
  opacity: 1;
  color: #2b6cb0;
}

/* ===== TYPE BADGES ===== */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  font-family: "Inter", sans-serif;
}

.type-payment    { background: #dcfce7; color: #166534; }
.type-refund     { background: #fee2e2; color: #991b1b; }
.type-revenue    { background: #dbeafe; color: #1e40af; }
.type-cos        { background: #f3e8ff; color: #6b21a8; }
.type-payout     { background: #f1f5f9; color: #334155; }

/* ===== NS JOURNAL BADGES ===== */
.ns-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  font-family: "Inter", sans-serif;
}

.ns-posted { background: #dcfce7; color: #166534; }
.ns-missing { background: #fee2e2; color: #991b1b; text-transform: uppercase; letter-spacing: 0.02em; }
.ns-internal-id { font-size: 10px; color: #94a3b8; margin-top: 1px; font-family: "Inter", sans-serif; text-align: center; }

/* ===== CONFIRMATION ID ===== */
.confirm-id {
  font-size: 13px;
  font-weight: 600;
  color: #007ae7;
}

/* ===== PAYOUT ID ===== */
.payout-id {
  font-size: 12px;
  color: #64748b;
}

/* ===== WARNING ROWS (missing NS) ===== */
.row-warning {
  border-left: 3px solid #fca5a5;
  background: #fef2f2;
}

.row-warning:hover {
  background: #fee2e2 !important;
}

/* ===== PAYOUT ROW EXPAND ===== */
.row-payout {
  background: #f1f5f9;
  border-left: 3px solid #475569;
}

.row-payout td {
  font-weight: 600;
  color: #1e293b;
}

.row-payout:hover {
  background: #e2e8f0 !important;
}

.row-payout.row-warning {
  background: #fef2f2;
  border-left-color: #f87171;
}

.expand-chevron {
  font-size: 16px;
  color: #94a3b8;
  vertical-align: middle;
  margin-right: 4px;
  transition: transform 0.15s;
}

.row-expanded .expand-chevron {
  transform: rotate(90deg);
  color: #2b6cb0;
}

/* Expanded content below payout row */
.expanded-content > td {
  padding: 0 !important;
  border-top: none;
  border-bottom: none;
}

.expanded-content:hover > td {
  background: transparent !important;
}

.payout-panel {
  margin: 12px 16px 16px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Dark summary header bar */
.payout-panel-header {
  background: #1e293b;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.payout-panel-header .pph-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.payout-panel-header .pph-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  white-space: nowrap;
}

.payout-panel-header .pph-value {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
}

.payout-panel-header .pph-value-fees {
  color: #f87171;
}

.payout-panel-header .pph-value-net {
  color: #4ade80;
}

.payout-panel-header .pph-value-journal {
  font-size: 14px;
}

.payout-panel-header .pph-value-journal .ns-badge {
  font-size: 12px;
  padding: 3px 10px;
}

/* Transactions section inside payout panel */
.payout-panel-body {
  padding: 12px 16px 16px;
}

.payout-panel-count {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

/* Sub-table inside expanded payout */
.sub-table {
  font-size: 12px;
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  width: 100%;
  border-collapse: collapse;
  font-family: "Inter", sans-serif;
}

.sub-table thead th {
  background: #edf2f7;
  font-size: 10px;
  padding: 8px 10px;
  font-family: "Inter", sans-serif;
  color: #475569;
}

.sub-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  font-family: "Inter", sans-serif;
  color: #334155;
}

.sub-table tbody tr:last-child td {
  border-bottom: none;
}

.sub-row {
  cursor: pointer;
  background: #fff;
}

.sub-row:hover {
  background: #f0f7ff !important;
}

.expanded-note {
  font-size: 13px;
  color: #94a3b8;
  padding: 16px;
  font-style: italic;
  text-align: center;
}

/* ===== SIDE PANEL DETAIL GRID ===== */
.ns-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}

.ns-detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ns-detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.ns-detail-value {
  font-size: 14px;
  color: #1e293b;
  font-weight: 500;
  word-break: break-all;
}

/* NS lines table in side panel */
.ns-lines-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
  font-family: "Inter", sans-serif;
}

.ns-lines-table th {
  text-align: left;
  font-weight: 600;
  color: #64748b;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 8px;
  border-bottom: 2px solid #e2e8f0;
}

.ns-lines-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}

.ns-lines-table .col-right {
  text-align: right;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 980px) {
  .page-header-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-wrap {
    margin: 0 -16px;
    border-radius: 0;
  }
}

@media (max-width: 768px) {
  .ns-summary-cards {
    grid-template-columns: 1fr 1fr;
  }

  .ns-date-range {
    flex-wrap: wrap;
  }

  .ns-search {
    width: 100%;
  }

  .ns-detail-grid {
    grid-template-columns: 1fr;
  }

  .type-chips {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}
