:root {
  --bg-primary: #f0f5f9;
  --bg-secondary: #e1e8f0;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --border-card: rgba(0, 120, 255, 0.08);
  --border-glow: rgba(0, 120, 255, 0.2);
  --text-primary: #2c3e50;
  --text-secondary: #5c6b7a;
  --text-muted: #95a5a6;
  --accent-blue: #3498db;
  --accent-cyan: #00bcd4;
  --accent-green: #2ecc71;
  --accent-red: #e74c3c;
  --accent-orange: #f1c40f;
  --gradient-main: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
  --gradient-bg:
    radial-gradient(
      ellipse at 15% 0%,
      rgba(241, 196, 15, 0.15) 0%,
      transparent 40%
    ),
    radial-gradient(
      ellipse at 85% 100%,
      rgba(52, 152, 219, 0.15) 0%,
      transparent 40%
    );
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-glow: 0 8px 30px rgba(0, 118, 255, 0.12);
  --shadow-modal: 0 20px 40px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family:
    "Noto Sans SC",
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--gradient-bg);
  pointer-events: none;
  z-index: 0;
}

.hidden {
  display: none !important;
}

/* Header */
.header {
  position: relative;
  z-index: 10;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-card);
  backdrop-filter: blur(20px);
  background: rgba(255, 255, 255, 0.85);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo img {
  height: 60px;
  width: auto;
  object-fit: contain;
}

.header h1 {
  font-size: 22px;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header h1 span {
  font-weight: 300;
  font-size: 14px;
  -webkit-text-fill-color: var(--text-secondary);
  margin-left: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-phone {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}
.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 118, 255, 0.2);
}
.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(0, 118, 255, 0.3);
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
}
.btn-outline:hover {
  background: rgba(52, 152, 219, 0.1);
}
.btn-text {
  background: transparent;
  color: var(--text-secondary);
}
.btn-text:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.05);
}
.btn-danger {
  background: rgba(231, 76, 60, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(231, 76, 60, 0.2);
}
.btn-danger:hover {
  background: rgba(231, 76, 60, 0.2);
}
.w-100 {
  width: 100%;
}

/* Layout */
.main {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px;
}

.dashboard-layout {
  display: flex;
  gap: 24px;
  align-items: start;
}

/* Sidebar */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  transition:
    width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.content-area {
  flex: 1;
  min-width: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  width: 100%;
}

.sidebar-action-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  transition: all 0.2s ease;
}

.sidebar-action-btn:hover {
  background: rgba(52, 152, 219, 0.15);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.toggle-sidebar-btn {
  background: transparent;
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.toggle-sidebar-btn:hover {
  background: var(--bg-secondary);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.toggle-icon {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 11px;
}

/* Collapsed styles */
.dashboard-layout.sidebar-collapsed .sidebar {
  width: 0;
  padding: 0;
  border-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.dashboard-layout.sidebar-collapsed .toggle-icon {
  transform: rotate(180deg);
}

.search-box {
  position: relative;
  margin-bottom: 16px;
}

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

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

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  margin-top: 4px;
  box-shadow: var(--shadow-modal);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}

.search-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border-card);
}
.search-item:hover {
  background: var(--bg-secondary);
}
.search-item span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.station-list {
  flex: 1;
  overflow-y: auto;
}

.station-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: background 0.2s;
  border: 1px solid transparent;
}

.station-item:hover {
  background: rgba(52, 152, 219, 0.05);
  border-color: var(--border-card);
}

.station-item label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
}

.station-item .name {
  font-size: 14px;
  font-weight: 500;
}

.station-item .setting-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.station-item .setting-btn:hover {
  color: var(--accent-blue);
  background: var(--bg-secondary);
}

/* Chart Area */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
}

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

.chart-sync-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(52, 152, 219, 0.1);
  color: var(--accent-blue);
  font-size: 13px;
  font-weight: 600;
  align-self: flex-start;
}

.chart-sync-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-blue);
  animation: pulse 1.2s ease-in-out infinite;
}

