:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #1d2226;
  --muted: #69717a;
  --faint: #9aa1a9;
  --line: #e4e7eb;
  --line-strong: #d3d8de;
  --accent: #1e4a73;
  --accent-hover: #163a5a;
  --accent-soft: #eef3f8;
  --ok: #1d6b3a;
  --ok-soft: #e9f4ed;
  --bad: #9b2c2c;
  --bad-soft: #f8ecec;
  --radius: 6px;
  font-family: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; font-weight: 600; line-height: 1.3; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 12px; }
main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }

/* Header */
.top {
  display: flex; align-items: center; gap: 32px; height: 56px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 26px; object-fit: contain; }
.nav { display: flex; gap: 24px; height: 100%; }
.nav a {
  display: flex; align-items: center; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.user { margin-left: auto; position: relative; }
.user summary { list-style: none; cursor: pointer; color: var(--muted); font-weight: 500; padding: 6px 0; }
.user summary::-webkit-details-marker { display: none; }
.user summary::after { content: "▾"; margin-left: 6px; font-size: 0.75em; }
.user[open] summary { color: var(--ink); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 180px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(20, 30, 40, 0.08); padding: 4px; display: flex; flex-direction: column;
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: 4px;
  color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--bg); text-decoration: none; }

/* Controls */
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius); cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); font-weight: 500;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.quiet { border-color: transparent; background: none; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); background: var(--bg); }
input[type="text"], input[type="search"], input[type="password"], input:not([type]), select, textarea {
  height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); width: 100%;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent);
}
label { display: block; font-weight: 500; margin: 0 0 16px; }
label > input, label > textarea, label > select { margin-top: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; color: var(--muted); white-space: nowrap; cursor: pointer; }
.check input { margin: 0; accent-color: var(--accent); }

