@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap");

:root {
  --color-primary: #7380ec;
  --color-danger: #ff7782;
  --color-success: #41f1b6;
  --color-warning: #ffbb55;
  --color-white: #fff;
  --color-info-dark: #7d8da1;
  --color-info-light: #dce1eb;
  --color-dark: #363949;
  --color-light: rgba(132, 139, 200, 0.18);
  --color-primary-variant: #111e88;
  --color-dark-variant: #677483;
  --color-background: #f6f6f9;
  --color-insight-1: rgb(99, 209, 35);
  --color-insight-2: rgb(233, 245, 59);
  --color-insight-3: rgb(204, 52, 67);
  --color-insight-4: rgb(56, 183, 238);
  --card-border-radius: 2rem;
  --border-radius-1: 0.4rem;
  --border-radius-2: 0.8rem;
  --border-radius-3: 1.2rem;
  --card-padding: 1.2rem;
  --padding-1: 1.2rem;
  --box-shadow: 0 2rem 3rem var(--color-light);
  --chart-background: #fff;
  --chart-font-color: #444;
  --chart-axis-color: #444;
}

body.dark-theme-variables {
  --color-background: #090d3e;
  --color-white: #0b0f4a;
  --color-primary: #fff;
  --color-dark: #edeffd;
  --color-dark-variant: #fff;
  --color-light: rgba(0, 0, 0, 0.4);
  --box-shadow: 0 2rem 3rem var(--color-light);
  --chart-background: #0d1256;
  --chart-font-color: #fff;
  --chart-axis-color: #fff;
}

body.dark-theme-variables #menu-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

body.dark-theme-variables #menu-btn:hover {
  background: var(--color-primary);
  color: #000;
}

body.dark-theme-variables .theme-toggler span {
  color: #ffffff;
}

body.dark-theme-variables .theme-toggler span.active {
  background: #ffffff;
  color: #000000;
}

* {
  margin: 0;
  padding: 0;
  outline: 0;
  appearance: none;
  text-decoration: none;
  list-style: none;
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: poppins, sans-serif;
  font-size: 0.88rem;
  background: var(--color-background);
  color: var(--color-dark-variant);
  overflow-x: hidden;
}

.container {
  display: grid;
  grid-template-columns:
    clamp(180px, 14vw, 220px) minmax(0, 1fr) clamp(260px, 22vw, 420px);
}

.container.no-right {
  grid-template-columns: 260px 1fr;
}

aside {
  grid-column: 1;
  overflow-y: auto;
}

main {
  padding: 1.5rem;
  overflow-y: auto;
  overflow-x: auto;
  min-width: 0;
}

.right {
  padding: 1.5rem;
  border-left: 1px solid var(--color-light);
  overflow-y: auto;
}

a {
  color: var(--color-dark);
}

img {
  display: block;
  width: 100%;
}

h1 {
  font-weight: 800;
  font-size: 1.8rem;
}

h2 {
  font-size: 1.4rem;
}

h3 {
  font-size: 0.87rem;
}

h4 {
  font-size: 0.8rem;
}

h5 {
  font-size: 0.77rem;
}

small {
  font-size: 0.75rem;
}

.profile-photo {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  overflow: hidden;
}

.text-muted {
  color: var(--color-info-light);
}

p {
  color: var(--color-dark-variant);
}

b {
  color: var(--color-dark-variant);
}

.primary {
  color: var(--color-primary);
}

.danger {
  color: var(--color-danger);
}

.success {
  color: var(--color-success);
}

.warning {
  color: var(--color-warning);
}

aside .top {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1.4rem;
}

aside .logo {
  display: flex;
  justify-content: center;
  width: 100%;
}

aside .logo img {
  width: 200px;
  height: auto;
}

aside .close {
  display: none;
}

aside .sidebar {
  display: flex;
  flex-direction: column;
  height: 86vh;
  position: relative;
  top: 3rem;
}

aside h3 {
  font-weight: 500;
}

aside .sidebar a {
  display: flex;
  color: var(--color-info-dark);
  margin-left: 2rem;
  gap: 1rem;
  align-items: center;
  position: relative;
  height: 3.7rem;
  transition: all 300ms ease;
}

aside .sidebar a span {
  font-size: 1.6rem;
  transition: all 300ms ease;
}

aside .sidebar a.active {
  background: var(--color-light);
  color: var(--color-primary);
  margin-left: 0;
}

aside .sidebar a.active:before {
  content: "";
  width: 6px;
  height: 100%;
  background: var(--color-primary);
}

aside .sidebar a.active span {
  color: var(--color-primary);
  margin-left: calc(1rem - 6px);
}

aside .sidebar a:hover {
  color: var(--color-primary);
}

aside .sidebar a:hover span {
  margin-left: 1rem;
}

