:root {
  --navy: #16375b;
  --navy-dark: #0c2744;
  --blue: #1e6a9f;
  --blue-light: #eaf3f8;
  --teal: #2b7a78;
  --green: #2e7d5b;
  --green-light: #e8f5ee;
  --amber: #9a6511;
  --amber-light: #fff6df;
  --ink: #17212b;
  --muted: #637080;
  --line: #dce3e9;
  --surface: #ffffff;
  --background: #f4f7f9;
  --shadow: 0 16px 40px rgba(20, 48, 74, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 95% 0%, rgba(30, 106, 159, 0.08), transparent 26rem),
    var(--background);
  line-height: 1.5;
}

a {
  color: inherit;
}

.site-header {
  min-height: 76px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  gap: 2rem;
  color: white;
  background: linear-gradient(115deg, var(--navy-dark), var(--navy));
  box-shadow: 0 6px 24px rgba(9, 30, 52, 0.16);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 12px;
  font-size: 1.35rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.72rem;
  font-weight: 500;
}

.main-nav {
  display: flex;
  gap: 0.3rem;
}

.main-nav a {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.user-menu {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.user-menu form {
  margin: 0;
}

.role-badge {
  padding: 0.28rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.76rem;
}

.text-button {
  padding: 0;
  border: 0;
  color: white;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

.page-heading {
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
}

.page-heading h1,
.login-intro h1 {
  max-width: 760px;
  margin: 0.2rem 0 0.65rem;
  color: var(--navy-dark);
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.page-heading p,
.login-intro p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  color: var(--muted);
  background: #edf1f4;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-active {
  color: var(--green);
  background: var(--green-light);
}

.status-development {
  color: var(--amber);
  background: var(--amber-light);
}

.metric-grid {
  margin-bottom: 1.25rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.metric-card {
  min-height: 155px;
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
}

a.metric-card:hover {
  border-color: #a8c5d9;
  transform: translateY(-1px);
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  margin: auto 0 0;
  color: var(--navy);
  font-size: 2.3rem;
  line-height: 1;
}

.metric-card small {
  margin-top: 0.45rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 1rem;
}

.section-heading {
  margin: 0 0 1rem;
  color: var(--navy-dark);
  font-size: 1.55rem;
}

.customer-resource-card {
  margin-bottom: 1.25rem;
}

.billing-card {
  margin-top: 1.25rem;
}

.billing-card .panel-heading {
  padding: 1.35rem 1.6rem 1rem;
}

.inline-action {
  margin: 0 0 1rem;
  display: inline-block;
}

.table-note {
  margin: 0;
  padding: 0.85rem 1.1rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

.table-subline {
  margin-top: 0.25rem;
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.total-row th {
  color: var(--navy-dark);
  border-top: 2px solid var(--blue);
  background: #f7fafc;
  font-size: 0.95rem;
}

.endpoint-error-row td {
  padding: 0.8rem 1rem 1rem;
  background: #fff7f7;
}

.endpoint-error {
  color: #7f2525;
}

.endpoint-error summary {
  font-weight: 800;
  cursor: pointer;
}

.endpoint-error pre {
  margin: 0.75rem 0 0;
  padding: 0.9rem;
  overflow-x: auto;
  color: #4a2020;
  border: 1px solid #efcaca;
  border-radius: 10px;
  background: white;
  font: 0.8rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
}

.panel,
.table-card,
.login-card {
  padding: 1.6rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel h2,
.login-card h2 {
  margin: 0 0 0.8rem;
  color: var(--navy-dark);
  font-size: 1.35rem;
}

.next-panel {
  color: white;
  border: 0;
  background: linear-gradient(140deg, var(--navy), #245f82);
}

.next-panel .eyebrow,
.next-panel h2,
.next-panel p {
  color: white;
}

.next-panel p {
  color: rgba(255, 255, 255, 0.78);
}

.check-list {
  margin: 1.2rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.8rem;
  list-style: none;
}

.check-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.check-list span {
  display: grid;
  flex: 0 0 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-light);
  font-weight: 800;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 44px;
  padding: 0.68rem 1rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  color: white;
  background: var(--blue);
}

.secondary-button {
  margin-top: 0.6rem;
  color: var(--navy);
  background: white;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.report-quantity-table {
  table-layout: fixed;
  font-size: 0.9rem;
}

.report-quantity-table th,
.report-quantity-table td {
  padding: 0.85rem 0.65rem;
}

.report-quantity-table th:first-child {
  width: 32%;
}

.report-quantity-table th:nth-child(2) {
  width: 9%;
}

.report-quantity-table th:nth-child(3) {
  width: 12%;
}

.report-quantity-table th:nth-child(4),
.report-quantity-table th:nth-child(5) {
  width: 15%;
}

.report-quantity-table th:nth-child(6) {
  width: 17%;
}

.report-quantity-table th:not(:first-child),
.report-quantity-table td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

.report-quantity-table .report-customer-cell {
  white-space: normal;
  overflow-wrap: anywhere;
}

.report-schedule {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.3;
}

.report-filter-panel {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
}

.report-filter {
  display: flex;
  align-items: end;
  gap: 1rem;
}

.report-filter > div {
  flex: 1;
}

.report-filter label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.report-filter select {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--navy-dark);
  background: white;
  font: inherit;
}

.resource-history-metrics {
  margin-bottom: 1.25rem;
}

.resource-history-table {
  table-layout: fixed;
}

.resource-history-table th:first-child {
  width: 22%;
}

.resource-history-table th:not(:first-child),
.resource-history-table td:not(:first-child) {
  text-align: right;
}

.resource-history-table td small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: normal;
}

.history-delta {
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.resource-table {
  table-layout: fixed;
}

.resource-table th,
.resource-table td {
  padding: 0.8rem 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-table th:nth-child(1) { width: 220px; }
.resource-table th:nth-child(2) { width: 135px; }
.resource-table th:nth-child(3) { width: 120px; }
.resource-table th:nth-child(4) { width: 125px; }
.resource-table th:nth-child(5) { width: 55px; }
.resource-table th:nth-child(6) { width: 70px; }
.resource-table th:nth-child(7) { width: 85px; }
.resource-table th:nth-child(8) { width: 90px; }
.resource-table th:nth-child(9) { width: 105px; }

th,
td {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #f8fafb;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

tbody tr:hover {
  background: #f9fbfc;
}

code {
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.row-link,
.back-link a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.back-link {
  margin: -1rem 0 1.5rem;
}

.cell-note {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.row-action {
  padding: 0.45rem 0.65rem;
  border: 1px solid #a8c5d9;
  border-radius: 8px;
  color: var(--blue);
  background: white;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.row-action:hover {
  background: var(--blue-light);
}

.status-error {
  color: #9c2f2f;
  background: #fff0f0;
}

.section-spacing {
  margin-top: 1rem;
}

.run-list {
  display: grid;
}

.run-list > div {
  padding: 0.8rem 0;
  display: grid;
  grid-template-columns: 150px 100px 160px 1fr;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.run-list > div:last-child {
  border-bottom: 0;
}

.detail-list {
  margin: 1.2rem 0 0;
}

.detail-list div,
.service-row {
  padding: 0.75rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.detail-list div:last-child,
.service-row:last-child {
  border-bottom: 0;
}

.detail-list dt,
.service-row small {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
  font-weight: 700;
}

.service-row small {
  display: block;
}

.service-amount {
  text-align: right;
  font-weight: 700;
}

.login-layout {
  min-height: calc(100vh - 180px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  align-items: center;
  gap: clamp(2rem, 8vw, 7rem);
}

.login-intro h1 {
  font-size: clamp(2.6rem, 5.5vw, 4.9rem);
}

.login-card {
  padding: 2rem;
}

.form-stack {
  display: grid;
  gap: 1rem;
}

.form-stack label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--navy-dark);
  font-size: 0.86rem;
  font-weight: 700;
}

.form-stack input {
  width: 100%;
  min-height: 46px;
  padding: 0.7rem 0.8rem;
  border: 1px solid #bfcbd4;
  border-radius: 9px;
  background: white;
  font: inherit;
}

.form-stack input:focus {
  outline: 3px solid rgba(30, 106, 159, 0.16);
  border-color: var(--blue);
}

.form-error {
  padding: 0.75rem;
  border-radius: 8px;
  color: #9c2f2f;
  background: #fff0f0;
}

.included-resources {
  margin: 0 1.25rem 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f6f9fb;
}

.included-resources > strong {
  color: var(--navy-dark);
}

.included-resources dl {
  margin: 0.7rem 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.included-resources dl div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.included-resources dt {
  color: var(--muted);
}

.included-resources dd {
  margin: 0;
  color: var(--navy-dark);
  font-weight: 700;
}

.fine-print,
.empty-state {
  color: var(--muted);
  font-size: 0.85rem;
}

.field-help {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.field-help ul,
.errorlist {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

.errorlist {
  color: #9c2f2f;
  font-size: 0.82rem;
}

.fine-print {
  margin: 1rem 0 0;
}

.development-box {
  margin-top: 1.2rem;
  padding: 1rem;
  border: 1px solid #d7b566;
  border-radius: 10px;
  background: var(--amber-light);
}

.development-box p {
  margin: 0.35rem 0 0.8rem;
  color: #684609;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .report-quantity-table,
  .report-quantity-table tbody,
  .report-quantity-table tr,
  .report-quantity-table td {
    display: block;
    width: 100%;
  }

  .report-quantity-table thead {
    display: none;
  }

  .report-quantity-table tr {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--line);
  }

  .report-quantity-table td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.28rem 0;
    border-bottom: 0;
  }

  .report-quantity-table td:not(:first-child) {
    text-align: right;
    white-space: normal;
  }

  .report-quantity-table td:not(:first-child)::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
    text-align: left;
  }

  .report-quantity-table .report-customer-cell {
    display: block;
    margin-bottom: 0.45rem;
    text-align: left;
  }

  .report-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .report-filter .primary-button {
    width: 100%;
  }

  .site-header {
    padding: 0.8rem 1rem;
    flex-wrap: wrap;
    gap: 0.8rem 1rem;
  }

  .main-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .role-badge {
    display: none;
  }

  .page-shell {
    padding-top: 2rem;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .metric-grid,
  .content-grid,
  .login-layout {
    grid-template-columns: 1fr;
  }

  .run-list > div {
    grid-template-columns: 1fr 1fr;
  }

  .login-layout {
    align-content: start;
  }
}

@media (max-width: 520px) {
  .included-resources dl {
    grid-template-columns: 1fr;
  }

  .resource-history-table,
  .resource-history-table tbody,
  .resource-history-table tr,
  .resource-history-table td {
    display: block;
    width: 100%;
  }

  .resource-history-table thead {
    display: none;
  }

  .resource-history-table tr {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--line);
  }

  .resource-history-table td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.35rem 0;
    border-bottom: 0;
    white-space: normal;
  }

  .resource-history-table td:not(:first-child)::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
    text-align: left;
  }

  .resource-history-table td > strong,
  .resource-history-table td > small {
    text-align: right;
  }

  .resource-history-table .history-date-cell {
    display: block;
    margin-bottom: 0.4rem;
    text-align: left;
  }

  .resource-history-table .history-date-cell small {
    text-align: left;
  }

  .brand small {
    display: none;
  }

  .page-shell {
    width: min(100% - 1.2rem, 1180px);
  }

  .page-heading h1,
  .login-intro h1 {
    font-size: 2.25rem;
  }

  .panel,
  .login-card {
    padding: 1.25rem;
  }
}
