/* ===== KEFRI PFM Portal — modern UI ===== */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;450;500;600;700&display=swap');

:root {
  --kefri: #5b7710;
  --kefri-600: #4e6810;
  --kefri-700: #3f540c;
  --kefri-800: #2f3f09;
  --kefri-900: #202b08;
  --lime: #93c790;
  --lime-200: #c4e0c1;
  --lime-50: #eff6ed;
  --terra: #bd5a2d;
  --terra-600: #a94d24;

  --ink: #1c211a;
  --muted: #69736280;
  --muted-2: #6a7264;
  --line: #e7e6dd;
  --paper: #ffffff;
  --bg: #f4f6ef;
  --bg-2: #eef1e7;

  --ok: #2c7a3f; --ok-bg: #e6f3e8;
  --warn: #96650f; --warn-bg: #faf0d7;
  --info: #2c5a8a; --info-bg: #e7eef8;
  --bad: #a3302a; --bad-bg: #f8e6e3;

  --r: 16px; --r-sm: 10px; --r-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(32,43,8,.04), 0 1px 3px rgba(32,43,8,.06);
  --shadow: 0 4px 12px rgba(32,43,8,.06), 0 12px 32px rgba(32,43,8,.07);
  --shadow-lg: 0 20px 60px rgba(32,43,8,.16);
  --sidebar-w: 264px;
  --topbar-h: 62px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: 'Inter', system-ui, sans-serif; color: var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(147,199,144,.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(91,119,16,.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.6; -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1,h2,h3 { font-family: 'Fraunces', Georgia, serif; color: var(--kefri-800); line-height: 1.18; font-weight: 600; letter-spacing: -.015em; margin: 0 0 .5em; }
a { color: var(--terra-600); text-decoration: none; }
a:hover { text-decoration: underline; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--kefri-800); color: #fff; padding: 10px 16px; z-index: 200; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }

/* ===== App shell ===== */
.app-shell { display: flex; min-height: 100vh; }

/* ===== Sidebar (glassy green) ===== */
.sidebar {
  width: var(--sidebar-w); position: fixed; inset: 0 auto 0 0; z-index: 60;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--kefri) 0%, var(--kefri-800) 100%);
  color: #eaf1dc; border-right: 1px solid rgba(255,255,255,.08);
}
.sidebar::before {
  content:''; position:absolute; inset:0; pointer-events:none;
  background: radial-gradient(400px 200px at 30% 0%, rgba(255,255,255,.10), transparent 70%);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; position: relative; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-logo { height: 42px; width: 42px; border-radius: 11px; background: #fff; padding: 4px; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.sidebar-title { font-family: 'Fraunces', serif; font-size: 1.12rem; font-weight: 600; color: #fff; }
.sidebar-sub { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--lime-200); }

.sidebar-nav { display: flex; flex-direction: column; padding: 8px 12px; gap: 2px; flex: 1; overflow-y: auto; position: relative; }
.nav-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .14em; color: rgba(234,241,220,.45); padding: 14px 12px 6px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 13px; border-radius: 11px; color: #dbe6c8; font-size: .93rem; font-weight: 500; transition: all .15s; position: relative; }
.nav-item:hover { background: rgba(255,255,255,.10); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.95); color: var(--kefri-800); font-weight: 600; box-shadow: 0 6px 16px rgba(0,0,0,.14); }
.nav-item.active .nav-ico { color: var(--kefri); }
.nav-ico { width: 18px; height: 18px; flex: none; opacity: .95; }
.nav-item.active .nav-ico svg, .nav-ico svg { width: 18px; height: 18px; display: block; }

.sidebar-foot { padding: 14px 16px 18px; position: relative; border-top: 1px solid rgba(255,255,255,.10); }
.sidebar-partner { height: 30px; filter: brightness(0) invert(1); opacity: .85; margin-bottom: 10px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-weight: 700; color: #fff; font-size: .85rem; }
.sidebar-user-name { font-size: .85rem; color: #fff; font-weight: 500; line-height: 1.1; }
.sidebar-user-role { font-size: .7rem; color: var(--lime-200); }
.btn-logout { width: 100%; background: rgba(255,255,255,.10); color: #fff; border: 1px solid rgba(255,255,255,.20); border-radius: 10px; padding: 9px; font-size: .85rem; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-logout:hover { background: rgba(255,255,255,.18); }

.sidebar-backdrop { position: fixed; inset: 0; background: rgba(32,43,8,.5); backdrop-filter: blur(2px); z-index: 55; opacity: 0; visibility: hidden; transition: opacity .2s; }
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* ===== Main ===== */
.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar { display: none; }
.main { flex: 1; padding: 30px 40px 48px; width: 100%; max-width: 1400px; }

/* Page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.7rem; }
.page-head .sub { color: var(--muted-2); font-size: .92rem; margin-top: 2px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Glass cards ===== */
.card {
  background: rgba(255,255,255,.82); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.6); border-radius: var(--r);
  padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.card.solid { background: var(--paper); }
.card h2 { margin-top: 0; font-size: 1.15rem; }

/* ===== Stat tiles ===== */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }
.tile {
  position: relative; overflow: hidden; border-radius: var(--r);
  padding: 20px; background: rgba(255,255,255,.82); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.6); box-shadow: var(--shadow-sm);
}
.tile .t-label { font-size: .78rem; color: var(--muted-2); font-weight: 500; }
.tile .t-value { font-family: 'Fraunces', serif; font-size: 2rem; font-weight: 700; color: var(--kefri-800); line-height: 1.1; margin-top: 4px; }
.tile .t-ico { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--lime-50); color: var(--kefri); }
.tile .t-ico svg { width: 18px; height: 18px; }
.tile.accent { background: linear-gradient(135deg, var(--kefri), var(--kefri-700)); border: none; color: #fff; }
.tile.accent .t-label { color: rgba(255,255,255,.8); }
.tile.accent .t-value { color: #fff; }
.tile.accent .t-ico { background: rgba(255,255,255,.2); color: #fff; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid transparent; border-radius: 11px; padding: 10px 18px; font-size: .92rem; font-weight: 600; cursor: pointer; font-family: inherit; transition: all .15s; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-sm { padding: 7px 13px; font-size: .84rem; border-radius: 9px; }
.btn-primary { background: var(--kefri); color: #fff; box-shadow: 0 6px 16px rgba(91,119,16,.28); }
.btn-primary:hover { background: var(--kefri-600); text-decoration: none; }
.btn-accent { background: var(--terra); color: #fff; box-shadow: 0 6px 16px rgba(189,90,45,.26); }
.btn-accent:hover { background: var(--terra-600); text-decoration: none; }
.btn-ghost { background: rgba(255,255,255,.7); color: var(--kefri-700); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--kefri); text-decoration: none; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border-radius: var(--r); }
.table { width: 100%; border-collapse: collapse; background: transparent; }
.table th, .table td { text-align: left; padding: 13px 16px; font-size: .9rem; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; font-size: .68rem; font-weight: 600; background: rgba(238,241,231,.6); }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: rgba(147,199,144,.10); }
.table tr:last-child td { border-bottom: none; }

/* ===== Pills ===== */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px; border-radius: 999px; font-size: .74rem; font-weight: 600; text-transform: capitalize; }
.pill::before { content:''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill-draft { background: var(--bg-2); color: var(--muted-2); }
.pill-submitted { background: var(--warn-bg); color: var(--warn); }
.pill-under_review { background: var(--info-bg); color: var(--info); }
.pill-approved { background: var(--ok-bg); color: var(--ok); }
.pill-rejected { background: var(--bad-bg); color: var(--bad); }
.pill-pending { background: var(--warn-bg); color: var(--warn); }
.pill-verified { background: var(--ok-bg); color: var(--ok); }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 16px 20px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.full { grid-column: 1/-1; }
label { font-size: .84rem; font-weight: 600; color: var(--ink); }
input, select, textarea { font-family: inherit; font-size: .94rem; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.9); color: var(--ink); width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--kefri); box-shadow: 0 0 0 4px rgba(91,119,16,.14); }
input[type=file] { padding: 8px; background: var(--bg-2); cursor: pointer; }
textarea { resize: vertical; min-height: 96px; }
.field-note { font-size: .78rem; color: var(--muted-2); }
fieldset { border: 1.5px solid var(--line); border-radius: var(--r); padding: 20px; margin: 0 0 20px; background: rgba(255,255,255,.5); }
legend { font-family: 'Fraunces', serif; color: var(--kefri-800); font-weight: 600; padding: 0 10px; font-size: 1.05rem; }
.form-actions { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.req { color: var(--terra); }
.radio-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.radio, .check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; font-size: .92rem; cursor: pointer; }
.radio input, .check input { width: auto; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 8px 16px; }
.med-block { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.med-block:last-of-type { border-bottom: none; }
.med-q { font-weight: 600; margin: 0 0 8px; }

/* Filter bar */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
.filter-bar .form-row { min-width: 170px; }

/* Chips / lists */
.chip { display: inline-block; background: var(--lime-50); border: 1px solid var(--lime-200); color: var(--kefri-800); border-radius: 999px; padding: 3px 11px; font-size: .78rem; margin: 2px; }
ul.clean { list-style: none; padding: 0; margin: 0; }
ul.clean li { padding: 12px 0; border-bottom: 1px solid var(--line); }
ul.clean li:last-child { border-bottom: none; }
.muted { color: var(--muted-2); }
.mt-0 { margin-top: 0; }
.doc-link { display: inline-flex; align-items: center; gap: 6px; }
.select-col { width: 40px; text-align: center; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Bulk bar */
.bulk-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; padding: 12px 16px; background: linear-gradient(135deg, var(--kefri), var(--kefri-700)); color: #fff; border-radius: var(--r); box-shadow: var(--shadow-sm); }
.bulk-bar.hidden { display: none; }
.bulk-bar .btn-ghost { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.25); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(32,43,8,.55); backdrop-filter: blur(4px); z-index: 80; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop.show { display: flex; }
.modal { background: var(--paper); border-radius: var(--r-lg); max-width: 560px; width: 100%; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.modal-close { background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--muted-2); line-height: 1; }
.char-count { font-size: .78rem; color: var(--muted-2); text-align: right; margin-top: 4px; }
.alert { padding: 12px 15px; border-radius: 10px; font-size: .9rem; margin-bottom: 16px; }
.alert-error { background: var(--bad-bg); color: var(--bad); border: 1px solid #e7b8b4; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #b8ddbf; }

/* Facts */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 14px; margin: 20px 0; }
.fact { background: var(--lime-50); border: 1px solid var(--lime-200); border-radius: var(--r-sm); padding: 13px 15px; }
.fact .k { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--kefri-700); font-weight: 600; }
.fact .v { font-weight: 600; color: var(--kefri-800); margin-top: 3px; }

/* Simple bar chart (reports) */
.barchart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 44px; align-items: center; gap: 12px; font-size: .88rem; }
.bar-track { background: var(--bg-2); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--kefri), var(--lime)); border-radius: 999px; }
.bar-val { text-align: right; font-weight: 600; color: var(--kefri-800); }