main .insights {
  display: grid;
  grid-template-columns: repeat(4, minmax(300px, 1fr));
  gap: 1.6rem;
  min-width: 1200px;
}

main .insights>div {
  background: var(--color-white);
  padding: var(--card-padding);
  border-radius: var(--card-border-radius);
  margin-top: 1rem;
  box-shadow: var(--box-shadow);
  transition: all 300ms ease;
}

main .insights>div:hover {
  box-shadow: none;
}

main .insights>div span {
  background: var(--color-primary);
  padding: 0.5rem;
  border-radius: 50%;
  color: var(--color-white);
  font-size: 2rem;
}

main .insights>div.voltage span {
  background: var(--color-insight-1);
}

main .insights>div.current span {
  background: var(--color-insight-2);
}

main .insights>div.power span {
  background: var(--color-insight-3);
}

main .insights>div.pf span {
  background: var(--color-insight-4);
}

main .insights>div .middle {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

main .insights h3 {
  margin: 1rem 0 0.6rem;
  font-size: 1rem;
}

main .histories {
  margin-top: 1.2rem;
}

main .history-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(550px, 1fr));
  gap: 1.5rem;

  background: var(--color-white);
  border-radius: var(--border-radius-1);
  padding: var(--card-padding);
  text-align: center;
  box-shadow: var(--box-shadow);

  min-width: 1200px;
}

main .history-charts:hover {
  box-shadow: none;
}

main .history-charts .history-divs {
  text-align: center;
}

main .histories h2 {
  margin-bottom: 0.8rem;
}

.history-charts {
  min-width: 0;
}

.history-divs {
  min-width: 0;
}

.right .top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.right .top button {
  display: none;
}

.right .gauge-charts {
  margin-top: 2rem;
}

.right .gauge-charts .item {
  background: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: var(--border-radius-3);
  box-shadow: var(--box-shadow);
  width: 100%;
  min-height: 180px;
  overflow: visible;
}

.right .gauge-charts .item:hover {
  box-shadow: none;
}

.right .gauge-charts .item .right {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin: 0;
  width: 100%;
}

.right .gauge-charts .item .icon {
  padding: 0.6rem;
  color: var(--color-white);
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
}

.right .gauge-charts .item.offline .icon {
  background: var(--color-danger);
}

.export-open-btn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 1rem;
}

.export-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.export-modal-content {
  background: #fff;
  padding: 1.6rem;
  border-radius: 12px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.export-modal-content input {
  padding: 6px 8px;
}

.export-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.export-actions button {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

.export-actions button:last-child {
  background: var(--color-primary);
  color: white;
}

.export-actions button:disabled {
  background: #aaa;
}

body.dark-theme-variables .export-modal-content {
  background: var(--chart-background);
  color: var(--chart-font-color);
}

body.dark-theme-variables .export-modal-content h3,
body.dark-theme-variables .export-modal-content label,
body.dark-theme-variables .export-modal-content small {
  color: var(--chart-font-color);
}

body.dark-theme-variables .export-modal-content input,
body.dark-theme-variables .export-modal-content select {
  background: #1a1f5a;
  color: #fff;
  border: 1px solid #3b3f8c;
}

body.dark-theme-variables .export-modal-content input::placeholder {
  color: #cbd5f5;
}

body.dark-theme-variables .export-open-btn {
  background: #1f2a6d;
  color: #ffffff;
  border: 1px solid #2e3a8c;
  box-shadow: none;
}

body.dark-theme-variables .connection-status h3 {
  color: #cbd5f5;
}

body.dark-theme-variables .connection-status .status {
  font-weight: 600;
}

body.dark-theme-variables .status.live {
  color: #22c55e;
}

body.dark-theme-variables .status.stale {
  color: #facc15;
}

body.dark-theme-variables .status.disconnected {
  color: #ef4444;
}

.overview-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-top: 2rem;
}

.overview-cards .card {
  background: var(--color-white);
  padding: 2rem;
  border-radius: var(--card-border-radius);
  box-shadow: var(--box-shadow);
  text-align: center;
  font-size: 1.2rem;
}

.ranking-table {
  margin-top: 2rem;
  background: var(--color-white);
  padding: 2rem;
  border-radius: var(--card-border-radius);
  box-shadow: var(--box-shadow);
}

.scada-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.scada-top {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.scada-top .box {
  background: var(--color-white);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  font-size: 20px;
}

.scada-peak {
  margin-top: 20px;
  font-size: 20px;
  font-weight: bold;
}

.scada-ranking {
  margin-top: 30px;
  font-size: 1.2rem;
}

.scada-ranking h3 {
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.scada-ranking div {
  padding: 6px 0;
  border-bottom: 1px solid var(--color-light);
}

.scada-alarm {
  margin-top: 30px;
  background: #300;
  padding: 20px;
  border-radius: 8px;
  font-size: 1.2rem;
}

.scada-alarm h3 {
  font-size: 1.3rem;
  color: #ff6b6b;
  margin-bottom: 12px;
}

.scada-alarm div {
  padding: 5px 0;
  font-weight: 600;
}

#power-gauge,
#pf-gauge,
#hz-gauge {
  width: 100%;
  height: 220px;
}

.history-divs,
#voltage-history,
#current-history,
#power-history,
#pf-history {
  width: 100%;
  min-width: 0;
  height: 260px !important;
}

#clock {
  font-size: 1rem;
  font-weight: 600;
  background: var(--color-white);
  padding: 8px 14px;
  border-radius: 10px;
  box-shadow: var(--box-shadow);
}

