/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn:hover { background: var(--bg-muted); }
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-muted); color: var(--text-primary); }

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

/* === Card === */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }

/* === Form === */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-input,
.form-select {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast);
  font-variant-numeric: tabular-nums;
}
.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-input.invalid {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* === Result Box === */
.result-box {
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}
.result-value {
  font-size: 28px;
  font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.result-unit {
  font-size: 14px;
  color: var(--text-secondary);
  margin-left: 4px;
}

/* === Badge === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 10px;
  background: var(--bg-muted);
  color: var(--text-secondary);
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger); }

/* === Toast === */
#toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 200ms ease, transform 200ms ease;
  min-width: 220px;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }

/* === Section header === */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.section-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
}
.section-desc {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* === Dashboard === */
.dash-hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  padding: 32px 28px;
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
}
.dash-hero h1 {
  color: #fff;
  font-size: 22px;
  margin-bottom: 8px;
}
.dash-hero p {
  color: rgba(255, 255, 255, 0.88);
  max-width: 640px;
  font-size: 13px;
  line-height: 1.55;
}

.dash-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 24px 0 12px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.module-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-decoration: none;
  color: var(--text-primary);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.module-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent, var(--color-primary));
  opacity: 0.85;
}
.module-card[data-accent="thermo"]      { --accent: var(--accent-thermo); }
.module-card[data-accent="rtd"]         { --accent: var(--accent-rtd); }
.module-card[data-accent="signal"]      { --accent: var(--accent-signal); }
.module-card[data-accent="unit"]        { --accent: var(--accent-unit); }
.module-card[data-accent="uncertainty"] { --accent: var(--accent-uncertainty); }

.module-card:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent, var(--color-primary));
}

.module-card.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.module-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.module-card-icon {
  font-size: 22px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  color: var(--accent, var(--color-primary));
}

.module-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.module-card-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.module-card-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}
.module-card-features li {
  font-size: 11.5px;
  color: var(--text-tertiary);
  padding-left: 14px;
  position: relative;
}
.module-card-features li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--accent, var(--color-primary));
  font-weight: 600;
}

.dash-footer-note {
  margin-top: 32px;
  padding: 16px;
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-light);
}
.dash-footer-note strong { color: var(--text-secondary); }

/* === Thermocouple module === */
.control-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.type-btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.type-btn {
  flex: 1;
  min-width: 48px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-variant-numeric: tabular-nums;
}
.type-btn:hover {
  border-color: var(--accent-thermo);
  color: var(--accent-thermo);
}
.type-btn.active {
  background: var(--accent-thermo);
  color: #fff;
  border-color: var(--accent-thermo);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.type-info {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.type-info strong { color: var(--text-primary); }

.mode-toggle {
  display: flex;
  gap: 6px;
}
.mode-btn {
  flex: 1;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}
.mode-btn .mode-sub {
  font-size: 10.5px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-top: 2px;
}
.mode-btn:hover {
  border-color: var(--accent-thermo);
  color: var(--text-primary);
}
.mode-btn.active {
  background: var(--color-primary-light);
  color: var(--accent-thermo);
  border-color: var(--accent-thermo);
}
.mode-btn.active .mode-sub { color: var(--accent-thermo); opacity: 0.75; }

/* Converter grid */
.converter-card { padding: 0; overflow: hidden; }
.converter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.converter-panel {
  padding: 24px;
}
.input-panel  { border-right: 1px solid var(--border-light); }
.result-panel { background: var(--bg-muted); }

.converter-panel h2 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.input-group + .input-group,
.input-group + .cjc-section { margin-top: 16px; }

.input-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.input-with-unit {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-with-unit .form-input { flex: 1; }

.unit-toggle {
  display: inline-flex;
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.unit-btn {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.unit-btn:hover:not(.active) { color: var(--text-primary); }
.unit-btn.active {
  background: var(--bg-surface);
  color: var(--accent-thermo);
  box-shadow: var(--shadow-sm);
}

/* CJC */
.cjc-section {
  margin-top: 20px;
  padding: 14px;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-medium);
}
.input-panel .cjc-section { background: var(--bg-page); }
.cjc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.cjc-info {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* Result */
.result-display {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  margin-bottom: 16px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.result-display .result-value {
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--accent-thermo);
}
.result-unit-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.result-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.result-controls-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.result-warning {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.4;
}

/* History */
.history-card { margin-top: 16px; }
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.history-header h2 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  padding: 10px 12px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.history-label { font-weight: 600; color: var(--accent-thermo); }
.history-time { color: var(--text-tertiary); }
.history-io {
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  gap: 6px;
  align-items: center;
}
.history-arrow { color: var(--text-tertiary); }
.history-output { color: var(--text-primary); font-weight: 500; }

/* === Batch / Tablo modu === */
.batch-toggle-row {
  margin-top: 16px;
  display: flex;
  justify-content: flex-start;
}
.batch-toggle-btn {
  font-size: 13px;
}
.batch-toggle-icon {
  display: inline-block;
  margin-right: 4px;
  transition: transform var(--transition-fast);
  font-size: 11px;
  color: var(--text-tertiary);
}

.batch-card {
  margin-top: 12px;
}

.batch-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.batch-header h2 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.batch-hint {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.batch-hint strong {
  color: var(--text-primary);
}

.batch-meta {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.batch-meta-pill {
  background: var(--color-primary-light);
  color: var(--accent-thermo);
  border: 1px solid var(--accent-thermo);
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.batch-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.batch-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.batch-table thead th {
  background: var(--bg-muted);
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}
.batch-table tbody tr {
  border-bottom: 1px solid var(--border-light);
}
.batch-table tbody tr:last-child { border-bottom: none; }
.batch-table tbody tr:hover { background: var(--bg-muted); }

.batch-table td {
  padding: 6px 12px;
  vertical-align: middle;
}
.batch-col-num {
  width: 40px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.batch-col-input { width: 40%; }
.batch-col-output { width: 40%; }
.batch-col-action { width: 36px; }

.batch-input {
  padding: 6px 10px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.batch-cell-empty { color: var(--text-tertiary); }
.batch-cell-error { color: var(--color-danger); font-size: 12px; }
.batch-cell-value { color: var(--text-primary); font-weight: 500; }
.batch-cell-unit { color: var(--text-secondary); font-size: 12px; margin-left: 2px; }

.batch-remove-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all var(--transition-fast);
}
.batch-remove-btn:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* Mobile */
@media (max-width: 640px) {
  .converter-grid { grid-template-columns: 1fr; }
  .input-panel { border-right: none; border-bottom: 1px solid var(--border-light); }
  .result-display .result-value { font-size: 30px; }
  .type-btn { font-size: 13px; padding: 8px; min-width: 40px; }
  .mode-btn { font-size: 12px; padding: 8px 10px; }
  .batch-header { flex-direction: column; gap: 8px; }
  .batch-table { font-size: 12px; }
}

/* === Utility === */
.text-muted { color: var(--text-tertiary); }
.text-center { text-align: center; }
.tabular { font-variant-numeric: tabular-nums; }
