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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #e7e2e2;
  min-height: 100vh;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  margin: 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 24px;
  color: #333;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
  text-decoration: none;
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.05);
}

.icon-user::before {
  content: '🏠';
}

.icon-energy::before {
  content: '⚡';
}

.content {
  padding: 0 20px;
  flex: 1;
}

/* Weather Card */
.weather-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  grid-column: span 2;
}

.weather-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.weather-icon {
  font-size: 48px;
  line-height: 1;
}

.weather-primary {
  display: flex;
  flex-direction: column;
}

.weather-temp {
  font-size: 32px;
  font-weight: 300;
  color: #333;
  line-height: 1;
}

.weather-temp .unit {
  font-size: 18px;
  color: #999;
}

.weather-description {
  font-size: 13px;
  color: #888;
  margin-top: 2px;
}

.weather-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.weather-location {
  font-size: 14px;
  color: #666;
  font-weight: 600;
  margin-bottom: 4px;
}

.weather-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: #888;
}

.weather-stats span {
  white-space: nowrap;
}

.weather-toggle {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: none;
  border: none;
  color: #ccc;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 12px;
  transition: color 0.2s;
}

.weather-toggle:hover {
  color: #666;
}

.loading {
  text-align: center;
  color: #666;
  font-size: 18px;
  padding: 60px 20px;
}

.empty-state {
  background: rgba(255, 255, 255, 0.95);
  padding: 60px 20px;
  border-radius: 15px;
  text-align: center;
  color: #666;
}

/* Sensors container - list view (default) */
.sensors-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Grid view container */
.app.grid-view .sensors-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.app.grid-view .weather-card {
  grid-column: span 2;
}

