﻿*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --accent: #f4511e;
  --success: #1e8e3e;
  --success-light: #e6f4ea;
  --warning: #f9ab00;
  --danger: #d93025;
  --bg: #f0f4f8;
  --card: #ffffff;
  --border: #dadce0;
  --text: #202124;
  --text-muted: #5f6368;
  --shadow: 0 1px 4px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.15);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  --ac-color: #1a73e8;
  --dc-color: #f4511e;
  --grid-color: rgba(0,0,0,.06);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, #1a1f3c 0%, #1a73e8 60%, #0d47a1 100%);
  color: #fff;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

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

.header-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-subtitle {
  font-size: 11px;
  opacity: .7;
  margin-top: 1px;
}

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

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #155a2e; transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-warning:hover { background: #e09000; transform: translateY(-1px); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #b52a1f; transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-ghost {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
}
.btn-ghost:hover { background: rgba(255,255,255,.25); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }

.btn:active { transform: scale(.97); }

/* ===== Main Layout ===== */
.main {
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
  padding: 16px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to right, #fafafa, #fff);
}

.card-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.card-body { padding: 16px 18px; }

/* ===== Left Panel ===== */
.left-panel {
  grid-column: 1;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== Right Panel ===== */
.right-panel {
  grid-column: 2;
  grid-row: 1;
}

/* ===== Bottom Panel ===== */
.bottom-panel {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== Parameter Controls ===== */
.param-group {
  margin-bottom: 14px;
}

.param-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.param-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.param-value-display {
  display: flex;
  align-items: center;
  gap: 6px;
}

.param-value-input {
  width: 70px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 6px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font);
  transition: border-color .2s;
}

.param-value-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.1);
}

.param-unit {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 24px;
}

.param-slider-wrap {
  position: relative;
  padding: 2px 0;
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  transition: all .2s;
}

