:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 4px 6px rgba(0, 0, 0, 0.05), 0 10px 24px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.page-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.page-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.sub-title {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.status {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status.loading { background: #dbeafe; color: var(--primary); }
.status.ok { background: #d1fae5; color: #047857; }
.status.error { background: #fee2e2; color: #b91c1c; }

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 22px 24px;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.controls .control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.controls .control-row:last-child { margin-bottom: 0; }

.controls label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 500;
}

.controls input[type="text"],
.controls input[type="datetime-local"],
.controls select {
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: #fff;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

.controls input:focus,
.controls select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.quick-btns { display: flex; gap: 8px; flex-wrap: wrap; }

button {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

button:hover {
  border-color: #cbd5e1;
  color: var(--text);
  background: #f8fafc;
}

button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.15);
}

button.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

button.primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.quick-btns button.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #bfdbfe;
  font-weight: 600;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.section-title h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.data-summary {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-tip {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: right;
  max-width: 360px;
}

.chart-box {
  width: 100%;
  height: 540px;
  border-radius: 10px;
  background: #fafbfc;
  border: 1px solid var(--border);
}

.field-selector {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.field-selector span {
  font-weight: 500;
}

.field-selector label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.field-selector input[type="radio"] {
  accent-color: var(--primary);
}

.video-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.video-controls label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.video-controls select {
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: #fff;
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.3);
}

#video-player {
  width: 100%;
  height: 100%;
  display: block;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  text-align: center;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
}

.video-overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-content p {
  margin: 6px 0;
  font-size: 15px;
  font-weight: 500;
}

.overlay-content .small {
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 400;
}

.video-info {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
  min-height: 22px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.video-info a {
  color: var(--primary);
  text-decoration: none;
}

.video-info a:hover {
  text-decoration: underline;
}

.page-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
}

.page-footer a {
  color: var(--primary);
  text-decoration: none;
}

.page-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .chart-box { height: 380px; }
  .controls .control-row { gap: 10px; }
  .section-title { flex-direction: column; align-items: flex-start; }
  .legend-tip { text-align: left; max-width: 100%; }
}
