@font-face {
  font-family: "Lato";
  src: url("./fonts/Lato-Light.ttf") format("truetype");
  font-style: normal;
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: url("./fonts/Lato-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: url("./fonts/Lato-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  /* AgriExplorer / GeoAgris tokens */
  --brand: #009739;
  --brand-dark: #018131;
  --brand-soft: rgba(0, 151, 57, 0.25);
  --brand-wash: #f3f3f3;
  --nav: #313a46;
  --nav-muted: #8391a2;
  --green: #009739;
  --green-deep: #018131;
  --green-soft: rgba(0, 151, 57, 0.25);
  --green-pill: rgba(0, 151, 57, 0.25);
  --cream: #f3f3f3;
  --card: #ffffff;
  --ink: #515050;
  --muted: #76777a;
  --line: #dadada;
  --warning: #efc700;
  --warning-soft: rgba(239, 199, 0, 0.25);
  --info: #0893cb;
  --info-soft: rgba(8, 147, 203, 0.25);
  --danger: #ec1c24;
  --danger-soft: rgba(236, 28, 36, 0.25);
  --map-open: #009739;
  --map-closed: #76777a;
  --sidebar-w: 220px;
  --topbar-h: 50px;
  --radius: 6px;
  --radius-control: 9px;
  --shadow-card: 0 0 35px rgba(154, 161, 171, 0.15);
  --control-min-height: 44px;
  --font: "Lato", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 0.9rem/1.5 var(--font);
  color: var(--ink);
  background: var(--cream);
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--nav);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 6px 28px;
}
.brand-logo {
  height: 28px;
  width: auto;
  display: block;
  max-width: 120px;
}
.brand strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}
.brand span {
  display: block;
  font-size: 0.75rem;
  color: var(--nav-muted);
}
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-nav a {
  color: var(--nav-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 400;
}
.side-nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.side-nav a.active { background: rgba(255,255,255,0.1); color: #fff; font-weight: 700; }
.side-nav svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.side-foot {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 14px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.side-user { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 700;
}
.side-user strong { display: block; font-size: 0.9rem; color: #fff; }
.side-user span { display: block; font-size: 0.75rem; color: var(--nav-muted); }
.side-foot button, .side-foot .logout {
  background: transparent; border: 0; color: var(--nav-muted);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; font: inherit; border-radius: var(--radius);
}
.side-foot button:hover { background: rgba(255,255,255,0.06); color: #fff; }
.side-vendor {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 6px 0; padding: 10px 6px 0;
  border-top: 1px solid rgba(255,255,255,0.12);
  color: var(--nav-muted); font-size: 0.75rem;
}
.side-vendor img {
  height: 18px; width: auto; max-width: 90px; display: block;
}

.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 32px;
  font-weight: 700;
  font-size: 0.95rem;
}
.workspace { flex: 1; min-width: 0; padding: 24px 32px 40px; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; font-weight: 700; }
.page-head .sub { color: var(--muted); margin: 6px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li {
  background: var(--card); border-left: 4px solid var(--brand);
  padding: 10px 14px; margin-bottom: 8px; border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow-card);
}
.messages li.error { border-left-color: var(--danger); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: 12px; }

.btn, button, .button {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: var(--radius-control);
  padding: 10px 14px;
  min-height: var(--control-min-height);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: var(--brand-dark);
  color: #fff;
}
.btn:hover, button:hover, .button:hover { text-decoration: none; filter: brightness(1.05); }
.btn-ghost, button.ghost, .button.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--muted);
}
.btn-quiet, button.quiet {
  background: transparent;
  color: var(--danger);
  padding: 0;
  min-height: auto;
  font-weight: 500;
}
.btn-link { background: transparent; color: var(--brand-dark); padding: 0; min-height: auto; font-weight: 700; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 700; }
input, select, textarea {
  font: inherit;
  font-weight: 400;
  padding: 10px 12px;
  min-height: var(--control-min-height);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand);
}
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; font-weight: 400; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; white-space: nowrap;
}
.pill-green { background: var(--green-pill); color: var(--brand-dark); }
.pill-orange { background: var(--warning-soft); color: var(--ink); }
.pill-gray { background: #ececec; color: var(--muted); }
.pill-blue { background: var(--info-soft); color: var(--ink); }
.pill-today { background: var(--green-soft); color: var(--brand-dark); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card .stat { font-size: 1.7rem; font-weight: 700; margin: 4px 0; letter-spacing: -0.02em; }
.stat-card .label { font-weight: 700; margin: 0; }
.stat-card.alert { border-color: var(--warning); background: #fffef5; }
.progress {
  height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0 6px;
}
.progress > span { display: block; height: 100%; background: var(--brand); }

.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 16px; }
.split-wide { display: grid; grid-template-columns: 1fr 1.2fr; gap: 14px; }

#map {
  height: 380px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #e8eee8;
}
.map-legend { font-size: 0.85rem; color: var(--muted); margin: 10px 0 0; }
.swatch {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 3px; margin-right: 4px; vertical-align: -1px;
}

.crew-card { margin-bottom: 10px; }
.crew-card header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.crew-card h3 { margin: 0; font-size: 1rem; }
.crew-card p { margin: 4px 0; color: var(--muted); font-size: 0.9rem; }
.crew-card p strong { color: var(--ink); font-weight: 700; }

.month-bar {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}
.month-bar .stat { font-size: 1.6rem; font-weight: 700; margin: 6px 0 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  min-height: var(--control-min-height);
}
.chip:hover { text-decoration: none; }
.chip.active { background: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }

.crew-filter { margin: 0 0 12px; }
.crew-filter details { position: relative; display: inline-block; min-width: 280px; }
.crew-filter summary {
  list-style: none;
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 36px 10px 14px;
  font-weight: 700;
  box-shadow: var(--shadow-card);
}
.crew-filter summary::-webkit-details-marker { display: none; }
.crew-filter summary::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  margin-top: -3px;
  border: 5px solid transparent;
  border-top-color: var(--ink);
}
.crew-filter details[open] summary { border-color: var(--brand-dark); }
.crew-filter-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  max-height: min(380px, calc(100vh - 180px));
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 10px;
}
.crew-filter-panel input[type="search"] {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.crew-filter-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}
.crew-filter-list label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  cursor: pointer;
  font-weight: 400;
  font-size: 0.9rem;
}
.crew-filter-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--brand);
}
.crew-filter-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.crew-filter-actions a { font-weight: 700; }
.crew-filter-actions button { min-height: 36px; }

