:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #65736c;
  --line: #d9e0dc;
  --paper: #f6f7f4;
  --surface: #ffffff;
  --soft: #eef3ef;
  --green: #207a52;
  --green-2: #0f5f44;
  --teal: #16798c;
  --gold: #c4861b;
  --red: #ba3b3b;
  --shadow: 0 18px 40px rgba(25, 43, 34, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.login-page {
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 525px);
  align-items: center;
  gap: clamp(26px, 5vw, 74px);
  padding: clamp(28px, 5vw, 90px);
  background:
    linear-gradient(90deg, rgba(14, 34, 29, 0.82) 0%, rgba(14, 34, 29, 0.52) 48%, rgba(14, 34, 29, 0.2) 100%),
    linear-gradient(180deg, rgba(11, 31, 27, 0.22), rgba(11, 31, 27, 0.48)),
    url("assets/Plant-V.jpg");
  background-size: cover;
  background-position: center;
}

.login-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: min(760px, calc(100vh - 120px));
  padding: 0;
  color: #fff;
}

.login-hero h1 {
  max-width: 980px;
  color: #fff;
  font-size: clamp(56px, 7.5vw, 112px);
  font-weight: 900;
  line-height: 0.96;
  text-transform: uppercase;
}

.login-hero p {
  max-width: 680px;
  margin: 28px 0 0;
  color: #fff;
  font-size: clamp(30px, 3vw, 48px);
  font-weight: 900;
  line-height: 1.08;
}

.feature-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.feature-strip span {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
  font-weight: 800;
}

.login-card {
  align-self: center;
  display: grid;
  gap: 18px;
  width: min(100%, 525px);
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 248, 246, 0.94);
  padding: clamp(24px, 3vw, 34px);
  box-shadow: 0 28px 70px rgba(11, 31, 27, 0.24);
  backdrop-filter: blur(6px);
}

.login-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-logo {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 84px;
  height: 64px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e1e8e5;
  padding: 6px;
}

.login-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-card-head span {
  display: block;
  margin-bottom: 4px;
  color: #89aaa3;
  font-size: 14px;
  font-weight: 700;
}

.login-card-head strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
}

.login-card h2 {
  margin-top: 14px;
  font-size: clamp(30px, 3vw, 38px);
  font-weight: 900;
}

.login-card label {
  margin-bottom: 0;
  color: #5d6b67;
}

.login-card input,
.login-card select {
  min-height: 52px;
  border-color: #d5dfdc;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 17px;
}

.login-card .primary {
  min-height: 56px;
  margin-top: 2px;
  background: #159787;
  font-size: 20px;
}

.login-card .primary:hover {
  background: #0f7f73;
}

.password-update {
  display: grid;
  gap: 10px;
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.password-update strong {
  color: var(--ink);
}

.forgot-link {
  width: fit-content;
  border: 0;
  background: transparent;
  color: #0f7f73;
  padding: 0;
  font-weight: 800;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  background: #10241d;
  color: #f8fbf7;
  overflow-y: auto;
}

.brand,
.user-chip,
.panel-heading,
.action-row,
.role-grid,
.segmented,
.topbar {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark,
.brand-logo,
.user-chip span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #dfeee5;
  color: #103524;
  font-weight: 800;
}

.brand-logo {
  background: #fff;
  padding: 5px;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand span,
.plant-card small,
.user-chip small,
.role-card small,
.metric span,
.status-list small {
  display: block;
  color: inherit;
  opacity: 0.72;
  font-size: 12px;
  line-height: 1.35;
}

.login-panel,
.plant-card,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.login-panel,
.plant-card {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  padding: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #9ed7c0;
}

.role-grid {
  gap: 8px;
  margin-bottom: 16px;
}

.role-card {
  flex: 1;
  min-height: 74px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  text-align: left;
}

.role-card span {
  display: block;
  margin-bottom: 4px;
  font-weight: 800;
}

.role-card.active,
.nav-link.active {
  border-color: #9ed7c0;
  background: #dfeee5;
  color: #103524;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 121, 140, 0.14);
}

.primary,
.secondary,
.ghost,
.nav-link {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
}

.primary {
  width: 100%;
  background: var(--green);
  color: #fff;
}

.primary:hover {
  background: var(--green-2);
}

.secondary {
  background: var(--soft);
  border-color: var(--line);
  color: var(--ink);
}

.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--green-2);
}

