:root {
  --bg: #f5f5f5;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card2: #ffffff;
  --border: rgba(0,0,0,0.06);
  --green: #4caf50;
  --green-soft: #81c784;
  --green-strong: #388e3c;
  --green-dim: rgba(76,175,80,0.12);
  --text-main: #111111;
  --text-muted: #555555;
  --shadow: 0 8px 24px rgba(0,0,0,0.05);
  /* Dark Sidebar/Navbar Variables */
  --dark-bg: rgba(26, 26, 26, 0.98);
  --dark-border: rgba(255,255,255,0.1);
  --dark-text: rgba(255,255,255,0.85);
  --dark-text-hover: #ffffff;
  --field-bg: #ffffff;
  --field-text: #1b2b22;
  --field-placeholder: #5c6f64;
  --field-border: rgba(27, 43, 34, 0.16);
}

body.dark-theme {
  --bg: #121212;
  --bg-card: rgba(30, 30, 30, 0.85);
  --bg-card2: #1e1e1e;
  --border: rgba(255,255,255,0.08);
  --text-main: #e0e0e0;
  --text-muted: #a0a0a0;
  --shadow: 0 8px 24px rgba(0,0,0,0.3);
  --dark-bg: #121212;
  --field-bg: #1c2220;
  --field-text: #f3f6f4;
  --field-placeholder: #a8b8ae;
  --field-border: rgba(255, 255, 255, 0.18);
}

/* Accessibility */
.badge-warning {
  color: #212529 !important;
}

/* Sidebar / logo branding — green accent, not yellow */
.brand-link .brand-text.font-weight-bold {
  color: var(--green) !important;
}
.brand-link .brand-text.font-weight-light {
  color: rgba(255, 255, 255, 0.85) !important;
}
.sidebar .user-panel .image i {
  color: var(--green) !important;
}
#darkModeToggle:hover i {
  color: var(--green) !important;
  text-shadow: 0 0 8px rgba(76, 175, 80, 0.6) !important;
}

body {
  font-family: 'Inter', 'Poppins', sans-serif;
  color: var(--text-main) !important;
  background: var(--bg) !important;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Poppins', sans-serif;
  color: var(--text-main);
  font-weight: 600;
}

.brand-text, .nav-link p, .info a {
  font-family: 'Poppins', sans-serif;
}

/* Base structural overrides */
.wrapper, .content-wrapper {
  background: transparent !important;
  border: none !important;
}

.main-header {
  background: var(--dark-bg) !important;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--dark-border) !important;
}

.main-sidebar {
  background: var(--dark-bg) !important;
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--dark-border) !important;
}

.brand-link {
  border-bottom: 1px solid var(--dark-border) !important;
  color: var(--dark-text-hover) !important;
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 0.8rem 0.75rem !important;
  overflow: visible !important;
  white-space: normal !important;
}

.brand-link .brand-image {
  float: none !important;
  margin: 0 !important;
  flex: 0 0 auto;
}

.brand-text {
  color: var(--dark-text-hover);
  display: inline-block !important;
  max-width: calc(100% - 44px);
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.86rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.015em;
  line-height: 1.15 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  hyphens: manual;
  word-break: keep-all;
}

.user-panel {
  border-bottom: 1px solid var(--dark-border) !important;
}

.user-panel .info a {
  color: var(--dark-text) !important;
  font-weight: 500;
}

/* Cards */
.card {
  background: var(--bg-card) !important;
  backdrop-filter: blur(12px);
  border: 1px solid var(--border) !important;
  border-radius: 16px;
  color: var(--text-main) !important;
  box-shadow: var(--shadow);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(76,175,80,0.12);
  border-color: rgba(76,175,80,0.25) !important;
}

.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 20px 24px;
}

.card-body {
  padding: 24px;
}

.card-title {
  color: var(--text-main);
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
}

/* Text overrides */
.text-muted { color: var(--text-muted) !important; }
.text-dark { color: var(--text-main) !important; }

/* Widgets - Small Boxes */
.small-box {
  background: #ffffff !important;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-main) !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
  overflow: hidden;
  position: relative;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.small-box:hover {
  transform: translateY(-4px);
  border-color: rgba(76,175,80,0.2);
  box-shadow: 0 12px 30px rgba(76,175,80,0.08);
}

.small-box.bg-info, .small-box.bg-success, .small-box.bg-warning, .small-box.bg-danger {
  background: #ffffff !important;
}

.small-box .inner {
  padding: 24px;
}

.small-box .inner h3 {
  font-size: 38px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text-main);
}

