:root {
  --color-primary: #2e9e52;
  --color-primary-dark: #217a3e;
  --color-secondary: #2ba6d9;
  --color-dark: #1c2530;
  --color-text: #2c3440;
  --color-muted: #6b7684;
  --color-bg: #f4f6f8;
  --color-white: #ffffff;
  --color-border: #e2e6ea;
  --color-danger: #d64545;
  --color-danger-bg: #fdecec;
  --color-success-bg: #e9f8ee;
  --color-warning: #b8860b;
  --color-warning-bg: #fdf3e0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 40, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}
a { color: var(--color-primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Top bar ---------------- */
.topbar {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--color-dark); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-logo { display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; }
.brand-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-text { font-size: 17px; }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 20px;
  padding: 4px 10px;
  cursor: pointer;
}

.topnav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.topnav a {
  color: var(--color-text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}
.topnav a:hover { background: var(--color-bg); text-decoration: none; }
.nav-user { font-size: 13px; color: var(--color-muted); margin-left: 10px; padding: 0 8px; white-space: nowrap; }
.role-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--color-secondary);
  color: #fff;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.nav-logout { color: var(--color-danger); font-weight: 600; padding: 8px 12px; }
.pill {
  display: inline-block;
  margin-left: 6px;
  background: var(--color-danger);
  color: #fff;
  font-size: 11px;
  border-radius: 20px;
  padding: 1px 7px;
}

/* ---------------- Layout ---------------- */
.page-wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.site-footer { text-align: center; color: var(--color-muted); font-size: 12px; padding: 30px 10px; }

.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.stat-box { text-align: center; padding: 18px 10px; }
.stat-box .num { font-size: 30px; font-weight: 700; color: var(--color-primary-dark); }
.stat-box .label { font-size: 13px; color: var(--color-muted); margin-top: 4px; }

/* ---------------- Forms ---------------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--color-text); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date],
input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--color-text);
  font-family: inherit;
}
textarea { resize: vertical; min-height: 80px; }
.form-row { margin-bottom: 16px; }
.form-actions { margin-top: 20px; }
.help-text { font-size: 12px; color: var(--color-muted); margin-top: 4px; }

.btn {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--color-secondary); }
.btn-secondary:hover { background: #1f89b5; }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #b83333; }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover { background: var(--color-bg); color: var(--color-text); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
th { color: var(--color-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.3px; }
tr:hover td { background: #fafbfc; }

/* ---------------- Badges ---------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-present { background: var(--color-success-bg); color: var(--color-primary-dark); }
.badge-absent { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-leave { background: #eef0fc; color: #5257c9; }
.badge-weekend { background: #f0f1f3; color: var(--color-muted); }
.badge-pending { background: var(--color-warning-bg); color: var(--color-warning); }

/* ---------------- Flash messages ---------------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.flash-success { background: var(--color-success-bg); color: var(--color-primary-dark); }
.flash-error { background: var(--color-danger-bg); color: var(--color-danger); }
.flash-info { background: #eaf6fb; color: #1f6685; }

/* ---------------- Auth pages ---------------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #f4f6f8 0%, #eef7f0 100%);
}
.auth-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(20,30,40,0.10);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.auth-logo { text-align: center; margin-bottom: 10px; }
.auth-logo img { height: 64px; }
.auth-title { text-align: center; font-size: 18px; font-weight: 700; margin: 6px 0 24px; color: var(--color-dark); }
.auth-links { text-align: center; margin-top: 16px; font-size: 13px; }

/* ---------------- Calendar ---------------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  min-height: 64px;
  padding: 6px;
  font-size: 12px;
}
.cal-cell .d { font-weight: 700; margin-bottom: 4px; }
.cal-head { font-size: 11px; text-transform: uppercase; color: var(--color-muted); text-align: center; padding: 4px 0; }
@media (max-width: 700px) {
  .cal-grid { grid-template-columns: repeat(7, 1fr); gap: 3px; }
  .cal-cell { min-height: 44px; padding: 3px; font-size: 10px; }
}

/* ---------------- Timeline (hourly updates) ---------------- */
.timeline { border-left: 2px solid var(--color-border); margin-left: 8px; padding-left: 18px; }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item::before {
  content: "";
  position: absolute; left: -23px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-primary);
}
.timeline-time { font-size: 12px; color: var(--color-muted); font-weight: 600; }
.timeline-text { margin-top: 2px; }

/* ---------------- Misc ---------------- */
.muted { color: var(--color-muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
hr.sep { border: none; border-top: 1px solid var(--color-border); margin: 20px 0; }

/* ---------------- Mobile nav ---------------- */
@media (max-width: 900px) {
  .nav-toggle { display: inline-block; }
  .topnav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    background: var(--color-white);
    border-top: 1px solid var(--color-border);
    margin-top: 10px;
    padding-top: 8px;
  }
  .topnav.open { display: flex; }
  .topnav a { padding: 12px; border-radius: 6px; }
  .nav-user { margin: 6px 0 0; padding: 8px 12px; }
  .nav-logout { padding: 12px; }
}