.nav-links {
  display: grid;
  gap: 8px;
}

.nav-link {
  width: 100%;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fbf7;
  text-align: left;
}

.admin-only {
  display: none;
}

.is-admin .admin-only {
  display: block;
}

.is-admin .student-only {
  display: none;
}

.plant-card {
  margin-top: auto;
}

.plant-visual {
  position: relative;
  height: 118px;
  margin-bottom: 14px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0)),
    linear-gradient(135deg, #1f7764, #22342f 55%, #d19b31);
}

.plant-visual::before,
.plant-visual::after {
  content: "";
  position: absolute;
  bottom: 18px;
  background: rgba(255,255,255,0.74);
}

.plant-visual::before {
  left: 24px;
  width: 116px;
  height: 36px;
}

.plant-visual::after {
  left: 136px;
  width: 52px;
  height: 62px;
}

.plant-visual span {
  position: absolute;
  bottom: 54px;
  width: 13px;
  height: 42px;
  background: rgba(255,255,255,0.8);
}

.plant-visual span:nth-child(1) { left: 42px; }
.plant-visual span:nth-child(2) { left: 72px; height: 58px; }
.plant-visual span:nth-child(3) { left: 102px; height: 48px; }

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
}

.user-chip {
  gap: 10px;
  max-width: 290px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-chip strong,
.user-chip small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.welcome-layout,
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 18px;
}

.wide-left {
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.7fr);
}

.welcome-copy,
.signal-board {
  min-height: 370px;
  border-radius: 8px;
  padding: 28px;
}

.welcome-copy {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(16,36,29,0.9), rgba(16,36,29,0.62)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='760' viewBox='0 0 1200 760'%3E%3Crect width='1200' height='760' fill='%231f7764'/%3E%3Cpath d='M0 560h1200v200H0z' fill='%2310241d'/%3E%3Cpath d='M90 454h390v106H90zM548 338h178v222H548zM775 404h314v156H775z' fill='%23f4f7f1' opacity='.8'/%3E%3Cpath d='M134 279h42v175h-42zM232 225h42v229h-42zM329 268h42v186h-42z' fill='%23f4f7f1' opacity='.72'/%3E%3Cpath d='M176 280c120-84 206-83 365 8 166 95 314 84 508-40' fill='none' stroke='%23d39a2d' stroke-width='18' opacity='.75'/%3E%3Ccircle cx='934' cy='166' r='76' fill='%23e0b33e' opacity='.9'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.welcome-copy .eyebrow {
  color: #c5ecd9;
}

.welcome-copy h2 {
  max-width: 720px;
  font-size: 40px;
}

.welcome-copy p {
  max-width: 660px;
  margin-bottom: 0;
  line-height: 1.6;
}

.signal-board {
  display: grid;
  align-content: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
}

.signal-board div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.signal-board span,
.status-list span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--gold);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.admin-hero,
.dashboard-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(22, 121, 140, 0.18);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #ecf6f2);
  padding: 22px;
  box-shadow: var(--shadow);
}

.admin-hero h2,
.dashboard-hero h2 {
  font-size: 28px;
}

