/* ArgusSOC, витяг «схема корпусу» для ArgusNOC. Стилі малювання (до chassis.js).
   Усе під коренем .ach, тож зі стилями сторінки не перетинається. Кольори теми: змінні --ach-*; темна тема типова, світла: data-theme="light" на корені.
   Кольори вогників (швидкість лінку, активність) сталі в обох темах. Анімація лише CSS; клас .noanim на корені її зупиняє. */
.ach {
  --ach-bg: #0f1419; --ach-bg2: #161b22; --ach-border: #2a3140; --ach-fg: #e6edf3; --ach-muted: #8b949e;
  --ach-acc: #12b886; --ach-ok: #37b24d; --ach-info: #4dabf7; --ach-warn: #f59f00; --ach-high: #ff7a1a; --ach-crit: #f03e3e; --ach-mute-bg: #2b313b;
  /* вогники: лівий (швидкість) і правий (активність) */
  --ach-led-bg: #0d1117; --ach-led-off: #2c333d; --ach-led-act: #b6ff3a;
  --ach-s100m: #f08c00; --ach-s1g: #2fbf4f; --ach-s10g: #3b8cff; --ach-s25g: #ffffff; --ach-s40g: #a78bfa; --ach-s100g: #2dd4bf; --ach-s200g: #ff5fa2; --ach-sx: #6b7280;
  /* скільки висоти вікна зайнято поза схемою (шапка сторінки, рядок підсумку): від цього залежить стискання схеми по висоті */
  --ach-vspace: 222px;
  color: var(--ach-fg); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; container-type: inline-size;
}
.ach[data-theme="light"] {
  --ach-bg: #f6f8fa; --ach-bg2: #ffffff; --ach-border: #d0d7de; --ach-fg: #1f2328; --ach-muted: #59636e;
  --ach-acc: #0c8a63; --ach-ok: #1a7f37; --ach-info: #0969da; --ach-warn: #9a6700; --ach-high: #bc4c00; --ach-crit: #cf222e; --ach-mute-bg: #eaeef2;
}
.ach *, .ach *::before, .ach *::after { box-sizing: border-box; }
.ach p { margin: 4px 0; } .ach .muted { color: var(--ach-muted); } .ach .small { font-size: 12px; } .ach .warn { color: var(--ach-warn); } .ach .nowrap { white-space: nowrap; }

/* --- гніздо порту --- */
.ach .pt-sq { display: inline-flex; flex-direction: column; align-items: center; justify-content: space-between; width: 24px; height: 28px; padding: 0; overflow: hidden; line-height: 1;
  border-radius: 3px; font-size: 9px; text-decoration: none; border: 1px solid var(--ach-border); color: var(--ach-fg); background: var(--ach-bg2); cursor: default; }
