/* ==================================================================
   Nazorat — rack-instrument dashboard
   Ranglar ma'no tashiydi: yashil = sog'lom, sariq = ogohlantirish,
   qizil = xavf, mis (copper) = tuzilma belgilari.
   Butun interfeys qalin (bold) yozuvda terilgan.
   ================================================================== */

:root {
  --ink:        #0A0D12;
  --panel:      #10151D;
  --panel-2:    #151B25;
  --rail:       #202836;
  --rail-hi:    #2C3648;

  --text:       #EAEFF7;
  --muted:      #98A5B8;
  --faint:      #6D7A8D;

  --copper:     #C87E4F;
  --copper-dim: #6B4630;

  --ok:         #46D6A0;
  --warn:       #F2B441;
  --crit:       #FF6B6B;
  --idle:       #5A7FA8;

  --font-display: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body:    "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r-sm: 3px;
  --r-md: 6px;
  --r-lg: 10px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  background-image: radial-gradient(120% 60% at 50% -10%, rgba(200, 126, 79, 0.10), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--copper);
  color: #120700;
  font-weight: 700;
  border-radius: var(--r-md);
  text-decoration: none;
}
.skip:focus { left: 8px; }

.ico {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ------------------------------------------------------------------
   Yuqori panel
   ------------------------------------------------------------------ */

.rail {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(10, 13, 18, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rail);
}

.rail__inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.rail__scan {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 1px;
  width: 100%;
  overflow: hidden;
}
.rail__scan::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--copper), transparent);
  transform: translateX(-100%);
  animation: scan 1.1s linear infinite;
}
@keyframes scan { to { transform: translateX(100%); } }

.brand { display: flex; align-items: center; gap: 11px; }

.brand__mark { width: 22px; height: 22px; fill: var(--rail-hi); }
.brand__mark--hi { fill: var(--copper); }

.brand__text { display: flex; flex-direction: column; line-height: 1; }

.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.06em;
}

.brand__sub {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--faint);
}

.tally {
  display: flex;
  gap: 22px;
  margin: 0;
  padding: 0 0 0 24px;
  border-left: 1px solid var(--rail);
}

.tally__item dt {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

.tally__item dd {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tally__of { color: var(--faint); font-weight: 600; }

.rail__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pick { display: flex; align-items: center; gap: 7px; }

.pick__label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.pick__select {
  appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--rail);
  border-radius: var(--r-md);
  padding: 7px 26px 7px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%2398A5B8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}

/* ------------------------------------------------------------------
   Tugmalar
   ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}

.btn--solid {
  background: var(--copper);
  color: #180B02;
  font-weight: 700;
}
.btn--solid:hover { background: #D89163; }

.btn--ghost {
  border-color: var(--rail);
  background: var(--panel-2);
  color: var(--text);
}
.btn--ghost:hover { border-color: var(--rail-hi); background: #1A2130; }

.btn kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border: 1px solid var(--rail-hi);
  border-radius: var(--r-sm);
  color: var(--faint);
}

.icobtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms var(--ease), background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.icobtn:hover { color: var(--text); background: var(--panel-2); border-color: var(--rail); }
.icobtn--danger:hover { color: var(--crit); border-color: rgba(255, 107, 107, 0.35); }

/* ------------------------------------------------------------------
   Sahifa tanasi
   ------------------------------------------------------------------ */

.hosts {
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.list { display: flex; flex-direction: column; gap: 18px; }

.empty {
  max-width: 460px;
  margin: 90px auto;
  text-align: center;
}

.empty__mark {
  width: 64px;
  height: 64px;
  fill: none;
  stroke: var(--rail-hi);
  stroke-width: 2;
  margin-bottom: 22px;
}
.empty__led { fill: var(--copper); stroke: none; }

.empty__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.01em;
  margin: 0 0 10px;
}

.empty__text { color: var(--muted); font-weight: 600; margin: 0 0 24px; }

.steps {
  margin: 0 0 22px;
  padding: 14px 16px;
  text-align: left;
  background: var(--ink);
  border: 1px solid var(--rail);
  border-left: 2px solid var(--copper);
  border-radius: var(--r-md);
  overflow-x: auto;
}
.steps code {
  display: block;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.8;
  color: var(--text);
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
}

/* ------------------------------------------------------------------
   Host paneli
   ------------------------------------------------------------------ */

.host {
  background: var(--panel);
  border: 1px solid var(--rail);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.host[data-state="down"] { border-color: rgba(255, 107, 107, 0.3); }

.host__head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rail);
}

