/* SGR TSL Platform — design system
 * Brand: Sustainable Growers Rwanda × Brider
 * Inspired by Bloomberg Philanthropies' coffee-and-earth palette,
 * tuned for women coffee farmer programmes.
 */

:root {
  /* Brand palette */
  --sgr-coffee:    #3F2A1D;   /* deep roasted coffee */
  --sgr-coffee-2:  #5C3A24;
  --sgr-cream:     #F5EBDC;   /* milk in coffee */
  --sgr-leaf:      #2F8F5D;   /* coffee plant green */
  --sgr-leaf-2:    #1F6E45;
  --sgr-cherry:    #C7301E;   /* coffee cherry red */
  --sgr-honey:     #E8A03C;   /* honey/sun */
  --sgr-sky:       #1E4D6B;   /* deep blue */
  --sgr-paper:     #FAF7F1;   /* warm paper */
  --sgr-ink:       #1F1B18;
  --sgr-mute:      #6E5F50;

  /* Neutrals */
  --bg-app:        #F8F5EE;
  --bg-card:       #FFFFFF;
  --border-soft:   #E8DECF;
  --border-firm:   #CFC2AE;
  --text-strong:   #1F1B18;
  --text-mute:     #6E5F50;
  --text-light:    #9C8A78;

  /* Status */
  --green-50:  #ECFDF5;  --green-500: #10B981;  --green-700: #047857;
  --amber-50:  #FFFBEB;  --amber-500: #F59E0B;  --amber-700: #B45309;
  --rose-50:   #FFF1F2;  --rose-500:  #F43F5E;  --rose-700:  #BE123C;
  --blue-50:   #EFF6FF;  --blue-500:  #3B82F6;  --blue-700:  #1D4ED8;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(63,42,29,0.06);
  --shadow-md: 0 6px 16px -4px rgba(63,42,29,0.10), 0 2px 6px -2px rgba(63,42,29,0.06);
  --shadow-lg: 0 16px 32px -8px rgba(63,42,29,0.16), 0 4px 12px -4px rgba(63,42,29,0.08);
  --shadow-card: 0 1px 0 rgba(63,42,29,0.04), 0 4px 14px -2px rgba(63,42,29,0.08);

  /* Radii */
  --r-sm: 6px;  --r-md: 10px;  --r-lg: 14px;  --r-xl: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text-strong);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ----- Login splash ----- */
.login-bg {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 20%, rgba(232,160,60,0.20), transparent 40%),
    radial-gradient(circle at 92% 12%, rgba(47,143,93,0.18), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(199,48,30,0.12), transparent 50%),
    linear-gradient(135deg, #2A1B12 0%, #3F2A1D 50%, #5C3A24 100%);
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle 4px at 10% 30%, rgba(245,235,220,0.06) 100%, transparent),
    radial-gradient(circle 3px at 25% 70%, rgba(245,235,220,0.06) 100%, transparent),
    radial-gradient(circle 5px at 70% 20%, rgba(245,235,220,0.06) 100%, transparent),
    radial-gradient(circle 3px at 85% 65%, rgba(245,235,220,0.06) 100%, transparent),
    radial-gradient(circle 4px at 50% 50%, rgba(245,235,220,0.04) 100%, transparent);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 920px;
  background: var(--bg-card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  min-height: 540px;
}
@media (max-width: 768px) {
  .login-card { grid-template-columns: 1fr; }
  .login-card .login-art { display: none; }
}

