/* ONESity Workspaces — frontend styling
   Palette derived from the ONESity logo: deep navy (structure/chrome) + brand
   green (primary actions/accents). Buttons use navy text on green rather than
   white-on-green — the brand green is too light for white text to meet AA
   contrast, and navy-on-green doubles as a nod to the logo's own color pairing. */

:root {
  --color-navy: #16233f;
  --color-navy-2: #1f3157;
  --color-navy-tint: #eef1f7;

  --color-green: #7cb342;
  --color-green-hover: #6ba238;
  --color-green-text: #4b7a22;   /* AA-safe on white, used for links/small text */
  --color-green-light: #eef6e4;  /* tint background for pills */

  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-danger-light: #fef2f2;

  --color-text: #16233f;
  --color-text-muted: #5b6472;
  --color-border: #e3e7ed;
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;

  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.07);
  --shadow-card-hover: 0 4px 10px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
  margin: 0;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------------- */
/* Header — navy brand bar                                                */
/* ---------------------------------------------------------------------- */

header {
  background: var(--color-navy);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* The logo is the way home from any screen. */
.brand-home {
  display: flex;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 8px;
}
.brand-home:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.brand-logo-chip {
  background: #fff;
  border-radius: 8px;
  padding: 4px 9px;
  display: flex;
  align-items: center;
  line-height: 0;
}

.brand-logo {
  height: 26px;
  width: auto;
  display: block;
}

/* Shown by app.js only if static/ONESity_logo.png 404s, so the header still
   reads cleanly before the real asset is in place. */
.brand-logo-fallback {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--color-navy);
  line-height: normal;
}

.brand-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
}

.brand h1 {
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.75);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.current-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.1);
  padding: 0.3rem 0.7rem 0.3rem 0.3rem;
  border-radius: 999px;
}

.current-user .avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-green);
  color: var(--color-navy);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

header .link-btn {
  color: rgba(255, 255, 255, 0.8);
}

header .link-btn:hover {
  color: #fff;
}

/* ---------------------------------------------------------------------- */
/* Page layout                                                             */
/* ---------------------------------------------------------------------- */

.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

h2 {
  font-size: 1.02rem;
  font-weight: 600;
  margin: 0 0 1.1rem;
  letter-spacing: -0.01em;
  color: var(--color-navy);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
}

.card-head h2 { margin: 0; }

/* ---------------------------------------------------------------------- */
/* Auth view — full-bleed split screen (brand hero + form panel)           */
/* ---------------------------------------------------------------------- */

#auth-view {
  display: flex;
  min-height: calc(100vh - 66px);
}

/* The rule above's #id specificity beats the browser's own "[hidden] { display: none }"
   rule, so the JS setting authView.hidden = true silently did nothing without this. */
#auth-view[hidden] {
  display: none;
}

.auth-hero {
  flex: 1 1 46%;
  background:
    radial-gradient(circle at 15% 15%, rgba(124, 179, 66, 0.18), transparent 45%),
    linear-gradient(160deg, var(--color-navy), var(--color-navy-2));
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 3rem clamp(1.5rem, 6vw, 5rem);
}

.hero-logo-chip {
  background: #fff;
  border-radius: 18px;
  padding: 1.1rem 1.6rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  display: inline-flex;
  margin-bottom: 2rem;
  line-height: 0;
}

.hero-logo {
  height: 92px;
  width: auto;
  display: block;
}

.hero-logo-fallback {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-navy);
  margin: 0;
  line-height: normal;
}

.hero-tagline {
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.82);
  max-width: 30rem;
  margin: 0;
}

.auth-forms {
  flex: 1 1 54%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  background: var(--color-surface);
}

.auth-forms .card {
  width: 100%;
  max-width: 380px;
  box-shadow: none;
  border: none;
  padding: 0;
  margin-bottom: 0;
}

@media (max-width: 800px) {
  #auth-view { flex-direction: column; min-height: 0; }
  .auth-hero { padding: 2.5rem 1.5rem; align-items: center; text-align: center; }
  .hero-logo { height: 72px; }
  .hero-tagline { max-width: none; }
  .auth-forms { padding: 2.5rem 1.5rem 3rem; }
}

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */

form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

