:root {
  color-scheme: light;
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --line: #d8e1ea;
  --text: #17212b;
  --muted: #667789;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --blue: #0b63ce;
  --amber: #b7791f;
  --red: #c2410c;
  --green: #15803d;
  --page-max: 1560px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

html,
body {
  height: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  background: #10202c;
  color: #fff;
  min-width: 0;
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
}

.brand {
  font-weight: 800;
  font-size: 22px;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: #b9cad8;
  font-size: 13px;
  font-weight: 500;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav button,
.logout {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  color: #dce8f0;
  background: transparent;
  cursor: pointer;
}

.nav button:hover,
.nav button.active {
  background: #1e394b;
  color: #fff;
}

.logout {
  margin-top: auto;
  background: #213849;
}

.content {
  min-width: 0;
  width: min(var(--page-max), 100%);
  margin: 0 auto;
  padding: 30px 34px;
  display: grid;
  gap: 22px;
  align-content: start;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
}

.topbar > div {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

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

.grid {
  display: grid;
  gap: 18px;
}

.grid.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 0;
  padding: 22px;
  box-shadow: 0 2px 8px rgba(20, 39, 56, 0.04);
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric strong {
  font-size: 32px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
  background: #fff;
}

th,
td {
  max-width: 340px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  background: var(--surface-soft);
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  background: #edf2f7;
  color: #334155;
}

.status.phage_found {
  background: #dcfce7;
  color: var(--green);
}

.status.in_research,
.status.pathogen_received {
  background: #dbeafe;
  color: var(--blue);
}

.status.submitted,
.status.pathogen_expected {
  background: #fef3c7;
  color: var(--amber);
}

.status.phage_not_found,
.status.rejected {
  background: #ffedd5;
  color: var(--red);
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  max-width: 100%;
}

.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form {
  display: grid;
  gap: 16px;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 16px 45px rgba(24, 43, 61, 0.12);
}

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 22px;
}

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

.event {
  border-left: 3px solid var(--primary);
  padding: 8px 0 8px 12px;
}

.event strong {
  display: block;
}

.message {
  padding: 12px 14px;
  border-radius: 8px;
  background: #e0f2fe;
  color: #075985;
}

.error {
  background: #ffedd5;
  color: #9a3412;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }

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

  .grid.cols-3,
  .form.two,
  .detail {
    grid-template-columns: 1fr;
  }

  .content {
    overflow: visible;
    padding: 20px;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar .btn {
    width: 100%;
  }

  .panel {
    padding: 18px;
  }

  table {
    min-width: 760px;
  }
}
