/* NM Backoffice portal. Built only on the NMBrand tokens (brand/tokens.css) and the density values of NMBrand docs/superficies/sistema-web.md:
   table text 14px, row 40px, content margin 24px, gap between blocks 16px, side menu 232px. No color, radius or font outside the tokens. */

@font-face { font-family: Figtree; font-weight: 400; font-style: normal; font-display: swap; src: url("/brand/figtree-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: Figtree; font-weight: 600; font-style: normal; font-display: swap; src: url("/brand/figtree-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: Figtree; font-weight: 700; font-style: normal; font-display: swap; src: url("/brand/figtree-latin-700-normal.woff2") format("woff2"); }

* { box-sizing: border-box; }
html { background: var(--background); }
body { margin: 0; background: var(--background); color: var(--text); font: 400 14px/1.5 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
.muted { color: var(--text-4); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.label { white-space: nowrap; }

/* Focus: 3px in brand, 2px away, on everything that takes focus. */
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
main:focus { outline: none; }

.skip-link { position: absolute; left: var(--space-8); top: -48px; z-index: 30; padding: var(--space-8) var(--space-12); border-radius: var(--radius-xs); background: var(--surface); border: 1px solid var(--border-strong); }
.skip-link:focus { top: var(--space-8); }

/* Shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.shell.collapsed { grid-template-columns: 56px minmax(0, 1fr); }
.menu { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--space-16); padding: var(--space-16) var(--space-8); background: var(--surface); border-right: 1px solid var(--border); overflow: hidden; }
.brand { display: flex; align-items: center; gap: var(--space-12); padding: 0 var(--space-8); min-height: 40px; }
.brand-name { display: flex; flex-direction: column; line-height: 1.2; font-size: 14px; }
.brand-name .muted { font-size: 12px; }
.logo { display: block; flex: none; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
.nav { flex: 1; overflow-y: auto; }
.nav-list { display: flex; flex-direction: column; gap: var(--space-4); }
.nav-link { position: relative; display: flex; align-items: center; gap: var(--space-12); min-height: 40px; padding: 0 var(--space-8); border-radius: var(--radius-xs); color: var(--text-3); text-decoration: none; font-weight: 600; }
.nav-link:hover { background: var(--hover); }
.nav-link[aria-current="page"], .nav-link[aria-current="true"] { background: var(--brand-background); color: var(--brand-dark); }
.nav-item.active > .nav-link { color: var(--text); }
.nav-sub { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-4); }
.nav-child { min-height: 36px; padding-left: calc(var(--space-8) + 18px + var(--space-12)); font-weight: 400; }
.nav-child[aria-current="page"] { font-weight: 600; }
.menu-footer { display: flex; flex-direction: column; gap: var(--space-4); border-top: 1px solid var(--border); padding-top: var(--space-8); }
.menu-action, .menu-toggle { position: relative; display: flex; align-items: center; gap: var(--space-12); min-height: 40px; padding: 0 var(--space-8); border: 0; border-radius: var(--radius-xs); background: none; color: var(--text-3); cursor: pointer; text-align: left; }
.menu-action:hover, .menu-toggle:hover { background: var(--hover); }
.collapsed .brand-name, .collapsed .nav-sub { display: none; }
.collapsed .nav-link .label, .collapsed .menu-action .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.collapsed .brand, .collapsed .nav-link, .collapsed .menu-action, .collapsed .menu-toggle { justify-content: center; padding-left: 0; padding-right: 0; }
.icon { flex: none; }

.content { padding: var(--space-24); display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }
.page { display: flex; flex-direction: column; gap: var(--space-16); }
.page-title { font-size: 22px; line-height: 1.25; font-weight: 700; }
.meta { display: flex; align-items: center; gap: var(--space-8); }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-8); min-height: 36px; padding: 0 var(--space-16); border: 1px solid var(--control-border); border-radius: var(--radius-xs); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--hover); }
.btn:disabled { color: var(--text-muted); cursor: default; }
.btn-primary { border-color: var(--brand); background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-dark); color: var(--on-brand); }
.btn-compact { min-height: 32px; padding: 0 var(--space-12); }
.btn[hidden], .chip[hidden] { display: none; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: var(--radius-xs); background: none; color: var(--text-4); cursor: pointer; }
.icon-button:hover { background: var(--hover); color: var(--text); }
.field { min-height: 36px; width: 240px; padding: 0 var(--space-12); border: 1px solid var(--control-border); border-radius: var(--radius-s); background: var(--surface); }
.chip { min-height: 32px; padding: 0 var(--space-12); border: 1px solid var(--control-border); border-radius: var(--radius-pill); background: var(--surface); font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-background); color: var(--brand-dark); font-weight: 600; }

/* Table */
.table-block { display: flex; flex-direction: column; gap: var(--space-12); }
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-12); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.table-count { margin-left: auto; color: var(--text-4); font-size: 13px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { height: 40px; padding: 0 var(--space-12); border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.data-table td { height: 40px; padding: 0 var(--space-12); border-bottom: 1px solid var(--highlight-soft); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--row-hover); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.sort-button { display: inline-flex; align-items: center; gap: var(--space-4); border: 0; background: none; padding: 0; font-weight: 600; font-size: 13px; color: inherit; cursor: pointer; }
.identifier { display: inline-flex; align-items: center; gap: var(--space-4); }
.copy-status { color: var(--brand-dark); font-size: 12px; }
.copy-status:empty { display: none; }

/* Badge: color AND word, 13px, radius 8. Red only as text and icon, never as a block. */
.badge { display: inline-flex; align-items: center; gap: var(--space-4); padding: 2px var(--space-8); border: 1px solid transparent; border-radius: var(--radius-xs); font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge .icon { width: 14px; height: 14px; }
.badge-ok { background: var(--brand-background); color: var(--brand-dark); }
.badge-wait { background: var(--attention-background); border-color: var(--attention); color: var(--attention-dark); }
.badge-problem { border-color: var(--border-strong); background: var(--surface); color: var(--error); }
.badge-neutral { background: var(--highlight-soft); color: var(--text-4); }

/* States */
.state-loading { color: var(--text-4); }
.state-empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-12); padding: var(--space-16); border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); max-width: 66ch; }
.table-message .state-empty { border: 0; }
.notice { display: flex; align-items: flex-start; gap: var(--space-12); padding: var(--space-12) var(--space-16); border: 1px solid var(--border-strong); border-radius: var(--radius-m); background: var(--surface); }
.notice > div { flex: 1; }
.notice-error > .icon { color: var(--error); margin-top: 3px; }

/* Dialog: the one thing that floats. */
.dialog-backdrop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-start; justify-content: center; padding: 15vh var(--space-16) var(--space-16); background: var(--background); background: color-mix(in srgb, var(--background) 70%, transparent); }
.dialog { width: min(480px, 100%); display: flex; flex-direction: column; gap: var(--space-16); padding: var(--space-24); border: 1px solid var(--border-strong); border-radius: var(--radius-l); background: var(--surface); box-shadow: var(--shadow-floating); }
.dialog:focus { outline: none; }
.dialog-title { font-size: 18px; font-weight: 700; }
.dialog-failure { color: var(--error); }
.dialog-failure:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-8); }

