:root {
  color-scheme: light;
  --navy: #162c4b;
  --ink: #24354a;
  --muted: #536477;
  --line: #dce4ec;
  --blue: #265990;
  --wash: #eef4fb;
  --gold: #f7c953;
  background: #edf1f5;
  color: var(--ink);
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.visually-hidden, .quick-filter > span, .shell:has(#content:not([hidden])) .status:not([data-error]) {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
html[data-access-checking="1"] body > :not(#cloud504-login):not(#access-error-panel) { visibility: hidden; }
html[data-access-checking="1"]::before {
  content: "504 DEVICES\A Abriendo módulo…";
  white-space: pre;
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-content: center;
  background: #f8fafc;
  color: var(--navy);
  text-align: center;
  font-weight: 750;
  pointer-events: none;
}

.shell {
  width: min(860px, calc(100% - 28px));
  margin: 14px auto;
  border: 1px solid #c9d6e4;
  border-radius: 12px;
  overflow: hidden;
  background: white;
  box-shadow: 0 8px 24px #2239580b;
}
.topbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-inline: 12px;
  background: linear-gradient(115deg,#172d4b,#25496f);
  color: white;
}
.brand {
  display: grid;
  place-items: center;
  width: 32px;
  height: 22px;
  border-radius: 5px;
  background: var(--gold);
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}
h1 { flex: 1; margin: 0; font-size: 16px; font-weight: 670; }
button, select, input { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
.topbar :is(button,a) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 6px;
  color: white;
  text-decoration: none;
  white-space: nowrap;
  font-size: 12px;
}
#refresh { border: 0; background: transparent; font-size: 20px; }
#refresh[aria-busy] { opacity: .65; }
.status { padding: 8px 12px; font-size: 12px; }
.status[data-error] { color: #89293a; background: #fff6f7; }
:is(a,button,summary):focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.topbar :focus-visible { outline-color: var(--gold); }

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: center;
  min-height: 42px;
  padding: 6px 12px;
  background: #f4f7fb;
  color: var(--muted);
  font-size: 12px;
}
.metrics > * { white-space: nowrap; }
.metrics strong { margin-right: 2px; color: var(--navy); font-variant-numeric: tabular-nums; }
.metrics .primary strong { color: var(--blue); font-size: 17px; font-weight: 750; }
#pending-link { color: #805017; text-decoration-color: #ac793d; text-underline-offset: 2px; }
#pending-link strong { color: inherit; }
.toolbar {
  display: grid;
  grid-template-columns: minmax(145px,1.6fr) minmax(90px,.7fr) minmax(85px,.65fr) auto auto;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
}
.query { display: block; position: relative; min-width: 0; }
.query::before, .query::after { content: ""; position: absolute; pointer-events: none; }
.query::before {
  left: 10px;
  top: calc(50% - 6px);
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
}
.query::after {
  left: 18px;
  top: calc(50% + 3px);
  width: 6px;
  height: 1.5px;
  background: var(--muted);
  transform: rotate(45deg);
}
.toolbar :is(input, select, button), .filter-extra :is(select,button), .pager button, #more-pending, .more-units {
  min-height: 34px;
  max-width: 100%;
  padding-inline: 8px;
  border: 1px solid #bccbdd;
  border-radius: 6px;
  background: white;
  font-size: 12px;
}
#query { width: 100%; padding-left: 29px; }
#query::placeholder { color: #596b7d; opacity: 1; }
.quick-filter select { width: 100%; }
#filter-toggle { background: var(--wash); color: #234972; font-weight: 650; }
:is(input,select):focus { outline: 0; border-color: var(--blue); }
.filter-extra {
  display: grid;
  grid-template-columns: repeat(4,minmax(90px,1fr)) auto;
  gap: 7px;
  align-items: end;
  padding: 0 12px 10px;
}
.filter-extra label { display: grid; min-width: 0; gap: 3px; color: var(--muted); font-size: 11px; }
.filter-extra select { width: 100%; color: var(--ink); }

.results { padding: 0 12px 8px; }
.results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 3px 8px;
  min-height: 27px;
  margin-bottom: 5px;
}
.results-header h2 { margin: 0; color: var(--navy); font-size: 14px; font-weight: 700; }
.result-count { margin: 0; color: var(--muted); font-size: 11px; }
.table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; }
#matrix { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.capacity-col { width: 23%; }
.available-col { width: 19%; }
.total-col { width: 15%; }
#matrix :is(th,td) { padding: 4px 12px; }
#matrix thead th {
  height: 34px;
  border-bottom: 1px solid var(--line);
  background: #eaf1fa;
  color: var(--navy);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
}
#matrix thead :is(.available-heading,.total-heading) { text-align: center; }
.available-heading abbr { display: none; text-decoration: none; }
.model-group:nth-of-type(even) { background: #f9fbfd; }
#matrix .model-group:not(:first-of-type) > tr:first-child > * { border-top: 1px solid var(--line); }
#matrix .model-group .variant-row + .variant-row > * { border-top: 1px solid #ebf0f5; }
#matrix .model-cell { text-align: left; overflow-wrap: anywhere; }
.model-cell strong { display: block; color: var(--navy); font-weight: 675; }
.model-cell small { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; font-weight: 450; }
.capacity-cell { color: #3f5065; }
#matrix :is(.available-cell,.total-cell) { text-align: center; font-variant-numeric: tabular-nums; }
#matrix .available-cell { padding-block: 2px; }
.total-cell { background: #f0f5fb; color: var(--navy); font-size: 16px; font-weight: 750; }
.capacity-value {
  position: relative;
  min-width: 52px;
  min-height: 27px;
  max-width: 100%;
  padding: 2px 16px 2px 7px;
  border: 0;
  border-radius: 5px;
  background: #e8f0fb;
  color: #194b7b;
  font-weight: 725;
  font-variant-numeric: tabular-nums;
}
.capacity-value::after { content: "›"; position: absolute; top: 50%; right: 6px; translate: 0 -52%; color: #4c6e92; font-weight: 500; }
.capacity-value:hover, .capacity-value[aria-expanded="true"] { background: #d5e6fa; color: #123c65; }
#matrix .variant-row.active .capacity-cell { color: #194b7b; font-weight: 650; }
#matrix .detail-row td { padding: 0; border-top: 1px solid #d5e0ed; background: #eef5fc; }
.detail-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 12px;
  min-height: 39px;
  padding: 4px 10px;
  color: #395269;
  font-size: 12px;
}
.detail-line > strong { color: #194f7e; }
.colors { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 5px; }
.detail-line .reserved { color: #86500b; }
.open-units {
  min-height: 34px;
  margin-left: auto;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: #1c5589;
  font-size: inherit;
  font-weight: 650;
}
.units-panel { padding: 5px 10px 8px; background: white; }
.unit-summary, .empty { margin: 0; padding: 5px 0; color: var(--muted); font-size: 12px; }
.units, #pending-rows { list-style: none; margin: 0; padding: 0; }
.units li, #pending-rows li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.units small, #pending-rows small { display: block; color: var(--muted); }
.unit-state { flex: 0 0 76px; text-align: right; font-size: 11px; }
.unit-state strong { display: block; }
.unit-state[data-state="reserved"] { color: #86500b; }
.unit-state[data-state="review"], .unit-state[data-state="sold"] { color: #952d45; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-block: 7px 0; }
.pending { padding-inline: 12px; border-top: 1px solid #eadbc9; background: #fffbf4; }
.pending summary {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 37px;
  color: #694919;
  font-size: 12px;
  list-style: none;
}
.pending summary::-webkit-details-marker { display: none; }
.pending summary::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: #b87426; }
.pending summary strong { margin-left: auto; text-align: right; }
.pending summary::after { content: "›"; font-size: 16px; }
.pending[open] summary::after { rotate: 90deg; }
.pending p { margin: 0 0 6px; color: var(--muted); font-size: 11px; }
.pending[open] { padding-bottom: 8px; }

@media (max-width: 620px) {
  .shell { width: 100%; margin: 0; border: 0; border-radius: 0; }
  .topbar { min-height: 45px; padding-inline: 9px; }
  .topbar :is(button,a) { min-width: 36px; min-height: 44px; }
  #back span { display: none; }
  .metrics { gap: 0 10px; padding-inline: 8px; font-size: 11px; }
  .metrics .primary strong { font-size: 16px; }
  .toolbar { grid-template-columns: minmax(0,1fr) auto auto; gap: 5px; padding: 7px 8px; }
  .toolbar .quick-filter { grid-row: 2; }
  .toolbar .quick-filter:has(#brand) { grid-column: 2 / 4; }
  #filters:not([data-expanded]) .quick-filter { display: none; }
  .sort select { width: 85px; }
  .filter-extra { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 0 8px 8px; }
  .filter-extra button { justify-self: start; }
  .results { padding-inline: 8px; }
  .capacity-col { width: 68px; }
  .available-col { width: 56px; }
  .total-col { width: 45px; }
  #matrix :is(th,td) { padding-inline: 6px; }
  #matrix thead th { height: 30px; }
  .available-heading span { display: none; }
  .available-heading abbr { display: inline; }
  #matrix .available-cell { padding-inline: 2px; }
  .capacity-value { min-width: 44px; padding-left: 5px; }
  .detail-line { gap: 2px 8px; font-size: 11px; }
  .unit-state { flex-basis: 64px; }
  .pending { padding-inline: 8px; }
}
@media (pointer: coarse) {
  .toolbar :is(input,select,button), .filter-extra :is(select,button), .pager button,
  #more-pending, .more-units, .capacity-value, .open-units, .pending summary { min-height: 44px; }
  #matrix .available-cell { padding-block: 0; }
  .capacity-value { border-block: 5px solid transparent; border-radius: 9px; background-clip: padding-box; }
}
