@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --sacco-green:   #0a6e4e;
  --sacco-green2:  #0d8a62;
  --sacco-light:   #e8f5f0;
  --sacco-gold:    #c49a2a;
  --sacco-gold2:   #e8b83e;
  --danger:        #c0392b;
  --warning:       #d68910;
  --info:          #1a6fa8;
  --text-primary:  #1a1f1c;
  --text-secondary:#4a5750;
  --text-muted:    #8a9e96;
  --bg:            #f4f7f5;
  --card:          #ffffff;
  --border:        #dce8e2;
  --sidebar-w:     240px;
  --radius:        10px;
  --shadow:        0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
}

/* ── LAYOUT ───────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sacco-green);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-logo .logo-mark {
  width: 36px; height: 36px;
  background: var(--sacco-gold);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: #fff; font-size: 16px;
  margin-bottom: 10px;
}
.sidebar-logo h2 {
  font-size: 13px; font-weight: 600;
  color: #fff; line-height: 1.3;
}
.sidebar-logo span {
  font-size: 11px; color: rgba(255,255,255,.55);
  font-weight: 400;
}

.sidebar-section {
  padding: 16px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  border-radius: 8px;
  margin: 1px 8px;
  font-size: 13.5px;
  font-weight: 400;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 500; }
.nav-item .nav-icon { font-size: 16px; opacity: .85; }

.sidebar-bottom {
  margin-top: auto;
  padding: 16px 8px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--sacco-gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 12px; color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role-badge { font-size: 10px; color: rgba(255,255,255,.5); }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 24px 28px; flex: 1; }

/* ── CARDS ───────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── STAT CARDS ──────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-card .stat-value { font-size: 28px; font-weight: 600; color: var(--sacco-green); line-height: 1; }
.stat-card .stat-sub   { font-size: 12px; color: var(--text-secondary); }
.stat-card.gold  .stat-value { color: var(--sacco-gold); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.info  .stat-value { color: var(--info); }

/* ── TABLE ───────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #fafcfb;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #f0f4f2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fbf9; }

/* ── BADGES ──────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-green   { background: #d4edda; color: #155724; }
.badge-yellow  { background: #fff3cd; color: #856404; }
.badge-red     { background: #f8d7da; color: #721c24; }
.badge-blue    { background: #d1ecf1; color: #0c5460; }
.badge-gray    { background: #e9ecef; color: #495057; }
.badge-orange  { background: #fde8d0; color: #8a4200; }

/* ── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  text-decoration: none;
  font-family: inherit;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary   { background: var(--sacco-green); color: #fff; }
.btn-primary:hover { background: var(--sacco-green2); }
.btn-gold      { background: var(--sacco-gold); color: #fff; }
.btn-gold:hover { background: var(--sacco-gold2); }
.btn-outline   { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-sm        { padding: 5px 12px; font-size: 12px; }
.btn-icon      { padding: 6px 8px; }

/* ── FORMS ───────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
input, select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--sacco-green);
  box-shadow: 0 0 0 3px rgba(10,110,78,.1);
}
textarea { resize: vertical; min-height: 80px; }
.serial-range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.serial-range span { text-align: center; color: var(--text-muted); font-size: 12px; }

/* ── MODAL ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card);
  border-radius: 14px;
  width: 560px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(12px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── ALERTS ──────────────────────────────────── */
.alert-bar {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: #d4edda; color: #155724; }
.alert-error   { background: #f8d7da; color: #721c24; }
.alert-info    { background: #d1ecf1; color: #0c5460; }
.alert-warning { background: #fff3cd; color: #856404; }

/* ── MISC ────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 18px; font-weight: 600; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.mono { font-family: 'DM Mono', monospace; font-size: 13px; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--sacco-green); }
.text-danger { color: var(--danger); }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.gap-10 { display: flex; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ── LOGIN PAGE ──────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #062e20 0%, #0a6e4e 60%, #0d8a62 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 400px; max-width: 94vw;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .mark {
  width: 52px; height: 52px; background: var(--sacco-green);
  border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 12px;
}
.login-logo h1 { font-size: 18px; font-weight: 700; color: var(--sacco-green); }
.login-logo p  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.login-form .form-group { margin-bottom: 16px; }
.login-btn { width: 100%; padding: 11px; font-size: 14px; }

/* ── BREADCRUMB ──────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--sacco-green); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── SEARCH BAR ──────────────────────────────── */
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.search-bar input { max-width: 300px; }

/* ── EMPTY STATE ─────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── SCROLLBAR ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccd8d2; border-radius: 3px; }
