/* Tensai Issuer Portal and client portal: what the UI library's ui.css does not have, the
   product's own parts (permissions, notifications, the licence card, offers, photos,
   automations, settings rows, the dashboard, licence requests). Loaded after ui.css, as the
   client portal's client.css is after this; uses its tokens. The rules came from the portals'
   app.css in the order they had there. */

/* ── forms: permissions and delivery ────────────────────────────────── */
/* "Everything" ticked: the choices give way to what it means. */
.grant-pick:has([name=grants_all]:checked) .choices:not(.grant-off), .grant-pick:has([name=grants_all]:checked) .grant-pick-note { display: none; }
/* Permissions the organisation lacks: shown greyed, with the way to turn them on for it. */
.choice.is-off { cursor: default; }
.choice.is-off a { pointer-events: auto; }
.grant-pick:not(:has([name=grants_all]:checked)) .grant-all-note { display: none; }
.grant-all-note .chip { margin: 2px 0; }
/* The offer form asks for a person only when the offer is sent to one. */
.delivery-pick:has([name=delivery][value=handover]:checked) .send-to:not(.has-err) { display: none; }
.delivery-pick .send-to { max-width: 640px; }

/* ── notifications ──────────────────────────────────────────────────── */
.notes { list-style: none; margin: 0; padding: 0; }
.note { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 12px; padding: 12px var(--card-pad); border-bottom: 1px solid var(--line); position: relative; }
.note:last-child { border-bottom: 0; }
.note.is-unread { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.note.is-unread::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.note-title { font-weight: 550; color: var(--text); }
.note-title a { color: inherit; }
.note-body { color: var(--muted); font-size: .88rem; margin-top: 2px; max-width: 100ch; }
.note-time { color: var(--faint); font-size: .8rem; white-space: nowrap; }
.dd-notes { max-height: 420px; overflow: auto; margin: 0 -5px; }
.dd-notes .note { padding: 10px 16px; grid-template-columns: 26px 1fr; }

/* ── licence card preview (matches the Tensai Wallet card) ──────────── */
.licence-card {
  position: relative; aspect-ratio: 1.586; width: 100%; max-width: 420px; border-radius: 12px; overflow: hidden; padding: 18px 20px;
  color: #fff; background: linear-gradient(135deg, #2f4f9e, #13234d);
  display: grid; grid-template-rows: auto 1fr auto; isolation: isolate; border: 1px solid #13234d;
}
.licence-card::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .08;
  background: repeating-radial-gradient(circle at 110% 120%, #fff 0 1px, transparent 1px 9px); }
.lc-top { display: flex; align-items: center; justify-content: space-between; }
.lc-brand { font: 700 .96rem/1 var(--font); letter-spacing: .16em; }
.lc-kind { font: 500 .6rem/1 var(--mono); letter-spacing: .12em; opacity: .9; margin-top: 6px; }
.lc-chip { background: var(--brand-green); color: #06261c; font: 600 .64rem/1 var(--mono); letter-spacing: .08em; padding: 5px 8px; border-radius: var(--r-sm); }
.lc-mid { display: flex; align-items: center; gap: 14px; min-height: 0; }
.lc-photo { width: 64px; aspect-ratio: .8; border-radius: var(--r-md); object-fit: cover; border: 1px solid rgba(255, 255, 255, .45); background: rgba(255, 255, 255, .15); flex: none; }
.lc-name { font: 600 1.18rem/1.15 var(--font); letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-num { font: 500 .8rem var(--mono); letter-spacing: .05em; opacity: .85; margin-top: 3px; }
.lc-bottom { display: flex; justify-content: space-between; gap: 10px; }
.lc-field small { display: block; font: 500 .56rem/1.2 var(--mono); letter-spacing: .1em; opacity: .85; }
.lc-field span { font-size: .8rem; font-weight: 500; }
.lc-field.end { text-align: right; }

/* ── offers: the PIN, the simulator's code, the live state ──────────── */
.pin { display: inline-flex; gap: 8px; }
.pin span { width: 44px; height: 54px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--surface-3);
  font: 500 1.65rem var(--mono); color: var(--text); }
.pin.sm span { width: 30px; height: 38px; font-size: 1.1rem; }
.sim-code { font-size: 1.9rem; font-weight: 600; letter-spacing: .12em; margin: 0; }
.live { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); flex-wrap: wrap; }
.live > .meter { flex: 0 0 200px; width: 200px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); position: relative; flex: none; }
.pulse::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: pulse 1.6s ease-out infinite; }
.pulse.tone-ok { background: var(--ok-solid); } .pulse.tone-ok::after { display: none; }
.pulse.tone-bad { background: var(--bad-solid); } .pulse.tone-bad::after { display: none; }
@keyframes pulse { 0% { opacity: .7; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.6); } }

/* ── photos ─────────────────────────────────────────────────────────── */
.photo { width: 132px; aspect-ratio: .8; border-radius: var(--r-md); object-fit: cover; background: var(--surface-3); border: 1px solid var(--line); display: grid; place-items: center; color: var(--faint); }
.photo.sm { width: 84px; }
.sig { max-width: 220px; max-height: 70px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px; }
.uploader { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }

