/* ==========================================================================
   Settings area
   ========================================================================== */

.settings-nav__back {
  position: relative; display: flex; align-items: center; gap: 10px; margin: 0 0 4px; padding: 6px 10px; border-radius: var(--radius);
  color: var(--sidebar-fg); font-size: 13.5px; font-weight: 450;
}
.settings-nav__back:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); text-decoration: none; }
.settings-nav__back > .icon { color: var(--sidebar-fg-muted); }
.settings-nav__back span { flex: 1; }
.settings-nav__title { display: flex; align-items: center; gap: 10px; margin: 14px 10px 0; font-weight: 600; font-size: 15px; color: var(--sidebar-fg-strong); }
.settings-nav__title .icon { color: var(--sidebar-fg-muted); width: 18px; height: 18px; }

/* ---------------------------------- page layout --------------------------------- */
.settings-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }
/* grid items (cards with tables inside) must be able to shrink on narrow screens */
.app--settings .stack { grid-template-columns: minmax(0, 1fr); }
.settings-stack--tight { gap: 14px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }

.card__heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card__heading h2, .card__heading h3 { font-size: 1.02rem; }
.card__sub { color: var(--text-2); font-size: 13px; margin-top: 2px; max-width: 70ch; }
.card__tabs { padding: 0 14px; }
.app--settings .card__header .badge, .app--settings .card__header .count-pill { flex: none; }