/* Customers and Customer (P2) */
.small { font-size: 12px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-16); flex-wrap: wrap; }
.customer-head .page-head { justify-content: flex-start; }
.customer-head, .customer-body { display: flex; flex-direction: column; gap: var(--space-16); }
.note { max-width: 66ch; color: var(--text-3); }
.back-link { color: var(--text-3); width: fit-content; }
.region { display: flex; flex-direction: column; gap: var(--space-12); }
.attention-band { display: flex; flex-wrap: wrap; gap: var(--space-12); }
.attention-band[hidden], .chips[hidden] { display: none; }
.attention-item { display: inline-flex; align-items: center; gap: var(--space-8); min-height: 40px; padding: 0 var(--space-16); border: 1px solid var(--border-strong); border-radius: var(--radius-m); background: var(--surface); font-size: 14px; cursor: pointer; }
.attention-item:hover { background: var(--hover); }
.attention-item[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-background); color: var(--brand-dark); font-weight: 600; }
.attention-count { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.search-form { display: flex; gap: var(--space-8); }
.list-footer { display: flex; align-items: center; gap: var(--space-16); }
.cell-stack { display: flex; flex-direction: column; line-height: 1.3; }
.row-link { color: var(--text); font-weight: 600; text-underline-offset: 3px; }
.state-lines { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) 0; }
.state-lines li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); white-space: nowrap; }
.stack-inline { display: inline-flex; flex-wrap: wrap; gap: var(--space-4); }
.data-table td:has(.state-lines) { height: auto; }
.form { display: flex; flex-direction: column; gap: var(--space-8); }
.form label { font-weight: 600; font-size: 13px; }
.field-full { width: 100%; }
.field-area { padding: var(--space-8) var(--space-12); resize: vertical; }
select.field { appearance: auto; }

