/* ===========================================================================
   Fiqi Group — Portal design layer
   Builds on css/site.css. Everything here serves the welfare and
   accountability portal: auth, dashboard, campaigns, money tables.

   The identity stays what the site already established — deep acacia green,
   gold, warm cream, Spectral for display type. This layer adds the depth,
   density and data presentation that a financial portal needs.
   =========================================================================== */

:root {
  /* Extra ink step the base sheet lacks */
  --ink-3: #64756c;

  /* Semantic colour for money and state */
  --pos:        #2f5a4b;
  --pos-soft:   #e3ece7;
  --warn:       #8a5a07;
  --warn-soft:  #fdf0da;
  --neg:        #99221a;
  --neg-soft:   #fbe4e2;
  --info:       #1f5673;
  --info-soft:  #e3eef4;

  /* Layered, warm elevation */
  --sh-xs:   0 1px 2px rgba(16,40,32, .06);
  --sh-ring: 0 0 0 1px rgba(16,40,32, .06);
  --sh-up:   0 18px 40px -16px rgba(47,90,75, .28), 0 2px 8px rgba(16,40,32, .06);
  --sh-deep: 0 36px 80px -28px rgba(38,74,62, .40), 0 4px 14px rgba(16,40,32, .08);

  /* Premium surface treatments */
  --grad-gold:  linear-gradient(135deg, #d8a845 0%, #c2902f 48%, #a97a22 100%);
  --grad-sheen: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,0));
  --grad-paper: linear-gradient(168deg, #ffffff 0%, #f4faf7 100%);

  --ring-focus: 0 0 0 3px rgba(82,127,110, .18);

  /* Tabular figures for every money column */
  --num: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* --------------------------------------------------------------- primitives */

.portal-body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(194, 144, 47, .07), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(82,127,110, .06), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

.num,
.money {
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -.01em;
}

.money-pos { color: var(--pos); }
.money-neg { color: var(--neg); }

/* Eyebrow with a gold rule, used above section titles */
.p-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--gold);
}
.p-eyebrow::before {
  content: "";
  width: 26px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad-gold);
}

/* ------------------------------------------------------------------- cards */

.p-card {
  position: relative;
  background: var(--grad-paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
  padding: 24px 26px;
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}

/* A hairline of light along the top edge — reads as depth, not decoration */
.p-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .9), transparent);
  pointer-events: none;
}

.p-card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-up);
  border-color: var(--line-2);
}

.p-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.p-card-head h3 { font-size: 18px; line-height: 1.3; }
.p-card-head p  { font-size: 14px; color: var(--muted); margin-top: 3px; }

