:root {
  --blue:       #1565C0;
  --blue-light: #E3F2FD;
  --blue-mid:   #BBDEFB;
  --teal:       #00ACC1;
  --bg:         #F4F6FA;
  --card-bg:    #FFFFFF;
  --red:        #E53935;
  --orange:     #FB8C00;
  --green:      #43A047;
  --text:       #2D2D2D;
  --muted:      #757575;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
  --sidebar-w:  240px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  margin: 0;
  line-height: 1.5;
}

/* Login Page */
.login-page {
  background: linear-gradient(135deg, var(--blue) 0%, var(--teal) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.form-group input {
  padding: 12px 16px;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--blue);
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: var(--muted);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  background: var(--blue);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.logo {
  font-size: 24px;
  font-weight: 600;
  color: white;
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar nav {
  flex: 1;
  padding: 24px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: all 0.2s;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
  font-weight: 500;
}

.nav-item .icon {
  font-size: 18px;
}

.location-switcher {
  padding: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.location-switcher-header {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.loc-item {
  display: block;
  padding: 8px 12px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  transition: all 0.2s;
}

.loc-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.loc-item.loc-active {
  background: rgba(255,255,255,0.15);
  color: white;
  font-weight: 500;
}

.sidebar-footer {
  padding: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-footer span {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
}

.sidebar-footer a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}

.sidebar-footer a:hover {
  color: white;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 32px;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--muted);
  font-size: 14px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* Locations Grid */
.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.location-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.location-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.location-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.location-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.location-info p {
  color: var(--muted);
  font-size: 14px;
  margin: 8px 0;
}

.location-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #E0E0E0;
}

.view-link {
  color: var(--blue);
  font-weight: 500;
  font-size: 14px;
}

/* Tanks */
.tanks-container {
  min-height: 200px;
}

.tank-section {
  margin-bottom: 32px;
}

.tank-section h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
}

.tanks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.tank-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.tank-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.tank-visual {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.tank-info h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.tank-building {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.tank-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.stat {
  flex: 1;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

.tank-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.last-updated {
  font-size: 12px;
  color: var(--muted);
}

/* Pump Detail */
.pump-detail-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.tank-large {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.pump-info-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.pump-main-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.main-stat {
  flex: 1;
}

.main-stat-value {
  font-size: 36px;
  font-weight: 600;
  color: var(--text);
}

.main-stat-label {
  font-size: 14px;
  color: var(--muted);
}

.pump-state {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #E0E0E0;
}

.badge-large {
  font-size: 16px;
  padding: 8px 16px;
}

.pump-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
}

.detail-label {
  color: var(--muted);
  font-size: 14px;
}

.detail-value {
  font-weight: 500;
  font-size: 14px;
}

.chart-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.chart-container h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Events */
.events-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.events-controls {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
}

.search-box input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  font-size: 14px;
}

.filter-controls select {
  padding: 10px 16px;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.events-table-container {
  overflow-x: auto;
}

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

.events-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid #E0E0E0;
}

.events-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid #E0E0E0;
}

.change-badge {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 4px;
}

.direction-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 14px;
}

.direction-badge.rising {
  background: #E8F5E9;
  color: var(--green);
}

.direction-badge.falling {
  background: #FFEBEE;
  color: var(--red);
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #E0E0E0;
}

/* Settings */
.settings-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.settings-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

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

.settings-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.settings-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #E0E0E0;
}

.info-label {
  color: var(--muted);
  font-size: 14px;
}

.info-value {
  font-weight: 500;
  font-size: 14px;
}

.map-container {
  height: 300px;
  border-radius: 8px;
  overflow: hidden;
}

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

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-primary:hover {
  background: #0D47A1;
}

.btn-secondary {
  background: #E0E0E0;
  color: var(--text);
}

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

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Badges */
.badge {
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.badge-red {
  background: #FFEBEE;
  color: var(--red);
}

.badge-orange {
  background: #FFF3E0;
  color: var(--orange);
}

.badge-green {
  background: #E8F5E9;
  color: var(--green);
}

.badge-blue {
  background: #E3F2FD;
  color: var(--blue);
}

/* Utility */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.error {
  text-align: center;
  padding: 40px;
  color: var(--red);
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error {
  background: #FFEBEE;
  color: var(--red);
}

/* Responsive */
@media (max-width: 1024px) {
  .pump-overview,
  .settings-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  
  .locations-grid,
  .tanks-grid {
    grid-template-columns: 1fr;
  }
  
  .events-controls {
    flex-direction: column;
  }
  
  .search-box {
    min-width: 100%;
  }
}
