:root {
  --sidebar-bg: #0f1a2e;
  --sidebar-bg-soft: #14213a;
  --sidebar-text: #aab4c8;
  --sidebar-text-dim: #6b7590;
  --accent: #12b886;
  --accent-dark: #0ca678;
  --accent-soft: #e6f9f2;
  --page-bg: #f4f6fa;
  --card-bg: #ffffff;
  --text-main: #10192b;
  --text-muted: #8892a4;
  --border: #edf0f5;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow-card: 0 2px 10px rgba(16, 25, 43, 0.04);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text-main);
  font-family: inherit;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* ---------- Layout ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 28px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
}

.brand .brand-dot {
  color: var(--accent);
}

.nav-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  all: unset;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--sidebar-text);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item i {
  font-size: 17px;
  width: 18px;
  text-align: center;
}

.nav-item:hover {
  background: var(--sidebar-bg-soft);
  color: #fff;
}

.nav-item.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.sub-item {
  all: unset;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--sidebar-text);
  transition: background 0.15s ease, color 0.15s ease;
}

.sub-item i {
  font-size: 17px;
  width: 18px;
  text-align: center;
}

.sub-item:hover {
  background: var(--sidebar-bg-soft);
  color: #fff;
}

.sub-item.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.submenu {
  display: none;
  margin-left: 20px;
}

.submenu.show {
    display: block;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 18px;
  margin-top: 18px;
}

.role-card {
  background: var(--sidebar-bg-soft);
  border-radius: var(--radius-md);
  padding: 16px;
}

.role-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--sidebar-text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.role-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.role-username {
  font-weight: 700;
  color: #fff;
  font-size: 14px;
  margin-bottom: 6px;
}