.block { display: flex; flex-direction: column; gap: var(--space-12); }
.block-title { font-size: 16px; font-weight: 700; }
.sub-block { display: flex; flex-direction: column; gap: var(--space-8); }
.sub-title { font-size: 14px; font-weight: 600; color: var(--text-3); margin: var(--space-8) 0 0; }
.situations { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-16); }
.situation { display: flex; flex-direction: column; gap: var(--space-8); padding: var(--space-16); border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); }
.situation p { max-width: 66ch; }
.situation-head { display: flex; align-items: center; gap: var(--space-12); flex-wrap: wrap; }
.situation-name { font-size: 14px; font-weight: 700; margin: 0; }
.usage-cell { display: inline-flex; align-items: center; gap: var(--space-8); }
.meter { width: 120px; height: 8px; appearance: none; border: 0; border-radius: var(--radius-xs); background: var(--highlight-soft); }
.meter::-webkit-meter-bar { height: 8px; border: 0; border-radius: var(--radius-xs); background: var(--highlight-soft); }
.meter::-webkit-meter-optimum-value, .meter::-webkit-meter-suboptimum-value, .meter::-webkit-meter-even-less-good-value { border-radius: var(--radius-xs); background: var(--control-border); }
.meter-near::-webkit-meter-optimum-value, .meter-near::-webkit-meter-suboptimum-value, .meter-near::-webkit-meter-even-less-good-value { background: var(--attention); }
.meter-over::-webkit-meter-optimum-value, .meter-over::-webkit-meter-suboptimum-value, .meter-over::-webkit-meter-even-less-good-value { background: var(--error); }
.meter::-moz-meter-bar { background: var(--control-border); border-radius: var(--radius-xs); }
.meter-near::-moz-meter-bar { background: var(--attention); }
.meter-over::-moz-meter-bar { background: var(--error); }

