:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --sidebar: #16232e;
  --text: #16202a;
  --muted: #5d6875;
  --line: #dce3ea;
  --accent: #176b87;
  --accent-dark: #115469;
  --danger-bg: #fff1f1;
  --danger: #9f1d1d;
  --ok-bg: #edf8f1;
  --ok: #176b3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 22px 16px;
}

.sidebar h1 {
  font-size: 24px;
  margin: 0 0 24px;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar a {
  color: #dbe7ee;
  text-decoration: none;
  border-radius: 6px;
  padding: 10px 12px;
}

.sidebar a.active,
.sidebar a:hover {
  background: #223545;
  color: #fff;
}

.content {
  padding: 28px;
  max-width: 1320px;
  width: 100%;
}

.shell {
  width: min(960px, calc(100vw - 32px));
  margin: 48px auto;
}

.shell-narrow {
  width: min(440px, calc(100vw - 32px));
}

.page-head {
  margin-bottom: 20px;
}

.page-head h2,
.panel h3 {
  margin-top: 0;
}

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

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}

form {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input[type="file"],
input[type="password"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
  font: inherit;
}

textarea {
  resize: vertical;
}

textarea::placeholder {
  color: #a7b2bd;
  opacity: 1;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  border: 2px dashed #aebdca;
  border-radius: 8px;
  background: #f8fbfd;
  color: var(--text);
  padding: 22px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.drag-active {
  border-color: var(--accent);
  background: #eef8fb;
}

.dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  min-height: 0;
}

.dropzone strong,
.dropzone span,
.dropzone small {
  pointer-events: none;
}

.dropzone span,
.dropzone small {
  color: var(--muted);
}

.dropzone small {
  max-width: 100%;
  overflow-wrap: anywhere;
}

button,
.button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  padding: 0 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

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

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

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.logout {
  margin-top: 24px;
}

.logout button {
  width: 100%;
  background: transparent;
  color: #fff;
  border-color: #496171;
}

table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafb;
}

.button-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

button.danger:hover {
  background: #7d1717;
}

.danger-outline {
  background: #fff;
  border-color: #efc0c0;
  color: var(--danger);
}

.danger-outline:hover {
  background: var(--danger-bg);
  border-color: #e7a8a8;
}

.inline-action {
  margin: 0;
}

.flash {
  margin-bottom: 14px;
}

.ciq-choices {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 0;
  display: grid;
  gap: 8px;
}

.ciq-choices legend {
  font-weight: 700;
  padding: 0 6px;
}

.ciq-choices .checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  cursor: pointer;
}

.ciq-choices .checkbox input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.uploader {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.uploader #ciq-status:empty {
  display: none;
}

.uploader .flash {
  margin-bottom: 0;
}

.summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ciq-list,
.batch-list {
  display: grid;
  gap: 10px;
}

.ciq-item,
.batch-card {
  display: grid;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.ciq-item {
  grid-template-columns: minmax(0, 1fr) auto;
}

.ciq-info,
.batch-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ciq-info strong,
.batch-main strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.batch-card {
  grid-template-columns: minmax(180px, 1fr) auto auto;
}

.batch-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.attempt-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 112px;
  gap: 16px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.attempt-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.attempt-number {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.status-pill {
  justify-self: start;
  border-radius: 999px;
  border: 1px solid #cfd7df;
  background: #eef2f5;
  color: #4a5562;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.status-completed {
  background: var(--ok-bg);
  border-color: #bedfc9;
  color: var(--ok);
}

.status-failed {
  background: var(--danger-bg);
  border-color: #f3c5c5;
  color: var(--danger);
}

.attempt-body {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.message-list {
  display: grid;
  gap: 8px;
}

.message-list .note,
.message-list .alert {
  margin-top: 0;
  overflow-wrap: anywhere;
}

.attempt-actions {
  display: grid;
  gap: 8px;
  justify-items: stretch;
}

.attempt-actions .button-sm {
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-pass {
  background: #e8f7ee;
  color: #176b3a;
  border-color: #b6e0c4;
}

.badge-fail {
  background: #fdecec;
  color: #9f1d1d;
  border-color: #f3c5c5;
}

.badge-match {
  background: #e7f3fb;
  color: #115469;
  border-color: #bcdcec;
}

.badge-mismatch {
  background: #fff0e2;
  color: #a65512;
  border-color: #f3d2ab;
}

.badge-check {
  background: #f3ecfb;
  color: #5a2d8c;
  border-color: #d9c5ef;
}

.badge-undefined {
  background: #eceff2;
  color: #4a5562;
  border-color: #cfd7df;
}

.progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(12, 20, 28, 0.45);
  padding: 24px;
}

.progress-overlay[hidden] {
  display: none;
}

.progress-card {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
  padding: 24px;
}

.progress-card h2 {
  margin: 0 0 8px;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebf1;
  margin: 18px 0 10px;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.alert {
  background: var(--danger-bg);
  border: 1px solid #f3c5c5;
  border-radius: 6px;
  color: var(--danger);
  margin-top: 8px;
  padding: 12px;
}

.ok {
  background: var(--ok-bg);
  border: 1px solid #bedfc9;
  border-radius: 6px;
  color: var(--ok);
  padding: 12px;
}

.note {
  background: #fff8e6;
  border: 1px solid #ead59d;
  border-radius: 6px;
  color: #6e5311;
  margin-top: 8px;
  padding: 12px;
}

.note p,
.alert p {
  margin: 0 0 6px;
}

.note p:last-child,
.alert p:last-child {
  margin-bottom: 0;
}

ul {
  margin: 0;
  padding-left: 20px;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .grid.two {
    grid-template-columns: 1fr;
  }

  .attempt-card {
    grid-template-columns: 1fr;
  }

  .batch-card {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .attempt-actions {
    display: flex;
    flex-wrap: wrap;
  }

  .batch-actions {
    justify-content: flex-start;
  }

  .attempt-actions .button-sm {
    width: auto;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .content {
    padding: 16px;
  }

  .attempt-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }

  .attempt-actions .button-sm {
    width: 100%;
  }

  .ciq-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .inline-action,
  .inline-action .button-sm {
    width: 100%;
  }

  .batch-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    width: 100%;
  }
}