.small-box .inner p {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0;
}

.small-box .icon > i {
  color: rgba(76,175,80,0.15) !important;
  transition: color 0.3s ease, transform 0.3s ease;
}
.small-box:hover .icon > i {
  color: rgba(76,175,80,0.3) !important;
  transform: scale(1.1);
}
.small-box > .small-box-footer {
  background: rgba(76,175,80,0.04) !important;
  color: var(--green) !important;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.3px;
}
.small-box > .small-box-footer:hover {
  background: rgba(76,175,80,0.08) !important;
  color: #43a047 !important;
}

/* Sidebar nav */
.nav-pills .nav-link {
  color: var(--dark-text);
  border-radius: 8px;
  margin: 4px 16px; /* 8px grid */
  font-weight: 500;
  transition: all 0.2s ease;
}
.nav-pills .nav-link p {
  color: var(--dark-text);
  margin: 0;
}
.nav-pills .nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: var(--dark-text-hover);
}
.nav-pills .nav-link:hover p {
  color: var(--dark-text-hover);
}
.nav-pills .nav-link.active {
  background: var(--green) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(76,175,80,0.3);
}
.nav-pills .nav-link.active p {
  color: #fff !important;
}

/* Tables */
.table { color: var(--text-main); }
.table-hover tbody tr:hover {
  background-color: rgba(76,175,80,0.05) !important;
  color: var(--text-main);
}
.table thead th {
  border-bottom: 2px solid var(--border) !important;
  border-top: none !important;
  color: var(--text-muted);
  font-weight: 600;
}
.table td { border-top: 1px solid var(--border) !important; }

/* Modals */
.modal-content {
  background: var(--bg-card2);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 16px;
  color: var(--text-main);
}
.modal-header {
  border-bottom: 1px solid var(--border) !important;
  background: transparent !important;
}
.modal-footer {
  border-top: 1px solid var(--border) !important;
}
.modal-title { font-family: 'Poppins', sans-serif; font-weight: 700; color: var(--text-main); }
.close { color: var(--text-main); text-shadow: none; opacity: 0.6; }
.close:hover { color: var(--text-main); opacity: 1; }

/* Forms */
.form-control {
  background: var(--field-bg) !important;
  border: 1.5px solid var(--field-border) !important;
  color: var(--field-text) !important;
  border-radius: 10px;
  padding: 12px 16px;
}
.form-control:focus {
  border-color: var(--green) !important;
  box-shadow: 0 0 0 3px rgba(76,175,80,0.1) !important;
  color: var(--field-text) !important;
}
.form-control::placeholder {
  color: var(--field-placeholder) !important;
  opacity: 1;
}

/* Breadcrumbs & Navbar */
.breadcrumb-item a { color: var(--green); font-weight: 500; }
.breadcrumb-item.active { color: var(--text-muted); }
.navbar-dark .navbar-nav .nav-link { color: var(--dark-text) !important; }
.navbar-dark .navbar-nav .nav-link:hover { color: var(--dark-text-hover) !important; }
.dropdown-menu {
  background: var(--dark-bg);
  border: 1px solid var(--dark-border);
  border-radius: 12px;
}
.dropdown-item { color: var(--dark-text); font-weight: 500; }
.dropdown-item:hover { background: rgba(255,255,255,0.05); color: var(--dark-text-hover); }
.fa-bars { color: var(--dark-text) !important; }