/* --------------------------------------------------------------- stat tiles */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px 22px;
  box-shadow: var(--sh-xs);
}
.stat .k {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat .v {
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  font-size: clamp(24px, 2.6vw, 31px);
  font-weight: 600;
  line-height: 1.1;
  margin-top: 10px;
  color: var(--ink);
}
.stat .s { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* Accent spine, colour-coded by meaning */
.stat::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--grad-gold);
}
.stat-green::after { background: linear-gradient(180deg, #527f6e, #264a3e); }
.stat-warn::after  { background: linear-gradient(180deg, #d9a43c, #8a5a07); }
.stat-neg::after   { background: linear-gradient(180deg, #c2503f, #99221a); }

/* ------------------------------------------------------------------ pills */

.p-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.p-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .85;
}
.pill-ok    { background: var(--pos-soft);  color: var(--pos); }
.pill-warn  { background: var(--warn-soft); color: var(--warn); }
.pill-neg   { background: var(--neg-soft);  color: var(--neg); }
.pill-info  { background: var(--info-soft); color: var(--info); }
.pill-mute  { background: #e7f0ea;          color: var(--muted); }

/* --------------------------------------------------------------- progress */

.p-progress {
  position: relative;
  height: 9px;
  border-radius: 999px;
  background: #dfeae4;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(16,40,32, .08);
}
.p-progress > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3f6b5c, #527f6e 60%, #d8a845);
  transition: width .9s cubic-bezier(.22, 1, .36, 1);
}
.p-progress-lab {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-top: 9px;
  color: var(--muted);
}
.p-progress-lab b { color: var(--ink); font-family: var(--num); }

/* ------------------------------------------------------------------ tables */

.p-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-xs);
}

.p-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  min-width: 560px;
}
.p-table th {
  text-align: start;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.p-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.p-table tbody tr:last-child td { border-bottom: 0; }
.p-table tbody tr { transition: background .16s ease; }
.p-table tbody tr:hover { background: var(--mint-tint); }
.p-table .ta-end { text-align: end; }
.p-table .nowrap { white-space: nowrap; }

/* ------------------------------------------------------------------- forms */

.p-field { display: grid; gap: 7px; }
.p-field > label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.p-field .hint { font-size: 12.5px; color: var(--muted); }

.p-input,
.p-select,
.p-textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.p-textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.p-input:hover,
.p-select:hover,
.p-textarea:hover { border-color: var(--line-strong); }
.p-input:focus,
.p-select:focus,
.p-textarea:focus {
  outline: none;
  border-color: var(--mint);
  box-shadow: var(--ring-focus);
  background: #fff;
}
.p-input[aria-invalid="true"] { border-color: var(--neg); }

.p-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.p-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ----------------------------------------------------------------- buttons */

.p-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease;
  text-decoration: none;
}
.p-btn:active { transform: translateY(1px); }
.p-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.p-btn[disabled] { opacity: .6; cursor: not-allowed; transform: none; }

.p-btn-primary {
  background: var(--grad-mint);
  color: #fff;
  box-shadow: 0 1px 2px rgba(38,74,62, .3), 0 8px 20px -10px rgba(38,74,62, .6);
}
.p-btn-primary:hover:not([disabled]) { box-shadow: 0 2px 4px rgba(38,74,62,.32), 0 14px 28px -12px rgba(38,74,62,.7); }

.p-btn-gold { background: var(--grad-gold); color: #3a2a05; }

.p-btn-quiet {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line-2);
}
.p-btn-quiet:hover:not([disabled]) { border-color: var(--line-strong); background: var(--surface-2); }

.p-btn-danger { background: var(--neg-soft); color: var(--neg); border-color: #f0cdc9; }
.p-btn-sm { font-size: 13.5px; padding: 7px 13px; }
.p-btn-block { width: 100%; }

/* -------------------------------------------------------------- auth shell */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}

.auth-aside {
  position: relative;
  overflow: hidden;
  background: var(--grad-mint);
  color: #fff;
  padding: clamp(36px, 5vw, 76px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
/* The original gold glow here was superseded by the photographic panel
   further down this file; it set height:70%, which left the duotone short. */
.auth-aside h2 {
  font-size: clamp(27px, 3vw, 40px);
  line-height: 1.18;
  margin-top: 22px;
}
.auth-aside p { color: rgba(255, 255, 255, .82); margin-top: 16px; font-size: 16.5px; line-height: 1.65; max-width: 44ch; }

.auth-points { display: grid; gap: 14px; margin-top: 30px; position: relative; z-index: 1; }
.auth-points div { display: flex; gap: 11px; align-items: flex-start; font-size: 15px; color: rgba(255,255,255,.92); }
.auth-points svg { flex: none; margin-top: 2px; }

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 5vw, 64px);
  background: var(--bg);
}
.auth-card { width: 100%; max-width: 430px; }

.auth-tabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--bg-warm);
  border: 1px solid var(--line);
  border-radius: 999px;
  margin-bottom: 26px;
}
.auth-tabs button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.auth-tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--mint);
  box-shadow: var(--sh-xs);
}

/* --------------------------------------------------------- dashboard shell */

.dash {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
}

.dash-side {
  background: var(--grad-mint);
  color: #fff;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.dash-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.dash-brand img { height: 38px; border-radius: 8px; background: #fff; padding: 3px; }
.dash-brand b { font-size: 16px; display: block; line-height: 1.2; }
.dash-brand span { font-size: 11.5px; color: rgba(255,255,255,.7); }

.dash-nav { display: grid; gap: 3px; }
.dash-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-radius: var(--r-sm);
  color: rgba(255, 255, 255, .84);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  transition: background .18s ease, color .18s ease;
}
.dash-nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.dash-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--gold);
}
.dash-nav svg { flex: none; opacity: .9; }

.dash-foot { margin-top: auto; padding: 0 8px; font-size: 12.5px; color: rgba(255,255,255,.62); }

.dash-main { padding: clamp(22px, 3vw, 40px); background: transparent; min-width: 0; }

