/* app.css — WeSail admin styles. Reuses the wesailxp palette (navy #102a3a,
 * sand #c9a77a, linen #f4efe6). Vendored stylesheet (no inline <style>, §11b CSP).
 * Plain hand-written CSS — no build step, no framework. */

:root {
  --navy: #102a3a;
  --navy-2: #1b3b4f;
  --sand: #c9a77a;
  --sand-2: #b8915f;
  --linen: #f4efe6;
  --linen-2: #ece4d6;
  --ink: #1d2730;
  --muted: #6b7780;
  --line: #d9d0c2;
  --ok: #2f7d5b;
  --warn: #b8915f;
  --danger: #9c3b34;
  --white: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 42, 58, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body.wesail {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--linen);
  line-height: 1.5;
}

a { color: var(--navy); }

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.85rem 1.5rem;
  background: var(--navy);
  color: var(--linen);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--linen); text-decoration: none; letter-spacing: 0.01em; }
.brand-mark { color: var(--sand); padding: 0 0.15rem; }
.topnav a { color: var(--linen); text-decoration: none; opacity: 0.8; padding: 0.25rem 0.1rem; }
.topnav a.active, .topnav a:hover { opacity: 1; border-bottom: 2px solid var(--sand); }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

.page-head h1 { margin: 0 0 0.25rem; color: var(--navy); }
.muted { color: var(--muted); }

/* ---- Cards ---- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}

/* ---- Filters ---- */
.filters { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; }
.filters label, .upload-form label { display: flex; flex-direction: column; font-size: 0.82rem; color: var(--muted); gap: 0.25rem; }
.filters select, .filters input, .upload-form select, .upload-form input {
  font: inherit; padding: 0.45rem 0.55rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--white); color: var(--ink); min-width: 9rem;
}

/* ---- Layout: table + viewer side by side ---- */
.payables-layout { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media (min-width: 1000px) {
  .payables-layout { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); align-items: start; }
}

/* ---- Data table ---- */
.table-card { overflow-x: auto; padding: 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table thead th {
  text-align: left; padding: 0.7rem 0.9rem; background: var(--linen-2);
  color: var(--navy); font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table th.num, .data-table td.num { text-align: right; }
.data-table tbody td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--linen-2); vertical-align: top; }
.payable-row:hover { background: var(--linen); }
.amount-cell { font-variant-numeric: tabular-nums; font-weight: 600; }
.due-hint { display: block; color: var(--muted); }
.due-hint.is-overdue { color: var(--danger); font-weight: 600; }

/* priority left-accent on the row */
.payable-row.prio-blocker td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.payable-row.prio-odyssey_relationship td:first-child { box-shadow: inset 3px 0 0 var(--sand); }