.login-art {
  background:
    linear-gradient(135deg, rgba(63,42,29,0.78), rgba(47,143,93,0.85)),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600"><defs><pattern id="p" x="0" y="0" width="60" height="60" patternUnits="userSpaceOnUse"><circle cx="30" cy="30" r="6" fill="white" opacity="0.04"/><circle cx="0" cy="0" r="3" fill="white" opacity="0.06"/><circle cx="60" cy="60" r="3" fill="white" opacity="0.06"/></pattern></defs><rect width="100%" height="100%" fill="url(%23p)"/></svg>');
  color: white;
  padding: 36px 32px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-art h1 {
  font-size: 28px; font-weight: 800; line-height: 1.18;
  margin: 16px 0 8px; letter-spacing: -0.01em;
}
.login-art p { color: rgba(255,255,255,0.85); font-size: 14px; }

.login-form { padding: 36px 36px; display: flex; flex-direction: column; }
.login-form h2 { font-size: 24px; font-weight: 800; margin: 0 0 4px; color: var(--text-strong); }
.login-form .sub { color: var(--text-mute); font-size: 13px; margin-bottom: 24px; }

.form-row { margin-bottom: 16px; }
.form-row label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.form-row .input-wrap { position: relative; }
.form-row input, .form-row select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-strong);
  outline: none;
  transition: all 0.15s ease;
}
.form-row input:focus, .form-row select:focus {
  border-color: var(--sgr-leaf);
  box-shadow: 0 0 0 3px rgba(47,143,93,0.15);
}
.form-row input::placeholder { color: var(--text-light); }

/* Custom select */
.form-row select {
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%236E5F50" stroke-width="2.5"><polyline points="6 9 12 15 18 9"></polyline></svg>');
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.btn-primary {
  width: 100%;
  background: var(--sgr-leaf);
  color: white;
  border: 0;
  padding: 13px 16px;
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
}
.btn-primary:hover { background: var(--sgr-leaf-2); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-mute);
  border: 1.5px solid var(--border-soft);
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-ghost:hover { border-color: var(--sgr-leaf); color: var(--sgr-leaf); }

.row-between { display: flex; align-items: center; justify-content: space-between; }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-mute); }
.muted-link { font-size: 13px; color: var(--sgr-cherry); font-weight: 600; text-decoration: none; }
.muted-link:hover { text-decoration: underline; }

/* ----- App chrome (post-login) ----- */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--sgr-coffee) 0%, var(--sgr-coffee-2) 100%);
  color: white;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--sgr-leaf); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; letter-spacing: -0.02em;
  box-shadow: 0 2px 8px rgba(47,143,93,0.4);
}
.sidebar-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidebar-sub { font-size: 11px; color: rgba(255,255,255,0.65); margin-top: 2px; }

.sidebar-nav {
  flex: 1; overflow-y: auto;
  padding: 14px 10px;
}
.sidebar-section { margin-bottom: 20px; }
.sidebar-section-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; padding: 6px 10px; color: rgba(255,255,255,0.45);
}
.sidebar-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 11px;
  border-radius: 8px;
  color: rgba(255,255,255,0.78);
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: white; }
.sidebar-link.active {
  background: rgba(47,143,93,0.18);
  color: white;
  position: relative;
}
.sidebar-link.active::before {
  content: ''; position: absolute; left: -10px; top: 6px; bottom: 6px;
  width: 3px; background: var(--sgr-leaf); border-radius: 0 3px 3px 0;
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.85; }
.sidebar-badge {
  margin-left: auto;
  background: var(--sgr-cherry); color: white;
  font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
}
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.main-pane { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  background: white;
  border-bottom: 1px solid var(--border-soft);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 16px;
  min-height: 60px;
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--text-strong); margin: 0; }
.topbar-sub { font-size: 12px; color: var(--text-mute); margin: 2px 0 0; }
.topbar-spacer { flex: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.pill-ok    { background: var(--green-50); color: var(--green-700); }
.pill-warn  { background: var(--amber-50); color: var(--amber-700); }
.pill-err   { background: var(--rose-50);  color: var(--rose-700); }
.pill-info  { background: var(--blue-50);  color: var(--blue-700); }
.pill-ghost { background: var(--bg-app);   color: var(--text-mute); }

.lang-select {
  padding: 6px 10px;
  border: 1.5px solid var(--border-soft);
  background: white;
  border-radius: var(--r-md);
  font-size: 12px; font-weight: 600;
  color: var(--text-strong);
  cursor: pointer;
}
.lang-select:focus { outline: none; border-color: var(--sgr-leaf); }

.scroll-pane {
  flex: 1; overflow-y: auto;
  background: var(--bg-app);
}
.page-content { padding: 24px; max-width: 1380px; margin: 0 auto; }

/* ----- Cards ----- */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 18px 20px; }
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text-strong); margin: 0; }

