
/* Habitat for Humanity Bangladesh — Official Design System Tokens */
:root {
  --hfh-deep-green: #003a1f;
  --hfh-primary-green: #00723f;
  --hfh-mid-green: #009245;
  --hfh-cyan-accent: #007b85;
  --hfh-leaf: #8dc63f;
  --hfh-orange: #f7941d;
  --hfh-alert-red: #b3261e;
  --hfh-ink: #1c2621;
  --hfh-muted: #5e6b63;
  --hfh-surface: #f4f8f5;
  --hfh-card-bg: #ffffff;
  --hfh-border: #d4e5da;
  --hfh-shadow: 0 4px 18px rgba(0, 58, 31, 0.06);
  --hfh-shadow-lg: 0 10px 30px rgba(0, 58, 31, 0.10);
  
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-bengali: 'Noto Sans Bengali', sans-serif;
  --font-serif: 'Noto Serif', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--hfh-ink);
  background-color: var(--hfh-surface);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Left Rail Navigation */
.left-rail {
  width: 275px;
  background: linear-gradient(180deg, #002c17 0%, var(--hfh-deep-green) 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.left-rail .brand {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

/* The mark sits directly on the rail. A white card behind a logo reads as a
   sticker; the reversed (white-on-transparent) mark is the correct treatment
   for a dark ground and is what Habitat's own guidance specifies. */
.brand-logo-card {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  min-width: 0;
}

.official-hfh-logo {
  max-width: 100%;
  height: auto;
  max-height: 48px;
  object-fit: contain;
}

.sidebar-toggle-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-radius: 6px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.brand-title h1 {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.brand-title p {
  font-size: 0.75rem;
  color: #a0d8b9;
  margin-top: 2px;
  font-weight: 600;
}

.left-rail nav {
  flex: 1;
  padding: 20px 12px;
}

.left-rail nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #d0e8db;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.left-rail nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transform: translateX(3px);
}

.left-rail nav a.active {
  background: var(--hfh-primary-green);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 114, 63, 0.35);
}

/* Inline SVG icons inherit currentColor, so they take the colour of the
   nav item, chip or button they sit in -- no per-context asset needed. */
.icon {
  display: inline-block;
  vertical-align: -0.18em;
  flex: 0 0 auto;
}

.nav-icon-img {
  width: 20px;
  height: 20px;
  opacity: 0.92;
}

.left-rail nav a.active .nav-icon-img {
  opacity: 1;
}

.btn-icon-img {
  width: 17px;
  height: 17px;
}

.left-rail nav a .badge {
  margin-left: auto;
  background-color: var(--hfh-orange);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
}

.left-rail .rail-footer {
  padding: 18px 20px;
  font-size: 0.76rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #a0d8b9;
  background: rgba(0, 0, 0, 0.1);
}

/* Collapsed State Styles */
body.sidebar-collapsed .left-rail {
  width: 76px;
}

body.sidebar-collapsed .left-rail .brand {
  padding: 16px 10px;
  align-items: center;
}

body.sidebar-collapsed .left-rail .brand-header-row {
  flex-direction: column;
  gap: 10px;
}

body.sidebar-collapsed .left-rail .brand-logo-card {
  padding: 6px;
}

body.sidebar-collapsed .left-rail .official-hfh-logo {
  max-height: 36px;
}

body.sidebar-collapsed .left-rail .brand-title,
body.sidebar-collapsed .left-rail .rail-footer,
body.sidebar-collapsed .left-rail nav a .nav-text {
  display: none !important;
}

body.sidebar-collapsed .left-rail nav {
  padding: 16px 8px;
}

body.sidebar-collapsed .left-rail nav a {
  justify-content: center;
  padding: 14px 10px;
  position: relative;
}

body.sidebar-collapsed .left-rail nav a .nav-icon-img {
  width: 26px;
  height: 26px;
}

body.sidebar-collapsed .left-rail nav a .badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.62rem;
  padding: 2px 5px;
}

/* Main Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Header Bar */
.top-bar {
  background-color: #ffffff;
  border-bottom: 1px solid var(--hfh-border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.disclaimer-banner {
  background: linear-gradient(90deg, #fff8e1 0%, #fff3cd 100%);
  border: 1px solid #ffe082;
  color: #7a5c00;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--hfh-surface);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--hfh-border);
}

.lang-toggle form button {
  background: transparent;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--hfh-muted);
  transition: all 0.2s ease;
}

.lang-toggle form button.active {
  background-color: #ffffff;
  color: var(--hfh-deep-green);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Main Content Area */
.content-area {
  padding: 28px 32px;
  flex: 1;
}

/* Typography & Display Headers */
.page-title {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--hfh-deep-green);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--hfh-muted);
  margin-bottom: 24px;
  font-weight: 500;
}

.hero-number {
  font-family: var(--font-serif);
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--hfh-deep-green);
  line-height: 1;
}

/* KPI Top Grid */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background-color: var(--hfh-card-bg);
  border: 1px solid var(--hfh-border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--hfh-shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--hfh-shadow-lg);
}