/* Hide item button */
.hide-item-btn {
  display: none;
  position: absolute;
  top: -8px;
  right: -8px;
  background: #e74c3c;
  border: 2px solid #fff;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: all 0.2s;
  z-index: 10;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hide-item-btn:hover {
  background: #c0392b;
  transform: scale(1.1);
}

.app.edit-mode .hide-item-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ensure hidden cards are fully hidden */
.sensor-card.hidden-item,
.weather-card.hidden-item {
  display: none !important;
}

/* Hidden sections panel */
.hidden-sections-panel {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.hidden-sections-panel h3 {
  font-size: 14px;
  font-weight: 600;
  color: #666;
  margin: 0 0 12px 0;
}

.hidden-sections-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hidden-section-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #fff;
  border-radius: 8px;
  font-size: 14px;
  color: #333;
}

.show-section-btn {
  background: #4a90d9;
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.show-section-btn:hover {
  background: #357abd;
}

/* Edit mode indicator */
.app.edit-mode .sensor-card,
.app.edit-mode .weather-card {
  cursor: grab;
  outline: 2px dashed rgba(100, 100, 255, 0.3);
}

.app.edit-mode .sensor-card:active,
.app.edit-mode .weather-card:active {
  cursor: grabbing;
}

/* List view sensor card (horizontal row layout) */
.sensor-card {
  background: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  display: flex;
  align-items: center;
}

.sensor-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.sensor-card.offline {
  opacity: 0.5;
}

.sensor-name {
  font-size: 16px;
  color: #666;
  font-weight: 500;
  flex: 1;
  text-align: left;
}

.sensor-stats {
  display: flex;
  gap: 12px;
  font-size: 14px;
  color: #888;
  flex: 1;
  justify-content: center;
}

.sensor-stats .stat {
  white-space: nowrap;
}

.temperature {
  font-size: 28px;
  font-weight: 300;
  color: #333;
  line-height: 1;
  flex: 1;
  text-align: center;
}

.temperature .unit {
  font-size: 16px;
  color: #999;
}

/* Grid view sensor card (vertical centered layout) */
.app.grid-view .sensor-card {
  flex-direction: column;
  text-align: center;
  padding: 16px 20px;
}

.app.grid-view .sensor-name {
  font-size: 16px;
  margin-bottom: 6px;
  flex: none;
}

.app.grid-view .temperature {
  font-size: 42px;
  min-width: auto;
  text-align: center;
}

.app.grid-view .temperature .unit {
  font-size: 24px;
}

.app.grid-view .sensor-stats {
  margin-right: 0;
  margin-top: 10px;
  justify-content: center;
  font-size: 14px;
  gap: 10px;
}


.last-update {
  font-size: 13px;
  color: #333;
  font-weight: 500;
  text-align: center;
  padding: 20px 0;
  margin-top: 16px;
}

.footer-actions {
  display: flex;
  justify-content: center;
  padding: 10px 0 20px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 15px;
  max-width: 1000px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  border-bottom: 2px solid #eee;
  padding-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
  color: #333;
  font-size: 24px;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  transition: all 0.2s;
}

.btn-close:hover {
  background: #f0f0f0;
  color: #333;
}

.controls {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-range label {
  font-weight: 500;
  color: #333;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  background: white;
  min-width: 150px;
}

.btn-nav {
  padding: 8px 12px;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-nav:hover:not(:disabled) {
  background: #e0e0e0;
}

.btn-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  background: white;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
  border: 1px solid #ddd;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.charts-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

.chart-wrapper {
  background: #f9f9f9;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid #eee;
}

.chart-wrapper h3 {
  margin: 0 0 20px 0;
  color: #333;
  font-size: 16px;
}

.chart-wrapper canvas {
  max-height: 300px;
}

/* Dark Mode */
.app.dark {
  background: #1a1a2e;
}

.app.dark .header h1 {
  color: #e0e0e0;
}

.app.dark .btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.app.dark .sensor-card {
  background: #252540;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.app.dark .sensor-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.app.dark .sensor-name {
  color: #aaa;
}

.app.dark .sensor-stats {
  color: #777;
}

.app.dark .temperature {
  color: #e0e0e0;
}

.app.dark .temperature .unit {
  color: #777;
}

.app.dark .last-update {
  color: #888;
}

.app.dark .loading {
  color: #888;
}

.app.dark .empty-state {
  background: rgba(30, 30, 50, 0.95);
  color: #888;
}

.app.dark .hide-item-btn {
  border-color: #252540;
}

.app.dark .hide-item-btn:hover {
  background: #c0392b;
}

.app.dark .hidden-sections-panel {
  background: rgba(30, 30, 50, 0.8);
}

.app.dark .hidden-sections-panel h3 {
  color: #aaa;
}

.app.dark .hidden-section-item {
  background: #252540;
  color: #e0e0e0;
}

.app.dark .modal-content {
  background: #252540;
}

.app.dark .modal-header h2 {
  color: #e0e0e0;
}

.app.dark .modal-header {
  border-bottom-color: #333;
}

.app.dark .btn-close {
  color: #aaa;
}

.app.dark .btn-close:hover {
  background: #333;
  color: #fff;
}

.app.dark .date-range label {
  color: #ccc;
}

.app.dark .select {
  background: #1a1a2e;
  color: #e0e0e0;
  border-color: #444;
}

.app.dark .btn-secondary {
  background: #333;
  color: #e0e0e0;
  border-color: #444;
}

.app.dark .btn-secondary:hover {
  background: #444;
}

.app.dark .chart-wrapper {
  background: #1a1a2e;
  border-color: #333;
}

.app.dark .chart-wrapper h3 {
  color: #e0e0e0;
}

.app.dark .weather-card {
  background: #252540;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.app.dark .weather-location {
  color: #ccc;
}

.app.dark .weather-temp {
  color: #e0e0e0;
}

.app.dark .weather-temp .unit {
  color: #777;
}

.app.dark .weather-description {
  color: #888;
}

.app.dark .weather-stats {
  color: #888;
}

.app.dark .weather-toggle {
  color: #555;
}

.app.dark .weather-toggle:hover {
  color: #aaa;
}

.app.dark .date-input {
  background: #1a1a2e;
  color: #e0e0e0;
  border-color: #444;
}

.app.dark .btn-nav {
  background: #333;
  color: #e0e0e0;
  border-color: #444;
}

.app.dark .btn-nav:hover:not(:disabled) {
  background: #444;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    padding: 15px 20px;
  }

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

  .modal-content {
    padding: 20px;
  }

  .controls {
    flex-direction: column;
  }

  .date-range {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .app.grid-view .sensor-card {
    padding: 12px 14px;
  }

  .app.grid-view .sensor-name {
    font-size: 14px;
  }

  .app.grid-view .temperature {
    font-size: 32px;
  }

  .app.grid-view .temperature .unit {
    font-size: 18px;
  }

  .app.grid-view .sensor-stats {
    font-size: 12px;
    gap: 8px;
  }
}