.role-desc {
  font-size: 12.5px;
  color: var(--sidebar-text-dim);
  line-height: 1.5;
  margin-bottom: 14px;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-logout:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- Main content ---------- */
.main {
  flex: 1;
  padding: 32px 40px 60px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 26px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.page-heading {
  font-size: 15px;
  color: var(--text-main);
}

.page-heading strong { color: var(--accent-dark); font-weight: 700; }

.topbar-date {
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.topbar-time {
  text-align: right;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Stat grids ---------- */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 22px 22px 24px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

/* .stat-card.highlight { */
/*   background: linear-gradient(155deg, var(--accent) 0%, var(--accent-dark) 100%); */
/*   color: #fff; */
/*   border: none; */
/* } */

.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.stat-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-card.highlight .stat-card-label { color: rgba(255, 255, 255, 0.85); }

.stat-card-arrow {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  color: var(--text-muted);
  font-size: 12px;
}

.stat-card.highlight .stat-card-arrow {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.stat-value .unit {
  font-size: 16px;
  font-weight: 600;
  margin-left: 4px;
  color: var(--text-muted);
}

.stat-card.highlight .stat-value .unit { color: rgba(255, 255, 255, 0.85); }

.stat-sub {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---------- Overview section ---------- */
.grid-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  padding: 26px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.panel-title {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.panel-subtitle {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.panel-status-list {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
}

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}


.overview-card {
  background: var(--page-bg);
  border-radius: var(--radius-md);
  padding: 18px;
  border: 1px solid var(--border);
}

.overview-card.active {
  background: var(--accent);
  color: #ffffff;
}

.overview-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.overview-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.overview-action {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
}

.overview-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.overview-card.active .overview-label{
  color: #ffffff;
}

.overview-value {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.overview-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- Device logs panel ---------- */
.logs-panel .panel-head { margin-bottom: 16px; }

.btn-viewall {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--text-main);
  white-space: nowrap;
}

.log-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.log-item:last-child { border-bottom: none; }

.log-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.log-device {
  font-weight: 700;
  font-size: 13.5px;
}

.log-time {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.log-message {
  font-size: 12.5px;
  color: var(--text-muted);
}

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .main { padding: 24px 18px 40px; }
  .grid-4 { grid-template-columns: 1fr; }
  .overview-grid { grid-template-columns: 1fr; }
}

/* ================= Login page ================= */
.login-page {
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, #16213e 0%, #0f1a2e 55%, #0b1220 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border-radius: 22px;
  padding: 38px 34px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.login-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 18px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 2px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.login-heading {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.5;
}

.field-group { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  background: var(--page-bg);
  border-radius: 10px;
  font-size: 16px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.field-input:focus { border-color: var(--accent); }

.login-error {
  background: #fdecec;
  color: #b3261e;
  border: 1px solid #f6c6c3;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  margin-bottom: 16px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.login-footer-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  font-size: 12.5px;
}

.login-footer-links a {
  color: var(--accent-dark);
  font-weight: 600;
}

.login-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0 18px;
}

.login-note {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.login-note code {
  background: var(--page-bg);
  padding: 1px 5px;
  border-radius: 4px;
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.home-link:hover { color: var(--text-main); }

/* ================= Flash messages ================= */
.messages-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.flash-msg {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}

.flash-success { background: var(--accent-soft); color: var(--accent-dark); }
.flash-error { background: #fdecec; color: #b3261e; }

/* ================= Users page ================= */
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}

.page-title-lg {
  font-size: 26px;
  font-weight: 800;
  margin: 4px 0 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.btn-primary-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 18px;
  border: none;
  border-radius: 10px;
  background: var(--text-main);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary-sm:hover { background: #223047; }

.grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.stat-simple {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.stat-simple-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-simple-value {
  font-size: 28px;
  font-weight: 800;
}

.stat-simple-value.c-green { color: var(--accent-dark); }
.stat-simple-value.c-red { color: #dc2626; }
.stat-simple-value.c-blue { color: #2563eb; }

/* filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.search-box {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  background: var(--card-bg);
  outline: none;
}

.search-box input:focus { border-color: var(--accent); }

.pill-group {
  display: flex;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.pill-btn {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.pill-btn.active {
  background: var(--text-main);
  color: #fff;
}

.pill-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}

/* table */
.table-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.you-badge {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 999px;
}

.role-superadmin { background: #f1e9fe; color: #7c3aed; }
.role-admin { background: #e7f1fe; color: #2563eb; }
.role-user { background: #f1f3f6; color: #52596b; }

.status-cell { display: flex; align-items: center; gap: 7px; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-dot.on { background: var(--accent-dark); }
.status-dot.off { background: #dc2626; }
.status-text.on { color: var(--accent-dark); font-weight: 600; }
.status-text.off { color: #dc2626; font-weight: 600; }

.action-icons { display: flex; gap: 6px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.icon-btn:hover { background: var(--page-bg); color: var(--text-main); }
.icon-btn.danger:hover { background: #fdecec; color: #b3261e; border-color: #f6c6c3; }

.table-footnote {
  padding: 14px 20px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ================= Modals ================= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 34, 0.55);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-overlay.open { display: flex; }

.modal-panel {
  width: 100%;
  max-width: 460px;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 28px 30px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}

.modal-title { font-size: 18px; font-weight: 800; }
.modal-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 22px; }

.modal-close-btn {
  border: none;
  background: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.role-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.role-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  flex-wrap: wrap;
}

.role-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.role-option:has(input:checked) {
  border-color: var(--text-main);
  border-width: 2px;
  padding: 11px 13px;
}

.role-option-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.field-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-note {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: -6px 0 16px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.btn-secondary {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary:hover { background: var(--page-bg); }

.modal-actions .btn-primary {
  flex: 1;
  background: var(--text-main);
}

.modal-actions .btn-primary:hover { background: #223047; }

#toast-container{
    position:fixed;
    top:20px;
    right:20px;
    display:flex;
    flex-direction:column;
    gap:12px;
    z-index:9999;
}

.toast{
    min-width:320px;
    padding:14px 18px;
    border-radius:10px;
    color:white;
    box-shadow:0 8px 20px rgba(0,0,0,.25);
    animation:slideIn .3s ease;
}

.toast.success{background:#16a34a;}
.toast.error{background:#dc2626;}
.toast.warning{background:#d97706;}
.toast.info{background:#2563eb;}

@keyframes slideIn{
    from{
        opacity:0;
        transform:translateX(100%);
    }
    to{
        opacity:1;
        transform:translateX(0);
    }
}

@media (max-width: 1200px) {
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .field-row-2 { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
}

/* ================= Weather page additions ================= */
/* Reuses tokens from style.css (--accent, --border, --card-bg, --page-bg, --text-main, --text-muted, --radius-md, --radius-lg) */

/* ---------- Status bar ---------- */
.page-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-statusbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
}

.status-pill--empty {
  background: #fdecec;
  color: #b3261e;
}

.status-pill--ok {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.status-meta {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.page-statusbar-right {
  font-size: 12.5px;
  color: #c94a3f;
  font-weight: 600;
}

/* ---------- Chart panel head ---------- */
.chart-panel .panel-head {
  align-items: center;
  margin-bottom: 18px;
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chart-panel .panel-title {
  font-size: 16px;
}

.btn-csv {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-csv:hover { background: var(--accent-dark); }


/* ---------- Chart controls row ---------- */
.chart-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

/* Dropdown-select: custom button + list, used for range and granularity */
.dropdown-select {
  position: relative;
}

.dropdown-select-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  min-width: 150px;
  justify-content: space-between;
}

.dropdown-select--sm .dropdown-select-btn { min-width: 120px; }

.dropdown-select-btn i {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.dropdown-select.is-open .dropdown-select-btn i {
  transform: rotate(180deg);
}

.dropdown-select.is-open .dropdown-select-btn {
  border-color: var(--accent);
}

.dropdown-select-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  width: 100%;
  min-width: 170px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(16, 25, 43, 0.12);
  display: none;
}

.dropdown-select.is-open .dropdown-select-list {
  display: block;
}

.dropdown-select-list li {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.dropdown-select-list li:hover {
  background: var(--page-bg);
}

.dropdown-select-list li.is-selected {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

/* ---------- Custom date range field (daterangepicker trigger) ---------- */
.daterange-field {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 10px;
  padding: 9px 14px;
  color: var(--text-muted);
  font-size: 13px;
}

.daterange-field[hidden] {
    display: none;
}

.daterange-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  width: 230px;
}

/* ---------- Chart + table body ---------- */
.chart-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

.chart-canvas-wrap {
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 18px 8px;
  min-height: 360px;
}

/* Daterangepicker: nudge the third-party widget toward the app palette */
.daterangepicker td.active,
.daterangepicker td.active:hover {
  background-color: var(--accent);
}

.daterangepicker .ranges li.active {
  background-color: var(--accent);
  color: #fff;
}

@media (max-width: 1100px) {
  .chart-body { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .chart-controls { flex-direction: column; align-items: stretch; }
  .dropdown-select-btn, .daterange-field { width: 100%; }
  .daterange-input { width: 100%; }
}

/* ================= Monitoring detail page: sensor picker + chart ================= */
.detail-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}

.sensor-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sensor-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.sensor-tile:hover {
  border-color: var(--accent);
}

.sensor-tile.active {
  background: linear-gradient(155deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: transparent;
  color: #fff;
}

.sensor-tile-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}

.sensor-tile.active .sensor-tile-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.sensor-tile-label {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-main);
}

.sensor-tile.active .sensor-tile-label { color: #fff; }

.sensor-tile-metric {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-weight: 800;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
  min-width: 44px;
  justify-content: center;
}

.sensor-tile-value {
  font-size: 13px;
}

.sensor-tile-unit {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.75;
}

.sensor-tile.active .sensor-tile-metric {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.sensor-tile-arrow {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  color: var(--text-muted);
  font-size: 12px;
}

.sensor-tile.active .sensor-tile-arrow {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.chart-panel {
  min-height: 100%;
}

@media (max-width: 960px) {
  .detail-layout { grid-template-columns: 1fr; }
  .sensor-picker { flex-direction: row; flex-wrap: wrap; }
  .sensor-tile { width: calc(50% - 6px); }
}

@media (max-width: 560px) {
  .sensor-tile { width: 100%; }
}