/* ── automations ────────────────────────────────────────────────────── */
.job { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px var(--card-pad); border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: 0; }
.job-name { font-weight: 550; color: var(--text); }
.job-name:hover { color: var(--accent-text); }
.job-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); font-size: .84rem; margin-top: 3px; }
.job-meta span { display: inline-flex; align-items: center; gap: 5px; }
.job-meta .i { width: 13px; height: 13px; }

/* ── settings ───────────────────────────────────────────────────────── */
/* A setting's label and help next to its control, kept close on a wide window. */
.setting-row { display: grid; grid-template-columns: minmax(0, 560px) minmax(240px, 420px); justify-content: space-between; gap: 12px 32px;
  padding: 16px var(--card-pad); border-bottom: 1px solid var(--line); align-items: start; }
.setting-row:last-child { border-bottom: 0; }
.setting-row .s-label { font-weight: 550; }
.setting-row > .seg, .setting-row > .switch, .setting-row > div > .seg { justify-self: start; }
.interval { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; }
.setting-row .s-help { color: var(--muted); font-size: .86rem; margin-top: 2px; }
.setting-row .s-meta { color: var(--faint); font-size: .8rem; margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.settings-grid .setting-row { grid-template-columns: minmax(0, 1fr) minmax(200px, 300px); }
/* A segmented control keeps its segments on one line ("Match this device"): its column is as
   wide as they are. */
.settings-grid .setting-row:has(> .seg) { grid-template-columns: minmax(0, 1fr) max-content; }

/* widget editor */
.widget-row { display: flex; align-items: center; gap: 12px; padding: 10px var(--card-pad); border-bottom: 1px solid var(--line); }
.widget-row:last-child { border-bottom: 0; }
.widget-row .grow { flex: 1; }

/* ── dashboard grid ─────────────────────────────────────────────────── */
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); grid-auto-flow: row dense; align-items: stretch; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-6 { grid-column: span 6; } .span-4 { grid-column: span 4; }
.lc-pair { display: grid; grid-template-columns: minmax(240px, 360px) minmax(0, 1fr); gap: 28px; align-items: center; }

/* ── emails, sign-in, email templates ───────────────────────────────── */
.email-reports-off { margin: 0 var(--card-pad) 14px; }
.email-delivery { min-width: 150px; max-width: 280px; }
.login-forgot { margin: -6px 0 14px; }
.tpl-list { padding: 4px var(--card-pad) 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); column-gap: 28px; }
.tpl-item { padding: 14px 0; border-bottom: 1px solid var(--line); }

/* ── lists: a toolbar's filters and its columns menu ────────────────── */
/* The filters are a form of their own (form[data-ui-filters], applied as they change), laid out
   as the toolbar is; the columns menu stands beside it, outside it, as its boxes are saved to
   the account and must not apply the filters. The menu keeps to the first row as they wrap. */
.toolbar-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1 1 0; min-width: 0; }
.toolbar:has(> .toolbar-filters) { flex-wrap: nowrap; align-items: flex-start; gap: 8px; }

/* ── as the page's width allows (container queries) ─────────────────── */
@container page (max-width: 1500px) {
  .lc-pair { grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 22px; }
}
@container page (max-width: 1180px) {
  .span-8, .span-6 { grid-column: span 12; }
  .span-4 { grid-column: span 6; }
}
@container page (max-width: 900px) {
  .lc-pair { grid-template-columns: 1fr; }
  .span-4 { grid-column: span 12; }
  .setting-row, .settings-grid .setting-row, .settings-grid .setting-row:has(> .seg) { grid-template-columns: 1fr; }
  .uploader { grid-template-columns: 1fr; }
}

/* ── licence requests ──────────────────────────────────────────────────────── */
/* The sidebar's alert count (requests waiting): the navy's own gold, as the current page's
   marker, in both themes (--gold-text is the dark gold for text on light surfaces). */
.sb-count.is-alert, .sb-link.is-active .sb-count.is-alert { background: var(--nav-accent); color: var(--nav-bg); }
.clamp-1 { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.req-person { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: start; padding: 16px var(--card-pad) 4px; }
.req-steps { list-style: none; margin: 0; padding: 0; }
.req-steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 12px var(--card-pad); border-top: 1px solid var(--line); font-size: .88rem; color: var(--text-2); }
.req-steps li:first-child { border-top: 0; }
.req-steps .n { font: 500 .76rem/1.35rem var(--mono); color: var(--accent-text); }
@media (max-width: 600px) {
  .req-person { grid-template-columns: 1fr; }
}

