* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Segoe UI", Arial, sans-serif; color: #222; background: #f4f6f8; }
header { display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: #2c3e50; color: #fff; }
header h1 { font-size: 18px; margin: 0; }
.header-right { display: flex; align-items: center; gap: 12px; }
#status-line { font-size: 12px; opacity: 0.85; }
button { cursor: pointer; border: none; border-radius: 4px; padding: 8px 14px;
  background: #428bca; color: #fff; font-size: 13px; }
button:hover { background: #357ebd; }
button:disabled { background: #9bbcd6; cursor: default; }
#error-banner { margin: 12px 20px; padding: 10px 14px; border-radius: 4px;
  background: #f2dede; color: #a94442; border: 1px solid #ebccd1; }
.hidden { display: none; }
#controls { display: flex; flex-direction: column; gap: 10px; padding: 12px 20px; }
.filter-top-row { display: flex; align-items: center; gap: 12px; }
#count-line { font-size: 12px; color: #555; }
.filter-groups { display: flex; gap: 14px; flex-wrap: wrap; }
.filter-group { margin: 0; border: 1px solid #dde3e8; border-radius: 6px;
  padding: 4px 12px 10px; background: #fff; }
.filter-group legend { font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.4px; color: #888; padding: 0 4px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-item { display: flex; flex-direction: column; gap: 2px; }
.filter-item .filter-label { font-size: 11px; color: #666; }
.filter-item input[type="date"], .filter-item input[type="text"] { padding: 5px 6px;
  font-size: 13px; border: 1px solid #ccc; border-radius: 4px; }
.filter-item input[type="text"] { width: 150px; }

/* Multiselect filter widget */
.ms { position: relative; display: inline-block; }
.ms-toggle { background: #fff; color: #222; font-weight: normal; border: 1px solid #ccc;
  border-radius: 4px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.ms-toggle:hover { border-color: #428bca; background: #fff; }
.ms.ms-active .ms-toggle { border-color: #428bca; color: #2c6ca0; background: #eef6fd; }
.ms-panel { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; background: #fff;
  border: 1px solid #ccc; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,0.16);
  width: 230px; padding: 8px; }
.ms-panel.hidden { display: none; }
.ms-search { width: 100%; box-sizing: border-box; padding: 5px 6px; margin-bottom: 6px;
  border: 1px solid #ddd; border-radius: 4px; font-size: 12px; }
.ms-actions { display: flex; gap: 6px; margin-bottom: 6px; }
.ms-actions button { flex: 1; padding: 4px 0; font-size: 11px; background: #eef3f8; color: #2c3e50; }
.ms-actions button:hover { background: #e0eaf3; }
.ms-options { max-height: 220px; overflow-y: auto; border-top: 1px solid #eee; padding-top: 4px; }
.ms-option { display: flex; align-items: center; gap: 6px; padding: 3px 2px; font-size: 12.5px;
  cursor: pointer; }
.ms-option:hover { background: #f5f8fb; }
.ms-option input { margin: 0; }
.ms-empty { font-size: 12px; color: #999; padding: 6px 2px; }
body:not(.auth-page) main { display: grid; grid-template-columns: 360px 1fr; gap: 20px; padding: 0 20px 20px; }
#chart { background: #fff; border-radius: 6px; padding: 12px; min-height: 320px;
  overflow: auto; align-self: start; }
#results { background: #fff; border-radius: 6px; padding: 0; overflow: auto; max-height: 70vh; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eee; font-size: 13px; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #f0f7ff; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.company-badge { display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: #34495e; color: #fff; font-size: 11px; letter-spacing: 0.3px; }
.loading-msg { padding: 40px 20px; text-align: center; color: #555; font-size: 15px; }
table.list th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.list th.sortable:hover { background: #f0f7ff; }
#detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; justify-content: center; align-items: flex-start; padding-top: 6vh; }
#detail-overlay.hidden { display: none; }
#detail-panel { background: #fff; border-radius: 8px; padding: 20px; width: 560px;
  max-width: 92vw; max-height: 84vh; overflow: auto; }
#detail-panel h2 { margin-top: 0; }
.detail-grid { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 13px; }
.detail-grid dt { color: #777; }
.detail-grid dd { margin: 0; }

.view-nav { display: flex; gap: 4px; margin-right: auto; margin-left: 24px; }
.view-nav a { border-radius: 4px; color: #dbe8f3; font-size: 12px; padding: 5px 8px; text-decoration: none; }
.view-nav a:hover, .view-nav a[aria-current="page"] { background: #40576e; color: #fff; }
.auth-page { align-items: center; background: #e9eef3; display: flex; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card { background: #fff; border-top: 4px solid #428bca; box-shadow: 0 14px 34px rgba(44, 62, 80, 0.16); max-width: 430px; padding: 32px; width: 100%; }
.auth-card h1 { color: #2c3e50; margin: 0 0 8px; }
.auth-kicker { color: #6f8496; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; margin: 0 0 8px; text-transform: uppercase; }
.auth-card form { display: grid; gap: 8px; margin-top: 24px; }
.auth-card input { border: 1px solid #b8c5d0; border-radius: 4px; font: inherit; padding: 9px; }
.auth-card button { justify-self: start; margin-top: 8px; }
.auth-status { color: #2c6ca0; min-height: 1.5em; }