.date-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}
.date-bar .day-label { font-weight: 700; }
.summary-line {
  display: flex; flex-wrap: wrap; gap: 14px;
  color: var(--muted); font-size: 0.9rem; margin: 0 0 14px;
}
.summary-line strong { color: var(--ink); }

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th { background: var(--cream); font-size: 0.8rem; color: var(--muted); font-weight: 700; }
table.data tr:last-child td { border-bottom: 0; }
table.data .group-row td {
  background: var(--cream);
  font-weight: 700;
  font-size: 0.9rem;
}
.person-name { font-weight: 700; }
.person-meta { color: var(--muted); font-size: 0.85rem; }
.before { color: var(--ink); font-size: 0.8rem; background: var(--warning-soft); }
.gps-warn { color: var(--ink); font-size: 0.8rem; margin-top: 4px; }
.lote-line { margin: 0 0 2px; }

.search-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 12px;
}
.search-bar input[type="search"] { flex: 1; min-width: 220px; }

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(49, 58, 70, 0.35);
  display: none; z-index: 40;
}
.drawer-backdrop.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
  background: #fff; z-index: 50; padding: 24px;
  box-shadow: -8px 0 24px rgba(0,0,0,0.12);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  overflow: auto;
}
.drawer.open { transform: translateX(0); }
.drawer header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.drawer h2 { margin: 0; font-size: 1.25rem; }
.drawer .fields { display: flex; flex-direction: column; gap: 14px; }
.drawer .fields .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drawer footer {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px;
}

.breadcrumb { color: var(--muted); font-size: 0.9rem; margin-bottom: 6px; }
.breadcrumb a { font-weight: 700; }

.login-page {
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  min-height: 100vh;
  background: var(--cream);
}
.login-brand {
  background: var(--brand);
  color: #fff;
  padding: 32px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.login-brand .brand { margin-bottom: auto; align-items: flex-start; }
.login-brand .brand-stacked {
  width: min(160px, 55%);
  height: auto;
  display: block;
}
.login-copy { margin: auto 0; max-width: 28rem; }
.login-copy h1 {
  font-size: 2rem; line-height: 1.2; margin: 0 0 12px; letter-spacing: -0.02em; font-weight: 700;
}
.login-copy p { color: rgba(255,255,255,0.85); margin: 0; }
.login-brand .foot {
  margin-top: auto;
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.login-brand .foot img {
  height: 20px;
  width: auto;
  max-width: 100px;
  filter: brightness(0) invert(1);
  opacity: 0.9;
}
.login-form-wrap {
  display: grid; place-items: center; padding: 40px 24px;
}
.login-form { width: min(360px, 100%); }
.login-form .form-brand {
  height: 36px;
  width: auto;
  max-width: 140px;
  display: block;
  margin-bottom: 20px;
}
.login-form h1 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 700; }
.login-form .sub { margin: 0 0 24px; color: var(--muted); }
.login-form form { display: flex; flex-direction: column; gap: 14px; }
.login-form button { width: 100%; justify-content: center; padding: 12px; }
.login-form .note { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }

@media (max-width: 1100px) {
  .stat-grid, .month-bar { grid-template-columns: 1fr 1fr; }
  .split, .split-wide { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .topbar { padding: 0 16px; }
  .workspace { padding: 20px 16px 32px; }
  .stat-grid, .month-bar { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-brand { min-height: 220px; }
}
