:root {
  --green-950: #102d24;
  --green-900: #153a2d;
  --green-800: #1d4c3a;
  --green-700: #286148;
  --green-600: #347b58;
  --green-100: #e8f2ec;
  --green-50: #f2f7f4;
  --ink: #17211d;
  --muted: #69756f;
  --line: #e3e9e5;
  --canvas: #f5f7f5;
  --white: #ffffff;
  --amber: #d99528;
  --amber-soft: #fff5df;
  --blue: #377da5;
  --blue-soft: #eaf4f9;
  --danger: #ba4a4a;
  --danger-soft: #fbecec;
  --violet-soft: #f1edf8;
  --shadow: 0 18px 45px rgba(21, 58, 45, .08);
  --sidebar-width: 246px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 12px 12px 12px 4px;
  color: var(--white);
  background: var(--green-700);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -.4px;
}
.brand-mark--large { width: 58px; height: 58px; border-radius: 16px 16px 16px 5px; font-size: 17px; }
.company-logo { display: block; object-fit: contain; }
.company-logo--login { width: 150px; height: 150px; margin: 0; }
.company-logo--mobile { width: 150px; height: 150px; margin: 0; }
.company-logo--sidebar { width: 51px; height: 51px; margin: -7px -3px -7px -5px; flex: 0 0 auto; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.eyebrow { margin: 0 0 12px; color: var(--green-600); font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; }

/* Login */
.login-page { min-height: 100vh; background: var(--white); }
.login-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(410px, .88fr) minmax(520px, 1.12fr); }
.login-brand {
  position: relative;
  display: flex;
  min-height: 100vh;
  padding: 58px clamp(42px, 6vw, 92px);
  overflow: hidden;
  flex-direction: column;
  color: var(--white);
  background: var(--green-950);
}
.login-brand::before {
  position: absolute;
  width: 520px;
  height: 520px;
  right: -280px;
  top: -260px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
  box-shadow: 0 0 0 75px rgba(255,255,255,.025), 0 0 0 150px rgba(255,255,255,.02);
  content: "";
}
.login-brand__content { position: relative; z-index: 1; margin: auto 0; max-width: 560px; }
.login-brand__content .eyebrow { color: #9ec5ae; }
.login-brand h1 { margin: 0 0 22px; font-size: clamp(46px, 5vw, 72px); line-height: .98; letter-spacing: -3.5px; }
.login-brand__content > p:last-child { margin: 0; max-width: 490px; color: #c8d8d0; font-size: 18px; line-height: 1.7; }
.login-brand__footer { position: relative; z-index: 1; margin: 0; color: #8fb09f; font-size: 12px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; }
.field-lines { position: absolute; right: -80px; bottom: 55px; width: 85%; height: 28%; transform: rotate(-8deg); opacity: .12; }
.field-lines span { display: block; height: 28px; margin: 18px 0; border-top: 1px solid #fff; border-radius: 50%; }
.login-panel { display: flex; min-height: 100vh; padding: 45px clamp(34px, 8vw, 120px) 30px; align-items: center; justify-content: center; flex-direction: column; }
.login-card { width: 100%; max-width: 455px; margin: auto 0; }
.login-card__mobile-brand { display: none; }
.login-heading { margin-bottom: 38px; }
.login-heading h2 { margin: 0 0 11px; font-size: 36px; letter-spacing: -1.2px; }
.login-heading > p:last-child { margin: 0; color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 22px; }
.form-group { display: grid; gap: 9px; }
.form-group label, .label-row label { font-size: 13px; font-weight: 700; }
.label-row { display: flex; align-items: center; justify-content: space-between; }
.text-link { color: var(--green-600); font-size: 12px; font-weight: 700; }
.form-group input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  outline: none;
  border: 1px solid #d8dfda;
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
  transition: border-color .18s, box-shadow .18s;
}
.form-group input::placeholder { color: #a5ada8; }
.form-group input:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(52,123,88,.11); }
.form-group input.input-error { border-color: var(--danger); }
.password-field { position: relative; }
.password-field input { padding-right: 82px; }
.password-toggle { position: absolute; top: 50%; right: 14px; padding: 5px 2px; transform: translateY(-50%); border: 0; color: var(--green-700); background: transparent; font-size: 12px; font-weight: 700; }
.field-error { min-height: 0; color: var(--danger); font-size: 11px; }
.field-error:empty { display: none; }
.check-control { display: inline-flex; width: fit-content; align-items: center; gap: 9px; color: var(--muted); cursor: pointer; font-size: 13px; }
.check-control input { width: 16px; height: 16px; accent-color: var(--green-700); }
.button { display: inline-flex; min-height: 44px; padding: 0 17px; border: 0; border-radius: 8px; align-items: center; justify-content: center; gap: 10px; font-size: 13px; font-weight: 750; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button--primary { color: var(--white); background: var(--green-700); box-shadow: 0 8px 18px rgba(40,97,72,.14); }
.button--primary:hover { background: var(--green-800); }
.button--full { width: 100%; min-height: 51px; justify-content: space-between; padding: 0 18px 0 21px; }
.form-message { min-height: 16px; margin: -8px 0 0; color: var(--green-700); font-size: 12px; }
.form-message--error { color: var(--danger); }
.button:disabled { cursor: wait; opacity: .72; transform: none; }
.login-help { margin: 30px 0 0; padding-top: 25px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: center; }
.login-help a { color: var(--green-700); font-weight: 700; }
.copyright { margin: auto 0 0; color: #9ca5a0; font-size: 11px; }

/* Dashboard shell */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: var(--sidebar-width);
  padding: 23px 16px 18px;
  color: #dce8e2;
  background: var(--green-950);
  flex-direction: column;
}
.sidebar__brand { display: flex; padding: 0 9px 25px; align-items: center; gap: 11px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar__brand strong { display: block; color: var(--white); font-size: 16px; }
.sidebar__brand small { display: block; margin-top: 1px; color: #93ad9f; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; }
.main-nav { display: flex; margin-top: 19px; flex-direction: column; gap: 3px; }
.nav-label { margin: 14px 11px 7px; color: #6f9281; font-size: 9px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; }
.nav-item { display: flex; min-height: 39px; padding: 0 12px; border-radius: 7px; align-items: center; gap: 12px; color: #a9bdb3; font-size: 12px; font-weight: 600; transition: color .15s, background .15s; }
.nav-item:hover { color: var(--white); background: rgba(255,255,255,.055); }
.nav-item.active { color: var(--white); background: var(--green-700); }
.nav-icon { display: inline-grid; width: 18px; place-items: center; font-size: 16px; }
.sidebar__footer { margin-top: auto; }
.support-card { display: flex; margin-bottom: 11px; padding: 13px 10px; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,.08); border-radius: 8px; background: rgba(255,255,255,.035); }
.support-card__icon { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 50%; color: var(--green-950); background: #9dc3ae; font-size: 12px; font-weight: 800; }
.support-card strong, .support-card small { display: block; }
.support-card strong { color: #dfe9e4; font-size: 10px; }
.support-card small { margin-top: 2px; color: #7f9d8e; font-size: 9px; }
.logout-link { display: flex; min-height: 38px; padding: 0 12px; align-items: center; gap: 12px; color: #8eaa9b; font-size: 11px; }
.logout-form { margin: 0; }
.logout-form .logout-link { width: 100%; border: 0; background: transparent; text-align: left; }
.logout-form .logout-link:hover { color: var(--white); }
.sidebar-backdrop { display: none; }
.main-content { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; z-index: 30; top: 0; display: flex; height: 66px; padding: 0 31px; border-bottom: 1px solid var(--line); align-items: center; justify-content: space-between; background: rgba(255,255,255,.95); backdrop-filter: blur(9px); }
.topbar__context { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #42a572; box-shadow: 0 0 0 4px #e9f5ee; }
.topbar__actions { display: flex; align-items: center; gap: 19px; }
.icon-button { position: relative; display: grid; width: 37px; height: 37px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: #52615a; background: var(--white); }
.notification-badge { position: absolute; top: -4px; right: -4px; display: grid; width: 16px; height: 16px; place-items: center; border: 2px solid var(--white); border-radius: 50%; color: var(--white); background: var(--danger); font-size: 8px; font-weight: 800; }
.menu-button { display: none; }
.user-profile { display: flex; align-items: center; gap: 9px; color: #7c8781; font-size: 11px; }
.avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 8px; color: var(--green-800); background: var(--green-100); font-size: 10px; font-weight: 800; }
.user-profile__text { display: grid; min-width: 94px; gap: 2px; }
.user-profile__text strong { color: var(--ink); font-size: 11px; }
.user-profile__text small { color: #8b9690; font-size: 9px; }
.content-wrap { width: min(100%, 1500px); margin: 0 auto; padding: 28px 30px 46px; }
.page-heading { display: flex; margin-bottom: 23px; align-items: flex-end; justify-content: space-between; gap: 24px; }
.current-date { margin: 0 0 7px !important; color: var(--green-600) !important; font-size: 10px !important; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; }
.page-heading h1 { margin: 0 0 5px; font-size: 25px; letter-spacing: -.75px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.metrics-grid { display: grid; margin-bottom: 19px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { padding: 17px 17px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.metric-card__top { display: flex; margin-bottom: 14px; align-items: center; justify-content: space-between; }
.metric-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 8px; font-size: 15px; }
.metric-icon--green { color: var(--green-700); background: var(--green-100); }
.metric-icon--blue { color: var(--blue); background: var(--blue-soft); }
.metric-icon--amber { color: var(--amber); background: var(--amber-soft); }
.metric-icon--violet { color: #75589d; background: var(--violet-soft); }
.trend, .metric-status, .quality-pill { padding: 4px 7px; border-radius: 12px; font-size: 8px; font-weight: 800; }
.trend--up { color: var(--green-700); background: var(--green-50); }
.metric-status { color: var(--blue); background: var(--blue-soft); }
.quality-pill { color: #75589d; background: var(--violet-soft); }
.metric-card > p { margin: 0 0 5px; color: var(--muted); font-size: 10px; }
.metric-value { margin-bottom: 5px; font-size: 23px; font-weight: 780; letter-spacing: -.6px; }
.metric-value small { font-size: 11px; font-weight: 700; }
.metric-note { color: #8a958f; font-size: 9px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 14px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.panel__header { display: flex; min-height: 68px; padding: 15px 18px; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.panel__header h2 { margin: 0 0 4px; font-size: 13px; letter-spacing: -.15px; }
.panel__header p { margin: 0; color: #87918c; font-size: 9px; }
.text-button { padding: 6px; border: 0; color: var(--green-700); background: transparent; font-size: 9px; font-weight: 800; }
.crop-list { padding: 2px 18px; }
.crop-row { display: grid; min-height: 72px; grid-template-columns: minmax(175px, 1fr) minmax(140px, .9fr) 95px; align-items: center; gap: 16px; border-bottom: 1px solid #edf0ee; }
.crop-row:last-child { border-bottom: 0; }
.crop-id { display: flex; align-items: center; gap: 10px; }
.crop-badge { display: grid; width: 33px; height: 33px; flex: 0 0 auto; place-items: center; border-radius: 8px; color: var(--white); background: var(--green-700); font-size: 9px; font-weight: 800; }
.crop-badge--light { color: var(--green-800); background: #cfe4d8; }
.crop-badge--dark { background: var(--green-950); }
.crop-id strong, .crop-id small { display: block; }
.crop-id strong { font-size: 10px; }
.crop-id small { margin-top: 4px; color: #8b9690; font-size: 8px; }
.progress-label { display: flex; margin-bottom: 7px; align-items: center; justify-content: space-between; color: #7d8983; font-size: 8px; }
.progress-label strong { color: var(--green-800); }
.progress-track { height: 5px; overflow: hidden; border-radius: 5px; background: #e9eeeb; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green-600); }
.stage-badge { justify-self: end; padding: 5px 8px; border-radius: 12px; font-size: 7px; font-weight: 800; white-space: nowrap; }
.stage-badge--green { color: var(--green-700); background: var(--green-100); }
.stage-badge--amber { color: #9a661d; background: var(--amber-soft); }
.stage-badge--blue { color: var(--blue); background: var(--blue-soft); }
.weather-symbol { color: var(--amber); font-size: 25px; }
.temperature { display: flex; padding: 16px 18px 13px; align-items: center; gap: 12px; }
.temperature > strong { font-size: 34px; letter-spacing: -1.5px; }
.temperature > span { color: #66736c; font-size: 9px; line-height: 1.45; }
.temperature small { color: #98a19c; font-size: 8px; }
.weather-stats { display: grid; padding: 0 18px 15px; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.weather-stats div { padding-right: 7px; border-right: 1px solid var(--line); }
.weather-stats div:last-child { border: 0; }
.weather-stats span, .weather-stats strong { display: block; }
.weather-stats span { margin-bottom: 4px; color: #919b96; font-size: 7px; }
.weather-stats strong { font-size: 9px; }
.irrigation-note { display: flex; margin: 0 14px 14px; padding: 10px; align-items: flex-start; gap: 8px; border-radius: 7px; color: var(--blue); background: var(--blue-soft); font-size: 8px; }
.irrigation-note > span { font-size: 6px; }
.irrigation-note strong, .irrigation-note small { display: block; }
.irrigation-note strong { font-size: 8px; }
.irrigation-note small { margin-top: 3px; color: #6f8998; font-size: 7px; }
.activity-panel { min-width: 0; }
.filter-button { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; color: #637069; background: var(--white); font-size: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 13px; color: #89958e; background: #fafbfa; font-size: 7px; font-weight: 800; letter-spacing: .5px; text-align: left; text-transform: uppercase; }
td { padding: 11px 13px; border-top: 1px solid #edf0ee; color: #5f6b65; font-size: 8px; white-space: nowrap; }
td strong, td small { display: block; }
td strong { color: var(--ink); font-size: 9px; }
td small { margin-top: 3px; color: #98a19c; font-size: 7px; }
.table-status { display: inline-flex; padding: 5px 7px; border-radius: 12px; font-size: 7px; font-weight: 800; }
.table-status--done { color: var(--green-700); background: var(--green-100); }
.table-status--progress { color: #9a661d; background: var(--amber-soft); }
.alert-count { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; color: var(--danger); background: var(--danger-soft); font-size: 8px; font-weight: 800; }
.alert-list { padding: 4px 14px; }
.alert-item { display: grid; min-height: 54px; padding: 8px 3px; grid-template-columns: 29px 1fr auto; align-items: center; gap: 9px; border-bottom: 1px solid #edf0ee; }
.alert-item:last-child { border: 0; }
.alert-icon { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 7px; font-size: 9px; font-weight: 900; }
.alert-item--warning .alert-icon { color: #9a661d; background: var(--amber-soft); }
.alert-item--danger .alert-icon { color: var(--danger); background: var(--danger-soft); }
.alert-item--info .alert-icon { color: var(--blue); background: var(--blue-soft); }
.alert-item strong, .alert-item small { display: block; }
.alert-item strong { font-size: 9px; }
.alert-item small { margin-top: 3px; color: #929c97; font-size: 7px; }
.alert-item > span:last-child { color: #a8b0ac; }

/* Weather import module */
.weather-module { display: grid; gap: 18px; }
.weather-module .page-heading { margin-bottom: 2px; }
.notice { padding: 12px 15px; border: 1px solid; border-radius: 8px; font-size: 12px; line-height: 1.5; }
.notice--success { color: var(--green-800); border-color: #bedaca; background: var(--green-50); }
.notice--error { color: #963e3e; border-color: #edcaca; background: var(--danger-soft); }
.weather-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 14px; align-items: start; }
.import-form { display: grid; padding: 18px; gap: 16px; }
.import-form__grid { display: grid; grid-template-columns: 1.2fr 1fr .7fr; gap: 12px; }
.weather-module .form-group select,
.weather-module .form-group input[type="number"] {
  width: 100%;
  height: 43px;
  padding: 0 11px;
  outline: none;
  border: 1px solid #d8dfda;
  border-radius: 7px;
  color: var(--ink);
  background: var(--white);
}
.weather-module .form-group select:focus,
.weather-module .form-group input[type="number"]:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(52,123,88,.11); }
.file-drop { display: grid; min-height: 135px; padding: 19px; place-items: center; align-content: center; gap: 6px; border: 1px dashed #adc7b8; border-radius: 9px; color: var(--ink); background: var(--green-50); cursor: pointer; text-align: center; }
.file-drop:hover { border-color: var(--green-600); background: #edf5f0; }
.file-drop__icon { display: grid; width: 43px; height: 43px; place-items: center; border-radius: 9px; color: var(--green-700); background: var(--green-100); font-size: 9px; font-weight: 900; }
.file-drop strong { font-size: 12px; }
.file-drop small { color: var(--muted); font-size: 9px; line-height: 1.5; }
.file-drop input { width: min(100%, 340px); margin-top: 7px; color: var(--muted); font-size: 9px; }
.file-drop input::file-selector-button { margin-right: 10px; padding: 7px 10px; border: 0; border-radius: 6px; color: var(--green-800); background: var(--white); font-weight: 700; cursor: pointer; }
.import-note { margin: 0 18px 18px; padding: 12px 13px; border-radius: 7px; color: #6d654f; background: #fbf7ed; }
.import-note strong { font-size: 9px; }
.import-note p { margin: 4px 0 0; font-size: 8px; line-height: 1.6; }
.import-note code { color: #675c43; font-size: 8px; }
.period-filter { display: grid; padding: 16px; gap: 13px; }
.button--secondary { border: 1px solid #cbd7d0; color: var(--green-800); background: var(--white); box-shadow: none; }
.button--secondary:hover { background: var(--green-50); }
.weather-metrics { margin: 0; }
.weather-data-panel, .import-history-panel { min-width: 0; }
.weather-table { min-width: 900px; }
.weather-table td, .weather-table th { padding-left: 15px; padding-right: 15px; }
.empty-state { padding: 28px !important; color: #8b9690; text-align: center; }
.import-history-panel table { min-width: 750px; }

@media (min-width: 1350px) {
  .content-wrap { padding: 34px 40px 56px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1.75fr) minmax(320px, .7fr); }
  .metric-card { padding: 20px; }
}

@media (max-width: 1080px) {
  :root { --sidebar-width: 215px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .activity-panel { order: 3; }
  .alerts-panel { order: 4; }
  .weather-layout { grid-template-columns: 1fr; }
  .period-filter { grid-template-columns: repeat(3, 1fr) auto; align-items: end; }
}

@media (max-width: 820px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { padding: 40px 24px 24px; }
  .login-card__mobile-brand { display: flex; width: 100%; margin-bottom: 42px; align-items: center; justify-content: center; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; z-index: 35; inset: 0; display: block; visibility: hidden; opacity: 0; background: rgba(9,26,20,.46); transition: opacity .22s, visibility .22s; }
  .sidebar-backdrop.visible { visibility: visible; opacity: 1; }
  .main-content { margin-left: 0; }
  .menu-button { display: grid; }
  .topbar { padding: 0 18px; }
  .topbar__context { display: none; }
  .content-wrap { padding: 23px 18px 38px; }
}

@media (max-width: 580px) {
  .login-heading h2 { font-size: 31px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { align-self: flex-start; }
  .metrics-grid { grid-template-columns: 1fr; }
  .crop-row { padding: 13px 0; grid-template-columns: 1fr auto; gap: 12px; }
  .crop-progress { grid-column: 1 / -1; }
  .user-profile__text, .user-profile > span:last-child { display: none; }
  .topbar__actions { gap: 10px; }
  .import-form__grid, .period-filter { grid-template-columns: 1fr; }
  .file-drop { min-height: 160px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