/* ----- KPI cards ----- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 700; color: var(--text-mute);
}
.kpi-value {
  font-size: 26px; font-weight: 800; color: var(--text-strong);
  margin-top: 4px;
  letter-spacing: -0.01em;
}
.kpi-delta {
  font-size: 11px; font-weight: 600; margin-top: 4px;
}
.kpi-delta.up   { color: var(--green-700); }
.kpi-delta.down { color: var(--rose-700); }
.kpi-delta.flat { color: var(--text-mute); }

.kpi-icon {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px;
  background: var(--sgr-cream); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sgr-coffee);
}

/* ----- Tables ----- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left; font-size: 10px; font-weight: 700;
  color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 14px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-soft);
}
.tbl tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-strong);
}
.tbl tbody tr:hover { background: rgba(245,235,220,0.4); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td {
  padding: 12px 14px;
  background: var(--bg-app);
  font-weight: 700;
}
.tbl-mono { font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 12px; }

/* ----- Sparkline / mini bar chart ----- */
.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 28px; }
.spark .bar { width: 5px; background: var(--sgr-leaf); border-radius: 1px; }

/* ----- Section title ----- */
.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; color: var(--text-mute);
  margin: 0 0 12px;
}

/* ----- Footer ----- */
.app-footer {
  background: white;
  border-top: 1px solid var(--border-soft);
  padding: 8px 24px;
  font-size: 11px; color: var(--text-light);
  display: flex; justify-content: space-between;
}

/* ----- Phone frame for mobile-view ----- */
.phone-frame {
  width: 320px; height: 640px;
  background: #1B1610;
  border-radius: 36px;
  padding: 14px 10px;
  box-shadow: 0 30px 60px -12px rgba(63,42,29,0.30), 0 0 0 8px #2D241D inset;
  position: relative;
  margin: 0 auto;
}
.phone-screen {
  width: 100%; height: 100%;
  background: #fff;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
}
.phone-notch {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 80px; height: 18px; background: #1B1610; border-radius: 0 0 14px 14px;
  z-index: 10;
}
.phone-status {
  background: #fff; padding: 24px 14px 6px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #1B1610; font-weight: 700;
}
.phone-content { height: calc(100% - 90px); overflow-y: auto; }
.phone-tabbar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid #E8DECF;
  display: flex; justify-content: space-around;
  padding: 8px 0 14px; font-size: 10px; color: #6E5F50;
}
.phone-tab.active { color: var(--sgr-coffee); font-weight: 700; }

/* ----- Utility ----- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-mute { color: var(--text-mute); }
.text-light { color: var(--text-light); }
.text-strong { color: var(--text-strong); }
.text-leaf { color: var(--sgr-leaf); }
.text-cherry { color: var(--sgr-cherry); }
.text-honey { color: var(--sgr-honey); }
.font-mono { font-family: 'JetBrains Mono', 'Consolas', monospace; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-xs { font-size: 11px; } .text-sm { font-size: 12px; } .text-base { font-size: 14px; }
.text-lg { font-size: 16px; } .text-xl { font-size: 18px; } .text-2xl { font-size: 22px; } .text-3xl { font-size: 28px; }

/* Two-column grid */
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 1024px) {
  .grid-2-1, .grid-1-1, .grid-3 { grid-template-columns: 1fr; }
}

/* Animations */
@keyframes slidein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.slide-in { animation: slidein 0.3s ease; }
