:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #101828;
  --ink: #101828;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #1769aa;
  --accent-dark: #0f4f82;
  --teal: #0f766e;
  --amber: #b86b00;
  --red: #b42318;
  --green: #11845b;
  --soft-blue: #eaf3fb;
  --soft-green: #edf8f3;
  --soft-amber: #fff5e5;
  --shadow: 0 18px 44px rgba(16, 24, 40, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef3f7 0, #f7f8fa 260px, var(--bg) 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 66px;
  padding: 0 30px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(216, 222, 232, 0.8);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: #fff;
  font-size: 13px;
}

.brand-name {
  letter-spacing: 0;
}

.nav {
  display: flex;
  gap: 6px;
}

.nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.nav a:hover,
.nav a.active {
  background: var(--soft-blue);
  color: var(--accent);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 58px;
}

.hero-band,
.result-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 22px;
  padding: 28px;
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: 14px;
  background: linear-gradient(135deg, #ffffff 0%, #eef7f4 58%, #fff7e8 100%);
  box-shadow: var(--shadow);
}

.result-hero {
  background: linear-gradient(135deg, #101828 0%, #164e63 52%, #14532d 100%);
  color: #fff;
}

.hero-actions,
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.result-hero .eyebrow {
  color: #a7f3d0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.02;
}

h2 {
  margin-bottom: 18px;
  font-size: 22px;
  line-height: 1.15;
}

h3 {
  margin: 22px 0 10px;
  font-size: 15px;
}

.result-subtitle {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.tool-panel,
.status-panel,
.case-summary,
.insight-panel,
.gauge-panel,
.chart-panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.tool-panel,
.status-panel,
.insight-panel,
.gauge-panel,
.chart-panel {
  padding: 24px;
}

.primary-panel {
  border-top: 4px solid var(--accent);
}

.insight-panel {
  background: #fbfcfd;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.panel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.case-summary {
  padding: 16px 18px;
  margin-bottom: 16px;
  color: var(--muted);
}

.edit-panel {
  margin-bottom: 18px;
}

.edit-panel[hidden] {
  display: none;
}

.case-summary p {
  margin: 0;
}

.factor-list {
  display: grid;
  gap: 12px;
}

.factor-list div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.factor-list strong,
.factor-list span {
  display: block;
}

.factor-list strong {
  margin-bottom: 4px;
}

.factor-list span {
  color: var(--muted);
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.form-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.case-form {
  display: grid;
  gap: 16px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

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

input:focus,
textarea:focus,
select:focus {
  outline: 3px solid rgba(23, 105, 170, 0.16);
  border-color: var(--accent);
}

input::placeholder,
textarea::placeholder {
  color: #b7c0cc;
  opacity: 1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.dictation-bar {
  display: grid;
  grid-template-columns: auto auto minmax(150px, 220px) minmax(160px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.dictation-bar.is-listening {
  border-color: #8ab4f8;
  background: var(--soft-blue);
}

.audio-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
}

.audio-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #98a2b3;
  box-shadow: 0 0 0 0 rgba(152, 162, 179, 0.35);
}

.audio-indicator.is-active .audio-dot {
  background: #16a34a;
  box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.14);
}

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

.dictation-lang {
  width: 100%;
}

.dictation-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.secondary-action,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-action {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.result-hero .secondary-action {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.text-button {
  color: var(--muted);
}

.primary-button:disabled,
.secondary-action:disabled,
.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.alert {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid;
  background: #fff;
}

.alert p {
  margin: 0;
}

.alert p + p {
  margin-top: 6px;
}

.alert.error {
  border-color: #f6b4ad;
  color: var(--red);
  background: #fff4f2;
}

.alert.warning {
  border-color: #f8cf8d;
  color: var(--amber);
  background: var(--soft-amber);
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  margin-bottom: 18px;
}

.gauge-panel {
  display: grid;
  gap: 22px;
  justify-items: center;
}

.gauge {
  --score: 0;
  --gauge-color: #16a34a;
  width: min(300px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(var(--gauge-color) calc(var(--score) * 3.6deg), #e6e9ef 0);
  box-shadow: inset 0 0 0 1px var(--line);
}

.gauge.level-excelente {
  --gauge-color: #16a34a;
}

.gauge.level-advertencia {
  --gauge-color: #f59e0b;
}

.gauge.level-bajo {
  --gauge-color: #ea580c;
}

.gauge.level-critico {
  --gauge-color: #dc2626;
}

.gauge-core {
  width: 68%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.12);
}

.gauge-core span {
  color: var(--muted);
  font-weight: 800;
}

.gauge-core strong {
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1;
}

.gauge-core small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.summary-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.summary-strip div {
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
}

.summary-strip span,
.summary-strip strong {
  display: block;
}

.summary-strip span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.factor-chart {
  display: grid;
  gap: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 12px;
}

.bar-row span {
  color: var(--muted);
  font-weight: 800;
}

.bar-row strong {
  text-align: right;
}

.bar-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf3;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
}

.bar-fill.availability {
  background: var(--accent);
}

.bar-fill.performance {
  background: var(--amber);
}

.bar-fill.quality {
  background: var(--teal);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 138px;
  padding: 20px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.metric small {
  color: var(--muted);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
  gap: 18px;
  margin-top: 18px;
}

.diagnostic {
  margin-bottom: 18px;
  color: #344054;
  font-size: 16px;
}

.recommendation-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recommendation-list li {
  padding: 12px 14px;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--soft-green);
}

.learning-panel {
  margin-top: 18px;
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.theory-block {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
  color: #344054;
}

.theory-block > p {
  max-width: 920px;
  margin-bottom: 0;
}

.theory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.theory-grid article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
}

.theory-grid h3 {
  margin: 0 0 8px;
  color: var(--ink);
}

.theory-grid p {
  margin-bottom: 10px;
}

.theory-grid ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.key-note {
  padding: 14px 16px;
  border: 1px solid #f8cf8d;
  border-radius: 10px;
  background: var(--soft-amber);
  color: #7a4500;
}

.formula-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
}

.formula-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.formula-card strong {
  font-size: 28px;
  line-height: 1;
}

.formula-card p {
  margin: 0;
  color: #344054;
}

.formula-card code {
  display: block;
  overflow-wrap: anywhere;
  padding: 10px;
  border-radius: 8px;
  background: #eef3f7;
  color: #1d2939;
  font-size: 13px;
}

.formula-card.oee-formula {
  border-color: #b7e4cd;
  background: var(--soft-green);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  width: 50%;
  color: var(--muted);
  font-weight: 800;
}

.data-table tr:last-child th,
.data-table tr:last-child td {
  border-bottom: 0;
}

.status-panel dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

.status-panel dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.status-panel dt {
  color: var(--muted);
  font-weight: 800;
}

.status-panel dd {
  margin: 0;
}

.status-panel ul {
  margin: 0;
  padding-left: 18px;
}

.status-panel li + li {
  margin-top: 8px;
}

@media (max-width: 960px) {
  .workspace-grid,
  .result-grid,
  .metrics-grid,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .form-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dictation-bar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar,
  .hero-band,
  .result-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    padding: 14px 18px;
  }

  .nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .form-grid,
  .form-grid.compact,
  .formula-grid,
  .theory-grid,
  .summary-strip,
  .bar-row {
    grid-template-columns: 1fr;
  }

  .bar-row strong {
    text-align: left;
  }

  .form-actions,
  .example-actions,
  .dictation-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-action,
  .text-button {
    width: 100%;
  }
}