input[type=range].ac-slider {
  background: linear-gradient(to right, var(--ac-color) var(--pct, 50%), #e0e0e0 var(--pct, 50%));
}

input[type=range].dc-slider {
  background: linear-gradient(to right, var(--dc-color) var(--pct, 0%), #e0e0e0 var(--pct, 0%));
}

input[type=range].freq-slider {
  background: linear-gradient(to right, #9c27b0 var(--pct, 15%), #e0e0e0 var(--pct, 15%));
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: all .15s;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(26,115,232,.4);
}

.ac-slider::-webkit-slider-thumb { border-color: var(--ac-color); }
.dc-slider::-webkit-slider-thumb { border-color: var(--dc-color); }
.freq-slider::-webkit-slider-thumb { border-color: #9c27b0; }

.param-range-hints {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== RMS Display ===== */
.rms-display {
  background: linear-gradient(135deg, var(--primary-light), #c5d8fc);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0;
  border: 1px solid rgba(26,115,232,.2);
}

.rms-label {
  font-size: 12px;
  color: var(--primary-dark);
  font-weight: 500;
}

.rms-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.rms-formula {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
}

/* ===== Heat Meters ===== */
.heat-section { margin-top: 4px; }

.heat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.heat-label {
  font-size: 12px;
  font-weight: 600;
  min-width: 46px;
}

.heat-label.ac { color: var(--ac-color); }
.heat-label.dc { color: var(--dc-color); }

.heat-bar-track {
  flex: 1;
  height: 20px;
  background: #f0f0f0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

.heat-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width .3s ease, background .3s;
  position: relative;
  min-width: 2px;
}

.heat-bar-fill.ac { background: linear-gradient(to right, #1a73e8, #4299ff); }
.heat-bar-fill.dc { background: linear-gradient(to right, #f4511e, #ff7043); }

.heat-bar-text {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  color: rgba(0,0,0,.5);
  white-space: nowrap;
}

.heat-value {
  min-width: 58px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.heat-value.ac { color: var(--ac-color); }
.heat-value.dc { color: var(--dc-color); }

.heat-diff {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.heat-diff-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.heat-diff-value {
  font-size: 15px;
  font-weight: 700;
  transition: color .3s;
  font-variant-numeric: tabular-nums;
}

/* ===== Balance Indicator ===== */
.balance-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  margin-bottom: 12px;
  transition: all .3s;
}

.balance-indicator.balanced {
  border-color: var(--success);
  background: var(--success-light);
}

.balance-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.balance-lamp {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ccc;
  border: 2px solid #aaa;
  transition: all .3s;
  box-shadow: none;
  position: relative;
}

.balance-lamp.on {
  background: radial-gradient(circle at 35% 35%, #6eff6e, #00c853);
  border-color: var(--success);
  box-shadow: 0 0 10px rgba(0,200,83,.6), 0 0 20px rgba(0,200,83,.3);
  animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 8px rgba(0,200,83,.6); }
  50% { box-shadow: 0 0 18px rgba(0,200,83,.9), 0 0 30px rgba(0,200,83,.4); }
}

.balance-text { font-size: 13px; font-weight: 600; }
.balance-percent { font-size: 11px; color: var(--text-muted); }

/* ===== Action Buttons Row ===== */
.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Waveform Canvas ===== */
.waveform-card {
  height: 100%;
  min-height: 360px;
}

.waveform-wrap {
  position: relative;
  width: 100%;
  height: calc(100% - 60px);
  min-height: 280px;
}

#waveformCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 0 0 var(--radius) var(--radius);
  background: #0a0f1a;
}

.canvas-legend {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,.8);
  background: rgba(0,0,0,.5);
  padding: 3px 8px;
  border-radius: 4px;
}

.legend-line {
  width: 20px;
  height: 2px;
  border-radius: 1px;
}

.canvas-stats {
  position: absolute;
  bottom: 12px;
  left: 14px;
  display: flex;
  gap: 12px;
}

.stat-badge {
  background: rgba(0,0,0,.6);
  color: rgba(255,255,255,.9);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ===== Record Table ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

thead th {
  background: linear-gradient(to bottom, #f8f9fa, #f0f4f8);
  padding: 9px 10px;
  text-align: center;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

tbody tr {
  transition: background .15s;
}

tbody tr:hover { background: var(--primary-light); }
tbody tr:nth-child(even) { background: #fafafa; }
tbody tr:nth-child(even):hover { background: var(--primary-light); }

tbody td {
  padding: 7px 10px;
  text-align: center;
  border-bottom: 1px solid #f0f0f0;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: #fef7e0; color: #b06000; }

.table-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== Report Area ===== */
.report-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

input[type=text], textarea, select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  transition: border-color .2s;
  background: #fff;
}

input[type=text]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.1);
}

textarea { resize: vertical; min-height: 70px; }

.report-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* ===== Exercises ===== */
.exercise-card {
  background: linear-gradient(135deg, #fffde7, #fff9c4);
  border: 1.5px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
}

.exercise-title {
  font-size: 13px;
  font-weight: 700;
  color: #6d4c00;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.exercise-q {
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 8px;
}

.exercise-q strong {
  color: var(--primary-dark);
}

.exercise-answer-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exercise-answer-input {
  width: 100px;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
}

.exercise-answer-input:focus {
  outline: none;
  border-color: var(--primary);
}

.exercise-feedback {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  display: none;
}

.exercise-feedback.correct { background: var(--success-light); color: var(--success); display: inline-block; }
.exercise-feedback.wrong { background: #fdecea; color: var(--danger); display: inline-block; }

/* ===== Tooltip ===== */
[data-tip] {
  position: relative;
  cursor: help;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(32,33,36,.92);
  color: #fff;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  z-index: 200;
  line-height: 1.4;
  max-width: 220px;
  white-space: normal;
  text-align: center;
}

[data-tip]:hover::after { opacity: 1; }

/* ===== Help Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(700px, 95vw);
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(.95);
  transition: transform .3s;
}

.modal-overlay.open .modal { transform: scale(1); }

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 { font-size: 17px; }
.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.modal-close:hover { background: #e0e0e0; }

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

.help-section { margin-bottom: 18px; }
.help-section h3 {
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--primary-light);
}

.help-section p, .help-section li {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

.help-section ul { padding-left: 18px; }
.help-section li { margin-bottom: 4px; }

.formula-box {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--primary-dark);
  margin: 8px 0;
  text-align: center;
}

/* ===== Report Preview Modal ===== */
.report-preview {
  padding: 24px;
  font-family: 'Times New Roman', serif;
  line-height: 1.8;
}

.report-preview h1 {
  text-align: center;
  font-size: 20px;
  margin-bottom: 6px;
  color: #1a1a1a;
}

.report-preview h2 {
  font-size: 15px;
  margin: 16px 0 6px;
  color: #333;
  border-bottom: 1px solid #ccc;
  padding-bottom: 4px;
}

.report-preview table {
  width: 100%;
  margin: 10px 0;
  border: 1px solid #ccc;
}

.report-preview th {
  background: #f0f4f8;
  padding: 6px 8px;
  border: 1px solid #ccc;
  font-size: 12px;
}

.report-preview td {
  padding: 5px 8px;
  border: 1px solid #ccc;
  font-size: 12px;
}

.report-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin: 8px 0;
  font-size: 13px;
  color: #444;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card { animation: fadeIn .4s ease both; }
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .1s; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .main {
    grid-template-columns: 300px 1fr;
  }
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .left-panel { grid-column: 1; grid-row: auto; }
  .right-panel { grid-column: 1; grid-row: auto; }
  .bottom-panel { grid-column: 1; grid-row: auto; }
}

@media (max-width: 600px) {
  .header-title { font-size: 14px; }
  .main { padding: 10px; gap: 10px; }
  .report-form { grid-template-columns: 1fr; }
}

/* ===== Print Styles ===== */
@media print {
  body { background: #fff; }
  .header, .left-panel, .waveform-card, .action-row, .report-actions { display: none !important; }
  .main { display: block; }
  .bottom-panel { display: block; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ===== Custom Scrollable Table ===== */
.record-table-wrap {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ===== Number Display ===== */
.num-display {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ===== Divider ===== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* ===== Info Row ===== */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  padding: 4px 0;
}
.info-row .info-label { color: var(--text-muted); }
.info-row .info-val { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== Tabs ===== */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  transition: all .2s;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab:hover:not(.active) { color: var(--text); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Steps Guide ===== */
.steps { display: flex; gap: 0; margin-bottom: 14px; }
.step {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 3px solid var(--border);
}
.step.done { border-bottom-color: var(--success); color: var(--success); }
.step.active { border-bottom-color: var(--primary); color: var(--primary); font-weight: 700; }
.step-num {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