/* Service actions (P3) */
.strong { font-weight: 600; }
.action-bar { display: flex; flex-direction: column; gap: var(--space-12); }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-8); }
.switch { display: inline-flex; align-items: center; gap: var(--space-8); min-height: 36px; padding: 0 var(--space-12); border: 1px solid var(--control-border); border-radius: var(--radius-xs); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.switch:hover { background: var(--hover); }
.switch-track { position: relative; width: 28px; height: 16px; border-radius: var(--radius-pill); background: var(--highlight-soft); border: 1px solid var(--control-border); }
.switch-thumb { position: absolute; top: 1px; left: 1px; width: 12px; height: 12px; border-radius: var(--radius-pill); background: var(--text-4); }
.switch[aria-checked="true"] { border-color: var(--attention); background: var(--attention-background); color: var(--attention-dark); }
.switch[aria-checked="true"] .switch-track { border-color: var(--attention); background: var(--attention-background); }
.switch[aria-checked="true"] .switch-thumb { left: 13px; background: var(--attention-dark); }
.switch[aria-checked="true"] .muted { color: var(--attention-dark); }
.notice[hidden] { display: none; }
.notice-wait { border-color: var(--attention); background: var(--attention-background); color: var(--attention-dark); }
.notice-wait > .icon { margin-top: 3px; }
.dialog-lines { display: flex; flex-direction: column; gap: var(--space-8); }
.dialog-body { display: flex; flex-direction: column; gap: var(--space-12); max-height: 60vh; overflow-y: auto; }
.plain-list { display: flex; flex-direction: column; gap: var(--space-4); list-style: disc; padding-left: var(--space-16); }
.field-row { display: flex; flex-direction: column; gap: var(--space-4); }
.field-row label, .check-row label { font-weight: 600; font-size: 13px; }
.check-row { display: flex; align-items: center; gap: var(--space-8); }
.check-row[hidden] { display: none; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--brand); }
.radio-list { display: flex; flex-direction: column; gap: var(--space-4); max-height: 180px; overflow-y: auto; }
.radio-row { display: flex; align-items: center; gap: var(--space-8); min-height: 40px; padding: 0 var(--space-8); border: 1px solid var(--border); border-radius: var(--radius-xs); cursor: pointer; font-weight: 400; }
.radio-row:has(input:checked) { border-color: var(--brand); background: var(--brand-background); }
.panel-backdrop { justify-content: flex-end; align-items: stretch; padding: 0; }
.panel { width: min(520px, 100%); height: 100%; border-radius: var(--radius-xs); border-width: 0 0 0 1px; }
.panel .dialog-body { flex: 1; max-height: none; }
.preview-region { display: flex; flex-direction: column; gap: var(--space-8); }
.row-menu { position: relative; display: inline-block; }
.menu-list { position: fixed; z-index: 25; min-width: 200px; display: flex; flex-direction: column; padding: var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-m); background: var(--surface); box-shadow: var(--shadow-floating); }
.menu-list[hidden] { display: none; }
.menu-list li { list-style: none; }
.menu-item { display: block; width: 100%; min-height: 36px; padding: 0 var(--space-12); border: 0; border-radius: var(--radius-xs); background: none; text-align: left; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); }

/* Catalog, controls and the OAuth client (P4) */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-8) var(--space-24); margin: 0; }
.facts dt { color: var(--text-4); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.situation-observe { border: 2px solid var(--attention); padding: calc(var(--space-16) - 1px); }
.item-fieldset { display: flex; flex-direction: column; gap: var(--space-8); min-width: 0; margin: 0; padding: var(--space-12); border: 1px solid var(--border); border-radius: var(--radius-m); }
.item-fieldset legend { padding: 0 var(--space-4); font-weight: 700; }
.chip[aria-disabled="true"] { cursor: default; }

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

/* Usage and Audit (P5) */
.usage-band { display: flex; flex-direction: column; gap: var(--space-8); max-width: 66ch; padding: var(--space-16); border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); }
.usage-band-figure { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.filter-field { display: flex; flex-direction: column; gap: var(--space-4); }
.chip-chosen { display: inline-flex; align-items: center; gap: var(--space-8); min-height: 40px; }
.picker-results { display: flex; flex-direction: column; gap: var(--space-8); }
.picker-results:empty { display: none; }
.audit-value { margin: 0; max-width: 36ch; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.data-table td:has(.audit-value) { height: auto; padding-top: var(--space-8); padding-bottom: var(--space-8); vertical-align: top; }
.data-table td:has(.cell-stack) { vertical-align: top; }
.filter-bar { align-items: flex-end; }
