:root {
  --bg: #f5f7fb;
  --ink: #1f2937;
  --muted: #64748b;
  --panel: #ffffff;
  --line: #d8dee9;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #047857;
  --amber: #b45309;
  --red: #b91c1c;
  --teal: #0f766e;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
textarea,
td {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 32px;
}

.workspace {
  max-width: 1180px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  background: #111827;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
}

.language-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #e8edf5;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.language-button {
  min-width: 48px;
  min-height: 34px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}

.language-button.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: 34px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.summary,
.panel p,
.review-note p {
  color: var(--muted);
}

.summary {
  max-width: 680px;
  margin-bottom: 0;
  font-size: 16px;
}

.status-pill {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 138px;
  padding: 14px 18px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  color: var(--green);
}

.status-pill span:first-child {
  font-size: 30px;
  font-weight: 800;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel,
.metrics-panel,
.result-panel {
  padding: 20px;
}

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

.panel-header p {
  margin-bottom: 0;
  font-size: 14px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  padding: 14px;
  color: var(--ink);
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

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

.secondary-button,
.icon-button {
  background: #eef2f7;
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary-button:hover,
.icon-button:hover {
  background: #e2e8f0;
}

.metrics {
  display: grid;
  gap: 12px;
}

.metrics div {
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics strong {
  display: block;
  font-size: 28px;
}

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

.review-note {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.review-note p {
  margin-bottom: 0;
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
}

th {
  padding: 11px 10px;
  background: #f1f5f9;
  color: #334155;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}

td {
  min-width: 96px;
  padding: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  vertical-align: top;
}

td[contenteditable="true"] {
  background: #fff;
  outline: none;
}

td[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.empty-row td {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.confidence {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.confidence.high {
  color: var(--green);
  background: #dcfce7;
}

.confidence.medium {
  color: var(--amber);
  background: #fef3c7;
}

.confidence.low {
  color: var(--red);
  background: #fee2e2;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.guide-card {
  width: min(560px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
}

.guide-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-language {
  margin-top: 10px;
}

.close-button {
  display: grid;
  min-width: 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  background: #eef2f7;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.guide-card ol {
  margin: 18px 0 0;
  padding-left: 22px;
  color: var(--muted);
}

.guide-card li {
  margin: 10px 0;
}

.guide-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 18px;
  }

  .intro,
  .panel-header,
  .actions,
  .guide-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 27px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }
}