/* ── Documents ─────────────────────────────────────────────────────────────── */
.doc-thumb { display: block; padding: 0; overflow: hidden; }
.doc-thumb img { display: block; width: 100%; height: auto; }
.doc-folders { list-style: none; margin: 0; padding: 0 var(--sp-4, 16px) var(--sp-4, 16px); display: grid; gap: 10px; }
.doc-folders li { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.doc-kinds { display: grid; gap: 6px; }
/* The share form shows the fields of the kind chosen (all of them where :has is not known). */
@supports selector(:has(*)) {
  form:has(input[name="kind"]) .doc-for-organisation,
  form:has(input[name="kind"]) .doc-for-person,
  form:has(input[name="kind"]) .doc-for-outside { display: none; }
  form:has(input[name="kind"][value="organisation"]:checked) .doc-for-organisation,
  form:has(input[name="kind"][value="person"]:checked) .doc-for-person,
  form:has(input[name="kind"][value="outside"]:checked) .doc-for-outside { display: grid; }
}
.doc-with { border: 0; padding: 0; margin: 0; min-width: 0; }

/* ── Credential branding (ACT CMP-ISS-11): previews and the editor ─────────────── */
.brand-thumb { display: block; width: 100%; height: auto; border-radius: 12px; }
.brand-mini { display: block; width: 107px; height: auto; border-radius: 6px; }
.brand-logo-thumb, .brand-bg-thumb { object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-3); }
.brand-locale { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin: 0; min-width: 0; display: grid; gap: 10px; }
.brand-picker { width: 44px; height: var(--ctl-h); padding: 2px; border: 1px solid var(--control-line); border-radius: var(--r-md); background: var(--surface); cursor: pointer; }
.brand-current { margin-bottom: 6px; }
.brand-publish { display: inline-block; vertical-align: top; }
.brand-publish > summary { list-style: none; }
.brand-publish > summary::-webkit-details-marker { display: none; }
.brand-publish[open] > form { margin-top: 8px; min-width: 240px; white-space: normal; }
/* The live card: its colours and images come from branding.js through the CSSOM. */
.brand-card { position: relative; display: flex; flex-direction: column; justify-content: flex-end; aspect-ratio: 85.6 / 53.98;
  padding: 16px; border-radius: 14px; overflow: hidden; color: #1F2933; background: #E8EBF0 center / cover no-repeat;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .14); }
.brand-card-logo { position: absolute; top: 16px; left: 16px; max-width: 56px; max-height: 56px; object-fit: contain; }
.brand-card-name { font-size: 1.1rem; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.brand-card-desc { margin-top: 4px; font-size: .8rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.brand-card-locale { position: absolute; right: 14px; bottom: 10px; font-size: .7rem; opacity: .85; }
.brand-card.is-issuer { justify-content: center; padding-left: 88px; background: #FFFFFF; border: 1px solid #D5DAE1; }
.brand-card.is-issuer .brand-card-logo { top: 50%; transform: translateY(-50%); }
/* Hosted issuing authorities' bar (authority_portal.go, _authority.html): the authority's name,
   the staff member's role there and the switcher. Each authority gets one of the portal's tinted
   tone pairs, so two authorities' portals look different at a glance. */
.ia-bar { display: inline-flex; align-items: center; gap: 8px; padding: 2px 4px 2px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); color: var(--text); min-width: 0; }
.ia-bar .ia-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }
.ia-bar .ia-role { font-size: .85em; white-space: nowrap; }
.ia-accent-0 { background: var(--info-soft); color: var(--info-text); border-color: var(--info-line); }
.ia-accent-1 { background: var(--ok-soft); color: var(--ok-text); border-color: var(--ok-line); }
.ia-accent-2 { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.ia-accent-3 { background: var(--neutral-soft); color: var(--neutral-text); border-color: var(--line-strong); }
/* ── Training (training.go): lessons, as the API references' Markdown pages are styled in
   client.css, scoped here; and a record prints alone. ────────────────────────────────── */
.training-body { line-height: 1.6; min-width: 0; }
.training-body h2 { font-size: 1.2rem; margin: 26px 0 10px; padding-top: 18px; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.training-body h2:first-child { margin-top: 4px; padding-top: 0; border-top: 0; }
.training-body h3 { font-size: 1.05rem; margin: 20px 0 8px; scroll-margin-top: 16px; }
.training-body p, .training-body ul, .training-body ol { margin: 0 0 12px; max-width: 82ch; }
.training-body li { margin: 3px 0; }
.training-body img { display: block; max-width: 100%; height: auto; margin: 8px 0 16px; border: 1px solid var(--line); border-radius: var(--r-md); }
.training-body code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: .86em; overflow-wrap: anywhere; }
.training-body .doc-code { position: relative; margin: 0 0 16px; }
.training-body .doc-code pre { margin: 0; padding: 14px 16px; background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; line-height: 1.5; }
.training-body .doc-code pre code { background: none; border: 0; padding: 0; font-size: .84rem; overflow-wrap: normal; }
.training-body .doc-copy { position: absolute; top: 8px; right: 8px; }
.training-body .doc-table { margin: 0 0 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.training-body .doc-table table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.training-body .doc-table th, .training-body .doc-table td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.training-body .doc-table th { background: var(--surface-2); font-weight: 600; }
.training-body .doc-table tr:last-child td { border-bottom: 0; }
@media print {
  .training-noprint, .skip-link { display: none !important; }
  .training-record { border: 0; box-shadow: none; }
}
