:root {
  --panel: #ffffff;
  --border: #d8dee6;
  --text: #1a2332;
  --muted: #5b6b7c;
  --accent: #1f8a70;
  --accent-hover: #187a62;
  --row: #f5f7fa;
  --row-active: #e7f5f0;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: #eef2f6;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background:
    radial-gradient(ellipse at 20% 10%, #d7ebe4 0%, transparent 45%),
    radial-gradient(ellipse at 90% 80%, #d6e0ef 0%, transparent 40%),
    #eef2f6;
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  width: min(400px, 100%);
  padding: 1.35rem 1.4rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(20, 40, 60, 0.12);
}

.login-card h1 {
  margin: 0 0 0.45rem;
  font-size: 1.35rem;
}

.login-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.login-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.login-card input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.login-card button[type="submit"] {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.login-card button[type="submit"]:hover {
  background: var(--accent-hover);
}

.login-card a {
  color: var(--accent);
}

.login-card code {
  font-size: 0.85em;
}

#shell[hidden] {
  display: none;
}

#tenant-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

#tenant-label {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}

#tenant-label strong {
  color: var(--text);
  font-weight: 600;
}

#btn-logout {
  flex-shrink: 0;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

#btn-logout:hover {
  color: var(--accent);
  border-color: var(--accent);
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#panel {
  position: fixed;
  z-index: 2;
  top: 1rem;
  left: 1rem;
  bottom: 1rem;
  width: min(420px, calc(100vw - 2rem));
  height: auto;
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(20, 40, 60, 0.12);
  overflow: hidden;
}

#search-form {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

#address {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

#address:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

#btn-search {
  flex-shrink: 0;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#btn-search:hover {
  background: var(--accent-hover);
}

#btn-search:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#btn-docs {
  flex-shrink: 0;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  padding: 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

#btn-docs:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.error {
  color: #b42318;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.error:empty {
  display: none;
}

#status {
  font-size: 0.85rem;
  color: var(--muted);
  flex-shrink: 0;
}

#status[hidden] {
  display: none;
}

#status.ok {
  color: var(--accent);
}

/* History fills panel when results hidden; 50-50 when results shown */
#lists {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 0.65rem;
}

#lists.results-hidden {
  grid-template-rows: 1fr;
}

#results-pane[hidden] {
  display: none;
}

.pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
  padding: 0.55rem 0.55rem 0.45rem;
}

.pane-title {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.scroll-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-right: 0.1rem;
  -webkit-overflow-scrolling: touch;
}

.candidate {
  display: block;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--row);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  flex: 0 0 auto;
  font: inherit;
}

.candidate:hover,
.candidate.active {
  border-color: var(--accent);
  background: var(--row-active);
}

.candidate .name {
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.candidate .meta {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#history .candidate {
  background: #fff;
}

.empty-hint {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.35rem 0.15rem;
}
