:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #626a78;
  --line: #d7dce5;
  --line-strong: #aab2c0;
  --accent: #176b87;
  --accent-ink: #ffffff;
  --soft: #e9f2f5;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.topbar h1,
.topbar p,
.table-toolbar h2,
.table-toolbar p,
.finding-panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 26px;
  line-height: 1.1;
  font-weight: 720;
}

.topbar p,
.table-toolbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  border: 1px solid var(--line);
  background: var(--soft);
  color: #214c58;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
}

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

.nav-link,
.back-link,
.lang-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-decoration: none;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
}

.lang-toggle {
  min-width: 82px;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 0;
}

.control-panel {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.file-drop {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 18px;
  min-height: 150px;
  align-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.file-drop.is-dragging {
  border-color: var(--accent);
  background: var(--soft);
}

.file-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-icon {
  width: 48px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--soft);
}

.file-title {
  font-weight: 700;
}

.file-note {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-grid div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-grid button {
  min-height: 38px;
  border: 1px solid #12576d;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.button-grid button:disabled {
  border-color: var(--line);
  background: #eef1f5;
  color: #8a92a0;
  cursor: not-allowed;
}

.action-status {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.action-status[data-kind="busy"] {
  color: #7a5d00;
}

.action-status[data-kind="success"] {
  color: #14633d;
}

.action-status[data-kind="error"] {
  color: #a12d2d;
}

.action-status a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.finding-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.finding-panel h2,
.table-toolbar h2 {
  font-size: 16px;
}

.finding-panel ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.table-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.table-toolbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.table-scroll {
  flex: 1;
  overflow: auto;
  padding: 18px;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid var(--line-strong);
}

th,
td {
  border: 1px solid var(--line-strong);
  padding: 8px 9px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-line;
}

th {
  background: #f0f3f7;
  font-weight: 720;
  text-align: center;
}

td {
  min-height: 38px;
}

.merged-cell {
  vertical-align: middle;
}

.parent-cell {
  background: #f8fbfc;
}

.empty-state {
  height: 220px;
  text-align: center;
  color: var(--muted);
}

.multiline {
  min-width: 180px;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

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

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-grid,
  .button-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.guide-shell {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0 52px;
}

.guide-title {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.guide-title h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.16;
  letter-spacing: 0;
}

.guide-title p,
.guide-copy p {
  color: var(--muted);
}

.guide-title p {
  margin: 0;
  font-size: 14px;
}

.guide-section {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(430px, 1.1fr);
  gap: 30px;
  align-items: center;
  padding: 30px 0;
  border-bottom: 1px solid var(--line);
}

.guide-section.wide {
  grid-template-columns: 1fr;
}

.guide-copy h2 {
  margin: 6px 0 10px;
  font-size: 22px;
  line-height: 1.24;
  letter-spacing: 0;
}

.guide-copy p {
  margin: 0;
  font-size: 14px;
  line-height: 1.62;
}

.eyebrow {
  color: var(--accent) !important;
  font-weight: 720;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.formula-panel,
.timeline-card,
.mini-table-card,
.rule-strip article,
.capability-grid article,
.workflow-list,
.output-list article {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 8px;
}

.capability-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.capability-grid article,
.output-list article {
  padding: 14px;
}

.capability-grid strong,
.output-list strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.capability-grid p,
.output-list p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.workflow-list {
  margin: 0;
  padding: 8px;
  list-style: none;
}

.workflow-list li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.workflow-list li:last-child {
  border-bottom: 0;
}

.workflow-list span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: #214c58;
  font-size: 13px;
  font-weight: 720;
}

.workflow-list p {
  margin: 0;
  font-size: 14px;
}

.output-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.formula-panel {
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  align-items: center;
  min-height: 104px;
  padding: 16px;
}

.formula-main {
  border: 1px solid var(--line-strong);
  background: #f7f9fb;
  padding: 16px 18px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

.formula-token {
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

.formula-token.plus {
  color: #0b77bd;
}

.formula-token.minus {
  color: #9b3f3f;
}

.timeline-card {
  padding: 22px 24px 20px;
}

.timeline-labels {
  display: grid;
  grid-template-columns: 60px 1fr 1fr 60px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.timeline-labels.top span:first-child {
  grid-column: 2;
  color: #0b77bd;
}

.timeline-labels.top span:last-child {
  grid-column: 3;
  justify-self: end;
  color: #9b3f3f;
}

.timeline-labels.bottom {
  margin-top: 10px;
}

.timeline-labels.bottom span:nth-child(2) {
  justify-self: start;
}

.timeline-labels.bottom span:nth-child(3) {
  justify-self: end;
}

.timeline-labels.bottom span:last-child {
  justify-self: end;
}

.timeline-track {
  display: grid;
  grid-template-columns: 60px 1fr 4.16fr 0.33fr 60px;
  align-items: center;
  height: 36px;
  margin-top: 8px;
}

.timeline-idle,
.timeline-active {
  display: block;
  height: 16px;
}

.timeline-idle.left {
  grid-column: 2;
  border-left: 3px solid #9198a5;
  border-bottom: 3px solid #9198a5;
}

.timeline-active {
  grid-column: 3;
  background: #1e9fdd;
  border-top: 3px solid #eef7fc;
  border-bottom: 3px solid #eef7fc;
}

.timeline-idle.right {
  grid-column: 4;
  border-right: 3px solid #9198a5;
  border-bottom: 3px solid #9198a5;
}

.mini-table-card {
  overflow: auto;
  padding: 12px;
}

.guide-table {
  min-width: 900px;
}

.guide-table th,
.guide-table td {
  font-size: 13px;
}

.guide-table td span {
  color: var(--muted);
  font-size: 12px;
}

.rule-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding-top: 24px;
}

.rule-strip article {
  padding: 14px;
}

.rule-strip strong {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.rule-strip p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 860px) {
  .top-actions {
    align-items: flex-start;
  }

  .guide-section,
  .rule-strip,
  .capability-grid,
  .output-list {
    grid-template-columns: 1fr;
  }

  .guide-title h1 {
    font-size: 26px;
  }

  .formula-panel {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}
