:root {
  --primary-color: #2196F3;
  --secondary-color: #1976D2;
  --background-color: #f5f5f5;
  --card-background: #ffffff;
  --text-color: #333;
  --text-secondary: #666;
  --border-color: rgba(0,0,0,0.1);
  --gauge-background: #eee;
  --danger-color: #f44336;
  --success-color: #4CAF50;
  --warning-color: #ff9800;
}

[data-theme="dark"] {
  --primary-color: #64B5F6;
  --secondary-color: #42A5F5;
  --background-color: #1a1a1a;
  --card-background: #2d2d2d;
  --text-color: #ffffff;
  --text-secondary: #aaaaaa;
  --border-color: rgba(255,255,255,0.1);
  --gauge-background: #404040;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
}

.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  padding-top: 80px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

h1 {
  color: var(--primary-color);
  font-size: 2em;
}

.datetime {
  font-size: 1.2em;
  color: var(--text-secondary);
}

.main-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.tank-container, .stats-container, .chart-container, .controls-container, .alerts-container {
  background: var(--card-background);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tanks {
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
}

.tank-wrapper {
  text-align: center;
}

.tank {
  width: 100px;
  height: 200px;
  border: 3px solid var(--primary-color);
  border-radius: 5px;
  position: relative;
  margin: 10px auto;
  background: rgba(33, 150, 243, 0.1);
  transition: all 0.3s ease;
}

.tank:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.water-level {
  position: relative;
  overflow: hidden;
  height: 8px !important;
}

.water-level:hover {
  filter: brightness(1.2);
}

.water-wave {
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: 50%;
  background: rgba(33, 150, 243, 0.4);
  border-radius: 38%;
  animation: horizontalWave 3s infinite linear;
  transform-origin: 50% 50%;
}

.water-wave:nth-child(2) {
  animation-delay: 0.1s;
  opacity: 0.5;
}

@keyframes horizontalWave {
  0% {
    transform: translateX(-50%);
  }
  50% {
    transform: translateX(-30%);
  }
  100% {
    transform: translateX(-50%);
  }
}

.measurement-marks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
}

.measurement-marks::before {
  content: '';
  position: absolute;
  left: -5px;
  width: 10px;
  height: 1px;
  background: #999;
}

.tank-info {
  margin-top: 10px;
}

.percentage {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--primary-color);
  display: block;
}

.volume {
  color: var(--text-secondary);
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.stats-card {
  text-align: center;
  padding: 15px;
  border-radius: 8px;
  background: rgba(33, 150, 243, 0.1);
}

.stat-value {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--primary-color);
  margin-top: 10px;
}

.controls {
  display: grid;
  gap: 20px;
  max-height: 500px;
  transition: max-height 0.3s ease-out;
  overflow: hidden;
}

.controls.minimized {
  max-height: 0;
  padding: 0;
  margin: 0;
  opacity: 0;
  transition: all 0.3s ease;
}

.control-group {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.valve-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  background: var(--primary-color);
  color: white;
  cursor: pointer;
  transition: background-color 0.3s;
}

.valve-btn:hover {
  background: var(--secondary-color);
}

.valve-btn.active {
  background: var(--success-color);
}

input[type="range"] {
  width: 100%;
}

.alerts {
  max-height: 200px;
  overflow-y: auto;
}

.alert {
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alert.danger {
  background: rgba(244, 67, 54, 0.1);
  color: var(--danger-color);
}

.alert.warning {
  background: rgba(255, 152, 0, 0.1);
  color: var(--warning-color);
}

.alert.success {
  background: rgba(76, 175, 80, 0.1);
  color: var(--success-color);
}

.chart-container {
  grid-column: span 2;
}

.circular-tanks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
  padding: 30px;
  background: var(--card-background);
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  margin-bottom: 30px;
  min-height: 400px;
}

.circular-tank {
  position: relative;
  width: 250px;
  height: 250px;
  margin: 0 auto;
}

.tank-circle {
  width: 100%;
  height: 100%;
  border: 8px solid var(--primary-color);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background: rgba(33, 150, 243, 0.1);
}