/* ===== Auth (applicant) ===== */
.auth-wrap { max-width: 440px; margin: 40px auto; }
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head img { height: 54px; margin-bottom: 12px; }

/* ===== Landing hero ===== */
.hero { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: 48px; margin-bottom: 24px; color: #fff; background: linear-gradient(135deg, var(--kefri) 0%, var(--kefri-700) 60%, var(--kefri-800) 100%); box-shadow: var(--shadow); }
.hero::after { content:''; position:absolute; inset:0; background: radial-gradient(600px 300px at 90% -20%, rgba(147,199,144,.35), transparent 60%); pointer-events:none; }
.hero .eyebrow { display: inline-flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--lime-200); font-weight: 600; margin-bottom: 14px; position: relative; }
.hero h1 { color: #fff; font-size: 2.4rem; margin: 0 0 14px; max-width: 22ch; position: relative; }
.hero p.lead { color: rgba(255,255,255,.9); font-size: 1.1rem; max-width: 62ch; margin: 0; position: relative; }
.hero-actions { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; position: relative; }
.hero .btn-ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.3); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; width: 280px; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .app-main { margin-left: 0; }
  .topbar { display: flex; align-items: center; gap: 14px; height: var(--topbar-h); background: linear-gradient(180deg, var(--kefri), var(--kefri-700)); padding: 0 16px; position: sticky; top: 0; z-index: 50; }
  .menu-btn { display: flex; flex-direction: column; gap: 5px; background: none; border: 0; cursor: pointer; padding: 6px; }
  .menu-btn span { width: 24px; height: 2px; background: #fff; border-radius: 2px; }
  .topbar-brand { display: flex; align-items: center; gap: 10px; color: #fff; }
  .topbar-brand:hover { text-decoration: none; }
  .topbar-brand img { height: 34px; background: #fff; border-radius: 8px; padding: 3px; }
  .topbar-brand span { font-family: 'Fraunces', serif; font-weight: 600; }
  .main { padding: 22px 18px 40px; }
  .two-col { grid-template-columns: 1fr; }
  .hero { padding: 32px; } .hero h1 { font-size: 1.8rem; }
  .form-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 40px; }
}
@media (max-width: 480px) { .main { padding: 18px 14px 36px; } .hero { padding: 26px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ===== Public pages (no sidebar) ===== */
.public-nav { background: linear-gradient(180deg, var(--kefri), var(--kefri-700)); box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 50; }
.public-nav-inner { max-width: 1160px; margin: 0 auto; padding: 0 24px; height: 68px; display: flex; align-items: center; justify-content: space-between; }
.public-brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.public-brand:hover { text-decoration: none; }
.public-brand img { height: 42px; width: 42px; border-radius: 11px; background: #fff; padding: 4px; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.public-brand-title { display: block; font-family: 'Fraunces', serif; font-size: 1.1rem; font-weight: 600; color: #fff; line-height: 1.1; }
.public-brand-sub { display: block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--lime-200); }
.public-links { display: flex; align-items: center; gap: 22px; }
.public-links a { color: #eaf1dc; font-size: .94rem; font-weight: 500; }
.public-links a:hover { color: #fff; text-decoration: none; }
.public-links a.active { color: #fff; }
.public-main { max-width: 1160px; margin: 0 auto; padding: 32px 24px 56px; }
@media (max-width: 560px) {
  .public-brand-sub { display: none; }
  .public-links { gap: 14px; }
  .public-nav-inner { padding: 0 16px; }
}

/* ===== Document previews ===== */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 16px; }
.doc-card { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; box-shadow: var(--shadow-sm); }
.doc-preview { height: 200px; background: var(--bg-2); display: grid; place-items: center; overflow: hidden; }
.doc-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-preview iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.doc-fallback { font-size: 3rem; opacity: .5; }
.doc-meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.doc-type { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--kefri-700); font-weight: 600; }
.doc-name { font-size: .86rem; color: var(--ink); word-break: break-word; }
.doc-name:hover { color: var(--terra-600); }
.upload-more { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; }
.upload-more summary { cursor: pointer; font-weight: 600; color: var(--kefri-700); font-size: .9rem; }
.upload-more summary:hover { color: var(--kefri); }
