:root {
  --ink: #1f3864;
  --accent: #2e5496;
  --bg: #f4f6fa;
  --line: #d7dde8;
  --muted: #6b7484;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: #1b1f27;
  font-size: 14px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Courier New", monospace; }
.error {
  background: #fdecec; border: 1px solid #f3c2c2; color: #8a1f1f;
  padding: 10px 12px; border-radius: 8px; margin: 12px 0;
}

/* ---------------------------------------------------------------- login --- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef2f9, #dfe7f4);
}
.login-card {
  width: 380px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 26px; box-shadow: 0 12px 40px rgba(31, 56, 100, .12);
}
.login-card label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; background: var(--ink);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand-mark.small { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }
.brand-title { font-weight: 700; font-size: 17px; color: var(--ink); }
.brand-sub { font-size: 12px; color: var(--muted); }
.hint { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.5; }

.brand-btn {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  padding: 0; margin: 0; cursor: pointer; color: inherit;
}
.brand-btn:hover .appbar-title { text-decoration: underline; }
.brand-btn:focus-visible { outline: 2px solid rgba(255,255,255,.6); outline-offset: 3px; border-radius: 8px; }

/* -------------------------------------------------------------- app bar --- */
.appbar {
  background: var(--ink); color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 20px; height: 52px;
}
.appbar-left, .appbar-right { display: flex; align-items: center; gap: 18px; }
.appbar-title { font-weight: 700; font-size: 16px; }
.appbar nav { display: flex; gap: 16px; margin-left: 18px; }
.appbar nav span { color: #c6d3e8; font-size: 13px; }
.appbar nav span.nav-active { color: #fff; font-weight: 600; }
.roles { font-size: 12px; color: #9fb2cd; }


.nav-item {
  background: none; border: none; color: #c6d3e8; font: inherit; font-size: 13px;
  cursor: pointer; padding: 4px 2px; border-bottom: 2px solid transparent;
}
.nav-item:hover { color: #fff; }
.nav-item.nav-active { color: #fff; font-weight: 600; border-bottom-color: rgba(255,255,255,.75); }
.link { color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }

/* --------------------------------------------------------------- layout --- */
.content { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; }

/* -------------------------------------------------------------- buttons --- */
.btn {
  border: 1px solid var(--line); background: #fff; color: #253044;
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: #b9c4d6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #274876; }
.btn.ghost { background: transparent; border-color: transparent; color: #dbe4f2; }
.content .btn.ghost { color: var(--ink); }
.btn.block { width: 100%; margin-top: 16px; }
.btn[disabled] { opacity: .55; cursor: default; }

/* -------------------------------------------------------------- filters --- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filters select, .filters input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.filters input:not([type="date"]) { min-width: 240px; flex: 1 1 auto; }
.filters input[type="date"] { width: 142px; }

/* ---------------------------------------------------------------- table --- */
.grid {
  width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.grid th {
  text-align: left; background: #e6ecf5; color: var(--ink); font-size: 12px;
  text-transform: none; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.grid td { padding: 10px 12px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
.grid tr:last-child td { border-bottom: none; }
.grid tr.row { cursor: pointer; }
.grid tr.row:hover td { background: #f7f9fd; }
.grid.tight td, .grid.tight th { padding: 7px 10px; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; border: 1px solid transparent; white-space: nowrap;
}
.st-gray { background: #f0f1f4; color: #4c5464; border-color: #dfe2e9; }
.st-blue { background: #e2eefc; color: #1c4f8f; border-color: #c5dcf7; }
.st-yellow { background: #fcf5e2; color: #7a5b00; border-color: #f0e0b0; }
.st-green { background: #e7f2e7; color: #1d5c22; border-color: #c8e3c8; }
.st-red { background: #faeaea; color: #8a2020; border-color: #f0c8c8; }

/* ------------------------------------------------------------------ tabs --- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 0; }
.tab {
  border: 1px solid transparent; border-bottom: none; background: transparent;
  padding: 9px 16px; cursor: pointer; color: var(--muted); font-size: 13px;
  border-radius: 8px 8px 0 0;
}
.tab.active {
  background: #fff; color: var(--ink); font-weight: 600;
  border-color: var(--line); border-bottom: 2px solid var(--accent);
}
.panel {
  background: #fff; border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); padding: 18px;
}

.props { display: grid; grid-template-columns: 190px 1fr; gap: 8px 16px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }

.actions { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.assign { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.assign select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }

/* ----------------------------------------------------------------- tests --- */
.test-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 16px;
}
.test-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cell-input {
  width: 110px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
}
.test-actions { display: flex; gap: 10px; margin-top: 12px; }
.test-actions input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
}
.remarks { margin-top: 10px; display: grid; gap: 6px; }
.remark { background: #fbf3f3; border: 1px solid #f0d3d3; border-radius: 8px; padding: 8px 10px; }
.remark.resolved { background: #f2f6f2; border-color: #d6e6d6; }

.doc-row {
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 10px;
}

/* ----------------------------------------------------------------- modal --- */
.modal-back {
  position: fixed; inset: 0; background: rgba(20, 30, 50, .35);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 460px; background: #fff; border-radius: 12px; padding: 22px;
  box-shadow: 0 20px 60px rgba(20, 30, 50, .25);
}
.modal label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
.modal input, .modal select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

@media (max-width: 760px) {
  .appbar nav { display: none; }
  .filters { flex-direction: column; }
  .filters input:not([type="date"]) { min-width: 0; }
  .props { grid-template-columns: 1fr; }
}