.flash {
  background: var(--accent-soft); color: var(--accent); border-radius: var(--radius);
  padding: 10px 14px; margin: 0 0 20px;
}
.flash.error { background: var(--bad-soft); color: var(--bad); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.empty { padding: 56px 16px; text-align: center; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); margin: 0 0 20px; }
.tabs a {
  padding: 10px 0; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a { display: inline-flex; align-items: center; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px;
  padding: 0 7px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums; color: #fff;
}
.badge.review { background: #b42318; }
.badge.accepted { background: var(--ok); }
.badge.rejected { background: #7a828b; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 16px; }
.filters .search { flex: 1 1 260px; }
.filters select, .filters .dept { flex: 0 1 180px; width: auto; }
.filters .reset { color: var(--muted); }

/* Table */
.table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.thead, .row > details > summary {
  display: grid; align-items: center; gap: 16px; padding: 0 16px 0 48px;
  grid-template-columns: minmax(0, 1fr) 120px 120px 150px 110px 16px;
}
.thead {
  height: 40px; font-size: 0.75rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--line);
}
.row { border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row > details > summary { list-style: none; cursor: pointer; min-height: 60px; padding-top: 10px; padding-bottom: 10px; }
.row > details > summary::-webkit-details-marker { display: none; }
.row > details > summary:hover { background: #fafbfc; }
.row > details[open] > summary { background: #fafbfc; }
.title { font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sub { color: var(--muted); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.chev { color: var(--faint); transition: transform 0.15s; font-size: 0.8rem; }
.row > details[open] .chev { transform: rotate(90deg); }
.panel { padding: 8px 16px 20px; background: #fafbfc; border-top: 1px solid var(--line); }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 0.78rem; font-weight: 500;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.more { display: block; text-align: center; padding: 16px; font-weight: 500; }

/* Key facts */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px 32px; margin: 16px 0; }
.facts dt { color: var(--muted); font-size: 0.78rem; margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.decide { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.decide input { flex: 1 1 280px; width: auto; }
.note { color: var(--muted); font-size: 0.86rem; margin: 12px 0 0; }

/* Tender page */
.back { display: inline-block; color: var(--muted); margin-bottom: 16px; }
.head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.layout { display: grid; gap: 24px; margin-top: 24px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 24px; }
.files { list-style: none; padding: 0; margin: 0 0 16px; }
.files li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.files li:last-child { border-bottom: 0; }
.upload { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload input[type="file"] { flex: 1 1 220px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 12px 0; }
.bar span { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }
.answers { margin-top: 20px; border-top: 1px solid var(--line); }
.answer { padding: 14px 0; border-bottom: 1px solid var(--line); }
.answer:last-child { border-bottom: 0; }
.answer h3 { font-size: 0.9rem; font-weight: 600; margin: 0 0 4px; }
.answer .text p { margin: 0 0 6px; }
.answer .text ul { margin: 0; padding-left: 18px; }
.answer details { margin-top: 6px; }
.answer summary { cursor: pointer; color: var(--muted); font-size: 0.86rem; }
.answer form { display: flex; gap: 8px; margin-top: 8px; }
.answer form input { flex: 1; }

/* History */
.history { list-style: none; padding: 0; margin: 0; }
.history li { position: relative; padding: 0 0 18px 18px; border-left: 1px solid var(--line); margin-left: 4px; }
.history li:last-child { padding-bottom: 0; }
.history li::before {
  content: ""; position: absolute; left: -4px; top: 6px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--line-strong);
}
.history li.accepted::before { background: var(--ok); }
.history li.rejected::before { background: var(--bad); }
.history .what { font-weight: 500; }
.history .meta { color: var(--muted); font-size: 0.8rem; }
.history .remark { margin-top: 4px; padding: 6px 10px; background: var(--bg); border-radius: 4px; overflow-wrap: anywhere; }

/* Websites */
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.grid th {
  text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; padding: 11px 16px; border-bottom: 1px solid var(--line);
}
table.grid td { padding: 11px 16px; border-bottom: 1px solid var(--line); }
table.grid tr:last-child td { border-bottom: 0; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; background: var(--faint); vertical-align: middle; }
.dot.ok { background: var(--ok); }
.dot.warn { background: #b7791f; }
.dot.bad { background: var(--bad); }

/* Forms page */
.narrow { max-width: 560px; }
.hint { color: var(--muted); font-size: 0.86rem; margin: -10px 0 16px; }

/* Sign in */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; }
.auth-card .logo { width: 72px; height: 58px; object-fit: contain; display: block; margin: 0 0 20px; }
.auth-card h1 { margin-bottom: 24px; }
.auth-card .btn { width: 100%; height: 38px; }

@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
}

@media (max-width: 720px) {
  main { padding: 20px 16px 48px; }
  .top { gap: 16px; padding: 0 16px; }
  .brand span { display: none; }
  .nav { gap: 16px; }
  .thead { display: none; }
  .row > details > summary { grid-template-columns: minmax(0, 1fr) 16px; gap: 4px 12px; }
  .row > details > summary .c-state, .row > details > summary .c-value { display: none; }
  .row > details > summary .c-close { grid-column: 1; grid-row: 2; font-size: 0.86rem; color: var(--muted); }
  .row > details > summary .chev { grid-column: 2; grid-row: 1 / span 3; }
  .row > details > summary .c-fhr { grid-column: 1; grid-row: 3; }
  .row > details > summary .c-fhr .fhr:empty { display: none; }
  .u-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .filters select, .filters .dept { flex: 1 1 140px; }
  .head { flex-direction: column; }
  .hide-sm { display: none; }
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.history .changes { margin-top: 4px; padding: 6px 10px; background: var(--bg); border-radius: 4px; overflow-wrap: anywhere; font-size: 0.9rem; }

/* Multi-select */
.thead, .row { position: relative; }
.pick {
  position: absolute; left: 0; top: 0; width: 48px; height: 100%; max-height: 60px; margin: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1;
}
.thead .pick { max-height: none; }
.row > .pick { align-items: flex-start; padding-top: 13px; height: 44px; }
.pick input { margin: 0; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.row.selected > details > summary { background: var(--accent-soft); }
.bulk {
  position: sticky; bottom: 16px; z-index: 4; margin-top: 16px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: 0 8px 24px rgba(20, 30, 40, 0.12);
}
.bulk[hidden] { display: none; }
.bulk input[type="text"] { flex: 1 1 240px; width: auto; }
.bulk-count { color: var(--muted); padding: 0 4px; white-space: nowrap; }
.bulk-count strong { color: var(--ink); }
.confirm {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  width: min(520px, calc(100% - 32px)); box-shadow: 0 16px 48px rgba(20, 30, 40, 0.18); color: var(--ink);
}
.confirm::backdrop { background: rgba(20, 26, 32, 0.35); }
.confirm h3 { margin: 0 0 12px; font-size: 1.05rem; font-weight: 600; }
.confirm-list { max-height: 220px; overflow: auto; margin: 0 0 16px; padding: 0 0 0 18px; color: var(--muted); }
.confirm-list li { margin: 2px 0; }
.confirm-remark { background: var(--bg); border-radius: 4px; padding: 8px 12px; margin-bottom: 20px; overflow-wrap: anywhere; }
.confirm-remark .muted { font-size: 0.78rem; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 720px) {
  .bulk { bottom: 8px; }
  .bulk input[type="text"] { flex-basis: 100%; order: 2; }
  .bulk-count { order: 1; flex: 1; }
  .bulk .btn { order: 3; }
}
.btn.primary.danger { background: var(--bad); border-color: var(--bad); }
.btn.primary.danger:hover { background: #7f2222; }
.decide .reason, .bulk .reason { flex: 0 1 240px; width: auto; }
.history .reason-label { font-weight: 500; font-size: 0.86rem; margin-bottom: 2px; }
.confirm-remark [data-reason-row] { margin-bottom: 8px; }
.user summary { display: flex; align-items: baseline; gap: 6px; }
.user summary::after { align-self: center; }
.u-name { color: var(--ink); font-weight: 500; }
.u-id { color: var(--faint); font-weight: 400; font-size: 0.86rem; }
@media (max-width: 720px) {
  .u-id { display: none; }
  .decide .reason, .bulk .reason { flex: 1 1 100%; }
  .bulk .reason { order: 2; }
}
.range { display: flex; align-items: center; gap: 6px; flex: 0 1 230px; }
.range input { width: 100%; min-width: 0; }
input[aria-invalid="true"] { border-color: var(--bad); }
@media (max-width: 720px) { .range { flex: 1 1 100%; } }
.terms { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 3px; }
.terms mark {
  background: #fdf1c7; color: #5c4a0c; border-radius: 3px; padding: 1px 6px;
  font-size: 0.75rem; font-weight: 500; line-height: 1.5;
}

/* FHR status */
.nav { flex: 1; }
.fhr { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; white-space: nowrap; color: var(--muted); }
.fhr[data-state="new"] { color: var(--accent); font-weight: 600; }
.fhr[data-state="failed"] { color: var(--bad); font-weight: 500; }
.fhr[data-state="generating"] { color: var(--ink); }
.mini-bar { width: 52px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: var(--accent); transition: width 0.6s; }
.dot-new { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; flex: none; }
.spin {
  width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none;
  border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

.activity { position: relative; }
.activity[hidden] { display: none; }
.activity summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.86rem; color: var(--ink);
}
.activity summary::-webkit-details-marker { display: none; }
.activity summary:hover, .activity[open] summary { background: var(--bg); }
.activity summary > span { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.activity-menu { width: 340px; padding: 8px 0; max-height: 70vh; overflow: auto; }
.activity-menu h4 {
  margin: 6px 14px 4px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.activity-menu a { display: block; padding: 8px 14px; border-radius: 0; }
.activity-menu .a-title { display: flex; align-items: baseline; gap: 8px; color: var(--ink); font-weight: 500; }
.activity-menu .a-title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-menu .a-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; color: var(--muted); font-size: 0.8rem; }
.activity-menu .mini-bar { width: 80px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 20; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 12px; max-width: 380px; padding: 12px 14px;
  background: var(--ink); color: #fff; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20, 30, 40, 0.2);
  font-size: 0.9rem;
}
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast a { color: #9cc3ea; font-weight: 600; white-space: nowrap; }
@media (max-width: 720px) {
  .activity-menu { width: calc(100vw - 32px); right: -60px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}