/* ---- Badges ---- */
.badge {
  display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.45rem;
  border-radius: 999px; margin-left: 0.35rem; vertical-align: middle; white-space: nowrap;
}
.badge-prio.prio-blocker { background: #f6dedb; color: var(--danger); }
.badge-prio.prio-odyssey_relationship { background: #f0e3d0; color: var(--sand-2); }
.badge-prio.prio-standard { background: var(--linen-2); color: var(--muted); }
.badge-charter { background: #e2ecef; color: var(--navy); }

.badge-status { color: var(--white); }
.badge-status.status-to_approve { background: var(--sand-2); }
.badge-status.status-unpaid, .badge-status.status-draft { background: var(--muted); }
.badge-status.status-approved { background: var(--navy); }
.badge-status.status-awaiting_reconciliation { background: var(--navy-2); }
.badge-status.status-paid { background: var(--ok); }
.badge-status.status-overdue { background: var(--danger); }
.badge-status.status-void { background: #b9b2a6; }

/* ---- Buttons ---- */
.btn {
  font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: 8px;
  padding: 0.5rem 0.9rem; text-decoration: none; display: inline-block; line-height: 1;
}
.btn-sm { padding: 0.32rem 0.6rem; font-size: 0.82rem; margin: 0.1rem 0.1rem 0 0; }
.btn-primary { background: var(--navy); color: var(--linen); }
.btn-primary:hover { background: var(--navy-2); }
.btn-secondary { background: var(--sand); color: var(--navy); }
.btn-secondary:hover { background: var(--sand-2); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: var(--linen-2); }

.actions-col, .actions-cell { white-space: nowrap; }
.pay-slot { display: inline-block; }
.pay-confirm { margin-top: 0.4rem; }
.pay-note { font-size: 0.78rem; margin: 0.3rem 0 0; }

/* ---- PDF viewer island ---- */
.viewer-card { padding: 0; position: sticky; top: 1rem; }
.viewer-head { padding: 0.6rem 0.9rem; background: var(--linen-2); color: var(--navy); font-weight: 600; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.viewer-body { min-height: 420px; display: flex; }
.viewer-empty { margin: auto; padding: 2rem; text-align: center; }
.pdf-frame { width: 100%; min-height: 420px; border: 0; }

/* ---- Upload ---- */
.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem 1rem; margin-bottom: 0.9rem; }
.upload-grid .span-2 { grid-column: 1 / -1; }
.upload-form input[type="text"], .upload-form input[type="date"] { min-width: 0; }
.upload-ok { background: #e3efe8; color: var(--ok); padding: 0.6rem 0.8rem; border-radius: 8px; margin-top: 0.8rem; }
.upload-error { background: #f6dedb; color: var(--danger); padding: 0.6rem 0.8rem; border-radius: 8px; margin-top: 0.8rem; }

/* ===================================================================== */
/* Home — the actionable inbox (SPEC §6.1)                               */
/* ===================================================================== */
.page-head { margin-bottom: 1rem; }
.page-head h2 { margin: 0; color: var(--navy); }

/* Buffer-breached banner (SPEC §6.1 MIDDLE). */
.banner { border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 1.1rem; font-weight: 600; }
.banner-danger { background: #f6dedb; color: var(--danger); border: 1px solid #e3b6b1; }

/* Three summary columns. */
.summary-grid { display: grid; grid-template-columns: 1fr; gap: 1.1rem; margin-bottom: 1.5rem; }
@media (min-width: 860px) { .summary-grid { grid-template-columns: repeat(3, 1fr); } }
.summary-col { margin-bottom: 0; }
.summary-head {
  margin: 0 0 0.6rem; font-size: 0.82rem; color: var(--navy);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.metric { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; padding: 0.28rem 0; }
.metric-label { color: var(--muted); font-size: 0.9rem; }
.metric-value { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; text-align: right; }
.metric-value.pos { color: var(--ok); }
.metric-value.neg { color: var(--danger); }

.callout { margin-top: 0.75rem; padding: 0.55rem 0.7rem; border-radius: 8px; display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.9rem; }
.callout-go { background: #f0e3d0; color: var(--sand-2); }
.callout-ok { background: #e3efe8; color: var(--ok); }
.callout span { opacity: 0.85; }

/* Action queue + buckets. */
.queue-head { display: flex; align-items: baseline; gap: 0.7rem; }
.queue-empty { padding: 1.25rem; border-style: dashed; }
.bucket { margin-bottom: 1.1rem; }
.bucket-head { display: flex; align-items: baseline; gap: 0.55rem; margin: 0 0 0.45rem; }
.bucket-head h3 { margin: 0; font-size: 1rem; color: var(--navy); }
.bucket-sub { font-size: 0.82rem; }
.bucket-rows { display: flex; flex-direction: column; gap: 0.45rem; }

.inbox-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--muted);
  border-radius: var(--radius); padding: 0.65rem 0.9rem; box-shadow: var(--shadow);
}
/* Bucket accent (SPEC §6.1: Blockers red, Today sand, This-week navy, Watch grey). */
.bucket-blocker   .inbox-row { border-left-color: var(--danger); }
.bucket-today     .inbox-row { border-left-color: var(--sand); }
.bucket-this_week .inbox-row { border-left-color: var(--navy); }
.bucket-watch     .inbox-row { border-left-color: var(--muted); }

.inbox-row-main { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.inbox-row-text { display: flex; flex-direction: column; min-width: 0; }
.inbox-title { font-weight: 600; color: var(--navy); }
.inbox-subtitle { font-size: 0.86rem; }
.inbox-detail { font-size: 0.85rem; white-space: nowrap; }
.inbox-row-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

/* ---- Modals ---- */
.modal {
  position: fixed; inset: 0; background: rgba(16, 42, 58, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--white); border-radius: var(--radius); padding: 1.5rem 1.75rem;
  max-width: 420px; box-shadow: 0 8px 30px rgba(16, 42, 58, 0.3);
}
.modal-card h2 { margin-top: 0; color: var(--navy); }
.modal-card .btn { margin-right: 0.5rem; margin-top: 0.5rem; }