.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.led[data-s="up"]   { background: var(--ok);   box-shadow: 0 0 0 3px rgba(70, 214, 160, 0.14); }
.led[data-s="down"] { background: var(--crit); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.14); }
.led[data-s="wait"] { background: var(--warn); box-shadow: 0 0 0 3px rgba(242, 180, 65, 0.14); }

.host__id { min-width: 0; }

.host__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host__addr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
}
.host__addr b { color: var(--muted); font-weight: 700; }

.host__tools { margin-left: auto; display: flex; align-items: center; gap: 4px; }

.stamp {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin-right: 8px;
  white-space: nowrap;
}

/* --- vitallar ---------------------------------------------------- */

.vitals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 22px;
  align-items: center;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.014), transparent);
  border-bottom: 1px solid var(--rail);
}

.gauge__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.gauge__name {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--faint);
}

.gauge__val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gauge__sub {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--faint);
}

/* Segmentli o'lchagich — rack/VU uslubi */
.meter {
  position: relative;
  height: 9px;
  background: var(--rail);
  border-radius: 1px;
  overflow: hidden;
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 6px);
  mask-image: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 6px);
}

.meter__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--ok);
  transition: width 420ms var(--ease), background-color 420ms var(--ease);
}
.meter[data-level="warn"] .meter__fill { background: var(--warn); }
.meter[data-level="crit"] .meter__fill { background: var(--crit); }

.trend { text-align: right; }

.trend__chart {
  display: block;
  width: 108px;
  height: 30px;
  overflow: visible;
}
.trend__line { fill: none; stroke: var(--copper); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend__area { fill: rgba(200, 126, 79, 0.12); stroke: none; }

.trend__label {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--faint);
}

/* --- xatolik chizig'i --------------------------------------------- */

.fault {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  color: #FFC2C2;
  background: rgba(255, 107, 107, 0.07);
  border-bottom: 1px solid rgba(255, 107, 107, 0.2);
  font-size: 13px;
  font-weight: 700;
}
.fault .ico { color: var(--crit); }

/* --- ikki ustun ---------------------------------------------------- */

.panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.pane { padding: 14px 18px 18px; min-width: 0; }
.pane + .pane { border-left: 1px solid var(--rail); }

.pane__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--rail);
}

.pane__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pane__count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
}
.pane__count b { color: var(--ok); font-weight: 700; }

.pane__note {
  margin: 6px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--faint);
}
.pane__note--warn { color: var(--warn); }

/* --- jarayonlar jadvali ------------------------------------------- */

.rows { display: flex; flex-direction: column; }

.rowhead,
.row,
.group__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px 58px 66px;
  gap: 10px;
  align-items: center;
}

.rowhead {
  padding: 4px 0 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.rowhead span:not(:first-child),
.row > .num { text-align: right; }

.row {
  padding: 8px 0;
  border-top: 1px solid rgba(32, 40, 54, 0.65);
}
.row:first-of-type { border-top: none; }

/* --- compose loyihasi bo'yicha guruh -------------------------------- */

.group + .group {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--rail);
}

.group__head { padding: 2px 0 7px; }

.group__name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--copper);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group__name--loose { color: var(--faint); font-style: italic; }

.group__num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--faint);
  white-space: nowrap;
}
.group__num.num--warn { color: var(--warn); }
.group__num.num--crit { color: var(--crit); }

/* guruh ichidagi qatorlar biroz ichkariroq */
.group .rows { padding-left: 10px; border-left: 1px solid rgba(200, 126, 79, 0.22); }

.row__id { min-width: 0; display: flex; align-items: center; gap: 8px; }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: var(--faint);
}
.dot[data-s="online"]  { background: var(--ok); }
.dot[data-s="running"] { background: var(--ok); }
.dot[data-s="stopped"] { background: var(--faint); }
.dot[data-s="exited"]  { background: var(--faint); }
.dot[data-s="errored"] { background: var(--crit); }
.dot[data-s="dead"]    { background: var(--crit); }
.dot[data-s="paused"]  { background: var(--warn); }
.dot[data-s="restarting"] { background: var(--warn); }

