:root {
  --ink: #17201b;
  --muted: #66736c;
  --line: #d9e0dc;
  --panel: #f7f9f8;
  --paper: #ffffff;
  --green: #1c7c54;
  --amber: #986b12;
  --red: #b83232;
  --blue: #275b9f;
  --shadow: 0 18px 48px rgba(23, 32, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(39, 91, 159, 0.08), transparent 34%),
    linear-gradient(180deg, #fbfcfb, #eef3f0);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 40px;
  border: 1px solid #193f2f;
  border-radius: 7px;
  padding: 0 14px;
  color: #fff;
  background: #193f2f;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover,
.file-button:hover {
  background: #245840;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

button.secondary {
  color: var(--ink);
  border-color: var(--line);
  background: var(--paper);
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1680px;
  margin: 0 auto;
}

.control-panel,
.main-panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.control-panel {
  min-width: 0;
  min-height: calc(100vh - 48px);
  padding: 22px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand-block h1,
.main-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1 {
  font-size: 28px;
  line-height: 1.1;
}

.lang-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.lang-switch button {
  min-height: 30px;
  padding: 0 10px;
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.lang-switch button.active {
  color: #fff;
  background: #193f2f;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.field-group {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.field-group label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 10px;
}

textarea {
  padding: 10px;
  line-height: 1.5;
  resize: vertical;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.keepa-box {
  min-width: 0;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.section-label {
  margin: 0;
  color: #33423a;
  font-size: 13px;
  font-weight: 800;
}

.hint-line {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.range-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.range-row button {
  min-width: 0;
  width: 100%;
  padding-inline: 10px;
  white-space: normal;
  text-align: center;
}

#finderSelection {
  min-height: 142px;
  font-family: "Roboto Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
  white-space: pre;
  overflow: auto;
}

.status-line {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status-line.error {
  color: var(--red);
}

.status-line.ok {
  color: var(--green);
}

.rule-list {
  display: grid;
  gap: 8px;
}

.rule-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  border-bottom: 1px solid var(--line);
}

.rule-list span {
  color: var(--muted);
}

.rule-list strong {
  text-align: right;
  font-size: 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
}

.main-panel {
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
}

.toolbar,
.result-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.toolbar {
  justify-content: space-between;
}

.toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#csvFile {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

#csvInput {
  min-height: 190px;
  display: block;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  padding: 18px;
  background: #fbfcfb;
}

.ops-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}

.ops-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--paper);
}

.ops-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ops-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.ops-actions button {
  min-height: 36px;
  padding: 8px 12px;
}

.ops-title h3 {
  margin: 0;
  font-size: 16px;
}

.ops-title small {
  color: var(--muted);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.status-grid div {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fbfcfb;
}

.status-grid span,
.download-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.matrix-grid {
  grid-template-columns: 0.8fr 0.8fr 1.4fr;
}

.download-list {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow: auto;
}

.download-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fbfcfb;
  text-decoration: none;
}

.download-row:hover {
  border-color: #94aea1;
  background: #f2f7f4;
}

.result-header {
  flex-wrap: wrap;
  background: var(--panel);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.filter-title {
  grid-column: 1 / -1;
  margin: 0;
  color: #33423a;
  font-size: 13px;
  font-weight: 800;
}

.field-group.compact {
  gap: 5px;
}

.field-group.compact label {
  font-size: 12px;
}

.check-filter {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.check-filter input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.filter-summary {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.metric {
  width: 108px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--paper);
}

.metric span {
  display: block;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.metric small {
  color: var(--muted);
}

.metric.pass span {
  color: var(--green);
}

.metric.review span {
  color: var(--amber);
}

.metric.reject span {
  color: var(--red);
}

#downloadCsv {
  margin-left: auto;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 375px);
}

.pagination-bar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.page-size-control,
.page-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-size-control label,
.page-controls span {
  color: var(--muted);
  font-size: 13px;
}

.page-size-control select {
  width: 92px;
  min-height: 36px;
}

.page-controls button {
  min-height: 36px;
  padding: 8px 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1480px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #33423a;
  background: #f0f4f2;
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 6px;
  padding: 0 9px;
  font-weight: 800;
}

.badge.pass {
  color: var(--green);
  background: #e8f4ee;
}

.badge.review {
  color: var(--amber);
  background: #fff5dc;
}

.badge.reject {
  color: var(--red);
  background: #fdeaea;
}

.muted,
.empty {
  color: var(--muted);
}

.empty {
  padding: 32px 18px;
  text-align: center;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    min-height: 0;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .page-size-control,
  .page-controls {
    justify-content: space-between;
  }

  .ops-panel {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .range-row {
    grid-template-columns: 1fr;
  }

  #downloadCsv {
    margin-left: 0;
  }

  .metric {
    flex: 1 1 100px;
  }
}
