:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --line: #ccd4dd;
  --text: #17202a;
  --muted: #66727f;
  --blue: #2459a6;
  --green: #167a43;
  --red: #a93434;
  --amber: #9a650d;
}

* {
  box-sizing: border-box;
}

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

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  background: #27313b;
  color: white;
}

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

h1 {
  font-size: 20px;
}

header p {
  margin-top: 4px;
  color: #d6dbe1;
}

nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

nav a,
nav button,
.button,
button {
  border: 1px solid #174684;
  background: var(--blue);
  color: white;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

nav form {
  margin: 0;
}

.secondary {
  background: #eef3f8;
  color: var(--blue);
}

.muted {
  color: var(--muted);
  margin-top: 8px;
}

.warn {
  color: var(--amber);
  font-weight: 700;
}

.connect-box {
  border: 1px solid var(--line);
  background: #f8fafc;
  padding: 14px;
  margin: 14px 0;
}

.auth-shell {
  min-height: calc(100vh - 130px);
  display: grid;
  place-items: start center;
  padding-top: 32px;
}

.auth-card {
  width: min(100%, 520px);
  background: white;
  border: 1px solid var(--line);
  padding: 24px;
}

.auth-brand {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.auth-brand h2 {
  font-size: 24px;
}

.auth-brand p {
  color: var(--muted);
  margin-top: 6px;
}

.connection-status {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  background: #f8fafc;
  padding: 12px;
  margin-bottom: 14px;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.security-note {
  border-left: 4px solid var(--blue);
  background: #f8fafc;
  color: var(--muted);
  padding: 10px 12px;
  line-height: 1.4;
}

.auth-disconnect {
  margin-top: 12px;
}

code {
  background: #edf1f5;
  border: 1px solid var(--line);
  padding: 2px 5px;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 16px;
}

.narrow {
  max-width: 760px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px 18px;
  margin-top: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #aab4bf;
  padding: 8px;
  font: inherit;
  background: white;
}

textarea {
  min-height: 88px;
}

.consent {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: flex-start;
  font-weight: 400;
  line-height: 1.4;
}

.consent input {
  width: 18px;
  margin-top: 2px;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
}

.toolbar,
.case-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics div {
  background: white;
  border: 1px solid var(--line);
  padding: 14px;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

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

th {
  background: #e5ebf2;
}

.status {
  display: inline-block;
  min-width: 120px;
  padding: 5px 8px;
  text-align: center;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #eef1f5;
}

.status.completed {
  color: var(--green);
  background: #eaf7ef;
}

.status.failed {
  color: var(--red);
  background: #fae9e9;
}

.status.processing,
.status.uploading-to-merimen {
  color: var(--amber);
  background: #fff5dc;
}

.upload-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  margin-top: 12px;
}

.inline-form label {
  max-width: 260px;
}

dl {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 16px;
  margin: 16px 0 0;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  header,
  .toolbar,
  .case-head,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  nav,
  .upload-form,
  .grid-form,
  .metrics {
    grid-template-columns: 1fr;
    width: 100%;
  }

  nav {
    flex-wrap: wrap;
  }
}
