/* ============================================================
   ChamaFlow — Core design system
   ============================================================ */
:root {
  --primary:    #10251D;
  --main:       #176B4D;
  --secondary:  #2B8A63;
  --accent:     #D8EF9B;

  --bg:         #F5F6F1;
  --card:       #FFFFFF;
  --text:       #1B2520;
  --muted:      #718078;
  --border:     #E5E8E2;

  --danger:     #B8443A;
  --warn:       #B98900;
  --info:       #2563EB;

  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;

  --shadow-sm:  0 1px 2px rgba(16,37,29,0.04);
  --shadow:     0 6px 20px rgba(16,37,29,0.06);
  --shadow-lg:  0 16px 40px rgba(16,37,29,0.10);

  --font:         'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Manrope', 'DM Sans', system-ui, sans-serif;

  --sidebar-w: 260px;
  --topbar-h:  68px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}
h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 26px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 700; }

p { margin: 0 0 8px; }

a { color: var(--main); text-decoration: none; }
a:hover { color: var(--secondary); }

.muted      { color: var(--muted); }
.small      { font-size: 13px; }
.text-right { text-align: right; }
.hidden     { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  font-family: var(--font); font-weight: 600; font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, color .15s ease, border-color .15s ease;
  text-decoration: none;
  color: var(--text);
  background: transparent;
}
.btn:active       { transform: translateY(1px); }
.btn-primary      { background: var(--main); color: #fff; }
.btn-primary:hover{ background: var(--secondary); color: #fff; }
.btn-outline      { border-color: var(--border); background: #fff; }
.btn-outline:hover{ border-color: var(--main); color: var(--main); }
.btn-ghost        { color: var(--muted); }
.btn-ghost:hover  { background: var(--bg); }
.btn-danger       { background: var(--danger); color: #fff; }
.btn-block        { width: 100%; }

/* Inputs */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
  font-family: var(--font);
  font-size: 14px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--main);
  box-shadow: 0 0 0 3px rgba(23,107,77,.12);
}

.form-row-between { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 18px; font-size: 13px; }
.checkbox { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); }
.checkbox input { width: 16px; height: 16px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; border: 1px solid; }
.alert-error   { background: #FDEEEC; border-color: #F5C9C4; color: #7A1B14; }
.alert-success { background: #ECF6EF; border-color: #C9E7D3; color: #10492F; }
.alert-warning { background: #FFF8E5; border-color: #F2E1B4; color: #6C4F00; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  border: 1px solid var(--border);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.empty-state { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 10px;
  border-radius: 999px;
  background: #EEF1EC; color: var(--text);
}
.badge-paid     { background: #DFF3E5; color: #14613C; }
.badge-pending  { background: #FFF6DC; color: #7A5A00; }
.badge-partial  { background: #E7EEFF; color: #173F9B; }
.badge-missed   { background: #FBE5E2; color: #7A1B14; }
.badge-open     { background: #E7EEFF; color: #173F9B; }
.badge-ready_for_payout { background: #FFF6DC; color: #7A5A00; }
.badge-closed   { background: #EEF1EC; color: var(--muted); }
.badge-info     { background: #E7EEFF; color: #173F9B; }
.badge-active   { background: #DFF3E5; color: #14613C; }
.badge-confirmed{ background: #DFF3E5; color: #14613C; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }

/* Avatars */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary); color: var(--accent);
  font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
  flex: 0 0 auto;
}
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; font-size: 22px; }

/* Brand marks */
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: var(--accent); color: var(--primary);
  border-radius: 10px; font-weight: 800; font-size: 13px;
  font-family: var(--font-display);
}
.brand-mark-lg { width: 46px; height: 46px; font-size: 18px; border-radius: 14px; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: inherit; }

/* App layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex; flex-direction: column;
  padding: 22px 14px;
  position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform .2s ease;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 22px;
  color: #fff;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: #7C9889; padding: 14px 12px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #CFDDD5; font-weight: 500; font-size: 14px;
  text-decoration: none;
}
.nav-link i { width: 18px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: var(--main); color: #fff; }
.nav-link-danger:hover { background: rgba(184,68,58,.15); color: #FFD2CD; }
.sidebar-footer { padding: 12px 10px 0; color: #7C9889; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35;
}

.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.menu-toggle {
  display: none;
  background: transparent; border: 0; font-size: 20px; cursor: pointer; color: var(--text);
}
.page-title { font-size: 18px; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  color: var(--text); background: #fff; border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { border-color: var(--main); color: var(--main); }
.badge-dot {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 999px; min-width: 16px; text-align: center;
}
.topbar-user { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.topbar-user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.topbar-user-meta strong { font-size: 13px; }
.topbar-user-meta small { color: var(--muted); font-size: 11px; }

.content { padding: 26px; max-width: 1200px; width: 100%; }
.app-footer { padding: 20px 26px 30px; color: var(--muted); font-size: 12px; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-header-user { display: flex; gap: 16px; align-items: center; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Forms grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 20px;
}
.form-group-full { grid-column: 1 / -1; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,37,29,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 60; padding: 16px;
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 22px 8px;
}
.modal-body { padding: 0 22px 22px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }

/* Toasts */
.toast-container {
  position: fixed; bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 80;
}
.toast {
  min-width: 240px; max-width: 340px;
  background: var(--primary); color: #fff;
  padding: 12px 14px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toast-in .18s ease;
}
.toast-success { background: #10492F; }
.toast-error   { background: #7A1B14; }
@keyframes toast-in {
  from { transform: translateY(6px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* Auth screens */
.auth-body { background: var(--bg); }
.auth-wrap {
  display: grid; grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}
.auth-brand {
  background: var(--primary); color: #fff;
  padding: 60px;
  display: flex; flex-direction: column; justify-content: center;
}
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.auth-logo .brand-name { color: #fff; font-size: 18px; }
.auth-brand h1 { color: #fff; font-size: 34px; margin-bottom: 8px; }
.auth-brand p  { color: #B7C9BE; max-width: 400px; }
.auth-features {
  list-style: none; padding: 0; margin: 28px 0 0;
  display: flex; flex-direction: column; gap: 10px;
  color: #CFDDD5;
}
.auth-features li { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.auth-features i  { color: var(--accent); }
.auth-card {
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px;
  background: #fff;
}
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card form { margin-top: 22px; max-width: 380px; }
.auth-card .btn-block { margin-top: 6px; }