.row__text { min-width: 0; }

.row__name {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row__meta {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.num--dim { color: var(--faint); }
.num--warn { color: var(--warn); }
.num--crit { color: var(--crit); }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--rail-hi);
  color: var(--muted);
}
.tag--crit { border-color: rgba(255, 107, 107, 0.4); color: var(--crit); }

/* ------------------------------------------------------------------
   Modal
   ------------------------------------------------------------------ */

.sheet {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--rail-hi);
  border-radius: var(--r-lg);
  background: var(--panel);
  color: var(--text);
}
.sheet::backdrop { background: rgba(5, 7, 10, 0.7); backdrop-filter: blur(3px); }
.sheet--tight { width: min(400px, calc(100vw - 32px)); }

.sheet__form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.sheet__head { margin-bottom: 2px; }

.sheet__title {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.field label em { color: var(--copper); font-style: normal; }

.field input {
  background: var(--ink);
  border: 1px solid var(--rail);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 160ms var(--ease);
}
.field input:hover { border-color: var(--rail-hi); }
.field input:focus { border-color: var(--copper); outline: none; }
.field input::placeholder { color: var(--faint); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2:has(.field--narrow) { grid-template-columns: 1fr 110px; }

.hint { margin: 0; font-size: 11.5px; font-weight: 600; color: var(--faint); line-height: 1.4; }

.check { display: flex; gap: 11px; align-items: flex-start; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }

.check__box {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: none;
  border: 1px solid var(--rail-hi);
  border-radius: var(--r-sm);
  background: var(--ink);
  display: grid;
  place-items: center;
}
.check__box svg { width: 12px; height: 12px; fill: none; stroke: #180B02; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check input:checked + .check__box { background: var(--copper); border-color: var(--copper); }
.check input:checked + .check__box svg { opacity: 1; }
.check input:focus-visible + .check__box { outline: 2px solid var(--copper); outline-offset: 2px; }

.check__text { font-size: 13px; font-weight: 700; display: flex; flex-direction: column; gap: 2px; }

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-weight: 700;
  background: var(--panel-2);
  border: 1px solid var(--rail);
  border-radius: var(--r-sm);
  padding: 0 4px;
}

.sheet__error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.25);
  color: #FFC2C2;
  font-size: 12.5px;
  font-weight: 700;
}

.sheet__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--rail);
  margin-top: 2px;
}
.sheet__foot .btn { padding-top: 9px; padding-bottom: 9px; }

/* ------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------ */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 340px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--panel-2);
  border: 1px solid var(--rail-hi);
  border-left: 2px solid var(--crit);
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: rise 220ms var(--ease);
}
.toast--ok { border-left-color: var(--ok); }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------
   Moslashuvchanlik
   ------------------------------------------------------------------ */

@media (max-width: 1180px) {
  .vitals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .trend { display: none; }
}

@media (max-width: 1023px) {
  .panes { grid-template-columns: minmax(0, 1fr); }
  .pane + .pane { border-left: none; border-top: 1px solid var(--rail); }
  .tally { display: none; }
}

@media (max-width: 767px) {
  .rail__inner { flex-wrap: wrap; padding: 12px 16px; gap: 12px; }
  .rail__actions { width: 100%; margin-left: 0; }
  .rail__actions .btn { flex: 1; justify-content: center; }
  .btn kbd { display: none; }
  .hosts { padding: 18px 14px 60px; }
  .vitals { grid-template-columns: 1fr; gap: 14px; padding: 14px; }
  .host__head { flex-wrap: wrap; padding: 13px 14px; }
  .host__tools { width: 100%; margin-left: 0; justify-content: space-between; }
  .pane { padding: 13px 14px 16px; }
  .rowhead, .row, .group__head { grid-template-columns: minmax(0, 1fr) 54px 62px; }
  .rowhead span:nth-child(2), .row .col-uptime, .group__head .col-uptime { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2:has(.field--narrow) { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
