:root {
  --brand-ink: #25303D;
  --brand-teal: #01AF98;
  --brand-highlight: #35EDD5;
  --brand-link: #006e61;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--brand-ink);
  background: #f2faf9;
  font-size: 13px;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
header {
  min-height: 54px;
  background: var(--brand-ink);
  color: white;
  display: flex;
  align-items: center;
  padding: 8px 20px;
  gap: 20px;
}
.brand { display: flex; flex-shrink: 0; gap: 12px; align-items: center; white-space: nowrap; }
.brand img { display: block; width: 83px; height: 34px; }
.brand span { font-size: 12px; letter-spacing: 1px; color: var(--brand-highlight); border-left: 1px solid #59636f; padding-left: 12px; }
#identity { margin-left: auto; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
#logout { flex-shrink: 0; }
main { max-width: 1760px; min-width: 0; margin: auto; padding: 14px 20px; }
.eyebrow { color: var(--brand-link); font-size: 11px; font-weight: 750; letter-spacing: 2px; }
h1 { font-size: 23px; letter-spacing: -.5px; margin: 0 0 10px; }
h2 { font-size: 17px; margin: 0 0 6px; }
h1, h2, h3, p, li, summary { overflow-wrap: anywhere; }
p { line-height: 1.4; margin: 5px 0 8px; }
.muted { color: #667780; font-size: 12px; }
#welcome { padding: 24px 0 36px; max-width: 650px; }
#welcome h1 { font-size: clamp(28px, 4vw, 38px); line-height: 1.15; }
button, a.primary {
  font: inherit;
  font-size: 13px;
  min-height: 32px;
  max-width: 100%;
  border: 1px solid #cad4d8;
  border-radius: 7px;
  padding: 6px 11px;
  background: white;
  color: var(--brand-ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  overflow-wrap: anywhere;
  touch-action: manipulation;
}
@media (hover: hover) { button:hover { background: #e9f2ef; } }
button:disabled { opacity: .5; cursor: wait; }
:focus-visible { outline: 3px solid var(--brand-link); outline-offset: 3px; }
.primary { background: var(--brand-teal) !important; color: var(--brand-ink) !important; border-color: var(--brand-teal) !important; }
button.danger { color: #a22a36; border-color: #dfb8bc; }
button.small { padding: 5px 9px; }
nav { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid #d7e0e3; margin-bottom: 10px; }
nav button { background: transparent; border: 0; border-radius: 0; padding: 7px 11px; border-bottom: 3px solid transparent; }
nav .selected { border-bottom-color: var(--brand-teal); color: var(--brand-link); font-weight: bold; background: #e5f7f3; }
.panel { min-width: 0; background: white; padding: 14px; border: 1px solid #dce4e6; border-radius: 8px; box-shadow: 0 4px 20px #20394a04; }
.page-title, .section-title { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: space-between; align-items: center; }
.page-title > div, .section-title > div { min-width: 0; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.badge { background: #e5f7f3; color: var(--brand-link); border-radius: 15px; padding: 5px 9px; font-size: 12px; }
label { display: block; font-size: 12px; font-weight: 600; margin: 6px 0; overflow-wrap: anywhere; }
input:not([type=checkbox]), textarea, select {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 480px;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid #c7d3d8;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: normal;
  margin-top: 4px;
}
textarea { min-height: 76px; resize: vertical; }
input[type=checkbox] { accent-color: var(--brand-teal); width: 20px; height: 20px; flex-shrink: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: normal; max-width: 100%; line-height: 1.35; }
form { padding: 4px 0 10px; min-width: 0; }
details { margin: 6px 0; color: #476375; min-width: 0; }
summary { cursor: pointer; font-size: 12px; padding: 7px 0; min-height: 32px; }
.table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; text-align: left; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #6b7c85; background: #f5f8f9; }
td, th { padding: 7px 9px; border-bottom: 1px solid #e9edef; vertical-align: top; }
td { font-size: 12px; max-width: 28rem; overflow-wrap: anywhere; }
td code { font-size: 12px; overflow-wrap: anywhere; }
td > div { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.table-message { padding: 12px 9px; color: #667780; }
#notice, .demo, #key-download { padding: 7px 11px; background: #fff4d8; border: 1px solid #ead59e; border-radius: 8px; margin-bottom: 8px; overflow-wrap: anywhere; }
#notice.error { background: #fff0f0; border-color: #dfb8bc; color: #8a2632; }
#key-download > button { margin: 0 8px 8px 0; }
.permission-row { margin: 0; font-weight: normal; min-height: 32px; display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 12px; padding: 5px 0; border-bottom: 1px solid #e9edef; }
.permission-row > span { overflow-wrap: anywhere; }
.permission-row select { width: 100%; margin: 0; }
.permission-row input { justify-self: end; }
footer { margin-top: 12px; font-size: 11px; color: #73838a; display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; overflow-wrap: anywhere; }
#new-key { border-bottom: 1px solid #eee; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); gap: 8px; margin: 10px 0; }
.metric { min-width: 0; border: 1px solid #dce4e6; border-radius: 8px; padding: 9px 11px; overflow-wrap: anywhere; }
.metric strong { display: block; font-size: clamp(16px, 1.5vw, 20px); margin-top: 4px; }
.metric p { margin-bottom: 0; }
.health { padding: 9px 12px; border-radius: 8px; font-weight: 700; border: 1px solid; overflow-wrap: anywhere; }
.health.green { background: #e4f5eb; color: #175b35; border-color: #86bb98; }
.health.amber { background: #fff3d6; color: #755100; border-color: #d3b15d; }
.health.red { background: #ffe7e7; color: #912929; border-color: #d98b8b; }
.health.unknown { background: #eef0f3; color: #49535e; border-color: #aab2bd; }
#monitor-reasons { padding-left: 22px; line-height: 1.4; }
#tab-monitor h3 { margin-top: 12px; }
#monitor-trend { display: block; width: 100%; max-width: 100%; height: auto; min-height: 120px; max-height: 220px; background: repeating-linear-gradient(to top, #f5f8f9 0, #f5f8f9 24%, #dce4e6 25%); border: 1px solid #dce4e6; border-radius: 8px; }
[hidden] { display: none !important; }

@media (max-width: 960px) {
  main { padding: 12px 16px; }
  .panel { padding: 12px; }
  nav { gap: 4px; }
  nav button { padding: 7px 10px; }
}

@media (max-width: 700px) {
  header { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 14px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left)); }
  .brand { grid-column: 1; grid-row: 1; }
  #logout { grid-column: 2; grid-row: 1; }
  #identity { grid-column: 1 / -1; grid-row: 2; margin-left: 0; line-height: 1.5; }
  main { padding: 24px max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .panel { padding: 18px; border-radius: 10px; }
  #welcome { padding: 28px 0 48px; }
  #welcome br { display: none; }
  .page-title { align-items: flex-start; }
  .page-title > div:first-child { flex: 1 1 100%; }
  .page-actions { width: 100%; justify-content: space-between; }
  .section-title { align-items: flex-start; }
  .section-title > button { margin-bottom: 12px; }
  nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 0; gap: 8px; margin-bottom: 18px; }
  nav button { border: 1px solid #d7e0e3; border-radius: 7px; padding: 11px 8px; }
  nav .selected { border: 2px solid var(--brand-teal); padding: 10px 7px; }
  input:not([type=checkbox]), textarea, select { max-width: 100%; }
  .permission-row { grid-template-columns: minmax(0, 1fr) 160px; gap: 12px; }
  .metric-grid { gap: 10px; }
  .metric { padding: 15px; }
  #notice, .demo, #key-download { padding: 14px; }
  #key-download > button { display: flex; width: 100%; margin: 0 0 10px; }
  footer { display: block; line-height: 1.6; }
  footer span { display: block; margin-top: 8px; }

  /* Keep column headers available to assistive technology; show labels on each card. */
  table, tbody { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  tbody tr { display: block; margin: 12px 0; padding: 8px 12px; border: 1px solid #dce4e6; border-radius: 8px; }
  td { display: grid; grid-template-columns: minmax(0, 34%) minmax(0, 1fr); gap: 12px; width: 100%; max-width: none; padding: 10px 0; font-size: 14px; }
  td::before { content: attr(data-label); font-size: 11px; font-weight: 700; color: #667780; letter-spacing: .3px; }
  td > * { min-width: 0; max-width: 100%; }
  td:last-child { border-bottom: 0; }
  td[data-empty=true] { display: none; }
  td.table-message { display: block; border: 0; }
  td.table-message::before { content: none; }
}

@media (max-width: 420px) {
  .panel { padding: 14px; }
  .permission-row { grid-template-columns: minmax(0, 1fr) auto; }
  .permission-row select { grid-column: 1 / -1; }
  .permission-row input { grid-column: 2; grid-row: 1; }
  .metric-grid { grid-template-columns: minmax(0, 1fr); }
  td { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  td > div > button, td > div > a.primary { width: 100%; }
}

/* Compact desktop work areas; mobile controls retain generous touch targets. */
.demo { font-size: 11px; }
#new-key { display: grid; grid-template-columns: minmax(0, 440px) auto minmax(0, 1fr); align-items: end; gap: 4px 10px; }
#new-key > label:first-child { grid-column: 1; grid-row: 1; }
#new-key > button { grid-column: 2; grid-row: 1; margin-bottom: 6px; }
#new-key > .check { grid-column: 1 / -1; grid-row: 2; margin: 4px 0; }
#external-invite-form, .permission-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 6px 12px; }
#external-invite-form > label, .permission-toolbar > label { flex: 1 1 210px; max-width: 440px; }
#external-invite-form > button, .permission-toolbar > button { margin-bottom: 6px; }
.permission-toolbar > label:nth-child(2) { flex: 0 1 190px; }
#permission-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; margin-top: 8px; }
.permission-row input { margin: 0; width: 18px; height: 18px; }
.metric p { font-size: 11px; line-height: 1.3; margin-top: 3px; }
.monitor-extra { border-top: 1px solid #e9edef; margin: 7px 0 0; }
.monitor-extra > summary { font-weight: 600; color: var(--brand-ink); }
#monitor-reasons { margin: 4px 0; font-size: 12px; }
#monitor-checked { margin-bottom: 4px; }
#monitor-trend { min-height: 90px; max-height: 150px; }
@media (max-width: 1100px) { #permission-options { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) {
  button, a.primary, input:not([type=checkbox]), textarea, select, summary { min-height: 44px; }
  button, a.primary { padding: 9px 11px; }
  input:not([type=checkbox]), textarea, select { font-size: 16px; }
  header { min-height: 54px; gap: 6px; padding-top: 9px; padding-bottom: 9px; }
  #identity { font-size: 12px; line-height: 1.3; }
  main { padding-top: 12px; padding-bottom: 14px; }
  #welcome { padding: 16px 0 24px; }
  .panel { padding: 12px; }
  .page-title > div:first-child { flex: 1 1 auto; }
  .page-actions { width: auto; margin-bottom: 8px; }
  .page-title h1 { font-size: 21px; }
  nav { gap: 5px; margin-bottom: 10px; }
  nav button { padding: 8px 6px; }
  nav .selected { padding: 7px 5px; }
  #new-key { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  #new-key > label:first-child, #new-key > .check, #new-key > button { grid-column: 1; grid-row: auto; }
  #new-key > button { justify-self: start; }
  #external-invite-form > label, .permission-toolbar > label { flex: 1 1 100%; max-width: 100%; }
  .permission-toolbar > label:nth-child(2) { flex: 1 1 100%; }
  .permission-row { min-height: 44px; padding: 6px 0; }
  .permission-row select { min-height: 44px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .metric { padding: 8px; }
  .metric strong { font-size: 16px; }
  .metric p { font-size: 11px; }
  tbody tr { margin: 7px 0; padding: 5px 9px; }
  td { padding: 6px 0; gap: 7px; font-size: 13px; }
  #notice, .demo, #key-download { padding: 8px 10px; }
  .section-title > button { margin-bottom: 5px; }
  footer { margin-top: 10px; }
}
@media (max-width: 360px) { .metric-grid { grid-template-columns: minmax(0, 1fr); } }

@media(max-width: 360px) { .brand { gap: 8px; } .brand img { width: 73px; height: 30px; } .brand span { padding-left: 8px; font-size: 11px; } }

#metric-definitions { display: grid; grid-template-columns: minmax(100px, 180px) minmax(0, 1fr); gap: 5px 12px; font-size: 12px; }
#metric-definitions dt { font-weight: 600; }
#metric-definitions dd { margin: 0; overflow-wrap: anywhere; }
@media(max-width: 420px) { #metric-definitions { grid-template-columns: minmax(0, 1fr); } }

.login-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }

.help-content { max-width: 1100px; }
.help-content > details { border-bottom: 1px solid #e1e8e6; padding: 4px 0; }
.help-content summary { font-weight: 600; }
.help-content p, .help-content li, .help-content dd { line-height: 1.55; }
.help-content p { margin: 8px 0; }
.help-content li { margin: 5px 0; }
.help-content code { overflow-wrap: anywhere; }
.help-content dl { margin: 8px 0; }
.help-content dt { font-weight: 600; margin-top: 10px; }
.help-content dd { margin: 4px 0 10px; }