form input,
form select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: var(--color-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

form input:focus,
form select:focus {
  outline: none;
  border-color: var(--color-green);
  box-shadow: 0 0 0 3px var(--color-green-light);
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

button {
  font-family: inherit;
}

button[type="submit"],
.btn-primary,
.btn-refresh,
table button {
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 7px;
  background: var(--color-green);
  color: var(--color-navy);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
}

button[type="submit"]:hover,
.btn-primary:hover,
.btn-refresh:hover,
table button:hover {
  background: var(--color-green-hover);
}

button[type="submit"]:active,
.btn-primary:active,
table button:active {
  transform: translateY(1px);
}

button[type="submit"]:focus-visible,
table button:focus-visible,
.link-btn:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: 2px;
}

button[type="submit"]:disabled, .btn-primary:disabled, table button:disabled {
  background: #d7dbe3;
  color: #8b93a3;
  cursor: not-allowed;
  transform: none;
}

.btn-danger {
  background: transparent;
  color: var(--color-danger);
  border: 1px solid #fecaca;
  margin-left: 0.5rem;
}

.btn-danger:hover {
  background: var(--color-danger-light);
  border-color: var(--color-danger);
}

.btn-danger:disabled {
  background: transparent;
  color: #c7c9d9;
  border-color: var(--color-border);
}

.link-btn {
  background: none;
  border: none;
  color: var(--color-green-text);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 500;
}

.link-btn:hover { color: var(--color-green-hover); text-decoration: underline; }

.btn-refresh {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.btn-refresh:hover {
  background: #fafafa;
  color: var(--color-text);
}

/* ---------------------------------------------------------------------- */
/* Feedback text                                                          */
/* ---------------------------------------------------------------------- */

.error { color: var(--color-danger); font-size: 0.85rem; min-height: 1.2em; margin-top: 0.6rem; }
.success { color: #15803d; font-size: 0.85rem; margin-top: 0.6rem; }

/* ---------------------------------------------------------------------- */
/* Workspaces table                                                        */
/* ---------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  margin-top: 0.9rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  text-align: left;
  padding: 0.55rem 0.6rem;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
}

td {
  text-align: left;
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

tbody tr:hover { background: var(--color-navy-tint); }
tbody tr:last-child td { border-bottom: none; }

.ws-name { font-weight: 600; color: var(--color-navy); }
.ws-type { color: var(--color-text-muted); }

.actions-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.actions-cell .btn-danger,
.actions-cell .btn-secondary {
  margin-left: 0; /* actions-cell's own gap replaces the old sibling-margin approach */
}

.role-pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.role-owner  { background: var(--color-green-light); color: var(--color-green-text); }
.role-editor { background: #dbeafe; color: #1e40af; }
.role-viewer { background: #f3f4f6; color: #374151; }

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.status-running   { background: var(--color-green-light); color: var(--color-green-text); }
.status-stopped    { background: #f3f4f6; color: #374151; }
.status-creating,
.status-starting  { background: #dbeafe; color: #1e40af; }
.status-stopping,
.status-deleting   { background: #fef3c7; color: #92400e; }
.status-error       { background: #fee2e2; color: #991b1b; }
.status-deleted    { background: #f3f4f6; color: #9ca3af; }

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.88rem;
  padding: 1.5rem 0 0.5rem;
}

/* ---------------------------------------------------------------------- */
/* Admin view                                                              */
/* ---------------------------------------------------------------------- */

/* Both secondary views carry the same "back to workspaces" affordance in the
   same place, so they share one rule — two rules with identical values is how
   they drift apart later. */
.admin-view-head,
.assets-view-head {
  margin-bottom: 1.25rem;
  /* Stays in view under the sticky header while the page scrolls, so "back" is
     never a scroll to the top away. --header-h is measured from the header. */
  position: sticky;
  top: var(--header-h, 3.75rem);
  z-index: 9;
  background: var(--color-bg);
  padding: 0.6rem 0;
}

.admin-denied {
  background: var(--color-danger-light);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 0;
}

.bool-pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.bool-yes { background: var(--color-green-light); color: var(--color-green-text); }
.bool-no  { background: #f3f4f6; color: #6b7280; }

/* ---------------------------------------------------------------------- */
/* Invite dialog                                                           */
/* ---------------------------------------------------------------------- */

#invite-dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-hover);
  padding: 1.5rem;
  width: 100%;
  max-width: 380px;
}

#invite-dialog::backdrop {
  background: rgba(17, 24, 39, 0.45);
}

#invite-dialog h2 {
  margin-bottom: 1.1rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.btn-secondary {
  background: transparent;
  color: var(--color-navy);
  border: 1px solid var(--color-border);
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--color-navy-tint);
}

.btn-secondary:disabled,
.btn-secondary:disabled:hover {
  background: transparent;
  color: #8b93a3;
  cursor: not-allowed;
}

@media (max-width: 560px) {
  .header-inner { padding: 0.75rem 1rem; }
  .page { padding: 1.5rem 1rem 2.5rem; }
  .card { padding: 1.1rem; }
  .current-user span.label { display: none; }
  .brand h1 { display: none; }
  .brand-divider { display: none; }
}

/* ===========================================================================
   Assets & sharing (REQ-0001) — BATCH-002 ownership/versions, BATCH-003 sharing

   Reuses the existing card/table/dialog language; everything new here is either
   a permission badge or a way of showing *why* a control is unavailable. The
   permission ladder gets three distinct visual weights on purpose — VIEW, EDIT
   and MANAGE_SHARING are not interchangeable, and a single neutral pill would
   flatten exactly the distinction this screen exists to teach.
   =========================================================================== */

.hint {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin: 0.4rem 0 0.8rem;
  line-height: 1.5;
}
.hint code { background: var(--color-navy-tint); padding: 0 0.25rem; border-radius: 4px; }
.hint-inline {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 400;
  margin-left: 0.5rem;
}

.principal-card .principal-id {
  display: block;
  background: var(--color-navy-tint);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  /* A UUID must stay selectable and must not force the card to scroll
     horizontally on a narrow window — this is the value people copy by hand. */
  word-break: break-all;
  user-select: all;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}
.form-row > label { flex: 1 1 12rem; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}
.checkbox-label input { width: auto; margin: 0; }

/* The ladder. Weight increases with authority so the three levels are
   distinguishable at a glance and not only by reading the word. */
.perm-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.perm-view {
  background: var(--color-navy-tint);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.perm-edit {
  background: var(--color-green-light);
  color: var(--color-green-text);
  border-color: #cfe6b4;
}
.perm-manage_sharing {
  background: var(--color-navy);
  color: #ffffff;
}
.perm-none { background: transparent; color: var(--color-text-muted); }

.paid-cell { color: var(--color-green-text); font-weight: 600; }

/* A revoked grant stays on screen as history rather than disappearing — struck
   through so it reads as "was", not "is". */
.revoked-row { color: var(--color-text-muted); }
.revoked-row td:first-child { text-decoration: line-through; }

.wide-dialog { max-width: 46rem; width: calc(100vw - 2rem); }

.dialog-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  /* Close stays reachable in a long dialog. The head reaches up over the dialog's
     own padding so scrolled content never shows above it. */
  position: sticky;
  top: calc(-1 * var(--dialog-pad, 1.5rem));
  margin-top: calc(-1 * var(--dialog-pad, 1.5rem));
  padding-top: var(--dialog-pad, 1.5rem);
  background: #fff;
  z-index: 2;
}
#asset-dialog { --dialog-pad: 1em; }
.dialog-head h2 { margin: 0; flex: 1 1 auto; font-size: 1.1rem; }

.dialog-panel {
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
  margin-top: 1rem;
}
.dialog-panel h3 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
}

/* Dimmed, not hidden: a panel the caller may not use still tells them it exists
   and says which permission it would take — hiding it would teach nothing. */
.panel-disabled { opacity: 0.55; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-top: 0.75rem;
}
.inline-form > label { flex: 1 1 9rem; }
.inline-form button { flex: 0 0 auto; }

@media (max-width: 640px) {
  .form-row > label,
  .inline-form > label { flex-basis: 100%; }
}

/* ===========================================================================
   Paid entitlements and protected duplication (REQ-0001) — BATCH-004

   One new idea needs a visual language of its own here, and it is not "another
   permission": an entitlement lives on a different axis from VIEW/EDIT/
   MANAGE_SHARING, so it deliberately does NOT reuse `.perm-badge`. A licence
   pill that looked like a permission pill would teach exactly the conflation
   the backend spends three services preventing — that buying something is a
   kind of being shared it.

   The refusal boxes are the other half. REQ-0001 asks for the affected node to
   be "clearly identified as unlicensed", so a denial gets a panel with the
   node in it, not a red sentence — and the two refusals are coloured apart
   because they have different remedies (buy it vs. ask for access).
   =========================================================================== */

/* The commercial axis. Amber, not green/navy: it reads as a state of the
   world ("you have not bought this yet"), not as a rank on the ladder. */
.lic-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.lic-ok      { background: var(--color-green-light); color: var(--color-green-text); }
.lic-missing { background: #fef3c7; color: #92400e; }
.lic-free    { background: #f3f4f6; color: #6b7280; }

/* An unlicensed dependency stays fully legible — the structure is exactly what
   an unlicensed recipient is entitled to read. Only the licence cell changes. */
.unlicensed-row td { background: #fffbeb; }

/* Offer status. WITHDRAWN is muted rather than red: taking something off sale
   is not a failure, and it leaves every entitlement already sold untouched. */
.offer-active    { background: var(--color-green-light); color: var(--color-green-text); }
.offer-draft     { background: #dbeafe; color: #1e40af; }
.offer-withdrawn { background: #f3f4f6; color: #9ca3af; }

/* A UUID somebody is meant to copy out of a table (an offer id, an entitlement
   id). Monospace and selectable, small enough not to dominate its row. */
.id-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  user-select: all;
}

/* The execution gate's answer. Three outcomes, three colours, because the
   remedies differ: nothing to do / buy a licence / ask the owner for access. */
#asset-execution-result {
  margin-top: 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
}
#asset-execution-result h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}
.exec-ok       { background: var(--color-green-light); border-color: #cfe6b4 !important; }
.exec-unlicensed { background: #fffbeb; border-color: #fde68a !important; }
.exec-unreadable { background: var(--color-danger-light); border-color: #fecaca !important; }

/* One refused node inside the box. A list, not a sentence: REQ-0001 wants the
   node identified, and two missing nodes must not collapse into one line. */
.exec-node {
  border-top: 1px solid rgba(22, 35, 63, 0.1);
  padding: 0.5rem 0 0.15rem;
  margin-top: 0.5rem;
}
.exec-node:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.exec-node-name { font-weight: 600; }
.exec-node-meta { color: var(--color-text-muted); font-size: 0.8rem; }

/* The "obtain or request the required entitlement" action REQ-0001 asks to be
   future-compatible with. It is a button today and buys nothing — PLAN-0003
   puts a provider behind it — so it says what it does. */
.acquire-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.4rem;
}
.acquire-row button { font-size: 0.78rem; padding: 0.3rem 0.7rem; }
.acquire-none { color: var(--color-text-muted); font-size: 0.8rem; margin-top: 0.4rem; }

/* Wider than the invite box it grew out of: it now carries a member table as
   well as the add form. */
.members-dialog { max-width: 34rem; width: calc(100vw - 2rem); }
.members-dialog .dialog-head { margin-bottom: 0.9rem; }
.members-dialog select { padding: 0.3rem 0.5rem; font-size: 0.85rem; }

/* The role <select> inside a member row — a table control, not a form field, so
   it must not inherit the full-width block styling `form select` applies. */
.row-select {
  width: auto;
  min-width: 7rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
}

/* ===========================================================================
   Usability pass — guided creation, tabbed asset detail, workspace identity,
   destructive actions.

   Nothing here introduces a new palette or a new shape: the wizard steps, the
   tab strip and the two new dialogs are built from the same card surface,
   border colour and radius as everything above. What is new is *hierarchy* —
   one obvious action per row, one visible section at a time in the detail
   dialog, and a visually distinct danger area for the one action that cannot be
   undone from the UI.
   =========================================================================== */

/* --- guided create ------------------------------------------------------- */

.wizard-step {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  margin: 0 0 1rem;
}

.wizard-step legend {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 0 0.4rem;
}

/* Visible labels, always — a placeholder disappears the moment somebody types
   into the field, which is exactly when they may still need to know what it is. */
.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-navy);
  margin: 0.9rem 0 0.35rem;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

/* One card per option, each carrying its own one-sentence explanation. The
   radio stays a real radio — the label wraps it, so keyboard focus, arrow-key
   navigation within the group and screen-reader semantics are the browser's
   rather than something reimplemented here. */
.choice-card {
  flex: 1 1 14rem;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "radio title"
    ".     help";
  gap: 0.15rem 0.6rem;
  align-items: start;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  margin: 0;
}

.choice-card:hover { border-color: var(--color-green); }

.choice-card input[type="radio"] {
  grid-area: radio;
  width: auto;
  margin: 0.15rem 0 0;
}

.choice-card:focus-within {
  border-color: var(--color-green);
  box-shadow: 0 0 0 3px var(--color-green-light);
}

.choice-title {
  grid-area: title;
  font-weight: 600;
  color: var(--color-navy);
}

.choice-help {
  grid-area: help;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.45;
}

/* The advanced/internal material every screen keeps available without putting
   it in the primary path. Collapsed by default, and never the only place a
   required choice lives. */
.tech-details {
  margin-top: 0.9rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.7rem;
}

.tech-details > summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.tech-details > summary:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: 2px;
}

.create-success {
  border: 1px solid #cfe6b4;
  background: var(--color-green-light);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.create-success h3 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--color-green-text); }
.create-success .dialog-actions { margin-top: 0.8rem; }

/* --- the asset area: lists and the asset page (PLAN-0006) ----------------- */

/* The list switch: My assets, Shared with me, Catalog; purchases and sales
   after a gap. The selected list is marked by an underline AND by
   aria-pressed, never by colour alone. */
.list-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.25rem;
  border-bottom: 1px solid var(--color-border);
  margin: 0.4rem 0 1rem;
}

.list-switch-gap { flex: 1 1 1rem; }

.list-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  border-radius: 0;
}

.list-btn:hover { color: var(--color-navy); }
.list-btn-minor { font-size: 0.82rem; }

.list-btn-active {
  color: var(--color-navy);
  border-bottom-color: var(--color-navy);
}

.list-btn:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: -2px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.pager-info { font-size: 0.85rem; color: var(--color-text-muted); }

/* One asset page, three stacked sections — no tab strip. */
.asset-section {
  border-top: 1px solid var(--color-border);
  padding-top: 0.9rem;
  margin-top: 1rem;
}

.asset-section > h3 { margin: 0 0 0.6rem; }
.asset-section h4 { margin: 0 0 0.5rem; font-size: 0.95rem; }

/* Status in words; the tint only repeats what the text already says. */
.status-text { font-size: 0.85rem; font-weight: 600; }
.status-licensed { color: var(--color-green-text); }

.offer-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.row-input {
  width: 6rem;
  padding: 0.3rem 0.45rem;
  margin-right: 0.35rem;
}

/* Label/value pairs, so "what is this" is scannable rather than a paragraph. */
.summary-grid {
  display: grid;
  grid-template-columns: minmax(7rem, max-content) 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 0.8rem;
}

.summary-grid dt { font-weight: 600; color: var(--color-navy); font-size: 0.85rem; }
.summary-grid dd { margin: 0; font-size: 0.85rem; color: var(--color-text); line-height: 1.5; }

/* --- destructive actions ------------------------------------------------- */

/* Visually distinct from everything around it: its own tinted panel and a red
   rule, so a delete is never one more button in a row of equals. */
.danger-zone {
  margin-top: 1.2rem;
  border: 1px solid #f3c9c9;
  border-left: 4px solid var(--color-danger);
  background: var(--color-danger-light);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.danger-zone h3 {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
  color: var(--color-danger-hover);
}

/* Secondary row actions, grouped and set back from the primary one. */
.row-secondary {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding-left: 0.5rem;
  margin-left: 0.25rem;
  border-left: 1px solid var(--color-border);
}

/* --- the two new dialogs ------------------------------------------------- */

#workspace-dialog,
#delete-asset-dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-hover);
  padding: 1.5rem;
  width: 100%;
  max-width: 32rem;
  color: var(--color-text);
}

#workspace-dialog::backdrop,
#delete-asset-dialog::backdrop {
  background: rgba(17, 24, 39, 0.45);
}

#delete-asset-dialog h2 { margin-bottom: 0.6rem; font-size: 1.05rem; }
#delete-asset-dialog p { font-size: 0.9rem; line-height: 1.55; }

/* Two ids that look alike, so each gets its own row with its own copy button —
   there is no shared "copy" that could hand over the wrong one. */
.id-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

.id-row .principal-id {
  flex: 1 1 16rem;
  display: block;
  background: var(--color-navy-tint);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  word-break: break-all;
  user-select: all;
}

.id-row .btn-refresh { flex: 0 0 auto; }

@media (max-width: 560px) {
  .choice-card { flex: 1 1 100%; }
  .row-secondary { border-left: none; padding-left: 0; margin-left: 0; }
  .summary-grid { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .summary-grid dd { margin-bottom: 0.5rem; }
}

/* ---------------------------------------------------------------------------
   BATCH-004A — publishing from a Workspace, and installations
   --------------------------------------------------------------------------- */

/* The publish card is the primary action on the Assets screen, so it is given
   the emphasis the draft card used to have: a left rule in the accent colour,
   which reads as "start here" without needing a second heading level. */
#publish-card {
  border-left: 4px solid #2f6fed;
}

#publish-card select,
#publish-card input[type="text"],
#publish-card input:not([type]) {
  width: 100%;
  max-width: 32rem;
  margin-bottom: 0.25rem;
}

#installations-table td {
  vertical-align: middle;
}

/* Long enough to be a sentence rather than a label, so it needs room not to
   wrap into three lines in a table cell. */
#installations-table .actions-cell button {
  white-space: nowrap;
}

@media (max-width: 720px) {
  #publish-card select,
  #publish-card input {
    max-width: 100%;
  }
}

