/* ── Tab Navigation ──────────────────────────────────────────────────────── */
.tab-btn {
  display: inline-block;
  padding: 14px 20px;
  font-size: .875rem;
  font-weight: 500;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  background: none;
  border-top: 0; border-left: 0; border-right: 0;
}
.tab-btn:hover   { color: #374151; border-bottom-color: #d1d5db; }
.tab-btn.active  { color: #2563eb; border-bottom-color: #2563eb; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  border: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: #2563eb; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-secondary { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover:not(:disabled) { background: #f9fafb; }
.btn-ghost     { background: transparent; color: #6b7280; }
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; color: #374151; }
.action-btn    { background: none; border: none; color: #9ca3af; font-size: 1rem; padding: 2px 4px; cursor: pointer; }
.action-btn:hover { color: #374151; }

/* ── Form Controls ───────────────────────────────────────────────────────── */
.filter-label { display: block; font-size: .75rem; font-weight: 500; color: #6b7280; margin-bottom: 4px; }
.filter-input {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: .875rem;
  color: #374151;
  background: #fff;
  outline: none;
}
.filter-input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }

/* ── Data Table ──────────────────────────────────────────────────────────── */
.data-table { font-size: .875rem; width: 100%; border-collapse: collapse; }
.data-table thead tr { background: #f9fafb; position: sticky; top: 0; z-index: 1; }
.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}
.data-table td { padding: 9px 12px; border-bottom: 1px solid #f3f4f6; }
.data-table tbody tr:hover { background: rgba(219,234,254,.25); }
.data-table tbody tr.row-neg    td { color: #b91c1c; }
.data-table tbody tr.row-pos    td { color: #1e40af; }
.data-table tbody tr.row-payout td { color: #b91c1c; }
.data-table tbody tr.locked-row       { background: rgba(254,226,226,.15); }
.data-table tbody tr.guest-folio-alert { background: rgba(254,226,226,.35); }
.data-table tbody tr.guest-folio-alert td { color: #b91c1c; }
.data-table tbody tr.selected-row { background: rgba(219,234,254,.55) !important; }
.data-table tbody tr.selected-row td { border-bottom-color: #bfdbfe; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge        { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 4px; font-weight: 500; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-gray   { background: #f3f4f6; color: #4b5563; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* ── Summary Chips ───────────────────────────────────────────────────────── */
.summary-chip {
  display: inline-flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  background: #fff !important;
  border: 1.5px solid #e5e7eb !important;
  border-radius: 10px !important;
  padding: 6px 14px !important;
  min-width: 108px;
  gap: 2px;
  cursor: pointer !important;
  text-align: left;
  transition: border-color .15s, background .15s;
  line-height: 1.2;
}
.summary-chip:hover  { border-color: #93c5fd !important; background: #eff6ff !important; }
.summary-chip.active { border-color: #2563eb !important; background: #eff6ff !important; }
.summary-chip-amount { display: block; font-size: .92rem; font-weight: 700; font-family: monospace; line-height: 1.3; }
.summary-chip-label  { display: block; font-size: .69rem; color: #6b7280; font-weight: 500; white-space: nowrap; }

/* ── Import Cards ────────────────────────────────────────────────────────── */
.import-card {
  background: #fff;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.import-card:hover { border-color: #60a5fa; background: rgba(219,234,254,.15); }
.import-icon  { font-size: 2.5rem; margin-bottom: 8px; }
.import-title { font-weight: 600; color: #374151; font-size: 1rem; margin-bottom: 4px; }
.import-desc  { font-size: .875rem; color: #9ca3af; line-height: 1.4; }

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
/* The confirm prompt is always triggered on top of other modals (e.g. Empty Bin
   from inside the Recycle Bin), so it must stack above every other overlay. */
#modal-confirm { z-index: 60; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

/* ── Wizard Steps ────────────────────────────────────────────────────────── */
.step-dot {
  font-size: .75rem;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #e5e7eb;
  color: #6b7280;
  font-weight: 500;
}
.step-dot.active { background: #2563eb; color: #fff; }
.step-dot.done   { background: #16a34a; color: #fff; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-slide {
  animation: toastIn .25s ease-out, toastOut .4s ease-in 3.2s forwards;
}
@keyframes toastIn  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(8px); } }

/* ── Invoice Workspace (top/bottom split) ────────────────────────────────── */
.invoice-workspace {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* List pane: fills viewport when detail is closed */
.invoice-list-pane {
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  min-height: 200px;
  transition: max-height .2s ease, flex .2s ease;
}

/* Detail pane: hidden by default */
.invoice-detail-pane {
  display: none;
  margin-top: 8px;
}

/* ── When detail is open: workspace becomes a fixed-height flex column ────── */
.invoice-workspace.detail-open {
  height: calc(100vh - 200px);
  min-height: 480px;
}
.invoice-workspace.detail-open .invoice-list-pane {
  flex: 0 0 auto;
  height: 30vh;
  max-height: 30vh;
  min-height: 140px;
}
.invoice-workspace.detail-open .invoice-detail-pane {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
/* Let the white inner card fill the detail pane and scroll */
.invoice-workspace.detail-open .invoice-detail-pane > div {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

/* ── Printable report ──────────────────────────────────────────────────────
   #print-area is hidden on screen and only revealed for printing, where the
   rest of the app is hidden so the report prints clean on its own pages. */
#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; visibility: visible; position: absolute; top: 0; left: 0; width: 100%; }
  @page { margin: 14mm; }
}
.print-doc { font-family: Arial, Helvetica, sans-serif; color: #111; }
.print-doc h1 { font-size: 20px; margin: 0 0 2px; }
.print-doc .print-sub { color: #555; font-size: 12px; margin: 0; }
.print-doc .print-meta { margin: 10px 0 14px; font-size: 12px; color: #333; }
.print-doc .print-summary { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 14px; font-size: 12px; }
.print-doc .print-summary b { font-size: 15px; display: block; }
.print-doc table { width: 100%; border-collapse: collapse; font-size: 11px; }
.print-doc th, .print-doc td { border: 1px solid #ccc; padding: 4px 6px; text-align: left; }
.print-doc th { background: #f1f5f9; }
.print-doc td.num, .print-doc th.num { text-align: right; }
.print-doc tr.total-row td { font-weight: bold; background: #f8fafc; }
.print-doc thead { display: table-header-group; }   /* repeat header on each page */
.print-doc tr { page-break-inside: avoid; }

/* ── Guest Folio (reprint) — mirrors the PMS folio layout ─────────────────── */
.folio-doc { font-family: "Times New Roman", Times, serif; color: #000; font-size: 13px; }
.folio-doc .folio-letterhead { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
.folio-doc .folio-logo { max-height: 60px; max-width: 170px; object-fit: contain; }
.folio-doc .folio-co-name { font-weight: bold; font-size: 15px; }
.folio-doc .folio-co-line { font-size: 11px; color: #222; line-height: 1.35; }
.folio-doc .folio-title { text-align: center; font-weight: bold; font-size: 20px; margin: 4px 0 22px; letter-spacing: .5px; }
.folio-doc .folio-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.folio-doc .folio-head-left { padding-top: 22px; }
.folio-doc .folio-guest { font-weight: bold; font-size: 14px; margin: 0; }
.folio-doc .folio-country { margin: 26px 0 0; }
.folio-doc .folio-head-right { text-align: right; }
.folio-doc .folio-head-right p { margin: 0 0 2px; font-weight: bold; }
.folio-doc .folio-stay { display: flex; gap: 40px; padding: 6px 0; border-top: 1px solid #000; font-weight: bold; }
.folio-doc table.folio-lines { width: 100%; border-collapse: collapse; margin: 0; }
.folio-doc table.folio-lines th { border-top: 1px solid #000; border-bottom: 1px solid #000; text-align: left; padding: 4px 8px; font-weight: bold; }
.folio-doc table.folio-lines td { padding: 3px 8px; border: 0; }
.folio-doc table.folio-lines .num { text-align: right; }
.folio-doc table.folio-lines .cur { text-align: left; padding-left: 24px; }
.folio-doc .folio-foot { display: flex; justify-content: space-between; align-items: flex-start; border-top: 1px solid #000; margin-top: 2px; padding-top: 6px; }
.folio-doc table.folio-tax td { padding: 1px 14px 1px 8px; }
.folio-doc table.folio-tax tr:first-child td { font-weight: bold; }
.folio-doc table.folio-totals td { padding: 1px 0 1px 24px; font-weight: bold; }
.folio-doc table.folio-totals td.num { text-align: right; min-width: 90px; }
.folio-doc table.folio-totals tr.bal td { border-top: 1px solid #000; border-bottom: 3px double #000; }
.folio-doc .folio-note { font-size: 11px; margin: 14px 0 0; }

/* ── Collapsible library (Charge Codes / Payment Types) ───────────────────── */
.lib-bar { cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 8px 4px;
  font-weight: 600; color: #374151; user-select: none; border-bottom: 1px solid #f1f5f9; }
.lib-bar:hover { color: #1d4ed8; }
.lib-bar > span:first-child { display: inline-block; width: 12px; color: #9ca3af; font-size: 11px; }
.lib-search-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0 8px; }
.lib-scroll { max-height: 360px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; }
.lib-scroll thead th { position: sticky; top: 0; background: #fff; z-index: 1; box-shadow: 0 1px 0 #e5e7eb; }

/* ── Sortable invoice-table headers ───────────────────────────────────────── */
.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort:hover { color: #1d4ed8; }
.th-sort-active { color: #1d4ed8; }
.sort-caret { font-size: 10px; color: #9ca3af; margin-left: 2px; }
.th-sort-active .sort-caret { color: #1d4ed8; }

/* Report summary: stack the two-column row on small screens */
@media (max-width: 640px) { .rpt-two-col { grid-template-columns: 1fr !important; } }