.circular-tank:first-child .tank-circle {
  border: 12px solid #455a64;
  background: 
    linear-gradient(45deg, #263238 25%, transparent 25%) -10px 0,
    linear-gradient(-45deg, #263238 25%, transparent 25%) -10px 0,
    linear-gradient(45deg, transparent 75%, #263238 75%) -10px 0,
    linear-gradient(-45deg, transparent 75%, #263238 75%) -10px 0;
  background-size: 20px 20px;
  background-color: #37474f;
  position: relative;
}

.circular-tank:first-child .tank-circle::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 30px;
  background: #546e7a;
  border-radius: 5px 5px 0 0;
  border: 4px solid #455a64;
  border-bottom: none;
}

.circular-tank:first-child .tank-circle::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 20px;
  background: #546e7a;
  border-radius: 0 0 5px 5px;
  border: 4px solid #455a64;
  border-top: none;
}

.circular-tank:first-child .water-circle {
  background: linear-gradient(180deg, 
    rgba(33, 150, 243, 0.8),
    rgba(33, 150, 243, 0.6)
  );
}

.circular-tank:first-child .measurement-marks::before {
  background: #90a4ae;
}

.circular-tank:first-child .industrial-markers {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.circular-tank:first-child .industrial-marker {
  position: absolute;
  width: 15px;
  height: 3px;
  background: #90a4ae;
  right: -20px;
}

.water-circle {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--primary-color);
  transition: height 0.5s ease-in-out;
}

.circular-measurement {
  position: absolute;
  width: 100%;
  height: 100%;
}

.circular-measurement::before {
  content: '';
  position: absolute;
  left: -5px;
  width: 10px;
  height: 2px;
  background: #999;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  transition: background-color 0.3s;
}

.download-btn:hover {
  background: var(--secondary-color);
}

.download-btn svg {
  width: 20px;
  height: 20px;
}

.ripple {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.5);
  animation: rippleAnim 2s infinite linear;
}

@keyframes rippleAnim {
  0% {
    transform: translateY(0) scaleY(1);
    opacity: 0.8;
  }
  100% {
    transform: translateY(-140px) scaleY(2);
    opacity: 0;
  }
}

.wave {
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: 50%;
  background: var(--primary-color);
  border-radius: 38%;
  animation: wave 5s infinite linear;
}

@keyframes wave {
  0% {
    transform: translate(-50%, 0) rotateZ(0deg);
  }
  50% {
    transform: translate(-50%, -2%) rotateZ(180deg);
  }
  100% {
    transform: translate(-50%, 0) rotateZ(360deg);
  }
}

.controls-container {
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 350px;
  border-radius: 15px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 1000;
  transition: transform 0.3s ease;
  cursor: move;
  user-select: none;
}

.controls-container:hover {
  transform: translateY(-5px);
}

.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

.minimize-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.minimize-btn:hover {
  background: var(--secondary-color);
  transform: scale(1.1);
}

.gauges-container {
  min-height: 300px;
  padding: 40px;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
  background: var(--card-background);
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.gauge {
  position: relative;
  width: 250px;
  height: 150px;
  margin: 0 auto;
}

.gauge svg {
  width: 100%;
  height: 100%;
}

.gauge-background {
  stroke: var(--gauge-background);
  stroke-width: 12;
}

.gauge-value {
  stroke-width: 12;
  transition: stroke-dashoffset 0.5s ease;
}

.gauge-markers {
  fill: none;
  stroke: var(--text-secondary);
  stroke-width: 1;
}

.gauge-text {
  fill: var(--text-color);
  font-size: 24px;
  font-weight: bold;
}

.gauge-label {
  color: var(--text-color);
  text-align: center;
  margin-top: 10px;
  font-size: 1.2em;
}

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1002;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
  fill: var(--text-color);
}

.water-circle .wave {
  animation: wave 5s infinite linear;
  animation-delay: 0s !important;
}

.water-circle .wave:nth-child(2) {
  animation: wave 5s infinite linear reverse;
  animation-delay: -2.5s !important;
}

.history-table-container {
  background: var(--card-background);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-top: 20px;
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.history-table th,
.history-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

.history-table th {
  background: rgba(33, 150, 243, 0.1);
  color: var(--primary-color);
  font-weight: 600;
}

.history-table tr:hover {
  background: rgba(33, 150, 243, 0.05);
}

.table-status {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.9em;
}

.table-status.normal { background: rgba(76, 175, 80, 0.2); color: var(--success-color); }
.table-status.warning { background: rgba(255, 152, 0, 0.2); color: var(--warning-color); }
.table-status.danger { background: rgba(244, 67, 54, 0.2); color: var(--danger-color); }

@media (max-width: 1200px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  
  .chart-container {
    grid-column: span 1;
  }
  
  .tanks {
    flex-direction: column;
    align-items: center;
  }
  
  .tank-wrapper {
    margin-bottom: 20px;
  }
  
  .circular-tanks {
    grid-template-columns: 1fr;
  }
  
  .controls-container {
    position: static;
    width: 100%;
    margin-top: 20px;
  }
  
  .gauges-container {
    grid-template-columns: 1fr;
  }
}

.main-menu {
  background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.8));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.3);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 1001;
  transition: all 0.3s ease;
}

.main-menu.scrolled {
  padding: 5px 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo {
  width: 50px;
  height: 50px;
  animation: rotateLogo 10s linear infinite;
}

@keyframes rotateLogo {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.menu-title {
  font-size: 1.5em;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transition: all 0.3s ease;
}

.menu-title:hover {
  transform: scale(1.05);
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  -webkit-background-clip: text;
  background-clip: text;
}

.menu-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, rgba(33,150,243,0.1), rgba(25,118,210,0.1));
  z-index: -1;
  transform: translateZ(0);
}

.menu-background::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.8), transparent);
  animation: pulseBackground 4s infinite;
}

@keyframes pulseBackground {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

.tank-container:hover,
.stats-container:hover,
.chart-container:hover,
.alerts-container:hover,
.circular-tanks:hover,
.history-table-container:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

h1, h2, h3 {
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transition: all 0.3s ease;
}

h1:hover, h2:hover, h3:hover {
  transform: scale(1.05);
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  -webkit-background-clip: text;
  background-clip: text;
}

.tank-wrapper:hover,
.stats-card:hover,
.gauge:hover {
  transform: translateY(-3px) scale(1.02);
  transition: all 0.3s ease;
}

.auto-adjust-btn {
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  margin: 10px;
  transition: all 0.3s ease;
}

.auto-adjust-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.auto-adjust-btn.active {
  background: linear-gradient(45deg, var(--success-color), var(--secondary-color));
}