/* ---------------------------------------------------------------------------
   BATCH-012 (REQ-0003) — Plan & Credits view and the Workspace dialog's credit
   panels. Existing tokens only; these are the pieces the app did not have yet.
   --------------------------------------------------------------------------- */

/* The details dialog now carries tables (limits, usage), so it is allowed the
   width the approved mockup gives it. Narrow screens keep the old behaviour. */
#workspace-dialog { max-width: 47.5rem; }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill-green { background: var(--color-green-light); color: var(--color-green-text); }
.pill-navy  { background: var(--color-navy-tint); color: var(--color-navy-2); }
.pill-amber { background: #fef3c7; color: #92400e; }
.pill-grey  { background: #eef0f3; color: var(--color-text-muted); }

.credit-plan-name { font-size: 1.35rem; font-weight: 700; margin: 0; }

dl.plan-facts { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin: 0.9rem 0 0; }
.kv { display: grid; gap: 0.1rem; }
.kv dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.credit-mini-num { font-size: 1.4rem; }

/* Workspace details — About: the label reads like a .kv dt, the text keeps the
   owner's line breaks and wraps long words instead of widening the dialog. */
.about-label {
  margin: 0.9rem 0 0.1rem;
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.about-description { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.about-description.is-empty { color: var(--color-text-muted); font-style: italic; }

.credit-balance {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.credit-balance h3 { font-size: 0.95rem; margin: 0 0 0.35rem; }
.credit-avail-num {
  font-size: 2.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.credit-avail-label { font-size: 0.8rem; color: var(--color-text-muted); }
.credit-meter {
  height: 10px;
  background: var(--color-navy-tint);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  margin: 0.8rem 0 0.4rem;
}
.credit-meter span { display: block; height: 100%; }
.credit-meter-avail { background: var(--color-green); }
.credit-meter-held { background: #f0b429; }

.credit-sources { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.credit-sources td { border-bottom: 1px solid var(--color-border); padding: 0.45rem 0; }
.credit-sources td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.credit-sources tbody tr:hover { background: none; }

.credit-reset-line {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  background: var(--color-navy-tint);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}

.credit-warning {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num.plus { color: var(--color-green-text); font-weight: 600; }

.more-row { display: flex; justify-content: center; margin-top: 0.75rem; }

.limit-input {
  width: 7rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
  text-align: right;
}
.limit-actions { display: flex; gap: 0.5rem; justify-content: flex-end; align-items: center; }
.usage-bar {
  width: 90px;
  height: 6px;
  background: var(--color-navy-tint);
  border-radius: 999px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.4rem;
}
.usage-bar span { display: block; height: 100%; background: var(--color-green); }
.usage-bar.warn span { background: #f0b429; }

@media (max-width: 640px) {
  .credit-balance { grid-template-columns: 1fr; }
}


/* BATCH-021 @implements REQ-0003 */
.commercial-eyebrow { color: var(--color-text-muted); font-size: .68rem; font-weight: 700; letter-spacing: .12em; margin: 0 0 .35rem; }
.commercial-section { border-top: 1px solid var(--color-border); padding-top: 1.15rem; margin-top: 1.3rem; }
.commercial-section summary { cursor: pointer; color: var(--color-navy); font-weight: 600; padding-bottom: .8rem; }
.commercial-section h3 { font-size: .95rem; margin: 0 0 .75rem; }
.commercial-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.commercial-grid label, .commercial-form label { display: flex; flex-direction: column; gap: .4rem; font-size: .85rem; }
.commercial-full { grid-column: 1 / -1; }
.commercial-check, .commercial-grid .commercial-check, .commercial-model-option, .commercial-grid .commercial-model-option { display: flex; flex-direction: row; align-items: center; gap: .55rem; }
.commercial-check input, .commercial-model-option input, .commercial-capability input { width: auto; margin: 0; }
.commercial-form { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(160px, 2fr) auto; gap: .85rem; align-items: end; margin-top: 1rem; }
.commercial-key-row { display: flex; align-items: center; flex-wrap: wrap; gap: .8rem; padding: .85rem 0; border-bottom: 1px solid var(--color-border); font-size: .85rem; }
.commercial-key-row span { flex: 1; color: var(--color-text-muted); }
.commercial-capability { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; padding: .85rem 0; font-size: .85rem; }
.commercial-capability strong { min-width: 130px; }
.commercial-capability .hint { flex: 1; }
.commercial-capability code { font-size: .75rem; opacity: .7; overflow-wrap: anywhere; }
.commercial-plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 1rem; margin-top: 1.2rem; }
.commercial-plan-card { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.2rem; background: var(--color-navy-tint); }
.commercial-plan-card h3 { margin: 0 0 .5rem; }
.commercial-price { font-size: 1.25rem; font-weight: 650; margin: .5rem 0; }
.commercial-plan-card ul { padding-left: 1.15rem; font-size: .82rem; line-height: 1.75; }
.commercial-billing-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1rem; font-size: .85rem; }
.commercial-notice:empty { display: none; }
.commercial-notice { background: var(--color-navy-tint); border-left: 3px solid var(--color-green); padding: .85rem; border-radius: 4px; font-size: .85rem; line-height: 1.5; }
.commercial-notice.is-warning { background: #fef3c7; border-left-color: #b45309; color: #78350f; }
.commercial-field { display: flex; flex-direction: column; gap: .35rem; max-width: 28rem; margin-bottom: 1rem; font-size: .85rem; font-weight: 500; color: var(--color-text-muted); }
/* `display: flex` above would beat the browser's own `[hidden] { display: none }`, so a hidden field would still show. */
.commercial-field[hidden] { display: none; }
/* With real payments on, the test-billing controls (mock checkout, mock history, mock cancel) are not shown. */
.real-billing-on .mock-only { display: none; }
.commercial-field select { width: 100%; padding: .55rem .7rem; font-size: .95rem; font-family: inherit; color: var(--color-text); border: 1px solid var(--color-border); border-radius: 7px; background: var(--color-surface); }
.commercial-field select:focus { outline: none; border-color: var(--color-green); box-shadow: 0 0 0 3px var(--color-green-light); }
.commercial-section table { margin-top: 1rem; }
.commercial-billing-grid .commercial-wide { grid-column: 1 / -1; }
.commercial-section h4 { font-size: .85rem; margin: 1.2rem 0 0; }
.commercial-inline { display: flex; flex-wrap: wrap; gap: .85rem; align-items: end; margin-top: 1rem; }
.commercial-inline label { display: flex; flex-direction: column; gap: .4rem; font-size: .85rem; min-width: 12rem; }
.commercial-section td { overflow-wrap: anywhere; }
@media (max-width: 680px) {
  .commercial-grid, .commercial-form, .commercial-billing-grid { grid-template-columns: 1fr; }
  .commercial-full { grid-column: auto; }
  .commercial-key-row { align-items: flex-start; }
  .commercial-capability strong { width: 100%; }
}

.commercial-form[hidden] { display: none; }