.row-actions { display: inline-flex; align-items: center; gap: 2px; flex-wrap: nowrap; }
.row-actions form, .inline-form { display: inline-flex; margin: 0; }
.btn--danger-text { color: var(--danger-ink); }
.btn--danger-text:hover { color: var(--danger-ink); background: var(--danger-soft); }
.btn.is-blocked { opacity: .5; }
.btn.is-done { color: var(--success-ink); border-color: color-mix(in srgb, var(--state-success) 40%, white); background: var(--success-soft); }
.context-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--text-2); font-size: 13.5px; }
.context-line .icon { color: var(--text-3); }
.context-line code, .callout code, .card__sub code { font-size: .85em; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text); }
.app--settings .callout > div { min-width: 0; }
.app--settings .callout a { text-decoration: underline; }
tr.is-inactive td { opacity: .6; }
tr.is-inactive td:last-child { opacity: 1; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat-strip__item { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
.stat-strip__item strong { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-strip__item span { color: var(--text-2); font-size: 12.5px; }

.table--compact td, .table--compact th { padding-top: 9px; padding-bottom: 9px; }
.entity__thumb--sm { width: 32px; height: 32px; border-radius: 9px; }
.entity__thumb--sm .icon { width: 16px; height: 16px; }

.segmented__option { display: inline-flex; cursor: pointer; position: relative; }
.segmented__option span { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 7px; color: var(--text-2); font-weight: 500; font-size: 13px; transition: background .15s, color .15s; }
.segmented__option:hover span { color: var(--text); }
.segmented__option input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.segmented__option input:focus-visible + span { box-shadow: var(--focus); }

/* explainers (collapsible) */
.json-details > summary, .field-kinds > summary { display: flex; align-items: center; gap: 12px; padding: 14px 20px; cursor: pointer; list-style: none; }
.json-details > summary::-webkit-details-marker, .field-kinds > summary::-webkit-details-marker { display: none; }
.json-details__title { display: grid; flex: 1; min-width: 0; }
.json-details__title small { color: var(--text-2); font-size: 13px; }
.json-details__chevron { color: var(--text-3); transition: transform .2s; }
details[open] > summary .json-details__chevron { transform: rotate(180deg); }
.json-details__body { display: grid; gap: 12px; padding: 0 20px 18px; min-width: 0; }
.json-details__body pre { overflow-x: auto; max-width: 100%; }
.json-block { margin: 0; padding: 16px 18px; border-radius: var(--radius); background: var(--ink); color: #E2E8F0; font-size: 12.5px; line-height: 1.6; overflow: auto; max-height: 360px; }
.json-block code { font-family: var(--mono); font-size: inherit; background: none; padding: 0; color: inherit; }

.field-kinds__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 0 22px 22px; }
.field-kind { display: grid; gap: 6px; align-content: start; padding: 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.field-kind p { color: var(--text-2); font-size: 13.5px; }
.field-kind strong { display: flex; align-items: center; gap: 8px; }
.kv-dot--category { background: var(--info); }
@media (max-width: 900px) { .field-kinds__grid { grid-template-columns: minmax(0, 1fr); } }

/* settings rows (parameters) */
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 320px); gap: 14px 28px; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row__label { display: grid; gap: 3px; }
.setting-row__label small { color: var(--text-2); font-size: 13px; max-width: 60ch; }
.setting-row__control .field { gap: 0; }
.setting-row__control .switch > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
@media (max-width: 720px) { .setting-row { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------- profile & images ------------------------------- */
.image-upload { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.image-upload__preview { display: grid; place-items: center; flex: none; transition: opacity .2s, filter .2s; }
.image-upload__preview.is-removed { opacity: .35; filter: grayscale(1); }
.image-upload__preview .org-avatar { width: 84px; height: 84px; border-radius: 22px; font-size: 26px; }
.image-upload__image { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08); }
/* logos are usually wide: shown whole, at their own proportions, in a wide frame */
.image-upload__preview--logo .org-avatar, .image-upload__preview--logo .image-upload__image {
  width: 180px; height: 84px; border-radius: var(--radius-lg); background: #fff; object-fit: contain; box-shadow: inset 0 0 0 1px var(--line);
}
.image-upload__preview--logo .org-avatar:not(.org-avatar--logo) { width: 84px; background: var(--brand-strong); box-shadow: none; }
.image-upload__preview--logo .org-avatar--logo img { padding: 10px 14px; }
.image-upload__body { display: grid; gap: 8px; min-width: 0; }
/* the generic image of an equipment category: a photo, shown like the asset cards (4:3) */
.image-upload__preview--generic .image-upload__image { width: 112px; height: 84px; border-radius: var(--radius); display: grid; place-items: center; }
.image-upload__remove { font-size: 13.5px; color: var(--text-2); }
.preference { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }

.session-list { display: grid; }
.session-item { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.session-item:last-child { border-bottom: 0; }
.session-item__icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.session-item.is-current .session-item__icon { background: var(--success-soft); color: var(--success-ink); }
.session-item__body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.session-item__body strong { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.session-item .button_to { margin: 0; }

/* -------------------------------- colour palette -------------------------------- */
.palette-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 28px; padding: 22px; }
.palette-editor__errors { grid-column: 1 / -1; }
.palette-editor__fields { display: grid; gap: 22px; align-content: start; min-width: 0; }
.palette-editor__preview { position: sticky; top: calc(var(--topbar-height) + 16px); align-self: start; display: grid; gap: 10px; }
@media (max-width: 1000px) { .palette-editor { grid-template-columns: minmax(0, 1fr); } .palette-editor__preview { position: static; order: -1; } }

.color-group h3 { font-size: .8rem; color: var(--text-3); margin-bottom: 8px; }
.color-list { display: grid; gap: 8px; }
.color-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 104px 32px; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); transition: border-color .15s, background .15s; }
.color-row.is-changed { border-color: var(--brand-line); background: var(--brand-soft); }
.color-row__swatch { position: relative; width: 44px; height: 44px; border-radius: 12px; background: var(--swatch, #ccc); box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .14); cursor: pointer; overflow: hidden; }
.color-row__swatch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.color-row__swatch:focus-within { box-shadow: var(--focus), inset 0 0 0 1px rgba(15, 23, 42, .14); }
.color-row__meta { display: grid; min-width: 0; line-height: 1.3; }
.color-row__meta small { color: var(--text-3); font-size: 12.5px; }
.color-row__auto { margin-top: 6px; font-size: 13px; gap: 8px; }
.color-row__auto input { width: 15px; height: 15px; margin-top: 1px; }
.color-row__hex:disabled { opacity: .7; }
.color-row__hex { font-size: 13px; text-transform: uppercase; text-align: center; padding: 0 8px; }
.color-row__hex:invalid { border-color: var(--state-danger); }
@media (max-width: 520px) { .color-row { grid-template-columns: 44px minmax(0, 1fr) 32px; } .color-row__hex { grid-column: 2; grid-row: 2; } }

.palette-checks { display: grid; gap: 10px; }
.contrast { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; }
.contrast > div { display: grid; line-height: 1.35; font-size: 14px; }
.contrast small { font-size: 12.5px; opacity: .85; }
.contrast__icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none; background: rgba(255, 255, 255, .6); }
.contrast.is-ok { background: var(--success-soft); color: var(--success-ink); border-color: color-mix(in srgb, var(--state-success) 28%, white); }
.contrast.is-bad { background: var(--danger-soft); color: var(--danger-ink); border-color: color-mix(in srgb, var(--state-danger) 28%, white); }
.palette-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.palette-footer form { margin: 0; }

/* live preview: derived tokens are redeclared so they follow the colours set on this element */
.palette-preview {
  --brand-ring: color-mix(in srgb, var(--brand) 32%, transparent);
  --brand-tint: color-mix(in srgb, var(--brand) 7%, white);
  --brand-line: color-mix(in srgb, var(--brand) 24%, white);
  --warning-soft: color-mix(in srgb, var(--state-warning) 11%, white);
  --warning-ink: color-mix(in srgb, var(--state-warning) 78%, black);
  --danger-soft: color-mix(in srgb, var(--state-danger) 9%, white);
  --danger-ink: color-mix(in srgb, var(--state-danger) 82%, black);
  --success-soft: color-mix(in srgb, var(--state-success) 10%, white);
  --success-ink: color-mix(in srgb, var(--state-success) 78%, black);
  --sidebar-fg: color-mix(in srgb, var(--sidebar-ink) 80%, var(--sidebar-bg));
  --sidebar-fg-strong: var(--sidebar-ink);
  --sidebar-fg-muted: color-mix(in srgb, var(--sidebar-ink) 52%, var(--sidebar-bg));
  --sidebar-active: color-mix(in srgb, var(--sidebar-ink) 8%, var(--sidebar-bg));
  --sidebar-line: color-mix(in srgb, var(--sidebar-ink) 9%, var(--sidebar-bg));
  display: grid; grid-template-columns: 132px minmax(0, 1fr); min-height: 300px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg);
}
.palette-preview__sidebar { display: grid; gap: 2px; align-content: start; padding: 14px 8px; color: var(--sidebar-fg); font-size: 12.5px;
  background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-line); }
.palette-preview__logo { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 0 6px; color: var(--sidebar-fg-strong); font-weight: 550; }
/* the product mark in miniature: the ring in the menu text colour, the core dot in the mark's accent */
.palette-preview__logo span { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 3.3px solid var(--sidebar-fg-strong);
  background: radial-gradient(circle, var(--sidebar-accent) 1.6px, transparent 2.1px); }
.pp-nav { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; }
.pp-nav .icon { color: var(--sidebar-fg-muted); }
.pp-nav.is-active { background: var(--sidebar-active); color: var(--sidebar-fg-strong); font-weight: 550; }
.pp-nav.is-active .icon { color: var(--sidebar-fg-strong); }
.palette-preview__main { display: grid; gap: 14px; align-content: start; padding: 16px; background: var(--bg); min-width: 0; }
.pp-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn--primary.pp-hover { --btn-bg: var(--brand-hover); --btn-border: var(--brand-hover); }
.pp-callout { font-size: 13px; padding: 10px 12px; }
.pp-bars { display: grid; gap: 8px; }
.palette-preview .btn { pointer-events: none; }

/* ----------------------------------- members ----------------------------------- */
.members-table td { vertical-align: middle; }
.members-table .entity__name { display: flex; align-items: center; gap: 8px; }
.invite-list { display: grid; }
.invite-item { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.invite-item__icon { width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.invite-item__body { display: grid; flex: 1; min-width: 200px; line-height: 1.35; }

.member-hero { display: flex; align-items: center; gap: 22px; padding: 24px; flex-wrap: wrap; }
.member-hero__body { display: grid; gap: 10px; min-width: 0; flex: 1; }
.member-hero__body h2 { font-size: 1.25rem; }
.member-hero__meta { display: flex; flex-wrap: wrap; gap: 6px 26px; }
.member-hero__meta dt { font-size: 12.5px; color: var(--text-3); }
.member-hero__meta dd { font-weight: 500; }
.member-mini { display: grid; gap: 10px; }
.member-mini li { display: flex; align-items: center; gap: 10px; }

.pill-select { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-option { position: relative; cursor: pointer; }
.pill-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill-option span { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-weight: 500; font-size: 13.5px; transition: all .15s; }
.pill-option span .icon { width: 0; margin-left: -6px; opacity: 0; transition: all .15s; }
.pill-option:hover span { border-color: var(--text-3); color: var(--text); }
.pill-option input:checked + span { background: var(--surface-3); border-color: var(--text-3); color: var(--text); }
.pill-option input:checked + span .icon { width: 14px; margin-left: 0; opacity: 1; }
.pill-option input:focus-visible + span { box-shadow: var(--focus); }
.pill-option input:disabled + span { opacity: .55; cursor: not-allowed; }

.grant-picker { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; display: grid; gap: 10px; min-width: 0; }
.grant-picker legend { padding: 0 6px; font-weight: 500; font-size: 13.5px; }
.grant-list { display: grid; max-height: 250px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.grant-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.grant-row:last-child { border-bottom: 0; }
.grant-row.is-selected { background: var(--surface-2); }
.grant-row .select { width: auto; min-width: 120px; flex: none; }
.grant-row .check { min-width: 0; }
.grant-row .check small { overflow-wrap: anywhere; }

/* the organization avatar inside "Voltar à aplicação" must not stretch with the label */
.settings-nav__back .org-avatar { flex: none; }

/* groups of characteristics of an equipment category (FieldDefinition#section): a heading row per group in the
   configuration table, a small heading in the asset's sheet and form */
.field-group__head th { background: var(--surface-2); font-weight: 600; color: var(--text); text-align: left; }
.field-group__head th .icon { color: var(--text-3); }
.field-group__head td { background: var(--surface-2); }
.kv-group { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin: 18px 0 2px; }
.kv-group:first-child { margin-top: 0; }
.form-grid > .form-grid__group { font-size: 13px; font-weight: 600; color: var(--text-2); padding-top: 12px; border-top: 1px solid var(--line); }
.form-grid > .form-grid__group:first-child { padding-top: 0; border-top: 0; }
