:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #6b7684;
  --line: #e3e7ec;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --error: #b91c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; }
.logout-form { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 14px; }
.link-btn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 14px; padding: 0;
}

/* ---- Home / search ---- */
.home {
  max-width: 1040px;
  margin: 0 auto;
  padding: 48px 20px;
}
.search-form {
  display: flex;
  gap: 10px;
  margin: 24px 0 8px;
}
.search-bar {
  flex: 1;
  font-size: 20px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.search-bar:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.search-btn {
  font-size: 18px;
  padding: 0 28px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.result-count { color: var(--muted); margin: 20px 2px 8px; }
.empty { color: var(--muted); }

/* ---- Results table ---- */
.table-wrap { overflow-x: auto; }
.results {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.results th, .results td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  white-space: nowrap;
}
.results thead th {
  background: #fafbfc;
  color: var(--muted);
  font-weight: 600;
}
.results tbody tr:last-child td { border-bottom: none; }
.results .num { text-align: right; font-variant-numeric: tabular-nums; }
.model { color: var(--muted); }
.results a { color: var(--accent); text-decoration: none; }
.results a:hover { text-decoration: underline; }

/* ---- Login ---- */
.login-body {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.subtitle { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-card label { display: block; font-size: 14px; margin-bottom: 14px; }
.login-card input {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
}
.login-card button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  cursor: pointer;
  margin-top: 6px;
}
.error { color: var(--error); font-size: 14px; margin: 0 0 14px; }

/* ---- Split view: results left, PDF right ---- */
.layout.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  height: calc(100vh - 51px);
}
.layout.split .home {
  max-width: none;
  margin: 0;
  padding: 16px 20px;
  overflow-y: auto;
}
.layout.split .search-bar { font-size: 16px; padding: 12px 14px; }
.layout.split .search-btn { font-size: 15px; padding: 0 18px; }

.results tbody tr.selected td { background: #eef3ff; }

.viewer {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--card);
  min-height: 0;
}
.viewer[hidden] { display: none; }
.viewer-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.viewer-title {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-bar a { color: var(--accent); text-decoration: none; white-space: nowrap; }
.viewer-bar a:hover { text-decoration: underline; }
.viewer-close {
  border: none; background: none; cursor: pointer;
  font-size: 16px; color: var(--muted); padding: 2px 6px;
}
.viewer-close:hover { color: var(--ink); }
.viewer-body { position: relative; flex: 1; min-height: 0; }
.viewer-loading {
  position: absolute; inset: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.viewer-body iframe {
  position: relative;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

/* Compact table while the PDF viewer is open */
.layout.split .results th, .layout.split .results td { padding: 10px 8px; white-space: normal; }
.layout.split .results td.vendor { min-width: 90px; }
.layout.split .results td.product { min-width: 160px; }
.layout.split .results td.num,
.layout.split .results td.col-date { white-space: nowrap; }
.view-link { font-weight: 600; }
@media (max-width: 1150px) {
  .layout.split .results td.product { min-width: 0; }
  .layout.split .results td.col-date { white-space: normal; }
}
