/* ==========================================================================
   Wireless Comms Matrix — page styles
   Builds on css/styles.css, css/led-tool.css and css/dmx-tool.css; adds only
   the comms tool's own components (prefixed .cm-).
   ========================================================================== */

.cm-layout [hidden] { display: none !important; }
.cm-layout textarea {
  width: 100%; min-height: 76px; resize: vertical;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
  font: inherit; font-size: 0.9rem; color: var(--color-text);
}
.cm-layout textarea:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; }

/* ---------- Partylines (input panel) ---------- */
.cm-channels { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.cm-ch {
  display: grid; grid-template-columns: 26px 30px minmax(0, 1fr) auto 26px; gap: 6px 8px; align-items: center;
  padding: 8px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
}
.cm-ch-no {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--c); color: #0b0b0f; font-size: 0.74rem; font-weight: 700;
}
.cm-ch input[type="color"] { width: 30px; height: 28px; padding: 0; border: 1px solid var(--color-border); border-radius: 4px; background: transparent; cursor: pointer; }
.cm-ch input[type="text"] {
  width: 100%; min-width: 0; padding: 7px 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-bg-alt); font-size: 0.88rem; color: var(--color-text);
}
.cm-ch input[type="text"]:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.cm-ch .cm-ch-desc { grid-column: 3 / 6; font-size: 0.8rem !important; padding: 5px 9px !important; color: var(--color-text-muted) !important; }
.cm-ch-move { display: inline-flex; flex-direction: column; }
.cm-ch-move button { border: 0; background: transparent; color: var(--color-text-muted); font-size: 0.55rem; line-height: 1; padding: 2px 4px; border-radius: 3px; }
.cm-ch-move button:hover:not(:disabled) { color: var(--white); background: var(--color-surface-4); }
.cm-ch-move button:disabled { opacity: 0.25; }
.cm-add-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.cm-add-row .btn { flex: 1 1 auto; }

