:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: #172033;
  background: #f7f8fb;
}

[hidden] { display: none !important; }

header {
  display: flex;
  gap: 2rem;
  align-items: center;
  padding: 1rem 2rem;
  background: #172033;
}

header a { color: white; text-decoration: none; }
.brand { font-weight: 700; }
nav { display: flex; gap: 1rem; }
nav { align-items: center; flex-wrap: wrap; }
.nav-menu { position: relative; }
.nav-menu summary { color: white; cursor: pointer; list-style: none; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary::after { content: "▾"; margin-left: .35rem; font-size: .75em; }
.nav-menu[open] summary::after { content: "▴"; }
.nav-dropdown {
  position: absolute;
  z-index: 10;
  top: calc(100% + .65rem);
  left: -.75rem;
  display: grid;
  min-width: max-content;
  padding: .5rem;
  border: 1px solid #34435d;
  border-radius: .5rem;
  background: #172033;
  box-shadow: 0 .5rem 1.25rem rgba(0, 0, 0, .22);
}
.nav-dropdown a { padding: .45rem .5rem; border-radius: .3rem; white-space: nowrap; }
.nav-dropdown a:hover, .nav-dropdown a:focus-visible { background: #293953; }
.session-user { color: #c9d2e3; }
.logout-form { margin: 0; }
.logout-form button {
  padding: 0;
  border: 0;
  color: white;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}
main { flex: 1; width: min(100% - 3rem, 70rem); margin: 2rem auto; }
footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 2rem;
  color: #c9d2e3;
  background: #172033;
  font-size: .85rem;
}
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: .75rem; border-bottom: 1px solid #dfe3ec; text-align: left; }

h1, h2 { line-height: 1.2; }
h2 { margin-top: 0; font-size: 1.15rem; }
code { font-size: .9em; }
small { color: #5b6475; }

.page-heading,
.actions,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.page-heading { margin-bottom: 1.5rem; }
.page-heading h1 { margin: .35rem 0 0; }
.dashboard-heading p { margin: .35rem 0 0; color: #5b6475; }
.breadcrumb { margin: 0; color: #5b6475; font-size: .9rem; }
.breadcrumb a { color: #2457c5; }
.actions { justify-content: flex-start; flex-wrap: wrap; }
.inline { display: inline; }

.button {
  display: inline-block;
  padding: .55rem .85rem;
  border: 1px solid #aeb6c5;
  border-radius: .35rem;
  color: #172033;
  background: white;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}
.button.primary { color: white; border-color: #2457c5; background: #2457c5; }
.button.danger { color: white; border-color: #b42318; background: #b42318; }
.button.small { padding: .3rem .5rem; font-size: .85rem; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button.is-loading::before {
  content: "";
  display: inline-block;
  width: .9rem;
  height: .9rem;
  margin-right: .5rem;
  border: .14rem solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -.12rem;
  animation: trace-spin .75s linear infinite;
}

.table-wrapper { overflow-x: auto; }
.break-all { overflow-wrap: anywhere; }
.profile-tabs { display: flex; gap: .35rem; overflow-x: auto; border-bottom: 1px solid #dfe3ec; }
.profile-tab { flex: 0 0 auto; padding: .65rem .9rem; border: 1px solid transparent; border-bottom: 0; border-radius: .5rem .5rem 0 0; color: #5b6475; background: transparent; cursor: pointer; font: inherit; font-weight: 650; }
.profile-tab:hover { color: #172033; background: #eef4ff; }
.profile-tab:focus-visible { outline: 3px solid #75a7d7; outline-offset: -3px; }
.profile-tab.is-active { border-color: #dfe3ec; color: #172033; background: white; }
.profile-count { display: inline-block; min-width: 1.25rem; margin-left: .4rem; padding: .05rem .35rem; border-radius: 1rem; color: #395074; background: #e9edf3; font-size: .8rem; text-align: center; }
.profile-panel { padding: 1.25rem; border: 1px solid #dfe3ec; border-top: 0; border-radius: 0 0 .5rem .5rem; background: white; }
.profile-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.profile-heading h2, .profile-heading span { margin: 0; }
.profile-heading span, .profile-empty { color: #5b6475; }
.empty-state, .card {
  padding: 1.25rem;
  border: 1px solid #dfe3ec;
  border-radius: .5rem;
  background: white;
}
.card { margin-bottom: 1rem; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.metric-card {
  display: grid;
  gap: .25rem;
  padding: 1.35rem;
  border: 1px solid #dfe3ec;
  border-radius: .65rem;
  color: #172033;
  background: linear-gradient(135deg, #fff 0%, #f3f6fc 100%);
  text-decoration: none;
  box-shadow: 0 .35rem 1rem rgba(23, 32, 51, .06);
}
.metric-card:hover { border-color: #9db3e4; }
.metric-card > span { color: #5b6475; font-weight: 650; }
.metric-card > strong { font-size: 2.25rem; line-height: 1.15; }
.dashboard-ranking-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.ranking-card { margin-bottom: 0; }
.ranking-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .8rem;
}
.ranking-heading h2, .ranking-heading p { margin: 0; }
.ranking-heading p { margin-top: .25rem; color: #5b6475; font-size: .9rem; }
.ranking-heading > a { color: #2457c5; white-space: nowrap; }
.usage-ranking { margin: 0; padding: 0; list-style: none; }
.usage-ranking li {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: .75rem;
  align-items: center;
  padding: .75rem 0;
  border-top: 1px solid #eef0f4;
}
.usage-rank {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  color: #2457c5;
  background: #eef4ff;
  font-size: .8rem;
  font-weight: 700;
}
.usage-entity { display: grid; min-width: 0; }
.usage-entity a { color: #172033; font-weight: 650; text-decoration: none; }
.usage-entity a:hover { color: #2457c5; text-decoration: underline; }
.usage-entity code { color: #5b6475; overflow-wrap: anywhere; }
.usage-ranking li > strong { min-width: 2rem; text-align: right; font-size: 1.05rem; }
.ranking-empty { margin: 0; padding: 1rem 0; color: #5b6475; border-top: 1px solid #eef0f4; }
.auth-card { max-width: 28rem; margin: 4rem auto; }
.section-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.template-option, .display-entry, .claim-editor { padding: 1rem; border: 1px solid #dfe3ec; border-radius: .45rem; background: #fbfcfe; }
.template-option h3, .display-entry h3 { margin-top: 0; }
.compact-heading { margin-bottom: .75rem; }
.top-spaced { margin-top: 1rem; }
.display-list, .claim-list { display: grid; gap: 1rem; }
.display-editor-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(17rem, .65fr); gap: 1.25rem; align-items: start; }
.display-editor-layout.no-preview { display: block; }
.credential-display-preview { position: sticky; top: 1rem; width: min(100%, 21rem); min-width: 0; }
.credential-preview-heading { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .55rem; color: #39445a; font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.credential-preview-card { position: relative; isolation: isolate; box-sizing: border-box; width: min(100%, 21rem); aspect-ratio: 1.586 / 1; overflow: hidden; border: 1px solid rgba(23, 32, 51, .16); border-radius: .8rem; color: #fff; background: #243b67; box-shadow: 0 .75rem 1.8rem rgba(23, 32, 51, .16); }
.credential-preview-card-static { margin: .8rem 0 1rem; }
.credential-preview-background { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.credential-preview-card::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(9, 17, 32, .06) 25%, rgba(9, 17, 32, .68) 100%); }
.credential-preview-content { position: relative; box-sizing: border-box; width: 100%; height: 100%; padding: 1.15rem; text-shadow: 0 .1rem .35rem rgba(0, 0, 0, .55); }
.credential-preview-identity { display: flex; align-items: flex-start; gap: .8rem; min-width: 0; }
.credential-preview-identity strong { min-width: 0; padding-top: .1rem; font-size: 1.05rem; line-height: 1.2; overflow-wrap: anywhere; }
.credential-preview-logo { display: block; max-width: 38%; width: auto; height: auto; max-height: 3.6rem; object-fit: contain; filter: drop-shadow(0 .15rem .3rem rgba(0, 0, 0, .22)); }
.credential-preview-description { position: absolute; top: 50%; right: 1.15rem; left: 1.15rem; display: block; font-size: .8rem; line-height: 1.35; opacity: .92; transform: translateY(-50%); overflow-wrap: anywhere; }
.credential-preview-status { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; color: #5b6475; font-size: .75rem; }
.credential-preview-status span { padding: .18rem .45rem; border-radius: 1rem; background: #e9edf3; }
.credential-preview-status span.success { color: #176b3a; background: #dcfce7; }
.credential-preview-status span.error { color: #8a1c13; background: #fee4e2; }
.error-text { color: #8a1c13; }
.claim-editor > summary { cursor: pointer; font-weight: 650; }
.claim-editor[open] > summary { margin-bottom: 1rem; }
.locale-row { display: grid; grid-template-columns: 10rem minmax(14rem, 1fr) auto; gap: .75rem; align-items: end; margin-bottom: .75rem; }
.credential-type-card > .page-heading p { margin-bottom: 0; }

.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.details-grid .wide { grid-column: 1 / -1; }
.details-grid div, .details-list div { min-width: 0; }
dt { color: #5b6475; font-size: .85rem; }
dd { margin: .2rem 0 0; }
.details-list div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid #eef0f4; }

.badge { display: inline-block; padding: .15rem .45rem; border-radius: 1rem; font-size: .8rem; }
.badge.success { color: #176b3a; background: #dcfce7; }
.badge.warning { color: #765b00; background: #fff3cd; }
.badge.muted { color: #5b6475; background: #e9edf3; }

.stacked-form { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: grid; gap: .35rem; }
input, select, textarea {
  box-sizing: border-box;
  width: 100%;
  padding: .55rem;
  border: 1px solid #aeb6c5;
  border-radius: .3rem;
  background: white;
  font: inherit;
}
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; }
input.compact { width: 6rem; }
.color-control { display: flex; align-items: center; gap: .5rem; }
.color-control .color-hex { min-width: 0; }
.color-control .color-picker {
  flex: 0 0 3rem;
  width: 3rem;
  height: 2.75rem;
  padding: .2rem;
  cursor: pointer;
}
.checkbox-row { display: flex; align-items: center; gap: .55rem; margin: .55rem 0; }
.configuration-enabled { align-self: start; flex-wrap: wrap; }
.configuration-enabled small { flex-basis: 100%; }
.status-list-card { border-color: #cbd9f3; background: #fbfdff; }
.status-list-card .page-heading { margin-bottom: .8rem; }
.status-list-card .page-heading p { margin: .3rem 0 0; color: #5b6475; }
.status-list-toggle { display: flex; align-items: flex-start; gap: .7rem; margin: 0; padding: 1rem; border: 1px solid #b9cae9; border-radius: .45rem; background: #f1f6ff; cursor: pointer; }
.status-list-toggle input { flex: 0 0 auto; width: auto; margin-top: .2rem; }
.status-list-toggle span { display: grid; gap: .25rem; }
.status-list-toggle small { color: #4a5870; }
.status-list-options { max-width: calc(50% - .5rem); margin-top: 1rem; }
.selection-list { margin-top: 1rem; border: 1px solid #dfe3ec; border-radius: .45rem; background: #fbfcfe; }
.selection-list .checkbox-row { margin: 0; padding: .8rem 1rem; border-bottom: 1px solid #e8ebf1; cursor: pointer; }
.selection-list .checkbox-row:last-child { border-bottom: 0; }
.selection-list > p { margin: 0; padding: 1rem; }
.notice { margin-top: 1rem; padding: .8rem; border-left: .3rem solid #2457c5; background: #eef4ff; }
.flash { margin-bottom: 1rem; padding: .75rem 1rem; border-radius: .35rem; }
.flash.success { color: #176b3a; background: #dcfce7; }
.flash.error { color: #8a1c13; background: #fee4e2; }

@media (max-width: 700px) {
  header, footer, .page-heading { align-items: flex-start; flex-direction: column; }
  .nav-dropdown { position: static; margin-top: .5rem; }
  .form-grid, .details-grid, .metric-grid, .dashboard-ranking-grid { grid-template-columns: 1fr; }
  .status-list-options { max-width: none; }
  .locale-row { grid-template-columns: 1fr; }
  .profile-panel { padding: 1rem; }
}

@media (max-width: 980px) {
  .display-editor-layout { grid-template-columns: 1fr; }
  .credential-display-preview { position: static; max-width: 30rem; }
}

.trace-table .trace-error td {
  background: #fff0f0;
  color: #8a1515;
}

.trace-table .trace-warning td {
  background: #fff8dc;
  color: #765b00;
}

.trace-table .trace-application-api td {
  background: #eef4ff;
  color: #173b7a;
}

.trace-table .trace-application-api.trace-error td {
  background: #f2edff;
  color: #55328c;
}

.trace-table .trace-application-api-detail td {
  border-left: .25rem solid #6d4bc3;
}

.trace-api-badge {
  background: #ddd2ff;
  color: #4b277d;
  white-space: nowrap;
}

.trace-table .trace-detail-row td {
  padding: 0;
  background: #f7f8fa;
}

.trace-table .trace-detail-row pre {
  width: 100%;
  max-width: none;
  max-height: 32rem;
  box-sizing: border-box;
  margin: 0;
  padding: 1rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.trace-table tbody { overflow-anchor: none; }

.trace-analysis-wait[hidden] { display: none; }
.trace-analysis-wait {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(41, 47, 58, .42);
  backdrop-filter: grayscale(.35);
}

.trace-analysis-wait-panel {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 1rem 1.2rem;
  border-radius: .5rem;
  color: #172033;
  background: white;
  box-shadow: 0 .8rem 2.5rem rgba(23, 32, 51, .28);
  font-weight: 650;
}

.trace-spinner {
  width: 1.35rem;
  height: 1.35rem;
  border: .18rem solid #b9c5dc;
  border-top-color: #2457c5;
  border-radius: 50%;
  animation: trace-spin .75s linear infinite;
}

@keyframes trace-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .button.is-loading::before,
  .trace-spinner { animation-duration: 1.8s; }
}

.trace-ai-result h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: 0 0 .5rem;
}

.trace-ai-findings { display: grid; gap: .75rem; }
.trace-ai-finding { padding: 1rem; border-left: .3rem solid #6b7280; background: #f7f8fa; }
.trace-ai-finding p:last-child, .trace-ai-finding ul:last-child { margin-bottom: 0; }
.trace-ai-error { border-left-color: #b42318; background: #fff0f0; }
.trace-ai-warning { border-left-color: #b7791f; background: #fff8dc; }
.trace-ai-info { border-left-color: #2457c5; background: #eef4ff; }
