:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --line: #dbe2e5;
  --text: #172126;
  --muted: #637179;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #b7791f;
  --danger-soft: #fff7e6;
  --info-soft: #e8f5f3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  align-items: stretch;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 76px;
  padding: 12px 28px 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-row {
  align-items: center;
  display: flex;
  gap: 12px;
}

.top-row-spread {
  justify-content: space-between;
}

.app-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

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

.session-tools {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-left: auto;
}

.session-tools form {
  margin: 0;
}

.session-badge {
  background: #f4f9f8;
  border: 1px solid #d6e7e4;
  border-radius: 8px;
  display: grid;
  gap: 2px;
  padding: 8px 12px;
}

.session-badge strong {
  color: var(--text);
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.session-badge span {
  color: var(--muted);
  font-size: 12px;
}

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

.major-tabs a {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #334148;
  display: inline-flex;
  font-size: 14px;
  font-weight: 650;
  min-height: 36px;
  padding: 8px 12px;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.major-tabs a.active {
  animation: nav-tab-brighten 220ms ease-out;
  background: #def3ef;
  border-color: #92cfc6;
  box-shadow: 0 0 0 1px rgba(146, 207, 198, 0.25), 0 10px 24px rgba(15, 118, 110, 0.18);
  color: var(--accent-strong);
  font-weight: 800;
}

.major-tabs a:hover {
  background: #f4f9f8;
  border-color: #d6e7e4;
  transform: translateY(-1px);
  text-decoration: none;
}

.nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.section-nav {
  border-top: 1px solid #edf1f2;
  padding-top: 9px;
}

.nav a {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #334148;
  display: inline-flex;
  min-height: 36px;
  padding: 7px 12px;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
  font-size: 14px;
  font-weight: 650;
}

.nav a:hover {
  background: #f4f9f8;
  border-color: #d6e7e4;
  text-decoration: none;
  transform: translateY(-1px);
}

.section-nav a.active {
  animation: nav-tab-brighten 220ms ease-out;
  background: #def3ef;
  border-color: #92cfc6;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.16);
  color: var(--accent-strong);
  font-weight: 800;
}

@keyframes nav-tab-brighten {
  0% {
    opacity: 0.7;
    transform: translateY(4px) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.page {
  margin: 0 auto;
  max-width: 1240px;
  padding: 26px 28px 48px;
}

.login-page {
  background:
    radial-gradient(circle at top right, rgba(222, 243, 239, 0.9), rgba(245, 247, 248, 0) 36%),
    var(--bg);
}

.auth-topbar {
  min-height: auto;
}

.login-main {
  align-items: center;
  display: flex;
  min-height: calc(100vh - 86px);
}

.auth-shell {
  margin: 0 auto;
  max-width: 480px;
  width: 100%;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(23, 33, 38, 0.1);
  padding: 26px;
}

.auth-copy {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-form {
  background: transparent;
  border: 0;
  margin-top: 0;
  max-width: none;
  padding: 0;
}

.auth-error {
  background: #ffecea;
  border: 1px solid #f2c1ba;
  border-radius: 8px;
  color: #9f3328;
  margin-bottom: 16px;
  padding: 10px 12px;
}

.auth-error p {
  margin: 0;
}

.auth-actions {
  justify-content: flex-start;
}

.page-head,
.section-head,
.panel-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
}

.muted,
.help {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 22px 0;
}

.stat-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-card {
  min-height: 96px;
  padding: 16px;
}

.stat-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  display: block;
  font-size: 32px;
  line-height: 1;
}

.stat-card.warn {
  background: var(--danger-soft);
  border-color: #f2d59d;
}

.stat-card.accent {
  background: var(--info-soft);
  border-color: #a8d9d3;
}

.split-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.split-layout > .panel:only-child {
  grid-column: 1 / -1;
}

.panel {
  padding: 18px;
}

.data-section {
  margin-top: 22px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 720px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 13px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef3f3;
  color: #405058;
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.compact table {
  min-width: 480px;
}

.right {
  text-align: right;
}

.button,
button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 650;
  min-height: 38px;
  padding: 8px 13px;
}

.button:hover,
button:hover {
  background: var(--accent-strong);
  text-decoration: none;
}

.button.secondary {
  background: #ffffff;
  color: var(--accent-strong);
}

.actions,
.form-actions {
  display: flex;
  gap: 10px;
}

.search-row,
.inline-form {
  align-items: end;
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.list-controls {
  flex-wrap: wrap;
}

.search-field {
  flex: 1 1 320px;
}

.page-size-field {
  flex: 0 0 160px;
}

.custom-page-size-field {
  flex: 0 0 130px;
}

label {
  color: #405058;
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #c9d3d7;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

input[type="checkbox"] {
  min-height: auto;
  width: auto;
}

select[multiple] {
  min-height: 148px;
}

.multi-picker-native {
  display: none;
}

.multi-picker {
  position: relative;
}

.multi-picker-selected {
  align-items: center;
  background: #f9fbfb;
  border: 1px solid #dce5e8;
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
  min-height: 42px;
  padding: 7px;
}

.multi-picker-empty {
  color: var(--muted);
  font-size: 13px;
  padding-left: 2px;
}

.multi-picker-chip {
  align-items: center;
  background: var(--info-soft);
  border: 1px solid #a8d9d3;
  border-radius: 999px;
  color: #164c48;
  display: inline-flex;
  font-size: 13px;
  font-weight: 650;
  gap: 6px;
  max-width: 100%;
  padding: 5px 6px 5px 10px;
}

.multi-picker-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-picker-remove,
.multi-picker-option,
.multi-picker-toggle {
  font: inherit;
}

.multi-picker-remove {
  align-items: center;
  background: #ffffff;
  border: 1px solid #8bc8c1;
  border-radius: 999px;
  color: #285d58;
  display: inline-flex;
  height: 20px;
  justify-content: center;
  min-height: 20px;
  padding: 0;
  width: 20px;
}

.multi-picker-remove:hover {
  background: #d8efeb;
}

.multi-picker-toggle {
  background: #ffffff;
  border: 1px solid #c9d3d7;
  color: var(--text);
  justify-content: space-between;
  width: 100%;
}

.multi-picker-toggle:hover {
  background: #f5f9f9;
}

.multi-picker-toggle::after {
  color: var(--muted);
  content: "v";
  font-size: 12px;
}

.multi-picker-menu {
  background: #ffffff;
  border: 1px solid #c9d3d7;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(23, 33, 38, 0.14);
  left: 0;
  margin-top: 6px;
  max-height: 290px;
  overflow: hidden;
  padding: 8px;
  position: absolute;
  right: 0;
  z-index: 30;
}

.multi-picker-search {
  margin-bottom: 8px;
}

.multi-picker-options {
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.multi-picker-option {
  background: #ffffff;
  border: 0;
  border-radius: 5px;
  color: var(--text);
  justify-content: flex-start;
  min-height: 34px;
  padding: 7px 9px;
  text-align: left;
  width: 100%;
}

.multi-picker-option:hover {
  background: var(--info-soft);
  color: var(--accent-strong);
}

.multi-picker-no-options {
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.search-row input {
  max-width: 420px;
}

.list-controls input {
  max-width: none;
}

.inline-form > label {
  margin-bottom: 0;
}

.inline-form select {
  max-width: 360px;
}

.focus-result {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.detail-grid div {
  background: #f9fbfb;
  border: 1px solid #e4eaec;
  border-radius: 6px;
  padding: 10px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

dd {
  margin: 0;
}

.plain-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.plain-list li {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 38px;
  padding: 8px 0;
}

.plain-list li:first-child {
  border-top: 0;
}

.plain-list span {
  color: var(--muted);
  font-size: 13px;
}

.bar-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.bar-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(130px, 1fr) 3fr 42px;
}

.bar-track {
  background: #e4eaec;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.bar-fill {
  background: var(--accent);
  height: 100%;
}

.account-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.match-summary {
  margin-top: 18px;
}

.section-note {
  margin-top: 14px;
}

.account-map-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.account-map {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-map summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: 18px minmax(220px, 1fr) minmax(110px, auto);
  list-style: none;
  padding: 14px 16px;
}

.account-map summary::-webkit-details-marker {
  display: none;
}

.account-map summary::before {
  color: var(--accent-strong);
  content: "+";
  font-weight: 800;
}

.account-map[open] summary::before {
  content: "-";
}

.account-main {
  display: grid;
  gap: 2px;
}

.account-main span,
.account-meta {
  color: var(--muted);
  font-size: 13px;
}

.account-count {
  background: var(--info-soft);
  border: 1px solid #a8d9d3;
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  justify-self: end;
  padding: 5px 10px;
  white-space: nowrap;
}

.account-detail-grid {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 14px 16px 0;
}

.account-vehicle-table {
  border-left: 0;
  border-radius: 0 0 8px 8px;
  border-right: 0;
  margin-top: 14px;
}

.match-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  min-width: 74px;
  padding: 4px 8px;
  text-align: center;
  text-transform: capitalize;
}

.match-exact {
  background: var(--info-soft);
  color: var(--accent-strong);
}

.match-loose {
  background: #fff7e6;
  color: #915f13;
}

.match-unmatched {
  background: #ffecea;
  color: #9f3328;
}

.close-candidate-list {
  display: grid;
  gap: 10px;
}

.close-candidate {
  display: grid;
  gap: 2px;
}

.match-score {
  background: #eef3f3;
  border: 1px solid #d6e0e3;
  border-radius: 999px;
  color: #405058;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  margin-left: 8px;
  padding: 2px 7px;
}

.edit-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 18px;
  max-width: 760px;
  padding: 18px;
}

.field-row {
  margin-bottom: 16px;
}

.errorlist {
  color: #a53d2d;
  margin: 6px 0 0;
  padding-left: 20px;
}

.pagination {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  margin-top: 16px;
}

@media (max-width: 840px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px 18px;
  }

  .top-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .top-row-spread,
  .session-tools {
    align-items: stretch;
    width: 100%;
  }

  .session-tools {
    flex-direction: column;
    margin-left: 0;
  }

  .page {
    padding: 22px 18px 40px;
  }

  .stats-grid,
  .split-layout,
  .detail-grid,
  .account-stats,
  .account-detail-grid {
    grid-template-columns: 1fr;
  }

  .account-map summary {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .account-count {
    justify-self: start;
  }

  .page-head,
  .section-head,
  .panel-head,
  .search-row,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .search-row input,
  .inline-form select {
    max-width: none;
  }
}
