/* Flow Lending Partner Portal.
   Brand tokens live in :root — adjust to match flowlending.ca exactly
   once the client shares brand hex values. */

:root {
  --navy: #0e2340;
  --navy-2: #16355e;
  --ink: #1d2733;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f7f9fc;
  --card: #ffffff;
  --accent: #b8923a;
  --accent-soft: #f4ecd9;
  --good: #15803d;
  --bad: #b91c1c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

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

/* ---------- header / nav ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--navy);
  color: #fff;
  flex-wrap: wrap;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.brand span { color: var(--accent); font-weight: 500; }
#site-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-right: auto; }
#site-nav a {
  color: #dbe4f0;
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.92rem;
}
#site-nav a:hover { background: var(--navy-2); color: #fff; }
.user-menu { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; color: #b9c6d8; }
.user-menu form { margin: 0; }
.user-menu button,
.nav-toggle {
  background: transparent;
  border: 1px solid #43597a;
  color: #dbe4f0;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}
.user-menu button:hover { background: var(--navy-2); }
.nav-toggle { display: none; font-size: 1.1rem; }

@media (max-width: 800px) {
  .nav-toggle { display: block; order: 3; margin-left: auto; }
  #site-nav { display: none; width: 100%; flex-direction: column; }
  #site-nav.open { display: flex; }
  .user-menu { order: 2; }
}

/* ---------- layout ---------- */
main { max-width: 76rem; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }
.site-footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 1.5rem; }

h1 { font-size: 1.45rem; color: var(--navy); margin: 0 0 1rem; }
h2 { font-size: 1.1rem; color: var(--navy); }
.subtle { color: var(--muted); font-size: 0.9rem; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-head h1 { margin: 0; }
.page-head input[type="search"] {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 16rem;
  font-size: 0.9rem;
}

/* ---------- tables ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.92rem;
}
.data-table th {
  text-align: left;
  background: #eef2f7;
  color: var(--navy);
  padding: 0.6rem 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}
.data-table th[data-dir="asc"]::after { content: " ↑"; color: var(--accent); }
.data-table th[data-dir="desc"]::after { content: " ↓"; color: var(--accent); }
.data-table td { padding: 0.55rem 0.8rem; border-top: 1px solid var(--line); }
.data-table tbody tr:hover { background: #f4f7fb; }

@media (max-width: 800px) {
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-active { background: #e7f6ec; color: var(--good); }
.badge-departed { background: #fdecec; color: var(--bad); }

/* ---------- cards / forms ---------- */
.auth-card {
  max-width: 26rem;
  margin: 3rem auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
}
.auth-card h1 { font-size: 1.25rem; }
.auth-card label { display: block; margin: 0.9rem 0 0.25rem; font-size: 0.9rem; font-weight: 600; }
.auth-card input,
.auth-card form p input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
}
.auth-card form p { margin: 0.7rem 0; }
.auth-card .helptext { color: var(--muted); font-size: 0.8rem; display: block; margin-top: 0.2rem; }
.auth-card ul { color: var(--muted); font-size: 0.85rem; padding-left: 1.2rem; }
.errorlist { color: var(--bad); font-size: 0.85rem; padding-left: 1.2rem; }
.errors { color: var(--bad); font-size: 0.9rem; }

button, .button {
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { background: var(--navy-2); }
button.danger { background: #fdecec; color: var(--bad); }
button.danger:hover { background: #fbdcdc; }
.auth-card button { width: 100%; margin-top: 1.2rem; }

select {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 0.9rem;
}

/* ---------- messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  background: var(--accent-soft);
  border: 1px solid #e5d9b8;
}
.messages li.error, .messages li.warning { background: #fdecec; border-color: #f5c6c6; }

/* ---------- staffing / contacts / resources ---------- */
.staffing-month { margin-bottom: 1.5rem; }
.staffing-month h2 { border-bottom: 2px solid var(--accent); display: inline-block; padding-bottom: 0.15rem; }
.staffing-list { list-style: none; padding: 0; }
.staffing-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
}
.staffing-list li .subtle { float: right; }

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}
.contact-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}
.contact-card h2 { margin: 0 0 0.2rem; }
.contact-card p { margin: 0.15rem 0; font-size: 0.9rem; }

.resource-list { list-style: none; padding: 0; }
.resource-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 1.1rem;
  margin-bottom: 0.5rem;
}
.resource-list a { font-weight: 600; text-decoration: none; }

.prose { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 2rem; max-width: 50rem; }
.prose h2 { margin-top: 1.4rem; }
.prose table { border-collapse: collapse; }
.prose td, .prose th { border: 1px solid var(--line); padding: 0.4rem 0.7rem; }

.row-actions { display: flex; gap: 0.4rem; }
.row-actions form { margin: 0; }

/* ---------- broker modal ---------- */
.has-modal { cursor: pointer; }
tr.has-modal:focus-visible, li.has-modal:focus-visible { outline: 2px solid var(--accent); }

#broker-modal {
  border: 0;
  border-radius: var(--radius);
  padding: 2rem 2.5rem 1.75rem;
  max-width: 32rem;
  width: min(92vw, 32rem);
  box-shadow: 0 20px 50px rgba(14, 35, 64, 0.35);
}
#broker-modal::backdrop { background: rgba(14, 35, 64, 0.45); }
#broker-modal h2 { margin: 0 0 0.2rem; font-size: 1.3rem; }
.modal-sub { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.95rem; }
.modal-fields { margin: 0; }
.modal-fields div {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
}
.modal-fields dt { color: var(--muted); font-size: 0.88rem; min-width: 8.5rem; margin: 0; flex-shrink: 0; }
.modal-fields dd { margin: 0; font-size: 0.95rem; flex: 1; overflow-wrap: anywhere; }
.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  padding: 0.1rem 0.5rem;
}
.modal-close:hover { background: var(--bg); color: var(--ink); }

/* ---------- sync page ---------- */
.sync-run { margin-bottom: 1.5rem; }
.sync-run h2 { margin-bottom: 0.4rem; }
.sync-failed h2 { color: var(--bad); }
.sync-notes { white-space: pre-wrap; font-size: 0.78rem; color: var(--muted); margin: 0; font-family: ui-monospace, monospace; }
