:root {
  --soil: #2E5339;        /* deep field green */
  --soil-light: #4C7A57;
  --wheat: #FAF6EC;       /* warm cream background */
  --card: #FFFFFF;
  --chili: #C1440E;       /* warm terracotta/chili accent */
  --chili-light: #E8763F;
  --turmeric: #D9A441;    /* amber accent for half-day / pending */
  --ink: #23291F;
  --ink-soft: #5B6259;
  --line: #E4DFD1;
  --present: #2E7D4F;
  --absent: #C1440E;
  --half: #D9A441;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(35, 41, 31, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--wheat);
  color: var(--ink);
  font-family: 'Noto Sans Devanagari', 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* Field-row signature stripe: alternating green/chili bar used as a section accent */
.field-stripe {
  height: 6px;
  width: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--soil) 0px, var(--soil) 28px,
    var(--chili) 28px, var(--chili) 40px
  );
}

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

.topbar {
  background: var(--soil);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar .brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.topbar .brand span { color: var(--turmeric); margin-left: 6px; }
.topbar .user-chip {
  background: rgba(255,255,255,0.12);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar form { display: inline; }
.logout-btn {
  background: var(--chili);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}

.nav {
  background: var(--soil-light);
  display: flex;
  gap: 4px;
  padding: 0 14px;
  overflow-x: auto;
}
.nav a {
  color: #fff;
  padding: 12px 14px;
  font-size: 14.5px;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  opacity: 0.88;
}
.nav a.active, .nav a:hover {
  border-bottom-color: var(--turmeric);
  opacity: 1;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 16px 60px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 18px;
  color: var(--soil);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 20px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  gap: 16px;
}
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 800px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--soil);
}
.stat-card .label { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--soil); }
.stat-card.alert { border-top-color: var(--chili); }
.stat-card.alert .value { color: var(--chili); }

table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #F3EFE2; color: var(--soil); font-weight: 700; font-size: 13.5px; }
tr:hover td { background: #FBF9F3; }

.btn {
  display: inline-block;
  background: var(--soil);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--soil-light); }
.btn.chili { background: var(--chili); }
.btn.chili:hover { background: var(--chili-light); }
.btn.outline { background: transparent; color: var(--soil); border: 1.5px solid var(--soil); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.status-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.status-btn {
  padding: 7px 12px;
  border-radius: 7px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.status-btn.present.selected { background: var(--present); color: #fff; border-color: var(--present); }
.status-btn.absent.selected { background: var(--absent); color: #fff; border-color: var(--absent); }
.status-btn.half.selected { background: var(--half); color: #fff; border-color: var(--half); }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 700; }
.badge.present { background: #E4F3E9; color: var(--present); }
.badge.absent { background: #FBE7DF; color: var(--absent); }
.badge.half { background: #FBF0DA; color: #9A7317; }
.badge.none { background: #EFEDE6; color: var(--ink-soft); }

label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--soil-light); border-color: var(--soil); }

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 14.5px;
  font-weight: 600;
}
.flash.success { background: #E4F3E9; color: var(--present); border: 1px solid #BFE3CB; }
.flash.error { background: #FBE7DF; color: var(--chili); border: 1px solid #F0C3AE; }

.labourer-photo {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--line); background: #eee;
}
.labourer-row { display: flex; align-items: center; gap: 10px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--soil) 0%, var(--soil-light) 55%, var(--wheat) 55%);
  padding: 16px;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  padding: 34px 30px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 { color: var(--soil); font-size: 22px; margin: 0 0 4px; }
.login-card p.sub { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 20px; }
.login-card .btn { width: 100%; margin-top: 14px; padding: 12px; font-size: 15px; }
.login-hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 16px; text-align: center; }

.pill-role {
  font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 20px;
}
.pill-role.super_admin { background: #E4F3E9; color: var(--present); }
.pill-role.supervisor { background: #EAF0FF; color: #3556C6; }

#camera-wrap { position: relative; max-width: 480px; margin: 0 auto; }
#camera-wrap video, #camera-wrap canvas { width: 100%; border-radius: 10px; background: #000; }
#camera-wrap canvas { position: absolute; top: 0; left: 0; }
.match-result { text-align: center; margin-top: 12px; font-size: 15px; font-weight: 700; min-height: 24px; }
.match-result.ok { color: var(--present); }
.match-result.no { color: var(--chili); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state .big { font-size: 40px; margin-bottom: 8px; }

.section-actions { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }

.totals-row td { font-weight: 700; background: #F3EFE2; }


/* Labourer photo identification */
.labourer-photo-clickable {
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.labourer-photo-clickable:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.photo-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.photo-modal.show { display: flex; }
.photo-modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.68);
}
.photo-modal-card {
  position: relative; z-index: 1;
  background: #fff; border-radius: 16px; padding: 18px;
  max-width: min(92vw, 480px); max-height: 92vh;
  box-shadow: 0 18px 60px rgba(0,0,0,.3);
  text-align: center;
}
.photo-modal-card img {
  display: block; width: min(82vw, 400px); height: min(72vh, 400px);
  object-fit: cover; border-radius: 12px; margin: 0 auto;
}
.photo-modal-close {
  position: absolute; right: 10px; top: 8px; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: #fff; color: #333;
  font-size: 26px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.18); z-index: 2;
}
.photo-modal-name { font-size: 18px; font-weight: 700; margin-top: 12px; color: var(--soil); }


.print-actions { display:flex; gap:8px; flex-wrap:wrap; }
@media print {
  .topbar, .nav, .field-stripe, .no-print, .print-actions { display:none !important; }
  body { background:#fff !important; }
  .container { max-width:none; padding:0; }
  .card { box-shadow:none !important; border:1px solid #ddd; }
  table { page-break-inside:auto; }
  tr { page-break-inside:avoid; page-break-after:auto; }
  .print-page { display:block !important; }
}
.pill-role.farm_admin { background: #FFF1D8; color: #8A5A00; }