.admin-hero p:not(.eyebrow),
.dashboard-hero p:not(.eyebrow) {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.dashboard-hero > img,
.hero-logo-accent {
  flex: 0 0 auto;
  width: 150px;
  max-width: 28vw;
  border-radius: 8px;
  opacity: 0.88;
  mix-blend-mode: multiply;
}

.compact-button {
  width: auto;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
}

.insight-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.insight-card strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.metric,
.panel {
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.1;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel.compact {
  align-self: start;
}

.panel-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.segmented {
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.segmented button {
  min-width: 86px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 8px 10px;
  font-weight: 800;
}

.segmented button.active {
  background: #fff;
  color: var(--green-2);
  box-shadow: 0 6px 18px rgba(25, 43, 34, 0.12);
}

.camera-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1513;
}

.camera-box video,
.camera-box canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  color: #fff;
  text-align: center;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(32,122,82,0.34), transparent),
    #0f1513;
}

.action-row {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.action-row .primary,
.action-row .secondary {
  width: auto;
}

.status-list {
  display: grid;
  gap: 10px;
}

.status-list div {
  display: grid;
  grid-template-columns: 12px minmax(80px, 1fr);
  gap: 4px 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-list small {
  grid-column: 2;
  color: var(--muted);
}

.status-list span.ok,
.signal-board span {
  background: var(--green);
}

.gps-readout {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item,
.permit-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.timeline-item strong,
.permit-card strong {
  display: block;
  margin-bottom: 5px;
}

.timeline-item span,
.permit-card p {
  color: var(--muted);
  line-height: 1.45;
}

.check-list,
.steps {
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.muted-text {
  color: var(--muted);
  line-height: 1.6;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  margin: 0;
}

.form-grid .full,
.form-grid button {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow-x: auto;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-actions .secondary {
  min-height: 36px;
  padding: 8px 10px;
}

table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.thumb {
  width: 56px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.thumb-button,
.table-link,
.icon-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--teal);
  font-weight: 800;
}

.thumb-button {
  display: inline-flex;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-size: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--green-2);
  font-weight: 800;
  font-size: 12px;
}

.badge.pending {
  background: #fff4d8;
  color: #8a5b09;
}

.badge.rejected {
  background: #f8e5e5;
  color: var(--red);
}

.permit-list {
  display: grid;
  gap: 12px;
}

.permit-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.permit-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.danger {
  background: #f8e5e5;
  color: var(--red);
  border-color: #efc1c1;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 40px));
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #10241d;
  color: #fff;
  padding: 13px 15px;
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(15, 26, 22, 0.58);
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-dialog {
  width: min(760px, 100%);
  max-height: min(840px, calc(100vh - 40px));
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.modal-photo {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 8px;
  background: #0f1513;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.detail-list div,
.map-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.map-preview {
  display: grid;
  min-height: 180px;
  align-content: center;
  gap: 8px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(16,36,29,0.88), rgba(22,121,140,0.74)),
    url("assets/Plant-V.jpg");
  background-size: cover;
  background-position: center;
}

.map-preview strong {
  font-size: 28px;
}

.modal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .login-page {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-hero {
    min-height: auto;
    padding-top: 36px;
  }

  .login-card {
    justify-self: start;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 20px;
  }

  .welcome-layout,
  .content-grid,
  .wide-left {
    grid-template-columns: 1fr;
  }

  .admin-hero,
  .dashboard-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-hero > img,
  .hero-logo-accent {
    width: 120px;
    max-width: 100%;
  }

  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 26px;
  }

  .welcome-copy,
  .signal-board {
    min-height: auto;
    padding: 20px;
  }

  .welcome-copy h2 {
    font-size: 28px;
  }

  .login-card {
    margin: 0;
    padding: 18px;
  }

  .login-hero h1 {
    font-size: 44px;
  }

  .login-hero p {
    font-size: 26px;
  }

  .metric-grid,
  .insight-grid,
  .detail-list,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .segmented,
  .role-grid {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    min-width: 0;
  }

  .action-row .primary,
  .action-row .secondary {
    width: 100%;
  }

  .permit-card {
    grid-template-columns: 1fr;
  }
}
