:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef3ee;
  --ink: #17201c;
  --muted: #64716b;
  --line: #dbe2da;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #b45309;
  /* Sidebar colors - Light Mode */
  --sidebar-bg: #D8BFD8; /* Thistle - Light Purple */
  --sidebar-text: var(--ink);
  --sidebar-nav-text: var(--muted);
  --sidebar-nav-hover-bg: rgba(0, 0, 0, 0.08);
  --sidebar-nav-active-text: var(--ink);
  --sidebar-nav-active-bg: rgba(0, 0, 0, 0.15);
  --sidebar-user-pill-text: var(--muted);
  --danger: #b42318;
  --ok: #16794c;
  --warn: #b76e00;
  --info: #2563eb;
  --shadow: 0 18px 45px rgba(32, 43, 38, 0.13);
}

body.dark-mode {
  --bg: #0a0f0d;
  --surface: #141b18;
  --surface-2: #1c2622;
  --ink: #e2e8e5;
  --muted: #94a39d;
  /* Sidebar colors - Dark Mode */
  --sidebar-bg: #4B0082; /* Indigo - Dark Purple */
  --sidebar-text: #fff;
  --sidebar-nav-text: rgba(255, 255, 255, 0.72);
  --sidebar-nav-hover-bg: rgba(255, 255, 255, 0.11);
  --sidebar-nav-active-text: #fff;
  --sidebar-nav-active-bg: rgba(255, 255, 255, 0.11);
  --sidebar-user-pill-text: rgba(255, 255, 255, 0.68);
  --line: #2d3b36;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.8fr);
}

.login-hero {
  position: relative;
  min-height: 100vh;
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(10, 29, 24, 0.85), rgba(10, 29, 24, 0.22)),
    url("https://images.unsplash.com/photo-1586773860418-d37222d8fce3?auto=format&fit=crop&w=1600&q=80") center / cover;
}

.login-hero h1 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(2.4rem, 5vw, 5.4rem);
  line-height: 0.95;
}

.login-hero p {
  max-width: 620px;
  margin: 18px 0 0;
  font-size: 1.06rem;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.86);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 720px;
  margin-top: 34px;
}

.hero-stat {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  border-radius: 8px;
}

.hero-stat strong {
  display: block;
  font-size: 1.7rem;
}

.hero-stat span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
}

.login-panel {
  min-height: 100vh;
  padding: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.login-card {
  width: min(100%, 430px);
}

.brand-row,
.top-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
}

.login-card h2 {
  margin: 32px 0 8px;
  font-size: 2rem;
}

.login-card > p {
  margin: 0 0 26px;
  color: var(--muted);
  line-height: 1.6;
}

.role-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 5px;
  margin-bottom: 20px;
  background: var(--surface-2);
  border-radius: 8px;
}

.role-tabs button {
  min-height: 42px;
  color: var(--muted);
  background: transparent;
  border-radius: 7px;
  font-weight: 700;
}

.role-tabs button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(20, 35, 29, 0.08);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.88rem;
}

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

.field textarea {
  min-height: 108px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.13);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.tiny-btn {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

.primary-btn {
  color: #fff;
  background: var(--brand);
}

.primary-btn:hover {
  background: var(--brand-dark);
}

.ghost-btn {
  color: var(--ink);
  background: var(--surface-2);
}

.danger-btn {
  color: #fff;
  background: var(--danger);
}

.tiny-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.8rem;
  color: var(--brand-dark);
  background: rgba(15, 118, 110, 0.1);
}

.action-stack,
.feedback-box {
  display: grid;
  gap: 7px;
  min-width: 150px;
}

.action-stack select,
.feedback-box select,
.feedback-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.feedback-box textarea {
  min-height: 62px;
  resize: vertical;
}

.image-thumb {
  width: 62px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.demo-box {
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.65;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.top-brand {
  margin-bottom: 26px;
}

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

.nav button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  color: var(--sidebar-nav-text);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav button.active,
.nav button:hover {
  color: var(--sidebar-nav-active-text);
  background: var(--sidebar-nav-hover-bg);
}

.sidebar-foot {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line); /* Using general line for consistency */
}

.user-pill {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #d97706;
  color: #fff;
  font-weight: 900;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.user-pill strong {
  display: block;
  font-size: 0.92rem;
}

.user-pill span {
  color: var(--sidebar-user-pill-text);
  font-size: 0.78rem;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.search {
  min-width: 270px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  padding: 18px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(24, 38, 32, 0.06);
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 2rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(24, 38, 32, 0.06);
}

.panel-head {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td strong {
  display: block;
}

td small {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.open {
  color: #7a2e0e;
  background: #ffedd5;
}

.badge.assigned {
  color: #1d4ed8;
  background: #dbeafe;
}

.badge.progress {
  color: #9a3412;
  background: #fed7aa;
}

.badge.resolved {
  color: #047857;
  background: #d1fae5;
}

.badge.closed {
  color: #475569;
  background: #e2e8f0;
}

.badge.priority-high {
  color: #991b1b;
  background: #fee2e2;
}

.badge.priority-medium {
  color: #92400e;
  background: #fef3c7;
}

.badge.priority-low {
  color: #166534;
  background: #dcfce7;
}

.list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.list-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
}

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

.work-detail-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.work-detail-card h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.work-detail-card p,
.work-detail-card small,
.work-detail-card li {
  color: var(--muted);
}

.work-detail-card ul {
  margin: 8px 0 0 16px;
  padding: 0;
}

.list-item span,
.list-item small {
  color: var(--muted);
  line-height: 1.5;
}

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

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

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

.person-card {
  padding: 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(24, 38, 32, 0.06);
}

.person-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.person-card h3 {
  margin: 0;
}

.person-card p {
  margin: 6px 0;
  color: var(--muted);
}

.category-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.category {
  padding: 16px;
  border-radius: 8px;
  color: #fff;
}

.category.civil {
  background: #7c3f1d;
}

.category.electrical {
  background: #1d4ed8;
}

.category.horticulture {
  background: #15803d;
}

.category strong {
  display: block;
  font-size: 1.55rem;
  margin-top: 8px;
}

.empty {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 999;
}

@media (max-width: 1050px) {
  .mobile-header {
    display: flex;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .login-shell,
  .app-shell,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .login-hero {
    min-height: 52vh;
  }

  .login-panel {
    min-height: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -270px;
    width: 270px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-foot {
    position: absolute;
    bottom: 22px;
  }

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

  .main {
    padding: 16px;
  }
}

@media (max-width: 720px) {
  .login-hero,
  .login-panel,
  .main,
  .sidebar {
    padding: 18px;
  }

  .hero-stats,
  .metrics,
  .cards,
  .category-strip,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .search {
    width: 100%;
  }

  .role-tabs {
    grid-template-columns: 1fr;
  }
}