/* ---------- Matrix ---------- */
.cm-matrix-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg-alt); }
.cm-matrix { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 0.84rem; }
.cm-matrix th, .cm-matrix td { border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border); padding: 0; }
.cm-matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--color-surface-2); }
.cm-mx-corner {
  left: 0; z-index: 3 !important; min-width: 210px; text-align: left; vertical-align: bottom;
  padding: 10px 12px !important; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted);
}
.cm-mx-corner span { display: block; }
.cm-mx-corner span + span { text-align: right; margin-top: -58px; margin-bottom: 44px; }
.cm-mx-col { width: 52px; min-width: 52px; height: 150px; vertical-align: bottom; border-top: 4px solid var(--c) !important; }
.cm-mx-col span {
  display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg);
  padding: 10px 0; font-weight: 700; color: var(--white); white-space: nowrap; max-height: 140px; overflow: hidden; text-overflow: ellipsis;
}
.cm-mx-col b { color: var(--c); margin-bottom: 6px; }
.cm-mx-row {
  position: sticky; left: 0; z-index: 1; background: var(--color-surface); text-align: left;
  padding: 7px 12px !important; min-width: 210px; max-width: 280px; font-weight: 400;
}
.cm-mx-row b { display: block; color: var(--white); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-mx-row small { display: block; color: var(--color-text-muted); font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-mx-group th {
  position: sticky; left: 0; text-align: left; padding: 6px 12px !important; background: var(--color-surface-3);
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-heading);
}
.cm-matrix td { text-align: center; }
.cm-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  width: 100%; min-height: 42px; border: 0; background: transparent; color: var(--white);
  font-weight: 700; font-size: 0.8rem; cursor: pointer; transition: background 120ms;
}
.cm-cell small { font-size: 0.62rem; font-weight: 600; opacity: 0.85; }
.cm-cell:hover { background: rgba(255, 255, 255, 0.06); }
.cm-cell:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.cm-cell.is-TL { background: #2fbf71; color: #06170d; }
.cm-cell.is-L { background: #25aae1; color: #04151d; }
.cm-cell.is-T { background: #f5a524; color: #1d1200; }
.cm-cell.is-TL:hover, .cm-cell.is-L:hover, .cm-cell.is-T:hover { filter: brightness(1.1); }
.cm-mx-total td, .cm-mx-total th { background: var(--color-surface-2); }
.cm-mx-total td { font-weight: 700; font-size: 0.8rem; color: var(--white); padding: 8px 2px; font-variant-numeric: tabular-nums; }
.cm-mx-total td.is-bad { color: #ff7a85; }
.cm-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-size: 0.8rem; color: var(--color-text-muted); align-items: center; }
.cm-legend i { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 4px; font-style: normal; font-weight: 700; font-size: 0.72rem; margin-right: 6px; }
.cm-legend .tl { background: #2fbf71; color: #06170d; }
.cm-legend .l { background: #25aae1; color: #04151d; }
.cm-legend .t { background: #f5a524; color: #1d1200; }
.cm-p2p { margin-top: 22px; }
.cm-p2p h3 { font-size: 0.95rem; margin-bottom: 10px; }

/* ---------- Beltpacks ---------- */
.cm-bps { display: flex; flex-direction: column; gap: 12px; }
.cm-bp { border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-2); padding: 14px 14px 12px; }
.cm-bp-head { display: grid; gap: 0 10px; grid-template-columns: 76px minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr) auto; align-items: end; }
.cm-bp-head .led-field { margin-bottom: 10px; }
.cm-bp-head .led-field input, .cm-bp-head .led-field select, .cm-dev-head .led-field input { padding: 8px 10px; font-size: 0.88rem; }
.cm-bp-actions { display: flex; gap: 2px; padding-bottom: 14px; }
.cm-dup svg { width: 15px; height: 15px; display: block; }
.cm-dup:hover { color: var(--white) !important; background: var(--color-surface-4) !important; }
.cm-keys { display: grid; gap: 8px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.cm-keys-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cm-key {
  border: 1px solid var(--color-border); border-top: 3px solid var(--c); border-radius: var(--radius-sm);
  padding: 6px; background: var(--color-surface); display: flex; flex-direction: column; gap: 5px; min-width: 0;
}
.cm-key:not(.is-set) { border-top-color: var(--color-border); }
.cm-key-no { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); }
.cm-key select {
  width: 100%; min-width: 0; padding: 6px 6px; font-size: 0.8rem; border-radius: 4px;
  border: 1px solid var(--color-border); background: var(--color-bg-alt); color: var(--color-text); color-scheme: dark;
}
.cm-key select:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.cm-key .cm-mode-sel { font-size: 0.74rem; color: var(--color-text-muted); }
.cm-key .cm-mode-sel:disabled { opacity: 0.4; }
.cm-bp-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-top: 16px; }
.cm-bp-tools .led-field { margin: 0; width: 90px; }
.cm-bp-tools .led-field input { padding: 9px 10px; }

/* ---------- Interfaces ---------- */
.cm-devices { display: flex; flex-direction: column; gap: 16px; }
.cm-dev { border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-2); padding: 14px; }
.cm-dev-head { display: grid; gap: 0 10px; grid-template-columns: auto minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; }
.cm-dev-head .led-field { margin-bottom: 8px; }
.cm-dev-head .dmx-x { margin-bottom: 14px; }
.cm-badge {
  align-self: center; margin-top: 10px; display: inline-block; padding: 5px 9px; border-radius: 4px;
  background: var(--color-primary); color: var(--white); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap;
}
.cm-dev-desc { font-size: 0.8rem; color: var(--color-text-muted); margin: 2px 0 12px; line-height: 1.45; }
.cm-dev-table { margin-top: 10px; }
.cm-io td { vertical-align: middle; white-space: normal; }
.cm-io td b { display: block; color: var(--white); font-weight: 600; white-space: nowrap; }
.cm-conn { display: block; color: var(--color-text-muted); font-size: 0.72rem; white-space: nowrap; }
.cm-io input[type="text"], .cm-io input[type="number"], .cm-io select {
  width: 100%; min-width: 110px; padding: 7px 9px; font-size: 0.84rem; border-radius: 4px;
  border: 1px solid var(--color-border); background: var(--color-bg-alt); color: var(--color-text); color-scheme: dark;
}
.cm-io select:disabled { opacity: 0.4; }
.cm-io input:focus, .cm-io select:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.cm-ant-no input { min-width: 0 !important; width: 64px !important; }
.cm-fixed { font-size: 0.8rem; color: var(--color-text-muted); }
.cm-chips { min-width: 150px; }
.cm-chip {
  display: inline-block; margin: 2px 4px 2px 0; padding: 3px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 600;
  background: color-mix(in srgb, var(--c) 22%, transparent); border: 1px solid var(--c); color: var(--white); white-space: nowrap;
}
.cm-chip em { font-style: normal; opacity: 0.75; margin-left: 2px; }
.cm-none { font-size: 0.76rem; color: var(--color-text-muted); font-style: italic; }
.cm-add-dev { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn.is-confirm { border-color: #e84855 !important; color: #ff7a85 !important; }

/* ---------- Responsive ---------- */
.cm-bp-head > :nth-child(1) { grid-area: no; }
.cm-bp-head > :nth-child(2) { grid-area: user; }
.cm-bp-head > :nth-child(3) { grid-area: role; }
.cm-bp-head > :nth-child(4) { grid-area: type; }
.cm-bp-head > :nth-child(5) { grid-area: act; }
.cm-bp-head { grid-template-areas: "no user role type act"; }
@media (max-width: 899px) {
  .cm-keys { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cm-keys-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cm-bp-head { grid-template-columns: 70px minmax(0, 1fr) minmax(0, 1fr) auto; grid-template-areas: "no user user act" "role role type type"; }
  .cm-dev-head { grid-template-columns: minmax(0, 1fr) auto; }
  .cm-dev-head .cm-badge { grid-column: 1; justify-self: start; margin: 0 0 10px; }
  .cm-dev-head .dmx-x { grid-column: 2; grid-row: 1; }
  .cm-dev-head .led-field { grid-column: 1 / -1; }
}
@media (max-width: 519px) {
  .cm-keys { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cm-bp-head { grid-template-areas: "no user user act" "role role role role" "type type type type"; }
  .cm-mx-row, .cm-mx-corner { min-width: 150px; max-width: 170px; }
}