/* Loader CSS */
.loader {
  position:fixed; inset:0;
  background:var(--bg);
  display:flex; flex-direction:column;
  justify-content:center; align-items:center;
  z-index:9999;
  opacity:1; visibility:visible;
  transition:opacity 0.3s ease, visibility 0.3s ease;
}
.loader.loader-hidden { opacity:0; visibility:hidden; }
.loader::before {
  content:'';
  position:absolute;
  width:300px; height:300px;
  background:radial-gradient(circle, rgba(76,175,80,0.08) 0%, transparent 70%);
  border-radius:50%;
  animation:glowPulse 2.5s ease-in-out infinite;
}
@keyframes glowPulse {
  0%,100% { transform:scale(1); opacity:0.6; }
  50%      { transform:scale(1.2); opacity:1; }
}
.rice-leaves {
  position:relative; width:110px; height:110px;
  margin-bottom:28px;
}
.rice-leaves::before {
  content:''; position:absolute; inset:-14px;
  border-radius:50%; border:2px solid transparent;
  border-top-color:var(--green);
  animation:spinRing 1.4s linear infinite;
}
.rice-leaves::after {
  content:''; position:absolute; inset:-24px;
  border-radius:50%; border:1px solid transparent;
  border-bottom-color:rgba(76,175,80,0.3);
  animation:spinRing 2.2s linear infinite reverse;
}
@keyframes spinRing { to { transform:rotate(360deg); } }
.rice-svg {
  width:100%; height:100%;
  transform-origin:bottom center;
  animation:riceSway 3s ease-in-out 1s infinite alternate;
  filter:drop-shadow(0 0 10px rgba(76,175,80,0.4));
}
.rleaf { opacity:0; animation:leafReveal 0.6s ease-out forwards; }
.rl1 { animation-delay:0.3s; }
.rl2 { animation-delay:0.6s; }
.rl3 { animation-delay:0.9s; }
@keyframes leafReveal {
  0%   { opacity:0; transform:scaleY(0) translateY(20px); }
  65%  { opacity:1; transform:scaleY(1.03) translateY(-2px); }
  100% { opacity:1; transform:scaleY(1) translateY(0); }
}
@keyframes riceSway {
  0%   { transform:rotate(-4deg) skewX(-1deg); }
  50%  { transform:rotate(2deg) skewX(0.5deg); }
  100% { transform:rotate(-3deg) skewX(-0.5deg); }
}
.loader-text {
  font-size:18px; font-weight:700;
  color:#fff; letter-spacing:5px;
  text-transform:uppercase;
  animation:fadeInUp 0.7s ease 0.5s both;
}
.loader-sub {
  font-size:11px; color:rgba(255,255,255,0.4);
  letter-spacing:3px; text-transform:uppercase;
  margin-top:6px;
  animation:fadeInUp 0.7s ease 0.7s both;
}
@keyframes fadeInUp {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}

/* Premium Dark Theme Overrides for high contrast and readability */
body.dark-theme .small-box {
  background: var(--bg-card2) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

body.dark-theme .small-box .inner h3,
body.dark-theme .small-box .inner p {
  color: var(--text-main) !important;
}

body.dark-theme .small-box-footer {
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--green) !important;
  border-top: 1px solid var(--border) !important;
}

body.dark-theme .small-box-footer:hover {
  background: rgba(255, 255, 255, 0.06) !important;
}

body.dark-theme .products-list {
  background-color: transparent !important;
}

body.dark-theme .products-list .item {
  background-color: transparent !important;
  border-color: var(--border) !important;
}

body.dark-theme .products-list .item .product-title {
  color: var(--text-main) !important;
}

body.dark-theme .table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(255, 255, 255, 0.015) !important;
}

body.dark-theme .table-hover tbody tr:hover {
  background-color: rgba(76, 175, 80, 0.15) !important;
}

body.dark-theme .modal-header {
  border-bottom: 1px solid var(--border) !important;
}

body.dark-theme .modal-footer {
  border-top: 1px solid var(--border) !important;
}

/* ── RESPONSIVE DASHBOARD MEDIA QUERIES ── */
@media (max-width: 992px) {
  .content-wrapper {
    min-height: calc(100vh - 57px);
  }

  .row > [class*="col-lg-"],
  .row > [class*="col-md-"] {
    margin-bottom: 12px;
  }

  .info-box,
  .small-box {
    margin-bottom: 12px;
  }
}

@media (max-width: 768px) {
  .card-body {
    padding: 16px;
  }
  .card-header {
    padding: 16px;
  }
  .small-box .inner {
    padding: 16px;
  }
  .small-box .inner h3 {
    font-size: 28px;
  }
  .content-header h1 {
    font-size: 24px;
  }

  .main-sidebar {
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }

  .brand-link {
    padding: 12px 10px !important;
  }

  .brand-text {
    font-size: 0.82rem !important;
  }

  .nav-sidebar .nav-link p {
    font-size: 14px;
  }

  .form-control,
  .custom-select,
  select.form-control {
    font-size: 16px; /* iOS: avoid zoom on focus */
  }
}

@media (max-width: 576px) {
  .small-box .inner h3 {
    font-size: 24px;
  }

  .content-header h1 {
    font-size: 20px;
  }

  .card-title {
    font-size: 1rem;
  }
}

