:root {
  font: 16px/1.55 system-ui, sans-serif;
  color: #142a3d;
  background: #edf6fb;
}
* { box-sizing: border-box; }
body { margin: 0; }
main {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: clamp(16px, 5vw, 48px);
  background: radial-gradient(ellipse at top left, #c5e9f8, transparent 62%);
}
.card {
  width: min(100%, 560px);
  padding: clamp(24px, 7vw, 52px);
  border: 1px solid #d6e6ef;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 80px #163a5d16;
}
.brand {
  color: #005d82;
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: 24px;
}
h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.1rem);
  line-height: 1.07;
  letter-spacing: -.045em;
}
p { margin: 18px 0 26px; color: #43596b; }
button, .button {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: 13px 22px;
  color: white;
  background: #00688c;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: #004e6a; }
:focus-visible { outline: 3px solid #005d82; outline-offset: 4px; }
footer { margin-top: 22px; color: #43596b; font-size: .9rem; }
ul { padding-left: 22px; overflow-wrap: anywhere; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
input {
  display: block;
  width: 100%;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #8296a5;
  border-radius: 8px;
  font: inherit;
}
.connections { list-style: none; padding: 0; margin: 24px 0 0; }
.connections li { padding: 16px 0; border-top: 1px solid #d6e6ef; }
.connections dl { margin: 8px 0 0; }
.connections dt { font-weight: 600; margin-top: 6px; }
.connections dd { margin: 0; color: #43596b; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { flex: none; display: block; }
select { display: block; width: 100%; margin: 0 0 16px; padding: 10px; font: inherit; }
.admin-layout { font-size: .9375rem; line-height: 1.45; align-items: start; grid-template-columns: minmax(0, 1fr); padding: clamp(10px, 1.8vw, 24px); }
.admin-layout .card { width: min(100%, 1440px); min-width: 0; padding: clamp(12px, 2vw, 26px); }
.admin-layout select { max-width: 48rem; }
.table-wrap {
  overflow: auto;
}
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
th, td { padding: 10px 14px; border-bottom: 1px solid #e2e7eb; overflow-wrap: anywhere; }
th { background: #f0f3f5; font-weight: 600; white-space: nowrap; }
tbody tr:nth-child(even) { background: #f8fafb; }
tbody tr:last-child td { border-bottom: 0; }
.pager { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.saved-connections { margin-top: 28px; }
.saved-connections summary { cursor: pointer; font-weight: 600; }

.list-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  margin: 0 0 14px;
  border-radius: 12px;
  background: #163a49;
}
.list-menu button { background: transparent; }
.list-menu button:hover { background: #285162; }
.list-menu button[aria-current="page"] { background: #e4f5ed; color: #163a49; }
.list-menu button:focus-visible { outline-color: #e4f5ed; outline-offset: -3px; }
#list-results { scroll-margin-top: 20px; overflow-wrap: anywhere; }
#list-results h2 { margin: 0; font-size: 1.125rem; line-height: 1.3; }
#list-results p { margin: 6px 0 14px; }
.invoice-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 16px 0; }
.invoice-filters > div { width: min(10rem, 100%); }

.admin-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 24px; margin-bottom: 12px; }
.admin-identity { display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; column-gap: 10px; }
.admin-identity .brand { display: contents; }
.admin-identity .brand img { grid-area: 1 / 1 / span 2; width: 36px; height: 36px; }
.admin-identity .brand span { grid-column: 2; font-size: .875rem; line-height: 1.2; }
.admin-identity h1 { grid-column: 2; font-size: 1.125rem; line-height: 1.3; letter-spacing: -.015em; }
.admin-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px 12px; min-width: 0; margin-left: auto; }
.admin-connection { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.admin-connection label { margin: 0; white-space: nowrap; }
.admin-connection select { width: min(18rem, 100%); min-width: 0; }
.admin-layout :is(button:not(.record-link), select, input[type="date"], input[type="search"]) {
  height: 2.5rem;
  margin: 0;
  padding: 0 12px;
  border-radius: 8px;
}
.admin-layout button { font-weight: 600; }
.admin-layout :is(select, input[type="date"], input[type="search"]) {
  border: 1px solid #8296a5;
  background-color: #fff;
  color: inherit;
}
@media (max-width: 620px) {
  .admin-controls { justify-content: flex-start; margin-left: 0; width: 100%; }
}
.admin-layout .record-link {
  height: auto;
  padding: 0;
  background: transparent;
  color: #005d82;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: .15em;
}
.admin-layout .record-link:hover { color: #00425c; }
.invoice-back { margin-bottom: 12px; }
.invoice-summary { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px 20px; margin: 14px 0; }
.invoice-summary dt { font-weight: 600; }
.invoice-summary dd { margin: 0; }

.invoice-contact { grid-column: span 2; }
.contact-table { min-width: 48rem; table-layout: fixed; }
.contact-table th:first-child { width: 38%; }
.contact-table th:nth-child(2) { width: 18%; }
.contact-table th:nth-child(3) { width: 16%; }
.contact-table :is(th, td):nth-child(n+4) { text-align: right; padding-inline: 12px; font-variant-numeric: tabular-nums; }
.contact-table td { vertical-align: top; height: 5.5rem; }
.contact-table .contact-name, .contact-table .contact-meta, .contact-table .contact-account {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-table .contact-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.contact-sort span { margin-left: 3px; font-size: .75rem; }
.contact-name { font-weight: 600; }
.contact-meta, .contact-overdue { display: block; font-size: .875rem; }
.contact-meta { color: #43596b; }
.contact-overdue { color: #963729; }
.contact-links { display: flex; white-space: nowrap; gap: 2px 12px; margin-top: 3px; }
.contact-links button { font-size: .875rem; }
@media (max-width: 900px) {
  .invoice-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .invoice-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.contact-search { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 16px 0; }
.contact-search > div { width: min(22rem, 100%); }
.tenant-api-link { display: inline-block; margin-left: 12px; }
.api-config-details { display: flex; flex-wrap: wrap; gap: 12px 32px; }
.api-config-details dt { font-weight: 600; }
.api-config-details dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.api-config-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.api-key-reveal { margin: 16px 0; padding: 12px; border-radius: 8px; background: #e4f5ed; overflow-wrap: anywhere; }
.api-key-reveal p { margin: 0 0 8px; }
.api-endpoints { padding-left: 20px; }
.api-endpoints li + li { margin-top: 6px; }
.contact-search .contact-role-filter { display: flex; align-items: center; gap: 8px; min-height: 2.5rem; margin: 0 0 0 6px; }
.contact-role-filter input { width: 1rem; height: 1rem; margin: 0; padding: 0; accent-color: #00688c; }
.contact-table .contact-name { max-width: 100%; }
.contact-name[aria-current="true"] { color: #163a49; }
html:has(.admin-layout) { scrollbar-gutter: stable; }
html:has(.contact-drawer[open]) { overflow: hidden; }
.contact-panel { padding: 20px; background: #fff; color: #142a3d; overflow-wrap: anywhere; }
.contact-drawer, .contact-panel-fallback {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(100%, 30rem);
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  border-left: 1px solid #dce5eb;
  box-shadow: -8px 0 32px #142a3d24;
  overflow: auto;
  overscroll-behavior: contain;
}
.contact-drawer::backdrop { background: #142a3d24; }
.contact-panel-fallback { z-index: 5; }
.contact-drawer > form {
  position: sticky;
  top: -20px;
  padding-block: 8px;
  background: #fff;
  z-index: 1;
}
.contact-panel > form { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.contact-panel h3 { margin: 0; font-size: 1.125rem; }
.contact-panel h4 { margin: 14px 0 6px; font-size: 1rem; }
.contact-panel dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 10px 0; }
.contact-panel dt { font-size: .875rem; font-weight: 600; color: #43596b; }
.contact-panel dd { margin: 0; }
.contact-panel ul { margin: 4px 0 8px; }
.contact-history li + li { margin-top: 6px; }
.contact-history li small { color: #43596b; }
.report-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.report-tabs button {
  color: #163a49;
  background: #eaf1f4;
}
.report-tabs button[aria-pressed="true"] { color: #fff; background: #163a49; }
.report-tabs button:hover:not([aria-pressed="true"]) { background: #dce9ee; }
.report-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 12px 0; }
.report-filters > div { width: min(11rem, 100%); }
.report-toolbar { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.report-toolbar label { margin: 0; }
.report-toolbar select { width: auto; }
.report-chart {
  border: 1px solid #dce7eb;
  border-radius: 16px;
  background: linear-gradient(180deg, #f4faf9 0, #fff 10rem);
  box-shadow: 0 10px 25px #163a490b;
  padding: clamp(14px, 2.5vw, 28px);
}
.report-chart-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding-bottom: 14px;
}
.report-chart h3 { font-size: 1.375rem; font-weight: 650; letter-spacing: -.025em; margin: 0; }
#list-results .report-chart-header p { margin: 4px 0 0; }
.report-metric {
  display: grid;
  gap: 2px;
  padding: 8px 13px;
  border-radius: 10px;
  background: #e3f2ed;
  color: #165d51;
}
.report-metric span { font-size: .875rem; }
.report-metric strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.report-frame { position: relative; min-width: 0; height: clamp(17rem, 33vw, 24rem); }
.report-frame-ranked { height: 24rem; }
.report-frame-tall { height: 32rem; }
.report-plot-age {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 1fr);
  align-items: center;
  gap: clamp(10px, 3vw, 32px);
  max-width: 56rem;
}
.report-plot-age .report-frame { height: clamp(14rem, 28vw, 20rem); }
.report-age-legend { list-style: none; margin: 0; padding: 0; }
.report-age-legend li {
  display: grid;
  grid-template-columns: .65rem minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #e8eef0;
}
.report-age-legend strong { font-variant-numeric: tabular-nums; }
.report-swatch { width: .65rem; height: .65rem; border-radius: 50%; }
.report-bucket-0 { background: #157d69; }
.report-bucket-1 { background: #34a68b; }
.report-bucket-2 { background: #e5ac4b; }
.report-bucket-3 { background: #da803e; }
.report-bucket-4 { background: #bc514f; }
.report-bucket-5 { background: #778993; }
#list-results .report-selection { margin: 10px 0 0; }
.report-selection:empty { display: none; }
.report-data { margin-top: 14px; }
.report-data summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }

@media (max-width: 620px) {
  .report-plot-age { grid-template-columns: minmax(0, 1fr); }
}

.list-results-header {
  display: flex;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 1rem 0;
}
#list-results .list-results-header p { margin: 0; }
.api-playground {
  position: fixed;
  inset: auto 0 0;
  box-sizing: border-box;
  width: min(100%, 76rem);
  max-width: 100%;
  max-height: 85dvh;
  margin: 0 auto;
  padding: 0;
  overflow: auto;
  border: 1px solid #d6e6ef;
  border-radius: 18px 18px 0 0;
  background: #fff;
  color: inherit;
  box-shadow: 0 -12px 48px #163a5d30;
}
.api-playground[open] { animation: playground-enter 180ms ease-out; }
.api-playground::backdrop { background: #14263a66; }
@keyframes playground-enter {
  from { transform: translateY(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .api-playground[open] { animation: none; }
}
.api-playground-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid #d6e6ef;
  background: #fff;
}
.api-playground-header h2, #list-results .api-playground-header p { margin: 0; }
.api-playground-content { padding: 1rem 1.25rem 1.5rem; }
.api-playground [hidden] { display: none; }
.api-methods { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.api-methods button[aria-pressed="false"] { background: #e7f1f6; color: #174555; }
.list-api-copy, .item-assist-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.list-api-copy input { flex: 1 1 20rem; min-width: 0; }
#list-api-copy-status:empty, #item-request-status:empty { display: none; }
.item-assist-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.item-assist fieldset {
  min-width: 0;
  margin: 0 0 .75rem;
  padding: .75rem;
  border: 1px solid #d6e6ef;
  border-radius: 8px;
}
.item-assist-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.item-assist label { display: grid; gap: .25rem; margin: 0; align-content: start; }
.item-assist-actions { margin-top: 1rem; }
.api-playground :is(input:not([type="hidden"]), select, textarea) {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: .45rem .65rem;
  border: 1px solid #8296a5;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: inherit;
}
.api-playground :is(input:not([type="hidden"]), select) { height: 2.5rem; }
.api-playground textarea { resize: vertical; }
.item-assist-fields textarea { height: 4rem; }
.item-assist :is(#item-request-preview, pre) { font-family: monospace; }
.item-assist pre { overflow: auto; }
.item-assist button:disabled { opacity: .6; cursor: default; }
@media (max-width: 760px) {
  .item-assist-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 440px) {
  .item-assist-fields { grid-template-columns: minmax(0, 1fr); }
}

.connection-management {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  align-items: baseline;
  margin: 0 0 1rem;
}

.admin-layout .item-assist button[data-remove-line] {
  margin-top: .75rem;
}

.playground-reference {
  margin-bottom: 1rem;
  padding: .65rem .85rem;
  border: 1px solid #d6e6ef;
  border-radius: 8px;
}
.playground-reference summary { cursor: pointer; font-weight: 600; }
.playground-reference [data-reference-table] { max-height: 16rem; overflow: auto; }

.onboarding-form {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: end;
  margin-block: 1rem;
  max-width: 64rem;
}

.onboarding-form label {
  display: grid;
  gap: .3rem;
  flex: 1 1 18rem;
  min-width: 0;
  margin: 0;
}

.onboarding-form input,
.onboarding-form button {
  min-height: 44px;
  margin: 0;
  padding-block: .6rem;
}

.onboarding-form button {
  border: 1px solid transparent;
}

.onboarding-table {
  overflow-x: auto;
  margin-top: 1rem;
}

.onboarding-table td form {
  margin-top: .5rem;
}

.disconnect-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}

.disconnect-link { color: #9c2525; }
.danger-button { background: #9c2525; }
.danger-button:hover { background: #771b1b; }

.wallboard-access {
  border: 1px solid #d6e6ef;
  border-radius: 10px;
  padding: .75rem 1rem;
}

.wallboard-access h3 { margin: 0; }
.wallboard-access dd { overflow-wrap: anywhere; }
.wallboard-access-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-top: .75rem;
}

.saved-connection-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.saved-tenant { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .saved-connection-row { grid-template-columns: 1fr; }
}
