:root {
  --primary:       #4a8a6b;
  --primary-dark:  #3a7259;
  --primary-light: #a8d5b5;
  --primary-xlight:#e8f5ee;
  --sidebar-bg:    #2d5a40;
  --sidebar-text:  #cce8d8;
  --sidebar-hover: #3a7259;
  --sidebar-active:#6bae8a;
  --bg:            #f0f7f3;
  --card-bg:       #ffffff;
  --text:          #2d4a38;
  --text-muted:    #6b8c7a;
  --border:        #c8e6d4;
  --danger:        #dc3545;
  --radius:        12px;
  --shadow:        0 2px 16px rgba(74,138,107,.12);
}

/* ── Reset / Base ─────────────────────────────────── */
* { box-sizing: border-box; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: .9375rem;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ── Layout Shell ─────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  width: 250px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform .25s ease;
  z-index: 100;
}
.sidebar-brand {
  padding: 1.4rem 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-brand img {
  height: 38px;
  width: auto;
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
  padding: 2px;
}
.sidebar-brand-icon {
  font-size: 1.7rem;
  color: var(--primary-light);
}
.sidebar-brand-name {
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: .72rem;
  color: var(--sidebar-text);
  opacity: .7;
}
.sidebar-nav {
  padding: .75rem 0;
  flex: 1;
}
.sidebar-section {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sidebar-text);
  opacity: .5;
  padding: .9rem 1.2rem .3rem;
  font-weight: 600;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.2rem;
  color: var(--sidebar-text);
  font-size: .875rem;
  border-radius: 0;
  transition: background .15s, color .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}
.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}
.sidebar-link i { font-size: 1rem; opacity: .85; }
.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  color: var(--sidebar-text);
  opacity: .6;
}

/* ── Main content ─────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--text-muted);
}
.topbar-user strong { color: var(--text); }
.page-body {
  padding: 1.5rem;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.card-header-title {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card-header-title i { color: var(--primary); }
.card-body { padding: 1.25rem; }

/* ── Stat cards ───────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--primary-xlight);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.green  { background: #e8f5ee; color: #4a8a6b; }
.stat-icon.blue   { background: #e3f2fd; color: #1976d2; }
.stat-icon.orange { background: #fff3e0; color: #e65100; }
.stat-icon.red    { background: #fce4e4; color: #c62828; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-danger    { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; text-decoration: none; }
.btn-success   { background: #4caf50; color: #fff; border-color: #4caf50; }
.btn-success:hover { background: #388e3c; border-color: #388e3c; color: #fff; text-decoration: none; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-icon { padding: .3rem .4rem; }

/* ── Forms ────────────────────────────────────────── */
.form-label { font-size: .875rem; font-weight: 500; margin-bottom: .35rem; display: block; color: var(--text); }
.form-control, .form-select {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74,138,107,.15);
}
.form-text { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 576px) { .form-row { grid-template-columns: 1fr; } }

/* ── Tables ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead tr { background: var(--primary-xlight); }
thead th { padding: .75rem 1rem; text-align: left; font-weight: 600; color: var(--text); border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: var(--primary-xlight); }
tbody tr:last-child { border-bottom: none; }
td { padding: .65rem 1rem; vertical-align: middle; color: var(--text); }
.td-muted { color: var(--text-muted); font-size: .82rem; }
.line-list { margin: 0; padding: 0; list-style: none; }
.line-list li { padding: .1rem 0; }
.line-list li + li { border-top: 1px solid var(--border); margin-top: .2rem; padding-top: .3rem; }

/* ── Badges ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .25em .6em;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1;
}
.badge-success  { background: #d4edda; color: #155724; }
.badge-warning  { background: #fff3cd; color: #856404; }
.badge-danger   { background: #f8d7da; color: #721c24; }
.badge-info     { background: #d1ecf1; color: #0c5460; }
.badge-secondary{ background: #e2e3e5; color: #383d41; }
.badge-primary  { background: var(--primary-xlight); color: var(--primary-dark); }

/* ── Alerts ───────────────────────────────────────── */
.alert {
  padding: .85rem 1rem;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-success { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.alert-info    { background: #d1ecf1; color: #0c5460; border-bottom-color: #bee5eb; }
.alert-warning { background: #fff3cd; color: #856404; border-color: #ffeeba; }

/* ── Login page ───────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2d5a40 0%, #4a8a6b 100%);
  padding: 1.5rem;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem;
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo img { max-height: 70px; max-width: 200px; object-fit: contain; }
.login-logo i { font-size: 3rem; color: var(--primary); }
.login-title { font-size: 1.25rem; font-weight: 700; text-align: center; margin-bottom: .25rem; }
.login-sub   { font-size: .85rem; color: var(--text-muted); text-align: center; margin-bottom: 1.5rem; }

/* ── Filters bar ──────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }

/* ── Pagination ───────────────────────────────────── */
.pagination {
  display: flex;
  gap: .3rem;
  justify-content: center;
  margin-top: 1rem;
}
.page-item a, .page-item span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text);
  background: #fff;
  text-decoration: none;
}
.page-item.active span { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.page-item a:hover { background: var(--primary-xlight); text-decoration: none; }

/* ── Sidebar toggle (mobile) ──────────────────────── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text);
  cursor: pointer;
  padding: .25rem;
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .main-content { width: 100%; }
  .overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  .overlay.show { display: block; }
}

/* ── Misc ─────────────────────────────────────────── */
.text-muted { color: var(--text-muted) !important; }
.text-right { text-align: right; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .75rem; opacity: .4; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ── Searchable select ────────────────────────────── */
.ss-wrap { position: relative; }
.ss-display {
  display: flex;
  align-items: center;
  gap: .4rem;
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
  background: #fff;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.ss-display:focus-within,
.ss-wrap.open .ss-display {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74,138,107,.15);
}
.ss-display .ss-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-display .ss-arrow { color: var(--text-muted); font-size: .75rem; transition: transform .15s; }
.ss-wrap.open .ss-arrow { transform: rotate(180deg); }
.ss-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  z-index: 200;
  display: none;
  overflow: hidden;
}
.ss-wrap.open .ss-panel { display: block; }
.ss-search-wrap { padding: .5rem; border-bottom: 1px solid var(--border); }
.ss-search {
  width: 100%;
  padding: .4rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
  outline: none;
}
.ss-search:focus { border-color: var(--primary); }
.ss-options { max-height: 220px; overflow-y: auto; }
.ss-option {
  padding: .5rem .85rem;
  font-size: .875rem;
  cursor: pointer;
  color: var(--text);
  transition: background .1s;
}
.ss-option:hover  { background: var(--primary-xlight); }
.ss-option.active { background: var(--primary-xlight); font-weight: 600; color: var(--primary-dark); }
.ss-option.hidden { display: none; }
.ss-no-results { padding: .65rem .85rem; font-size: .85rem; color: var(--text-muted); }