.chart-title {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-range-select {
  padding: 6px 12px;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.time-range-select:focus {
  border-color: var(--accent-blue);
}

.chart-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.btn-refresh:hover {
  background: rgba(52, 152, 219, 0.15);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.btn-refresh:active {
  transform: scale(0.97);
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.85);
    opacity: 0.45;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

.chart-wrapper {
  flex: 1;
  position: relative;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 100px 20px;
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border-card);
}
.empty-state .emoji {
  font-size: 64px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state .emoji img {
  height: 120px;
  width: auto;
  object-fit: contain;
}
.empty-state h2 {
  font-size: 24px;
  margin-bottom: 10px;
  color: var(--text-primary);
}
.empty-state p {
  color: var(--text-secondary);
}

/* Weather Table */
.weather-container {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-top: 24px;
}

.weather-header {
  margin-bottom: 20px;
}

.weather-header h3 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.weather-table-wrapper {
  overflow-x: auto;
}

.weather-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 13px;
  min-width: 780px;
}

.weather-station-title {
  margin: 16px 0 8px;
  color: var(--text-primary);
  font-size: 15px;
}

.weather-table th,
.weather-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-card);
}

.weather-table th {
  color: var(--text-secondary);
  font-weight: 500;
  background: rgba(0, 0, 0, 0.02);
}

.weather-table td {
  color: var(--text-primary);
}

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

.weather-table tr:hover td {
  background: rgba(52, 152, 219, 0.05);
}

.weather-cell-param {
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  background: rgba(0, 0, 0, 0.02);
  width: 120px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 39, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: white;
  width: 100%;
  max-width: 400px;
  border-radius: 16px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}
.close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
}
.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.help-text {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
  margin-left: 6px;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.form-group input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.row-group {
  display: flex;
  gap: 10px;
}
.row-group input {
  flex: 1;
}

.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toggle-group label {
  margin-bottom: 0;
}

.form-actions {
  margin-top: 24px;
}

.auth-links {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.auth-links a {
  color: var(--accent-blue);
  text-decoration: none;
}
.auth-links a:hover {
  text-decoration: underline;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--text-muted);
  transition: 0.4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--accent-green);
}
input:checked + .slider:before {
  transform: translateX(20px);
}

/* ========== Mobile Responsive ========== */
@media (max-width: 768px) {
  .header {
    padding: 12px 16px;
  }

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

  .logo {
    font-size: 22px;
  }

  .header-right {
    gap: 8px;
  }

  .user-phone {
    font-size: 12px;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main {
    padding: 12px;
  }

  .dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .sidebar {
    width: 100% !important;
    height: auto;
    border-radius: 12px;
    padding: 14px;
    transition: none;
  }

  .content-area {
    width: 100% !important;
  }

  .dashboard-layout.sidebar-collapsed .sidebar {
    display: none !important;
  }

  .toggle-icon {
    transform: rotate(90deg);
  }

  .dashboard-layout.sidebar-collapsed .toggle-icon {
    transform: rotate(270deg);
  }

  .station-list {
    max-height: 132px;
    overflow-y: auto;
  }

  .sidebar-header h3 {
    font-size: 15px;
  }

  .sidebar-header {
    margin-bottom: 10px;
  }

  .search-box {
    margin-bottom: 10px;
  }

  .search-box input {
    padding: 8px 12px;
    font-size: 13px;
  }

  .station-item {
    padding: 8px 10px;
    margin-bottom: 4px;
  }

  .station-item .name {
    font-size: 13px;
  }

  .chart-container {
    height: auto;
    min-height: 350px;
    border-radius: 12px;
    padding: 14px;
  }

  .chart-header {
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .chart-title {
    font-size: 15px;
  }

  .chart-actions {
    width: 100%;
    display: flex;
    gap: 8px;
  }

  .btn-refresh,
  .time-range-select {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .chart-wrapper {
    min-height: 280px;
  }

  .empty-state {
    padding: 50px 16px;
    border-radius: 12px;
  }

  .empty-state .emoji {
    font-size: 48px;
    margin-bottom: 14px;
  }

  .empty-state h2 {
    font-size: 20px;
  }

  .modal {
    max-width: calc(100vw - 32px);
    border-radius: 12px;
  }

  .modal-header {
    padding: 16px 20px;
  }

  .modal-body {
    padding: 16px 20px;
  }
}

@keyframes blink {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}