.kpi-card .kpi-label {
  font-size: 0.82rem;
  color: var(--hfh-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.kpi-card .denominator {
  font-size: 0.84rem;
  color: var(--hfh-muted);
  margin-top: 6px;
  font-weight: 600;
}

/* Progress Bars */
.progress-bar-bg {
  width: 100%;
  height: 8px;
  background-color: #e5efe9;
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--hfh-primary-green) 0%, var(--hfh-leaf) 100%);
  border-radius: 4px;
}

/* Status Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.chip.on-track {
  background-color: #e6f5ec;
  color: var(--hfh-mid-green);
  border: 1px solid #c2e5d1;
}

.chip.exception {
  background-color: #fff3e0;
  color: #d97706;
  border: 1px solid #fde68a;
}

.chip.pending {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.chip.critical {
  background-color: #fee2e2;
  color: var(--hfh-alert-red);
  border: 1px solid #fca5a5;
}

/* UI Panels & Cards */
.panel {
  background-color: var(--hfh-card-bg);
  border: 1px solid var(--hfh-border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--hfh-shadow);
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--hfh-deep-green);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.data-table th {
  background-color: #f7faf8;
  color: var(--hfh-deep-green);
  text-align: left;
  padding: 12px 16px;
  font-weight: 700;
  border-bottom: 2px solid var(--hfh-border);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--hfh-border);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: #f8fcf9;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary {
  background-color: var(--hfh-primary-green);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 114, 63, 0.2);
}

.btn-primary:hover {
  background-color: var(--hfh-deep-green);
  box-shadow: 0 6px 16px rgba(0, 58, 31, 0.3);
  transform: translateY(-1px);
}

.btn-orange {
  background-color: var(--hfh-orange);
  color: #ffffff;
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--hfh-ink);
  border: 1px solid var(--hfh-border);
}

.btn-secondary:hover {
  background-color: var(--hfh-surface);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

/* Alerts & Messages */
.alert-messages {
  margin-bottom: 20px;
}

.alert-item {
  padding: 12px 18px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.alert-item.success {
  background-color: #e6f5ec;
  color: var(--hfh-mid-green);
  border: 1px solid #b7e1cd;
}

.alert-item.info, .alert-item.warning {
  background-color: #fff3e0;
  color: #d97706;
  border: 1px solid #fde68a;
}

/* ---------------------------------------------------------------------------
   Layout utilities
   Grid definitions were inline on the elements, where no media query could
   reach them. They live here so the breakpoints below can restack them.
--------------------------------------------------------------------------- */

.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.split-main {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.gap-sm { gap: 12px; }
.gap-lg { gap: 24px; }
.mb-16 { margin-bottom: 16px; }

/* ---------------------------------------------------------------------------
   Breakpoints
   The stylesheet had none: a fixed 275px rail and a hard four-column KPI grid
   at every width. Three steps -- laptop, tablet, phone. The phone step matters
   beyond tidiness: field capture exists to represent a phone, so it has to be
   presentable at phone width.
--------------------------------------------------------------------------- */

/* Laptops and small desktops: four KPIs stop fitting before the rail does. */
@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .split-main { grid-template-columns: 1fr; }
  .content-area { padding: 24px; }
  .top-bar { padding: 12px 24px; }
}

/* Tablets: reclaim the rail's width by showing icons only. Reuses the same
   presentation as the manual collapse toggle. */
@media (max-width: 900px) {
  .left-rail { width: 76px; }
  .left-rail .brand { padding: 16px 10px; align-items: center; }
  .left-rail .brand-header-row { flex-direction: column; gap: 10px; }
  .left-rail .official-hfh-logo { max-height: 30px; }
  .left-rail .brand-title,
  .left-rail .rail-footer,
  .left-rail nav a .nav-text { display: none; }
  .left-rail nav { padding: 16px 8px; }
  .left-rail nav a { justify-content: center; padding: 14px 10px; position: relative; }
  .left-rail nav a .badge { position: absolute; top: 4px; right: 6px; font-size: 0.62rem; padding: 2px 5px; }
  .sidebar-toggle-btn { display: none; }

  .split-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 1.55rem; }
  .hero-number { font-size: 2.6rem; }

  /* Wide tables scroll inside their own card rather than the page. */
  .panel { overflow-x: auto; }
  .data-table { min-width: 560px; }
}

/* Phones. */
@media (max-width: 640px) {
  body { display: block; }

  .left-rail {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 0 8px;
  }
  .left-rail .brand { display: none; }
  .left-rail nav { display: flex; gap: 4px; padding: 8px 0; flex: 1; }
  .left-rail nav a { margin-bottom: 0; padding: 10px 12px; }

  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
  }
  .disclaimer-banner { font-size: 0.72rem; }
  .lang-toggle { align-self: flex-start; }

  .content-area { padding: 16px; }
  .kpi-row { grid-template-columns: 1fr; gap: 14px; }
  .page-title { font-size: 1.35rem; }
  .hero-number { font-size: 2.3rem; }
}

/* Page header: title on the left, actions on the right -- until there is no
   room for both, when the actions drop beneath the title rather than
   squeezing it into two words per line. */
.page-header {
  display: flex;
  justify-content: space-between;
  /* Aligned to the top so the actions sit level with the title, top-right of
     the content area. Aligned to flex-end they dropped to the bottom of the
     header block and appeared to hover on top of the KPI cards. */
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.page-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

@media (max-width: 760px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .page-actions { flex-wrap: wrap; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }
}