.ach a.pt-sq { cursor: pointer; }
.ach .pt-sq.up { background: var(--ach-ok); border-color: var(--ach-ok); color: #fff; }      /* лінк є */
.ach .pt-sq.off { background: var(--ach-mute-bg); color: var(--ach-muted); }                  /* вимкнено адміністратором */
.ach .pt-sq.down { background: transparent; }                                                /* лінка нема */
.ach .pt-sq.err { border: 2px solid var(--ach-warn); }                                       /* є помилки за 5 хв, годину або добу */
/* обвідка групи портів: шість кольорів по колу за порядком groups[]. Версія 2: без червоного, помаранчевого, жовтого й зеленого (вони лишені за помилками й оптикою):
   синій, бірюзовий, фіолетовий, рожевий, сірий, білий. Три середні кольори сталі, від теми не залежать */
.ach .pt-sq.lg0 { box-shadow: 0 0 0 2px var(--ach-info); } .ach .pt-sq.lg1 { box-shadow: 0 0 0 2px #2dd4bf; } .ach .pt-sq.lg2 { box-shadow: 0 0 0 2px #a78bfa; }
.ach .pt-sq.lg3 { box-shadow: 0 0 0 2px #ff5fa2; } .ach .pt-sq.lg4 { box-shadow: 0 0 0 2px var(--ach-muted); } .ach .pt-sq.lg5 { box-shadow: 0 0 0 2px var(--ach-fg); }
/* версія 2: точка стану оптики в правому верхньому куті гнізда. Кольори сталі в обох темах. nol: порожнє червоне кільце «нема світла»; off: сіра «порт вимкнено вручну» */
.ach .pt-sq { position: relative; }
.ach .pt-od { position: absolute; top: 1px; right: 1px; width: 6px; height: 6px; border-radius: 50%; border: 1px solid #0d1117; box-sizing: border-box; background: #8b949e; }
.ach .pt-od.ok { background: #37d05a; } .ach .pt-od.warn { background: #ffb400; } .ach .pt-od.crit { background: #ff3b3b; }
.ach .pt-od.nol { width: 7px; height: 7px; background: transparent; border: 1.5px solid #ff3b3b; } .ach .pt-od.off { background: #8b949e; }
.ach .pt-sq.bad .pt-od, .ach .sw-split .pt-od { display: none; }
.ach .pt-legend .pt-od { position: static; display: inline-block; margin-right: 2px; vertical-align: middle; }
.ach .pt-n { display: block; padding-top: 3px; white-space: nowrap; }
/* два вогники внизу гнізда: лівий pt-l1 швидкість лінку кольором, правий pt-l2 активність блиманням */
.ach .pt-leds { display: flex; justify-content: space-between; gap: 2px; width: 100%; padding: 2px; background: var(--ach-led-bg); }
.ach .pt-l1, .ach .pt-l2 { display: block; flex: 1 1 0; min-width: 0; height: 4px; border-radius: 1px; background: var(--ach-led-off); }
.ach .pt-l1.s100m { background: var(--ach-s100m); } .ach .pt-l1.s1g { background: var(--ach-s1g); } .ach .pt-l1.s10g { background: var(--ach-s10g); } .ach .pt-l1.s25g { background: var(--ach-s25g); }
.ach .pt-l1.s40g { background: var(--ach-s40g); } .ach .pt-l1.s100g { background: var(--ach-s100g); } .ach .pt-l1.s200g { background: var(--ach-s200g); } .ach .pt-l1.sx { background: var(--ach-sx); }
@keyframes achled { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .12; } }
.ach .pt-l2.act { background: var(--ach-led-act); animation: achled .8s linear infinite; }
.ach .pt-l2.a1 { animation-duration: 1.6s; } .ach .pt-l2.a2 { animation-duration: .8s; } .ach .pt-l2.a3 { animation-duration: .4s; } .ach .pt-l2.a4 { animation-duration: .2s; }
/* несправний порт (позначено вручну): штриховка, закреслений номер, вогників нема, зелена цятка, якщо лінк є */
.ach .pt-sq.bad { background: repeating-linear-gradient(135deg, #3a2326 0 4px, #2a1c1f 4px 8px); border: 1px solid #7a3b40; color: #c98a8f; text-decoration: line-through; position: relative; box-shadow: none; }
.ach .pt-sq.bad .pt-leds { visibility: hidden; } .ach .pt-sq.bad.up::after { content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--ach-ok); }

/* --- вентилятор і блок живлення --- */
.ach .pt-fan { display: inline-block; width: 18px; height: 18px; border-radius: 50%; color: var(--ach-muted); border: 1px solid currentColor;
  background: conic-gradient(currentColor 0 12%, transparent 0 25%, currentColor 0 37%, transparent 0 50%, currentColor 0 62%, transparent 0 75%, currentColor 0 87%, transparent 0); }
.ach .pt-fan.ok { color: var(--ach-ok); } .ach .pt-fan.warn { color: var(--ach-warn); } .ach .pt-fan.crit { color: var(--ach-crit); } .ach .pt-fan.mute { color: var(--ach-muted); opacity: .55; }
@keyframes achspin { to { transform: rotate(360deg); } } .ach .pt-fan.spin { animation: achspin 1.6s linear infinite; }
.ach .pt-psu { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 18px; padding: 0 4px; border: 1px solid currentColor; border-radius: 3px;
  font-size: 9px; font-style: normal; font-weight: 600; letter-spacing: .2px; line-height: 1; color: var(--ach-muted); }
.ach .pt-psu.ok { color: var(--ach-ok); } .ach .pt-psu.warn { color: var(--ach-warn); } .ach .pt-psu.crit { color: var(--ach-crit); } .ach .pt-psu.mute { color: var(--ach-muted); opacity: .6; }
.ach.noanim .pt-l2.act, .ach.noanim .pt-fan.spin { animation: none; }

/* --- запасна схема і «інші порти»: сітка у два ряди, стовпчиками --- */
.ach .pt-face { margin: 6px 0 10px; padding: 3px 3px 0; }
.ach .pt-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 18px; margin-bottom: 8px; }
.ach .pt-slot { max-width: 100%; min-width: 0; }
.ach .pt-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 28px); grid-auto-columns: minmax(0, 24px); gap: 5px; max-width: 100%; }
.ach .pt-grid .pt-sq { width: 100%; min-width: 0; } .ach .pt-grid .pt-sq.w2 { grid-column: span 2; }
.ach .pt-mgmt { display: inline-flex; align-items: center; gap: 6px; } .ach .pt-mgrow { display: flex; align-items: center; gap: 6px; }
.ach .pt-env { display: inline-flex; flex-direction: column; gap: 6px; margin: 0 0 0 auto; padding: 0 0 0 14px; border-left: 1px solid var(--ach-border); align-self: center; }
.ach .pt-env-g { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ach .pt-legend { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: center; margin-top: 4px; }
.ach .pt-legend .pt-sq { width: 11px; height: 11px; vertical-align: middle; margin-right: 2px; display: inline-block; }
.ach .pt-lgled { display: inline-flex; background: var(--ach-led-bg); padding: 2px 3px; border-radius: 2px; vertical-align: middle; } .ach .pt-lgled .pt-l1, .ach .pt-lgled .pt-l2 { flex: none; width: 10px; height: 5px; }

/* --- схема корпусу з таблиці ---
   --u: довжина одного «пікселя схеми». Схема вписується в ширину блока і у видиму висоту вікна: менше з двох обмежень, не більше 1px і не менше 0.7px
   (далі прокручується сама схема). Природні розміри --w0 і --h0 ставить chassis.js */
.ach .ach-ch { margin: 4px 0 6px; overflow-x: auto; padding: 3px; max-width: 100%;
  --w0: 1000; --h0: 230; --u: clamp(.7px, min(calc((100cqw - 8px) / var(--w0)), calc((100vh - var(--ach-vspace)) / var(--h0))), 1px); }
.ach .sw-stack { display: inline-flex; flex-direction: column; gap: calc(var(--u) * 8); min-width: max-content; }
.ach .sw-fr { display: flex; flex-direction: column; gap: calc(var(--u) * 8); padding: calc(var(--u) * 10) calc(var(--u) * 28); min-width: max-content; border: 1px solid var(--ach-border); border-radius: 6px; background: var(--ach-bg2); position: relative; }
/* вуха кріплення в стійку */
.ach .sw-fr::before, .ach .sw-fr::after { content: ""; position: absolute; top: 8px; bottom: 8px; width: 13px; border: 1px solid var(--ach-border); border-radius: 3px;
  background: radial-gradient(circle at 50% 22%, var(--ach-border) 0 3px, transparent 4px), radial-gradient(circle at 50% 78%, var(--ach-border) 0 3px, transparent 4px); }
.ach .sw-fr::before { left: 7px; } .ach .sw-fr::after { right: 7px; }
.ach .sw-tier { display: flex; gap: calc(var(--u) * 14); align-items: flex-end; }
/* решітка: широка (grow) тягнеться на всю вільну ширину поверху, вузька стоїть перед блоком */
.ach .sw-vent { flex: 1 1 60px; min-height: calc(var(--u) * 60); align-self: stretch; border: 1px solid var(--ach-border); border-radius: 4px; background: radial-gradient(circle, var(--ach-border) 1px, transparent 1.5px) 0 0 / 7px 7px; }
.ach .sw-vent.sw-vn { flex: 0 0 calc(var(--u) * 18); min-height: 0; }
.ach .sw-b { display: flex; flex-direction: column; gap: 3px; }
.ach .sw-box { border: 1px solid var(--ach-border); border-radius: 4px; padding: calc(var(--u) * 6) calc(var(--u) * 8); background: var(--ach-bg); }
.ach .sw-g { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, calc(var(--u) * 28)); grid-auto-columns: calc(var(--u) * 24); gap: calc(var(--u) * 4) calc(var(--u) * 3); }
.ach .sw-w .sw-g { grid-auto-columns: calc(var(--u) * 38); }
.ach .sw-g > .ach-wide { grid-column: span 2; }
.ach .ach-ch .pt-sq { width: 100%; min-width: 0; height: calc(var(--u) * 28); font-size: max(8px, calc(var(--u) * 10)); }
/* гніздо з таблиці без даних опитування і контури консолі та USB: пунктир */
.ach .ach-ch .pt-sq.sw-none, .ach .ach-ch .pt-sq.sw-con { border-style: dashed; color: var(--ach-muted); background: transparent; justify-content: center; }
.ach .ach-ch .pt-sq.sw-none .pt-n, .ach .ach-ch .pt-sq.sw-con .pt-n { padding: 0; } .ach .ach-ch .pt-sq.sw-con { border-radius: 0; }
/* розбитий порт: смужки в одному гнізді, кожна зі своїм станом; номера і вогників на смужці нема */
.ach .sw-split { display: flex; gap: 1px; min-width: 0; } .ach .ach-ch .sw-split .pt-sq { flex: 1 1 0; width: auto; border-radius: 1px; } .ach .sw-split .pt-n, .ach .sw-split .pt-leds { display: none; }
/* група керування: консоль «C», порт керування «M» (мідне гніздо з виступом), USB «U» */
.ach .sw-mgg { display: flex; align-items: flex-end; gap: calc(var(--u) * 4); } .ach .ach-ch .sw-mgg .pt-sq { width: calc(var(--u) * 28); flex: none; }
.ach .ach-ch .pt-sq.sw-cu { border-radius: 2px; position: relative; overflow: visible; margin-top: 4px; }
.ach .ach-ch .pt-sq.sw-cu::before { content: ""; position: absolute; top: -4px; left: 50%; width: 8px; height: 3px; margin-left: -5px; background: inherit; border: 1px solid var(--ach-border); border-bottom: 0; }
.ach .sw-cap { font-size: 10px; text-align: center; line-height: 1.2; } .ach .sw-box .sw-cap, .ach .sw-cap-top { width: 0; min-width: 100%; }
/* вигляд ззаду: другий корпус під переднім */
.ach .sw-back .sw-rl { text-align: left; } .ach .sw-units { align-items: stretch; gap: calc(var(--u) * 8); }
.ach .sw-unit { flex: 1 1 0; min-width: calc(var(--u) * 58); min-height: calc(var(--u) * 64); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px 4px;
  border: 1px solid var(--ach-border); border-radius: 4px; background: var(--ach-bg); font-size: max(8px, calc(var(--u) * 11)); color: var(--ach-muted); }
/* версія 2: довга назва блока переноситься, щонайбільше два рядки, далі три крапки; повна назва в підказці блока */
.ach .sw-unit { min-width: calc(var(--u) * 58); overflow: hidden; }
.ach .sw-unit b { color: var(--ach-fg); font-weight: 600; max-width: 100%; text-align: center; line-height: 1.15; white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; } .ach .sw-unit.sw-u-psu { flex-grow: 1.6; } .ach .sw-unit.sw-u-blank { border-style: dashed; background: transparent; }
.ach .sw-unit.ok .sw-ust { color: var(--ach-ok); } .ach .sw-unit.warn { border-color: var(--ach-warn); } .ach .sw-unit.warn .sw-ust { color: var(--ach-warn); } .ach .sw-unit.crit { border-color: var(--ach-crit); } .ach .sw-unit.crit .sw-ust { color: var(--ach-crit); }
.ach .sw-units .sw-mgg { align-self: center; } .ach .sw-units .pt-env { margin: 0; padding: 0; border: 0; align-self: center; }
.ach .ach-label { align-self: center; font-size: max(8px, calc(var(--u) * 10)); color: var(--ach-muted); white-space: nowrap; } .ach .ach-gap { flex: 0 0 calc(var(--u) * 14); }