/* Shared dashboard home — technician / farmer / admin / superadmin */
.sam-home-welcome,
.tech-home-welcome,
.admin-home-welcome {
  background: linear-gradient(90deg, #1b5e2a 0%, #2d8a45 55%, #4aa85c 100%);
  color: #fff;
  border-radius: 16px;
  padding: 22px 24px 20px;
  margin-bottom: 18px;
  box-shadow: 0 10px 24px rgba(27, 94, 42, 0.18);
}
.sam-home-welcome h2,
.tech-home-welcome h2,
.admin-home-welcome h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  color: #102418 !important;
}
.sam-home-welcome p,
.tech-home-welcome p,
.admin-home-welcome p {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 400;
  opacity: 1;
  color: #fff !important;
}
.sam-home-areas,
.tech-home-areas {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.sam-home-chip,
.tech-home-chip {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: #fff !important;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
}
.sam-home-tile {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  border-radius: 14px;
  padding: 16px 16px 14px;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(22, 40, 28, 0.06);
  cursor: pointer;
  text-decoration: none !important;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.sam-home-tile:hover,
.sam-home-tile:focus {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(22, 40, 28, 0.1);
  outline: none;
}
.sam-home-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sam-home-tile-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.95rem;
}
.sam-home-tile-icon.tone-orange { background: #e67e22; }
.sam-home-tile-icon.tone-blue { background: #2e86de; }
.sam-home-tile-icon.tone-red { background: #c0392b; }
.sam-home-tile-icon.tone-green { background: #1e8a3d; }
.sam-home-tile-go { color: #8aa093; font-size: 0.8rem; }
.sam-home-tile strong {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
  color: #1b2b22;
  font-weight: 800;
}
.sam-home-tile-label {
  display: block;
  margin-top: 6px;
  color: #5f7267;
  font-size: 0.84rem;
  font-weight: 600;
}
.sam-home-actions,
.tech-home-actions,
.admin-home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.sam-home-action,
.tech-home-action,
.admin-home-action {
  border: 0;
  background: #e8f6ec;
  color: #1b5e2a;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.sam-home-action:hover,
.sam-home-action:focus,
.tech-home-action:hover,
.tech-home-action:focus,
.admin-home-action:hover,
.admin-home-action:focus {
  background: #d4efdc;
  outline: none;
}
.sam-home-action i,
.tech-home-action i,
.admin-home-action i { margin-right: 6px; }
body.dark-theme .sam-home-tile {
  background: #23272b;
  box-shadow: none;
}
body.dark-theme .sam-home-tile strong { color: #f1f4f2; }
body.dark-theme .sam-home-tile-label { color: #a7b3ac; }
body.dark-theme .sam-home-action,
body.dark-theme .tech-home-action,
body.dark-theme .admin-home-action {
  background: rgba(40, 167, 69, 0.16);
  color: #9ee4b0;
}

.sam-profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.sam-profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1e8a3d;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sam-profile-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #102418;
}
.sam-profile-role {
  color: #5f7267;
  font-size: 0.88rem;
  font-weight: 600;
}
.sam-profile-card .form-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #5f7267;
  margin-bottom: 6px;
}
.sam-profile-card .form-control[readonly] {
  background: #f4f7f5;
}
body.dark-theme .sam-profile-hero {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
body.dark-theme .sam-profile-name { color: #f1f4f2; }
body.dark-theme .sam-profile-role { color: #a7b3ac; }
body.dark-theme .sam-profile-card .form-control[readonly] {
  background: #23272b;
  color: #f1f4f2;
}

/* Technician profile */
.tp-card {
  max-width: 820px;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(22, 40, 28, 0.07);
}
.tp-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  background: linear-gradient(135deg, #1e8a3d 0%, #2fa65a 100%);
  color: #fff;
}
.tp-avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #fff;
  color: #1e8a3d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3);
}
.tp-name {
  margin: 0 0 6px;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
}
.tp-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 0.8rem;
  font-weight: 600;
}
.tp-body { padding: 20px 24px 24px; }
.tp-section {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #5f7267;
}
.tp-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}
.tp-fact {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid #e3ece6;
  border-radius: 12px;
  background: #f7faf8;
  font-weight: 400;
  cursor: text;
  flex: 0 1 auto;
  min-width: 0;
}
.tp-fact-email { width: 340px; max-width: 100%; }
.tp-fact-short { width: 210px; max-width: 100%; }
.tp-fact-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e2f4e7;
  color: #1e8a3d;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tp-fact-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tp-fact-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: #6b7d72;
}
.tp-fact-value {
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1b2b22;
  width: 100%;
  text-overflow: ellipsis;
  outline: none;
}
.tp-count {
  min-width: 22px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #1e8a3d;
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0;
  text-align: center;
}
.tp-count:empty { display: none; }
.tp-hint {
  margin: -4px 0 12px;
  font-size: 0.85rem;
  color: #6b7d72;
}
.tp-areas { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-area {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #e8f6ec;
  border: 1px solid #c5e5cf;
  color: #1b5e2a;
  font-size: 0.85rem;
  font-weight: 600;
}
.tp-area i { color: #2fa65a; font-size: 0.78rem; }
body.dark-theme .tp-card { background: #1d2124; box-shadow: none; }
body.dark-theme .tp-banner { background: linear-gradient(135deg, #17672e 0%, #1e8a3d 100%); }
body.dark-theme .tp-section,
body.dark-theme .tp-hint,
body.dark-theme .tp-fact-label { color: #a7b3ac; }
body.dark-theme .tp-fact { background: #23272b; border-color: #333a3f; }
body.dark-theme .tp-fact-icon { background: rgba(40, 167, 69, 0.18); color: #9ee4b0; }
body.dark-theme .tp-fact-value { color: #f1f4f2; }
body.dark-theme .tp-area {
  background: rgba(40, 167, 69, 0.16);
  border-color: rgba(40, 167, 69, 0.35);
  color: #9ee4b0;
}
/* Admin: Pest Thresholds */
.th-section {
  margin: 0 0 16px;
  border: 1px solid #d6ecdc;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(22, 40, 28, 0.05);
  overflow: hidden;
}
.th-section > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #f3faf5;
  cursor: pointer;
  list-style: none;
}
.th-section > summary::-webkit-details-marker { display: none; }
.th-summary-text { flex: 1; min-width: 0; }
.th-summary-text strong { display: block; font-size: 1rem; }
.th-summary-text small { color: #4d6156; font-size: 0.85rem; }
.th-chevron { color: #1e8a3d; transition: transform 0.2s ease; }
.th-section[open] .th-chevron { transform: rotate(180deg); }
.th-section[open] > summary { border-bottom: 1px solid #e8efea; }
.th-intro-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #1e8a3d;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.th-footnote { margin: 0; padding: 10px 16px 14px; font-size: 0.8rem; color: #6b7d72; }
.th-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #e8efea;
}
.th-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.th-bulk label { margin: 0; font-size: 0.88rem; }
.th-bulk .form-control { width: 110px; border-radius: 10px; }
.th-toolbar .btn { border-radius: 10px; font-weight: 600; }
.th-table th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #5f7267;
  border-top: 0;
}
.th-table td { vertical-align: middle; }
.th-sci { display: block; color: #7a8b81; font-style: italic; font-size: 0.78rem; }
.th-input { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.th-input .form-control { width: 90px; border-radius: 10px; font-weight: 700; }
.th-default, .th-custom { font-size: 0.74rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.th-default { background: #eef2ef; color: #5f7267; }
.th-custom { background: #fff4d6; color: #8a6100; }
.th-levels { display: flex; flex-wrap: wrap; gap: 6px; }
.th-level { font-size: 0.76rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.th-level.is-low { background: #e8f6ec; color: #1b5e20; }
.th-level.is-mod { background: #fff4d6; color: #8a6100; }
.th-level.is-high { background: #fde8e8; color: #b42318; }
.th-actions { white-space: nowrap; }
.th-actions .btn { border-radius: 8px; margin-left: 4px; }
body.dark-theme .th-section { background: #1d2124; border-color: rgba(40, 167, 69, 0.3); box-shadow: none; }
body.dark-theme .th-section > summary { background: rgba(40, 167, 69, 0.1); }
body.dark-theme .th-summary-text small,
body.dark-theme .th-footnote { color: #c4cec8; }
body.dark-theme .th-toolbar { border-color: #333a3f; }
body.dark-theme .th-table th { color: #a7b3ac; }
body.dark-theme .th-default { background: #2a3034; color: #c4cec8; }
@media (max-width: 576px) {
  .th-toolbar { flex-direction: column; align-items: stretch; }
  .th-actions { text-align: left !important; }
}

/* Technician: Register IoT Device modal */
.tech-device-modal .modal-content {
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(22, 40, 28, 0.25);
}
.tech-device-modal .modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e8efea;
}
.tech-device-modal .modal-title { font-weight: 700; font-size: 1.1rem; }
.tech-device-modal .modal-body { padding: 18px 20px; }
.tech-device-modal .modal-dialog-scrollable form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.tech-device-modal .modal-footer { padding: 12px 20px; border-top: 1px solid #e8efea; }
.tech-device-modal .modal-footer .btn { border-radius: 10px; padding: 8px 18px; font-weight: 600; }
.tech-device-modal .form-group { margin-bottom: 16px; }
.tech-device-modal .form-group > label { margin-bottom: 6px; font-size: 0.9rem; }
.tech-device-modal .form-control {
  height: auto;
  min-height: 44px;
  padding: 10px 12px;
  line-height: 1.4;
  font-size: 0.95rem;
  border-radius: 10px;
}
.tech-device-modal select.form-control {
  padding-right: 32px;
  text-overflow: ellipsis;
}
.tech-device-modal .form-text { font-size: 0.8rem; line-height: 1.4; margin-top: 6px; }
.tech-device-scope {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #d6ecdc;
  border-radius: 12px;
  background: #f3faf5;
}
.tech-device-scope p { margin: 0 0 10px; font-size: 0.88rem; color: #3f5247; }
.tech-area-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tech-area-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #b9dfc4;
  color: #1b5e20;
  font-size: 0.8rem;
  font-weight: 600;
}
.tech-area-chip i { color: #2fa65a; font-size: 0.72rem; }
body.dark-theme .tech-device-modal .modal-header,
body.dark-theme .tech-device-modal .modal-footer { border-color: #333a3f; }
body.dark-theme .tech-device-scope { background: rgba(40, 167, 69, 0.1); border-color: rgba(40, 167, 69, 0.3); }
body.dark-theme .tech-device-scope p { color: #c4cec8; }
body.dark-theme .tech-area-chip { background: #23272b; border-color: rgba(40, 167, 69, 0.4); color: #9ee4b0; }

.tp-id { flex: 1; min-width: 0; }
.tp-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tp-edit-btn:hover { background: rgba(255, 255, 255, 0.28); }
.tp-card [hidden] { display: none !important; }
.tp-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
  margin-bottom: 16px;
}
.tp-field label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #4d6156;
}
.tp-field .form-control { border-radius: 10px; }
.tp-field .form-control[readonly] { background: #f2f5f3; color: #6b7d72; }
.tp-field-hint { display: block; margin-top: 4px; font-size: 0.75rem; color: #7a8b81; }
.tp-password {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #e3ece6;
  border-radius: 12px;
  background: #f7faf8;
}
.tp-password summary {
  cursor: pointer;
  font-weight: 600;
  color: #1e8a3d;
  list-style: none;
}
.tp-password summary::-webkit-details-marker { display: none; }
.tp-password summary i { margin-right: 6px; }
.tp-password[open] summary { margin-bottom: 12px; }
.tp-password .tp-edit-grid { margin-bottom: 0; }
.tp-edit-error {
  margin: 0 0 12px;
  color: #c0392b;
  font-size: 0.86rem;
  font-weight: 600;
}
.tp-edit-error:empty { display: none; }
.tp-edit-actions { display: flex; justify-content: flex-end; gap: 10px; }
.tp-edit-actions .btn { border-radius: 10px; padding: 8px 18px; font-weight: 600; }
body.dark-theme .tp-field label { color: #c4cec8; }
body.dark-theme .tp-field .form-control { background: #23272b; border-color: #333a3f; color: #f1f4f2; }
body.dark-theme .tp-field .form-control[readonly] { color: #a7b3ac; }
body.dark-theme .tp-password { background: #23272b; border-color: #333a3f; }
body.dark-theme .tp-password summary { color: #9ee4b0; }
@media (max-width: 576px) {
  .tp-banner { padding: 18px; flex-wrap: wrap; }
  .tp-edit-btn { width: 100%; justify-content: center; }
  .tp-body { padding: 16px 18px 20px; }
  .tp-fact-email,
  .tp-fact-short { width: 100%; }
  .tp-edit-actions .btn { flex: 1; }
}
