/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: Arial, "Helvetica Neue", Helvetica, Ubuntu, sans-serif;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e0e3e8;
  --text: #1a1c1f;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --nav-h: 44px;
  --header-h: 60px;
  --sidebar-w: 280px;
  --radius: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
}

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

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--nav-h);
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Two-panel layout ───────────────────────────────────────────────────── */
.cnc-layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
  gap: 20px;
  align-items: flex-start;
}

/* ── Input sidebar ──────────────────────────────────────────────────────── */
.cnc-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: calc(var(--nav-h) + var(--header-h) + 20px);
  max-height: calc(100vh - var(--nav-h) - var(--header-h) - 40px);
  overflow-y: auto;
}

/* ── Form sections ──────────────────────────────────────────────────────── */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.form-field:last-child { margin-bottom: 0; }

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.label-optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}

.form-field select,
.form-field input[type="number"] {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}
.form-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.form-field select:focus,
.form-field input[type="number"]:focus {
  border-color: var(--accent);
  background-color: var(--surface);
}
.form-field input[type="number"]::placeholder { color: #aaa; }

/* ── Main results area ──────────────────────────────────────────────────── */
.cnc-main {
  flex: 1;
  min-width: 0;
}

/* ── Results placeholder ────────────────────────────────────────────────── */
.results-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}
.results-placeholder svg { width: 48px; height: 48px; }

/* ── Result cards ───────────────────────────────────────────────────────── */
.result-cards-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  min-width: 150px;
  flex: 1;
}

.result-card--primary {
  border-left: 3px solid var(--accent);
}

.result-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.result-card-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.result-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.result-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

.result-clamped-badge {
  font-size: 10px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 20px;
  padding: 1px 7px;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}

/* ── Recommendations panel ──────────────────────────────────────────────── */
.recs-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.recs-panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.rec-row {
  display: grid;
  grid-template-columns: 180px auto 1fr;
  gap: 6px 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
  font-size: 13px;
}
.rec-row:last-child { border-bottom: none; }

.rec-label { font-weight: 600; color: var(--text); }
.rec-value { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; white-space: nowrap; }
.rec-note  { font-size: 11px; color: var(--text-muted); }

/* ── Coolant note ───────────────────────────────────────────────────────── */
.coolant-note {
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  color: #3730a3;
  margin-bottom: 12px;
  line-height: 1.5;
}

/* ── Source citation ────────────────────────────────────────────────────── */
.source-citation {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.source-citation strong { color: var(--text); }

/* ── Error state ────────────────────────────────────────────────────────── */
.results-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 14px 16px;
  color: #991b1b;
  font-size: 13px;
}

/* ── Lathe advisory banner ──────────────────────────────────────────────── */
.lathe-note {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  color: #78350f;
  margin-bottom: 12px;
  line-height: 1.5;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .cnc-layout {
    flex-direction: column;
    padding: 12px 16px;
  }
  .cnc-sidebar {
    width: 100%;
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  .result-card-value { font-size: 22px; }
  .rec-row {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .rec-note { grid-column: 1 / -1; }
}

/* ── Scrollbar (webkit) ─────────────────────────────────────────────────── */
.cnc-sidebar::-webkit-scrollbar { width: 4px; }
.cnc-sidebar::-webkit-scrollbar-thumb { background: #dde; border-radius: 2px; }

.hidden { display: none !important; }
