/* ──────────────────────────────────────────────────────────────────────────
   SABPortal — Benjel Client Portal styles.
   Palette tokens approximate the benjel.ca brand; pin exact hex when provided.
   ────────────────────────────────────────────────────────────────────────── */
:root {
  --forest:       #14492f;   /* deep forest-green sidebar */
  --forest-dark:  #0e3522;
  --leaf:         #2f8f4e;   /* leaf-green accents / primary actions */
  --leaf-dark:    #246e3c;
  --leaf-soft:    #e6f2ea;
  --page:         #f5f7f4;   /* soft off-white page */
  --surface:      #ffffff;
  --ink:          #1f2a24;
  --muted:        #6b7d72;
  --line:         #e3e9e4;
  --amber:        #c98a16;
  --danger:       #c0392b;
  --sidebar-w:    240px;
  --radius:       12px;
  --shadow:       0 1px 3px rgba(20,73,47,.08), 0 1px 2px rgba(20,73,47,.06);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}
a { color: var(--leaf-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
hr { border-color: var(--line); }

/* ── Bootstrap primary override ─────────────────────────────────────────── */
.btn-primary { background: var(--leaf); border-color: var(--leaf); }
.btn-primary:hover, .btn-primary:focus { background: var(--leaf-dark); border-color: var(--leaf-dark); }
.btn-outline-primary { color: var(--leaf-dark); border-color: var(--leaf); }
.btn-outline-primary:hover { background: var(--leaf); border-color: var(--leaf); }
.progress-bar { background: var(--leaf); }
.alert-success { background: var(--leaf-soft); border-color: #bfe0cb; color: var(--leaf-dark); }

/* ── Layout ─────────────────────────────────────────────────────────────── */
#wrapper { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--forest); color: #eaf3ee;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 1040;
}
.sidebar-brand { padding: 22px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-logo { max-width: 150px; max-height: 54px; }
.sidebar-brand-text { font-size: 1.4rem; font-weight: 700; color: #fff; }
.sidebar-tagline { font-size: .8rem; color: #a9c9b6; margin-top: 4px; }
.sidebar-nav { padding: 12px 8px; flex: 1; }
.sidebar-nav .nav-link {
  color: #ffffff; border-radius: 8px; padding: 10px 14px; margin-bottom: 2px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar-nav .nav-link.active { background: var(--leaf); color: #fff; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.1); }

.main-content { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 22px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-weight: 600; flex: 1; }
.lang-toggle { font-size: .9rem; color: var(--leaf-dark); }
.help-link { font-size: 1.2rem; color: var(--leaf-dark); display: inline-flex; line-height: 1; }
.help-link:hover { color: var(--leaf); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.burger { display: none; }
.content-area { padding: 22px; max-width: 1180px; width: 100%; }
.flash-container { padding: 12px 22px 0; }
.test-db-banner {
  background: var(--amber); color: #fff; text-align: center; font-weight: 700;
  font-size: .8rem; padding: 3px; letter-spacing: .05em;
}

.page-head { margin-bottom: 18px; }
.section-title { font-size: 1.05rem; font-weight: 600; margin: 26px 0 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-title { color: var(--ink); }

/* ── Stat cards ─────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card { display: flex; align-items: center; gap: 14px; padding: 16px; }
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px; background: var(--leaf-soft);
  color: var(--leaf-dark); display: grid; place-items: center; font-size: 1.3rem; flex: none;
}
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-value.sm { font-size: 1.1rem; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* ── Project progression cards (2 per row, room for milestone dates) ─────── */
.project-card-flow { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.project-prog-card { min-width: 0; }
.project-prog-card .card-body { padding: 20px 22px; }
.ppc-head { display: flex; flex-direction: column; margin-bottom: 16px; }
.ppc-name { font-weight: 600; font-size: 1.05rem; }
.ppc-meta { color: var(--muted); font-size: .82rem; }
.ppc-foot { margin-top: 14px; }

/* ── Progression timeline (single renderer) ─────────────────────────────── */
.prog-track { display: flex; align-items: flex-start; width: 100%; overflow-x: auto; }
.prog-step { display: flex; flex-direction: column; align-items: center; text-align: center; flex: 0 0 auto; min-width: 66px; padding: 0 2px; }
.prog-connector { flex: 1 1 auto; min-width: 6px; height: 3px; background: var(--line); margin-top: 13px; border-radius: 2px; }
.prog-connector.state-done { background: var(--leaf); }
.prog-node {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--line); color: var(--muted); font-size: .8rem;
}
.prog-step.state-done  .prog-node { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.prog-step.state-current .prog-node { border-color: var(--leaf); color: var(--leaf-dark); box-shadow: 0 0 0 3px var(--leaf-soft); }
.prog-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.prog-label { font-size: .72rem; margin-top: 5px; color: var(--ink); }
.prog-step.state-future .prog-label { color: var(--muted); }
.prog-date { font-size: .68rem; color: var(--muted); margin-top: 2px; }
.prog-date.planned { font-style: italic; }

/* ── Status pills ───────────────────────────────────────────────────────── */
.status-pill {
  display: inline-block; white-space: nowrap; padding: 3px 11px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--leaf-soft); color: var(--leaf-dark);
}
.status-pill.state-done { background: #e4efe8; color: var(--leaf-dark); }
.status-pill.state-current { background: var(--leaf-soft); color: var(--leaf-dark); }

/* ── Projects list ──────────────────────────────────────────────────────── */
.filter-group .btn { border-radius: 999px; margin-left: 4px; }
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-row {
  display: grid; grid-template-columns: 1.6fr 1.4fr 1.4fr auto; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px; color: inherit;
}
.project-row:hover { text-decoration: none; border-color: var(--leaf); }
.pr-name { font-weight: 600; }
.pr-meta, .pr-stage-label { color: var(--muted); font-size: .8rem; }
.pr-stage-value { font-weight: 500; }
.pr-expected { color: var(--muted); font-weight: 400; }
.pr-progress { display: flex; align-items: center; gap: 10px; }
.pr-progress .progress { flex: 1; height: 8px; background: var(--line); }
.pr-chevron { color: var(--muted); }

/* ── Detail ─────────────────────────────────────────────────────────────── */
.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.milestone-list { list-style: none; padding: 0; margin: 0; }
.milestone-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.milestone-list li:last-child { border-bottom: 0; }
.milestone-list .ms-label { font-weight: 500; }
.milestone-list li.state-future .ms-label { color: var(--muted); font-weight: 400; }
.ms-date.planned { font-style: italic; color: var(--muted); }
.kv { display: flex; gap: 8px; margin-bottom: 6px; }
.kv .k { color: var(--muted); min-width: 120px; }
.notes { white-space: pre-line; color: var(--ink); }

/* ── Team / general info ────────────────────────────────────────────────── */
.team-supervisor { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--leaf-soft); color: var(--leaf-dark); display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.sup-name { font-weight: 600; }
.sup-role, .sup-line { font-size: .85rem; color: var(--muted); }
.gi-title { font-weight: 600; margin-bottom: 6px; }
.gi-line { font-size: .88rem; color: var(--ink); margin-bottom: 4px; }

/* ── Contacts ───────────────────────────────────────────────────────────── */
.bottom-grid, .contact-summary { margin-top: 18px; }
.bottom-grid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; }
.contact-summary { list-style: none; padding: 0; }
.contact-summary li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.cs-meta { color: var(--muted); font-size: .85rem; }
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.contact-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.contact-card.readonly { background: var(--page); }
.cc-head { display: flex; justify-content: space-between; align-items: center; }
.cc-name { font-weight: 600; }
.cc-line { font-size: .85rem; color: var(--muted); margin-top: 3px; }
.cc-roles { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.role-tag { font-size: .72rem; background: var(--leaf-soft); color: var(--leaf-dark); padding: 2px 8px; border-radius: 999px; }

/* ── User guide ─────────────────────────────────────────────────────────── */
.guide { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.guide-title { display: flex; align-items: center; gap: 9px; color: var(--leaf-dark); }
.guide-title i { font-size: 1.1rem; }
.guide-points { margin: 6px 0 0; padding-left: 18px; }
.guide-points li { margin-bottom: 7px; font-size: .9rem; line-height: 1.45; }
@media (max-width: 768px) { .guide { grid-template-columns: 1fr; } }

/* ── Account / client info list ─────────────────────────────────────────── */
.info-list { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
.info-list dt { color: var(--muted); font-weight: 500; }
.info-list dd { margin: 0; }
@media (max-width: 576px) { .info-list { grid-template-columns: 1fr; gap: 2px 0; }
  .info-list dd { margin-bottom: 8px; } }

/* ── Tables (reports / billing) ─────────────────────────────────────────── */
.table thead th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--line); }
.locked-row { color: var(--muted); background: var(--page); }
.lock-reason { font-size: .78rem; color: var(--amber); }
.new-badge { background: var(--leaf); color: #fff; font-size: .68rem; padding: 1px 7px; border-radius: 999px; margin-right: 6px; }
.inv-status { padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.inv-paid { background: var(--leaf-soft); color: var(--leaf-dark); }
.inv-due { background: #fdf3e0; color: var(--amber); }
.inv-overdue { background: #fbe6e3; color: var(--danger); }
.badge-overdue { display: inline-block; margin-left: 8px; font-size: .7rem; font-weight: 700;
  background: #fbe6e3; color: var(--danger); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }

/* ── Sidebar contact block (above logout) ───────────────────────────────── */
.sidebar-contact { font-size: .72rem; line-height: 1.35; color: #b9d4c4;
  padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-contact .sc-line { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px;
  word-break: break-word; }
.sidebar-contact .sc-line i { flex: none; }
.sidebar-contact a { color: #cfe8d8; }
.sidebar-contact a:hover { color: #fff; }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-page { background: linear-gradient(160deg, var(--forest), var(--leaf-dark)); min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-logo-top { width: 100%; max-width: 400px; text-align: center; margin-bottom: 18px; }
.login-logo-top .login-logo { max-width: 220px; max-height: 84px; width: auto; }
.login-logo-top .login-brand-text { color: #fff; font-size: 1.9rem; font-weight: 700; }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.25); padding: 32px; width: 100%; max-width: 400px; }
.login-brand { text-align: center; margin-bottom: 6px; }
.login-logo { max-width: 180px; max-height: 70px; }
.login-brand-text { font-size: 1.8rem; font-weight: 700; color: var(--forest); }
.login-subtitle { text-align: center; color: var(--muted); margin-bottom: 20px; }
.login-help { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 18px; margin-bottom: 6px; }
.login-divider { display: flex; align-items: center; text-align: center; color: var(--muted);
  font-size: .8rem; margin: 16px 0; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; border-bottom: 1px solid var(--line); }
.login-divider span { padding: 0 12px; }
.login-lang { display: block; text-align: center; font-size: .85rem; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--forest); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
.sidebar-backdrop.show { display: block; }
@media (max-width: 992px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid, .bottom-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .burger { display: inline-flex; }
  .project-row { grid-template-columns: 1fr; gap: 8px; }
  .stat-grid, .stat-grid-3 { grid-template-columns: 1fr; }
}


/* ── Active-client selector ───────────────────────────────────────────────────
   Sidebar, under the logo and above the menu. Only rendered when the signed-in
   address is a contact on more than one client, so most sessions never see it. */
.sidebar-client {
  padding: 12px 14px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  background: rgba(0, 0, 0, .14);
}
.sidebar-client-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .62);
}
.sidebar-client-select {
  width: 100%;
  padding: .48rem 1.9rem .48rem .65rem;
  font-size: .87rem;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: rgba(255, 255, 255, .10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3E%3Cpath d='M4.5 6.5L8 10l3.5-3.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .55rem center;
  background-size: 14px;
  transition: background-color .15s ease, border-color .15s ease;
}
.sidebar-client-select:hover {
  background-color: rgba(255, 255, 255, .17);
  border-color: rgba(255, 255, 255, .38);
}
.sidebar-client-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, .6);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .13);
}
/* The list itself is drawn by the OS — it needs readable colours of its own. */
.sidebar-client-select option { color: #1d2b23; background: #fff; }