.dash-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.dash-top h1 { font-size: clamp(24px, 3vw, 33px); line-height: 1.2; }
.dash-top p  { color: var(--muted); margin-top: 6px; font-size: 15px; }

.who {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 7px 6px 15px;
  box-shadow: var(--sh-xs);
}
.who .nm { font-size: 14px; font-weight: 600; line-height: 1.15; }
.who .rl { font-size: 11.5px; color: var(--muted); }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad-gold);
  color: #3a2a05;
  font-weight: 700;
  font-size: 14px;
  flex: none;
}

/* --------------------------------------------------------------- utilities */

.p-section { margin-top: 30px; }
.p-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.p-row-end { justify-content: flex-end; }
.p-spread { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.p-muted { color: var(--muted); }
.p-small { font-size: 13.5px; }
.p-empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.p-empty svg { opacity: .4; margin-bottom: 12px; }

.p-note {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--gold);
  border-radius: 10px;
  padding: 13px 17px;
  font-size: 14px;
  color: var(--ink-2);
}
.p-note-warn { border-inline-start-color: var(--warn); background: var(--warn-soft); }
.p-note-neg  { border-inline-start-color: var(--neg);  background: var(--neg-soft); }

.p-msg { font-size: 14px; margin-top: 12px; display: none; }
.p-msg.on { display: block; }
.p-msg-ok  { color: var(--pos); }
.p-msg-bad { color: var(--neg); }

/* Loading shimmer for data that is on its way */
.p-skel {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, #e7f0ea 25%, #f2f8f5 50%, #e7f0ea 75%);
  background-size: 400% 100%;
  animation: p-shimmer 1.4s ease-in-out infinite;
  height: 15px;
}
@keyframes p-shimmer {
  from { background-position: 100% 0; }
  to   { background-position: 0 0; }
}

/* Modal, used for record/approve forms */
.p-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 28, 18, .5);
  backdrop-filter: blur(3px);
}
.p-modal[hidden] { display: none !important; }
.p-modal-box {
  width: min(620px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-deep);
  padding: 28px;
  animation: p-pop .22s cubic-bezier(.22, 1, .36, 1);
}
@keyframes p-pop {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1000px) {
  .dash { grid-template-columns: 1fr; }
  .dash-side {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    padding: 14px 16px;
  }
  .dash-nav { grid-auto-flow: column; gap: 6px; }
  .dash-nav a { white-space: nowrap; }
  .dash-foot { display: none; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

@media (max-width: 620px) {
  .p-grid-2, .p-grid-3 { grid-template-columns: 1fr; }
  .p-card { padding: 20px 18px; }
  .dash-brand span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ---------------------------------------------- auth panel photograph ----
   A real photograph of a completed community well handover, carried under a
   mint duotone so the image belongs to the palette instead of fighting it.
   Credit and licence: assets/img/CREDITS.md

   Stacking, in order: photo (0) -> duotone (1) -> grain (2) -> content (3).
   The content must be last, or the overlays dim the text. */
.auth-aside { isolation: isolate; }

.auth-photo {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url('../assets/img/community-well.jpg');
  background-size: cover;
  background-position: 62% 46%;
  /* The photograph is bright and sunlit; it has to be taken well down before
     white type can sit on it. */
  filter: grayscale(.45) brightness(.42) contrast(1.12) saturate(.85);
}

/* Duotone: deep mint in the shadows, warm gold lifting one corner. Kept light
   enough that the people in the photograph are still legible. */
.auth-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  height: auto;
  z-index: 1;
  background:
    linear-gradient(168deg, rgba(20,43,35,.80) 0%, rgba(28,58,48,.86) 42%, rgba(16,36,29,.96) 100%),
    radial-gradient(70% 46% at 88% 2%, rgba(194,144,47,.22), transparent 62%);
  pointer-events: none;
}

/* A faint grain stops the large flat panel banding on cheap screens. */
.auth-aside::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: .22;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

.auth-aside > *:not(.auth-photo) { position: relative; z-index: 3; }

/* The panel carries white text over a photograph, so give it a shadow rather
   than trusting the gradient alone. */
/* site.css colours h2 for light backgrounds; this panel is dark. */
.auth-aside h2,
.auth-aside h2 * { color: #fff; }
.auth-aside p { color: rgba(255,255,255,.88); }
.auth-aside h2,
.auth-aside p,
.auth-aside .auth-points { text-shadow: 0 1px 3px rgba(14,32,26,.45); }