body.dark-theme-variables #clock {
  background: var(--chart-background);
}

.top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.top-clock {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 12px;
  background: var(--color-white);
  border-radius: 8px;
  box-shadow: var(--box-shadow);
}

body.dark-theme-variables .top-clock {
  background: var(--chart-background);
  color: var(--chart-font-color);
}

.logout-btn {
  padding: 0.6rem 1.3rem;
  border-radius: 0.7rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
}

body:not(.dark-theme-variables) .logout-btn {
  background: #ef4444;
  color: #fff;
}

body.dark-theme-variables .logout-btn {
  background: #ff3b3b;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(255, 0, 0, 0.6);
}

body.dark-theme-variables .logout-btn:hover {
  background: #ff0000;
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.9);
  transform: translateY(-2px);
}

.theme-toggler span {
  cursor: pointer;
  font-size: 1.6rem;
  padding: 0.3rem;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.theme-toggler span.active {
  background: var(--color-primary);
  color: white;
  transform: scale(1.2);
}

.theme-toggler span:hover {
  transform: scale(1.15);
}

.collapse-sidebar aside {
  width: 0;
  overflow: hidden;
}

.collapse-sidebar .sidebar {
  display: none;
}

.collapse-sidebar aside .logo {
  display: none;
}

.collapse-sidebar .container {
  grid-template-columns: 0 minmax(0, 1fr) clamp(260px, 22vw, 420px);
}

.collapse-sidebar .container.no-right {
  grid-template-columns: 0 minmax(0, 1fr);
}

#menu-btn {
  background: var(--color-light);
  border: none;
  padding: 0.5rem 0.7rem;
  border-radius: 0.6rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

#menu-btn span {
  font-size: 1.8rem;
  transition: transform 0.3s ease;
}

#menu-btn:hover {
  background: var(--color-primary);
  color: #fff;
  transform: scale(1.05);
}

body.collapse-sidebar #menu-btn span {
  transform: rotate(90deg);
}

.dashboard-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.8rem 2rem;
  background: var(--color-white);
  box-shadow: var(--box-shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.dashboard-header .top-clock {
  margin-right: auto;
  font-weight: 500;
  font-size: 0.9rem;
}

body,
aside,
main,
.right,
.dashboard-header,
.overview-cards .card,
.history-charts,
.gauge-charts .item {
  transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.login-page {
  background: url("/images/login-bg.png") no-repeat center center/cover;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.login-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.login-wrapper {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  padding: 40px;
  border-radius: 20px;
  width: 360px;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
}

.login-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}

.login-logo img {
  display: block;
  width: 140px;
  height: auto;
}

.login-card input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

.login-card button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #7380ec;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: 0.3s ease;
}

.login-card button:hover {
  background: #111e88;
  transform: translateY(-2px);
}

.login-card h2 {
  margin-top: 10px;
  margin-bottom: 20px;
  text-align: center;
}

.history-divs {
  width: 100% !important;
  min-width: 0;
}

.history-charts {
  width: 100%;
}

@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr !important;
  }

  .right {
    border-left: none;
  }

  main .insights {
    grid-template-columns: 1fr !important;
    min-width: 0 !important;
  }

  main .history-charts {
    grid-template-columns: 1fr !important;
    min-width: 0 !important;
  }

  .right .gauge-charts .item {
    width: 100%;
  }

  main {
    overflow-x: hidden;
  }
}

@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr !important;
  }

  aside {
    position: fixed;
    left: -260px;
    top: 0;
    width: 260px;
    height: 100vh;
    background: var(--color-white);
    z-index: 2000;
    transition: left 0.3s ease;
  }

  body.show-sidebar aside {
    left: 0;
  }

  body.show-sidebar::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
  }

  main .insights {
    grid-template-columns: 1fr !important;
    min-width: 0 !important;
  }

  main .history-charts {
    grid-template-columns: 1fr !important;
    min-width: 0 !important;
  }

  main {
    overflow-x: hidden;
  }
}

.container.no-right {
  grid-template-columns: 220px 1fr;
}