:root {
  --primary: #1e1e1e;
  --primary-dark: #111111;
  --primary-light: #e8f5de;
  --green: #52a820;
  --green-dark: #3d8016;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --border: #dde8d8;
  --text: #0f1a0a;
  --text-muted: #5a6e52;
  --success: #52a820;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warn: #c2410c;
  --warn-light: #ffedd5;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --header-h: 56px;
  --bottomnav-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 { margin: 0 0 4px; }

/* ---- Top nav ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: var(--primary); color: white;
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
}
.topbar .brand { font-weight: 700; margin-right: 12px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.topbar .brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.nav-tabs { display: flex; align-items: center; gap: 2px; overflow-x: auto; flex: 1; }
.nav-tab {
  padding: 8px 12px; border-radius: 6px; font-size: 13px; white-space: nowrap;
  opacity: 0.75; transition: all .15s;
}
.nav-tab:hover { opacity: 1; background: rgba(255,255,255,0.06); }
.nav-tab.active { opacity: 1; font-weight: 600; background: rgba(82,168,32,0.25); color: #c8f0a0; }
.nav-divider { width: 1px; height: 28px; background: rgba(255,255,255,0.18); flex-shrink: 0; }
.nav-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nav-user { font-size: 12.5px; opacity: 0.85; white-space: nowrap; }
.nav-private-link { color: #c8f0a0 !important; }

/* ---- Bottom nav (mobile) ---- */
.bottomnav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottomnav-h);
  background: var(--primary); z-index: 60;
  align-items: stretch;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: rgba(255,255,255,0.65); font-size: 10px; flex: 1; height: 100%;
}
.bn-item .bn-icon { font-size: 18px; }
.bn-item.active { color: #c8f0a0; }

/* ---- Layout ---- */
.container { max-width: 1180px; margin: 0 auto; padding: 20px 16px 32px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: inherit; transition: all .15s;
}
.btn-primary { background: var(--green); color: white; }
.btn-primary:hover { background: var(--green-dark); }
.btn-outline { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); border-color: var(--green); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 6px 10px; }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.home-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; gap: 12px; align-items: flex-start;
  transition: all .15s;
}
.home-card:hover { border-color: var(--green); box-shadow: 0 4px 16px rgba(82,168,32,0.15); transform: translateY(-1px); }
.home-card-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.home-card-title { font-weight: 600; font-size: 14.5px; }
.home-card-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.home-card-stat { font-size: 12px; color: var(--green-dark); font-weight: 600; margin-top: 6px; }

.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 13.5px; background: white; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(82,168,32,0.15); }
textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-green { background: #e8f5de; color: #3d8016; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-orange { background: var(--warn-light); color: var(--warn); }
.badge-red { background: var(--danger-light); color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }

/* ---- Progress ---- */
.progress { width: 100%; height: 8px; border-radius: 6px; background: var(--border); overflow: hidden; }
.progress > div { height: 100%; background: var(--green); }
.progress.over > div { background: var(--danger); }

/* ---- Empty state ---- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-icon { font-size: 32px; margin-bottom: 8px; }
.empty-text { font-size: 14px; font-weight: 500; margin-bottom: 4px; color: var(--text); }

/* ---- Auth pages ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--primary); padding: 20px; }
.auth-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: 12px; padding: 32px 28px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.auth-card .brand { display: flex; align-items: center; gap: 8px; justify-content: center; margin-bottom: 4px; font-weight: 700; font-size: 17px; }
.auth-card .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.auth-card h1 { text-align: center; font-size: 15px; color: var(--text-muted); font-weight: 500; margin-bottom: 24px; }
.auth-error { background: var(--danger-light); color: #b91c1c; padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.auth-private .auth-card { border-top: 4px solid var(--primary); }

/* ---- Utility ---- */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gap-8 { gap: 8px; }
.small { font-size: 12px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); margin: 24px 0 10px; }
.section-title:first-child { margin-top: 0; }
.tag-priv { background: var(--primary); color: #c8f0a0; }

.priv-tabs { display: flex; align-items: center; gap: 2px; overflow-x: auto; flex: 1; }

@media (max-width: 760px) {
  .topbar .nav-tabs, .topbar .nav-divider { display: none; }
  .bottomnav { display: flex; }
  .container { padding-bottom: calc(var(--bottomnav-h) + 24px); }
  .form-row { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px; }
  .topbar .priv-divider { display: none; }
  .topbar .priv-tabs { order: 3; width: 100%; }
  .topbar .nav-right { margin-left: 0; }
}
