/* Colours are the desktop application's palette (app/gui/styles.py) so a
   result looks the same in the browser as it does in the Qt window. */
:root {
  --green: #1b7f3b;  --green-bg: #e6f4ea;
  --yellow: #8a6d00; --yellow-bg: #fdf3d0;
  --orange: #a4530a; --orange-bg: #fdecd8;
  --red: #a01722;    --red-bg: #fbe4e6;
  --grey: #44474d;   --grey-bg: #eef0f3;

  --ink: #1c1f23;
  --muted: #5b6067;
  --line: rgba(0, 0, 0, 0.15);
  --line-soft: rgba(0, 0, 0, 0.08);
  --surface: #ffffff;
  --page: #f4f6f8;
  --accent: #2a6fd6;

  --font: "Segoe UI", Tahoma, "Arial Unicode MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* A class that sets `display` outranks the user-agent [hidden] rule, which
   would otherwise leave the result buttons visible before the first search. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; }

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  white-space: nowrap;
}
.pill-ok      { color: var(--green);  background: var(--green-bg); }
.pill-warming { color: var(--yellow); background: var(--yellow-bg); }
.pill-error   { color: var(--red);    background: var(--red-bg); }

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* --- form ---------------------------------------------------------------- */

.field { margin-bottom: 12px; }
.field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 13px;
}

input[type="text"], textarea {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 4px;
}
input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 111, 214, 0.15);
}
input.narrow { max-width: 240px; }
textarea { resize: vertical; min-height: 74px; }

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

button, .button-link {
  font: inherit;
  padding: 7px 15px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #fbfbfc;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover:not(:disabled), .button-link:hover { background: #f0f2f5; }
button.primary {
  font-weight: 650;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover:not(:disabled) { background: #245fb8; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.hint { color: var(--muted); font-size: 12px; margin: 0; }

/* --- result banner ------------------------------------------------------- */

.banner {
  white-space: pre-line;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.banner-info        { color: var(--grey);   background: var(--grey-bg); }
.banner-GOOD        { color: var(--green);  background: var(--green-bg); }
.banner-REVIEW      { color: var(--yellow); background: var(--yellow-bg); }
.banner-APPROXIMATE { color: var(--orange); background: var(--orange-bg); }
.banner-FAILED      { color: var(--red);    background: var(--red-bg); }

#map-wrap { margin-top: 12px; }
#map {
  width: 100%;
  height: 340px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--grey-bg);
}
.map-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

/* --- detail grids -------------------------------------------------------- */

.panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 16px;
  align-items: start;
}

dl.grid {
  display: grid;
  grid-template-columns: minmax(140px, auto) minmax(0, 1fr);
  gap: 2px 14px;
  margin: 0;
}
dl.grid dt {
  color: var(--muted);
  text-align: right;
  padding: 3px 0;
  font-size: 13px;
}
dl.grid dd {
  margin: 0;
  padding: 3px 0;
  overflow-wrap: anywhere;
}
dl.grid dd.empty { color: rgba(0, 0, 0, 0.35); }
dl.grid .row-sep {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line-soft);
  margin: 6px 0;
}

/* --- candidates ---------------------------------------------------------- */

.table-scroll { overflow-x: auto; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
}
th, td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}
th {
  font-weight: 650;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
}
td.numeric, th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: #eef4fd; }
tbody tr[aria-selected="true"] { background: #dfeafb; }

.empty { color: var(--muted); margin: 8px 0 0; font-size: 13px; }

footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 4px 20px 28px;
}
footer p { color: var(--muted); font-size: 12px; margin: 0; }

@media (max-width: 900px) {
  .panels { grid-template-columns: minmax(0, 1fr); }
  dl.grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.grid dt { text-align: left; font-weight: 600; padding-bottom: 0; }
  dl.grid dd { padding-top: 0; margin-bottom: 6px; }
}
