/* Apps 365 Licence Manager. System fonts only (no web fonts, no CDN). */
:root {
  --brand: #4554ea;
  --brand-dark: #2f3cc4;
  --ink: #0f162e;
  --text: #1b2135;
  --muted: #4f5870;
  --line: #d9deea;
  --bg: #f5f6fa;
  --card: #ffffff;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --error: #b42318;
  --error-bg: #fef3f2;
  --warn: #93370d;
  --warn-bg: #fffaeb;
  --info: #1d3a8a;
  --info-bg: #eef2ff;
  --radius: 8px;
  --focus: 3px solid #4554ea;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--brand-dark); }
a:hover { color: var(--ink); }

:focus-visible { outline: var(--focus); outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: .5rem 1rem;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus { top: .5rem; }

/* Header */
.site-header { background: var(--ink); color: #fff; }
.site-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.5rem;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: .5rem; }
.brand:hover { color: #fff; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  background: var(--brand);
  font-size: .9rem;
}
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.nav a { color: #dfe3ff; text-decoration: none; padding: .35rem .65rem; border-radius: 6px; display: inline-block; }
.nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a[aria-current="page"] { background: var(--brand); color: #fff; }
.signout { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.who { color: #c9cff0; font-size: .9rem; }
.site-header .button-quiet { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }

/* Layout */
.page { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.site-footer { max-width: 1180px; margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); font-size: .85rem; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 1rem; color: var(--ink); }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; color: var(--ink); }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: 0 0 .75rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

.hint, .muted { color: var(--muted); font-size: .9rem; }

/* Notices */
.notice { border-left: 4px solid; border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }
.notice p:last-child, .notice ul:last-child { margin-bottom: 0; }
.notice-ok { background: var(--ok-bg); border-color: var(--ok); }
.notice-error { background: var(--error-bg); border-color: var(--error); }
.notice-warn { background: var(--warn-bg); border-color: var(--warn); }
.notice-info { background: var(--info-bg); border-color: var(--info); }
.error-summary h2 { font-size: 1rem; margin-bottom: .35rem; color: var(--error); }
.error-summary ul { margin: 0; padding-left: 1.25rem; }
.error-summary a { color: var(--error); }

/* Stats */
.stats { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.stat {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  text-decoration: none;
  color: var(--text);
}
a.stat:hover { border-color: var(--brand); color: var(--text); }
.stat-number { display: block; font-size: 1.6rem; font-weight: 700; color: var(--ink); }
.stat-label { display: block; color: var(--muted); font-size: .85rem; }

/* Forms */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1.25rem; }
.field { margin-bottom: 1rem; }
label, .label { display: block; font-weight: 600; margin-bottom: .3rem; }
input[type="text"], input[type="email"], input[type="url"], input[type="date"], input[type="number"],
input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid #aab2c5;
  border-radius: 6px;
  padding: .5rem .6rem;
}
input:disabled, select:disabled, textarea:disabled { background: #eef0f5; color: var(--muted); }
textarea { min-height: 5rem; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error); border-width: 2px; }
.field-error { color: var(--error); font-weight: 600; font-size: .9rem; margin: .3rem 0 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .35rem; }
.check { display: flex; align-items: flex-start; gap: .5rem; margin: .35rem 0; }
.check input { margin-top: .3rem; width: 1.05rem; height: 1.05rem; flex: 0 0 auto; }
.check label { font-weight: 400; margin: 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }

.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: .6rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.button-quiet { background: #fff; color: var(--brand-dark); border-color: #aab2c5; }
.button-quiet:hover { background: var(--info-bg); color: var(--ink); border-color: var(--brand); }
.button-danger { background: #fff; color: var(--error); border-color: var(--error); }
.button-danger:hover { background: var(--error); color: #fff; border-color: var(--error); }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 160px; flex: 1 1 160px; }
.filters .actions { margin-top: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
caption { text-align: left; font-weight: 700; padding: 0 0 .5rem; }
th, td { text-align: left; vertical-align: top; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .85rem; font-weight: 600; }
tbody tr:hover { background: #fafbff; }
td.num { text-align: right; }
.empty { color: var(--muted); }

/* Tags */
.tag { display: inline-block; font-size: .78rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.tag-active { background: var(--ok-bg); color: var(--ok); border-color: #abefc6; }
.tag-expiring { background: var(--warn-bg); color: var(--warn); border-color: #fedf89; }
.tag-expired { background: var(--error-bg); color: var(--error); border-color: #fecdca; }
.tag-revoked { background: #f2f4f7; color: #344054; border-color: #d0d5dd; }
.tag-neutral { background: #f2f4f7; color: #344054; border-color: #d0d5dd; }
.tag-trial { background: var(--info-bg); color: var(--info); border-color: #c7d2fe; }

/* Keys and code */
code, pre, .key-output { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; }
code { background: #eef0f5; padding: .05rem .3rem; border-radius: 4px; font-size: .9em; }
pre {
  background: #0f162e;
  color: #e6e9f5;
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: .85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.key-output { width: 100%; min-height: 7rem; font-size: .8rem; word-break: break-all; }
.copy-status { color: var(--ok); font-weight: 600; }
.minted { border: 2px solid var(--ok); }

dl.kv { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: .4rem 1rem; margin: 0; }
dl.kv dt { font-weight: 600; color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .5rem; }

.pager { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .75rem; color: var(--muted); }

/* Sign-in */
.login-wrap { max-width: 420px; margin: 3rem auto; }

/* Hidden once the script runs (no-script fallbacks). */
.js .js-hide { display: none; }

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

@media (max-width: 640px) {
  .signout { margin-left: 0; }
  dl.kv { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* The two-factor QR code on the set-up page: white tile with its quiet zone, never stretched. */
.qr { margin: .5rem 0 1rem; }
.qr svg { display: block; max-width: 100%; height: auto; border: 1px solid #d5dae6; border-radius: 6px; }

/* Usage page: the 30-day activity chart (SVG with presentation attributes and classes, no inline styles). */
.chart-wrap { overflow-x: auto; }
.chart { display: block; width: 100%; max-width: 760px; height: auto; }
.chart-bar { fill: var(--brand); }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; }
td.wrap { overflow-wrap: anywhere; max-width: 28rem; }

/* Help: the "How this page works" panel, the Help page and the guided tour. */
html:not(.js) .js-only { display: none; }
.lede { font-size: 1.05rem; color: var(--muted); max-width: 70ch; }
.page-help { background: var(--info-bg); border: 1px solid #c7d2fe; border-radius: var(--radius); padding: .6rem .9rem; margin: 0 0 1.25rem; }
.page-help > summary { cursor: pointer; font-weight: 600; color: var(--info); }
.page-help[open] > summary { margin-bottom: .5rem; }
.help-steps { margin: 0 0 .75rem; padding-left: 1.4rem; display: grid; gap: .35rem; max-width: 75ch; }
.help-tips { margin: 0 0 .75rem; padding-left: 1.2rem; display: grid; gap: .3rem; max-width: 75ch; }
.page-help-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 0; }
.help-index ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.help-tours { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.help-guide h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.help-top { margin: .75rem 0 0; font-size: .9rem; }
.help-guide { scroll-margin-top: 1rem; }
.tour-shade { position: fixed; inset: 0; background: rgba(15, 22, 46, .35); z-index: 900; }
.tour-target { position: relative; z-index: 950; outline: 3px solid var(--brand); outline-offset: 4px; border-radius: var(--radius); }
/* Sections and fields get a card behind them above the shade; buttons and links keep their own colours. */
.tour-target:not(.button):not(a) { background-color: var(--card); }
.tour-target { scroll-margin-top: 16px; }
.site-header .tour-target { outline-color: #fff; }
.tour-pop { position: fixed; z-index: 1000; width: min(360px, calc(100vw - 24px)); background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 22, 46, .25); padding: 1rem 1.1rem; }
.tour-pop:focus { outline: var(--focus); outline-offset: 2px; }
.tour-pop-docked { left: 12px; right: 12px; bottom: 12px; width: auto; }
.tour-pop-corner { right: 24px; bottom: 24px; }
.tour-count { margin: 0 0 .25rem; font-size: .8rem; color: var(--muted); letter-spacing: .02em; }
.tour-title { margin: 0 0 .35rem; font-size: 1.05rem; }
.tour-text { margin: 0 0 .9rem; }
.tour-actions { display: flex; gap: .5rem; align-items: center; }
.tour-close { margin-left: auto; background: none; border: 0; color: var(--brand-dark); text-decoration: underline; cursor: pointer; font: inherit; padding: .25rem; }
@media (prefers-reduced-motion: reduce) { .tour-pop, .tour-target { transition: none; } }
