:root {
  color-scheme: dark;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Consolas", "DejaVu Sans Mono", "Courier New", monospace;
  --bg: #0a101c;
  --panel: #111a2b;
  --panel-2: #172238;
  --line: #233150;
  --text: #e6ecf5;
  --text-2: #a7b5ca;
  --muted: #71829c;
  --accent: #3987e5;
  --accent-2: #2a6fc4;
  --ok: #2fbf71;
  --bad: #e5484d;
  --warn: #e0a000;
  --series-1: #3987e5;
  --chart-grid: rgba(167, 181, 202, .10);
  --chart-axis: #8393ab;
  --chart-cross: rgba(230, 236, 245, .35);
  /* HMI (MCGS) uslubi */
  --hmi-title-1: #2c66b0;
  --hmi-title-2: #1b437c;
  --hmi-body: #0c1830;
  --hmi-lcd-bg: #03130b;
  --hmi-lcd: #6dff9e;
  --hmi-lcd-dim: #2f7a4d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 var(--font); }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: #35507e; background: #1c2a45; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { color: #ffb4b6; border-color: #5a2a33; }
.btn.danger:hover { background: #3a1a20; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 5px 11px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-2); color: #fff; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select {
  background: #0b1424; border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; outline: none; min-width: 0; }
input:focus, select:focus { border-color: var(--accent); }
input[type=color] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
label.field > input, label.field > select { font-size: 14px; color: var(--text); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  background: rgba(10, 16, 28, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(var(--hmi-title-1), var(--hmi-title-2));
  display: grid; place-items: center; color: var(--hmi-lcd); font-family: var(--mono); font-size: 13px; }
.top-stats { display: flex; gap: 22px; margin-left: 8px; }
.top-stat { display: flex; flex-direction: column; line-height: 1.15; }
.top-stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.top-stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: 20px; }
.user-chip .role { font-size: 11px; color: var(--muted); }

.page { padding: 18px 20px 40px; max-width: 1800px; margin: 0 auto; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h2 { margin: 0 10px 0 0; font-size: 18px; font-weight: 600; }

/* ---------- HMI panel ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(410px, 1fr)); gap: 14px; }
.hmi { border-radius: var(--radius); overflow: hidden; background: var(--hmi-body); border: 1px solid #1f3560;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4) inset, 0 6px 20px rgba(0,0,0,.25); user-select: none; }
a.card { color: inherit; display: block; border-radius: var(--radius); transition: transform .12s, box-shadow .12s; }
a.card:hover { transform: translateY(-2px); }
a.card:hover .hmi, a.card:hover .mcgs { outline: 2px solid #3f6bb3; }
.hmi-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px;
  background: linear-gradient(var(--hmi-title-1), var(--hmi-title-2)); color: #fff; font-weight: 600; font-size: 13px; }
.hmi-title .hmi-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hmi-title .hmi-model { font-weight: 400; opacity: .75; font-size: 11px; white-space: nowrap; }
.hmi-body { padding: 10px 12px 6px; display: grid; gap: 6px; }
.hmi-row { display: grid; grid-template-columns: 74px 1fr 44px; align-items: center; gap: 8px; }
.hmi-lbl { color: #cfdcf0; font-size: 13px; }
.hmi-unit { color: #9fb3d1; font-size: 12px; }
.lcd { background: var(--hmi-lcd-bg); color: var(--hmi-lcd); font-family: var(--mono); font-size: 19px; text-align: right;
  padding: 2px 10px; border-radius: 4px; border: 1px solid #0e2d1c; text-shadow: 0 0 6px rgba(109,255,158,.45);
  font-variant-numeric: tabular-nums; min-height: 28px; letter-spacing: .02em; }
.lcd.stale { color: var(--hmi-lcd-dim); text-shadow: none; }
.lcd.err { color: #ff8f8f; font-size: 13px; text-shadow: none; }
.hmi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 10px; }
.state-btn { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; letter-spacing: .05em;
  padding: 4px 14px; border-radius: 5px; background: #2a3448; color: #c7d0de; border: 1px solid #3a465e; min-width: 78px; justify-content: center; }
.state-btn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state-btn.run { background: #0f3a22; color: #5ff09a; border-color: #1f6b40; }
.state-btn.stop { background: #3d1418; color: #ff8a8d; border-color: #7a2a30; }
.state-btn.off { background: #262b35; color: #8c95a5; border-color: #3a404c; }
.hmi-today { font-size: 12px; color: #b8c6dc; }
.hmi-today b { color: #fff; font-size: 14px; font-variant-numeric: tabular-nums; }
.hmi-bar { display: flex; justify-content: space-between; padding: 5px 12px; background: #091224; border-top: 1px solid #1b2c4d;
  font-size: 11px; color: #7f93b3; gap: 8px; }
.hmi-bar .err { color: #ff9a9a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hmi.big .hmi-row { grid-template-columns: 110px 1fr 60px; }
.hmi.big .lcd { font-size: 30px; min-height: 42px; }
.hmi.big .hmi-lbl { font-size: 16px; }
.hmi.big .hmi-unit { font-size: 14px; }
.hmi.big .hmi-title { padding: 10px 14px; font-size: 14px; }
.hmi.big .hmi-title .hmi-name { font-size: 16px; }
.hmi.big .hmi-body { padding: 14px 14px 8px; gap: 9px; }
.add-card { display: grid; place-items: center; min-height: 250px; border: 2px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); cursor: pointer; font-size: 15px; background: transparent; }
.add-card:hover { border-color: var(--accent); color: var(--text); }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.panel h3 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head .sub { color: var(--muted); font-size: 12px; }
.detail-top { display: grid; grid-template-columns: minmax(520px, 680px) 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 900px) { .detail-top { grid-template-columns: 1fr; } .top-stats { display: none; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi b { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi em { font-style: normal; color: var(--text-2); font-size: 13px; margin-left: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 230px; }
.multi .mini { position: relative; height: 130px; }
.multi .mini.tall { height: 200px; }
.multi .mini-title { font-size: 12px; color: var(--text-2); margin: 8px 0 0 4px; display: flex; gap: 6px; align-items: center; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 8px; }
.legend label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.legend label.off { opacity: .45; }
.legend input { display: none; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid rgba(35, 49, 80, .55); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl input[type=text], .tbl input[type=number], .tbl select { width: 100%; padding: 4px 7px; font-size: 13px; }
.tbl .live { font-family: var(--mono); color: var(--hmi-lcd); text-align: right; white-space: nowrap; }
.tbl tr.hit td { background: rgba(57, 135, 229, .15); }
.scroll { max-height: 420px; overflow: auto; }
.events { max-height: 230px; overflow: auto; font-size: 13px; }
.events div { display: flex; gap: 10px; padding: 4px 0; border-bottom: 1px solid rgba(35,49,80,.5); }
.events time { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.ev-online { color: var(--ok); } .ev-offline { color: var(--bad); } .ev-run { color: var(--ok); } .ev-stop { color: var(--warn); }

/* edit */
.edit-grid { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 14px; }
.hmi-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; }
.notice { padding: 10px 12px; border-radius: 8px; background: #1a2740; border: 1px solid #2b4170; color: var(--text-2); font-size: 13px; }
.notice.warn { background: #2e2410; border-color: #6b5417; color: #f1d58a; }
.notice.bad { background: #331418; border-color: #6e2a31; color: #ffb3b6; }
.notice.good { background: #0f2b1d; border-color: #1f6b40; color: #9ff0c2; }
.sticky-save { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; justify-content: flex-end; padding: 12px 0; margin-top: 14px; background: var(--bg); border-top: 1px solid var(--line); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); }
.badge.edit { background: #3b2a0a; border-color: #8a6414; color: #ffd27a; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(3, 6, 12, .7); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(560px, 100%); max-height: 92vh; overflow: auto; padding: 18px 20px; }
.modal.wide { width: min(900px, 100%); }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal .stack { display: grid; gap: 12px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(ellipse at top, #13233f 0%, var(--bg) 60%); }
.login { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px 26px 22px; }
.login h1 { margin: 10px 0 4px; font-size: 20px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.login .stack { display: grid; gap: 12px; }
.err-text { color: #ff9a9a; font-size: 13px; min-height: 18px; }

/* toast */
#toast-root { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 200; }
.toast { background: #1b2943; border: 1px solid #2f4673; padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.toast.bad { background: #3a161b; border-color: #7a2a30; }
.toast.good { background: #12321f; border-color: #1f6b40; }

/* chart tooltip */
.mc-wrap { position: relative; }
.mc-wrap canvas { display: block; }
.mc-tip { position: absolute; display: none; pointer-events: none; background: rgba(8, 13, 24, .96); border: 1px solid #2c3f66;
  border-radius: 7px; padding: 7px 9px; font-size: 12px; z-index: 5; min-width: 120px; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.mc-tip-t { color: var(--muted); margin-bottom: 4px; font-family: var(--mono); }
.mc-tip-r { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.mc-tip-r i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.mc-tip-r span { color: var(--text-2); flex: 1; }
.mc-tip-r b { font-variant-numeric: tabular-nums; margin-left: 10px; color: var(--text); }
.mc-tip-r em { font-style: normal; color: var(--muted); }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .top-actions { margin-left: 0; flex-wrap: wrap; width: 100%; }
  .page { padding: 12px; }
  .grid { grid-template-columns: 1fr; }
}

/* ---------- MCGS / TDGSK ekrani ---------- */
.mcgs { --m-red: #c8161d; --m-red-2: #9b0f15; --m-blue: #12309a; --m-blue-line: #5a78d8; --m-val: #6fe9ff;
  --m-body: #c3c6dc; --m-body-2: #b2b6d0; --m-ink: #1b2140; --m-font: "Courier New", "Lucida Console", monospace;
  --m-serif: "SimSun", "NSimSun", "Times New Roman", serif;
  background: #1a1d22; border: 6px solid #3b4046; border-radius: 6px; overflow: hidden; user-select: none;
  box-shadow: 0 0 0 1px #000 inset, 0 8px 22px rgba(0,0,0,.35); font-family: var(--m-font); }
.m-head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px;
  background: linear-gradient(var(--m-red), var(--m-red-2)); color: #fff; padding: 4px 8px; border-bottom: 2px solid #f0f0f0; }
.m-name { color: #ffe14a; font-weight: 700; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-title { font-weight: 700; font-size: 15px; letter-spacing: .02em; white-space: nowrap; text-align: center; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.m-clock { text-align: right; line-height: 1.05; font-weight: 700; font-size: 11px; display: flex; flex-direction: column; align-items: flex-end; }
.m-clock b { font-size: 12px; }
.m-top { display: grid; grid-template-columns: 1fr 1fr 1fr auto; background: var(--m-blue); border-bottom: 2px solid #e8e8f0; }
.m-cell { padding: 3px 6px; border-right: 2px solid var(--m-blue-line); min-width: 0; }
.m-r { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 4px; line-height: 1.35; }
.m-r > span { color: #fff; font-weight: 700; font-size: 11px; white-space: nowrap; }
.m-r .m-val { color: var(--m-val); font-weight: 700; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.m-r .m-unit { color: #fff; font-style: normal; font-weight: 700; font-size: 11px; min-width: 24px; }
.m-run { display: grid; place-items: center; padding: 4px 6px; }
.m-state { display: inline-grid; place-items: center; min-width: 52px; height: 34px; padding: 0 6px; font-family: var(--m-serif);
  font-size: 13px; border: 2px solid #e8e8e8; box-shadow: inset -2px -2px 0 rgba(0,0,0,.25); }
.m-state.run { background: #78f000; color: #1a3d00; }
.m-state.stop { background: #e01b22; color: #fff; }
.m-state.off { background: #8a8f99; color: #20242b; font-size: 11px; }
.m-body { background: linear-gradient(var(--m-body), var(--m-body-2)); color: var(--m-ink); padding: 6px 14px 4px; font-family: var(--m-serif); }
.m-big { display: grid; grid-template-columns: 34% 1fr 34px 30px; align-items: baseline; gap: 6px; line-height: 1.2; }
.m-big > em { font-style: normal; }
.m-share { font: inherit; color: inherit; margin-left: .4em; }
.m-tshare { color: #ffe14a; font-weight: 700; }
.m-big > span { text-align: right; font-size: 18px; }
.m-big .m-val { text-align: right; font-weight: 400; font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.m-big .m-unit { font-style: normal; font-size: 18px; }
.m-big.tot .m-val { font-size: 26px; }
.m-modes { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; background: #d3d6e6; color: #4a4f66;
  padding: 4px 8px; border-top: 2px solid #eef0f6; font-family: var(--m-serif); font-size: 11px; }
.m-mode-r { text-align: right; }
.m-ctrl { background: #34d2d6; color: #0b4a63; border: 1px solid #8fe9ec; padding: 3px 14px; font-size: 15px; letter-spacing: .06em; white-space: nowrap; }
.m-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: linear-gradient(#c8161d, #a01017);
  color: #fff; padding: 3px 8px; font-size: 11px; }
.m-foot .m-today b { color: #fff; font-size: 13px; }
.m-foot .m-age { color: #ffe0e0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; text-align: right; }
.m-foot .m-age .err { color: #fff3a0; }
.m-val.stale { opacity: .55; }
.m-val.err { color: #ff5a5a !important; font-size: 12px !important; }
/* katta (ichki oyna) */
.mcgs.big .m-title { font-size: 20px; }
.mcgs.big .m-name { font-size: 14px; }
.mcgs.big .m-clock b { font-size: 15px; } .mcgs.big .m-clock { font-size: 13px; }
.mcgs.big .m-r > span, .mcgs.big .m-r .m-unit { font-size: 13px; }
.mcgs.big .m-r .m-val { font-size: 15px; }
.mcgs.big .m-state { min-width: 70px; height: 44px; font-size: 17px; }
.mcgs.big .m-body { padding: 14px 18px 10px; }
.mcgs.big .m-big > span { font-size: 26px; }
.mcgs.big .m-big .m-val { font-size: 38px; }
.mcgs.big .m-big.tot .m-val { font-size: 42px; }
.mcgs.big .m-big .m-unit { font-size: 26px; }
.mcgs.big .m-big { grid-template-columns: 34% 1fr 56px 40px; }
.mcgs.big .m-modes { font-size: 13px; padding: 8px 12px; }
.mcgs.big .m-ctrl { font-size: 22px; padding: 6px 26px; }
.mcgs.big .m-foot { font-size: 12px; padding: 5px 10px; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } .m-top { grid-template-columns: 1fr 1fr 1fr; } .m-run { grid-column: 1 / -1; } }

/* ---------- bosh ekran bo'limlari ---------- */
.grp { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px dashed var(--line); }
.grp:last-child { border-bottom: 0; }
.grp-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(410px, 1fr)); gap: 16px; align-items: start; }
.grp-card { cursor: pointer; border-radius: 8px; color: inherit; display: block; }
.grp-card.static { cursor: default; }
.grp-card.static:hover .mcgs { outline: none; }
.grp-card:hover .mcgs { outline: 2px solid #ffd54a; }
.grp-mcgs { border-color: #8a6a12; box-shadow: 0 0 0 1px #000 inset, 0 0 0 2px rgba(255, 213, 74, .25), 0 8px 22px rgba(0,0,0,.35); }
.grp-mcgs .m-name { color: #ffe14a; }
.grp-mcgs .m-title { font-size: 17px; letter-spacing: .06em; text-transform: uppercase; }
.grp-mix { display: flex; flex-wrap: wrap; gap: 2px 12px; justify-content: center; grid-template-columns: none; min-height: 28px; }
.grp-mix b { color: #1b2140; }
.m-state.part { background: #f0c419; color: #3a2c00; }
.grp-empty { color: var(--muted); padding: 18px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; display: grid; place-items: center; }
.add-card.sm { min-height: 120px; font-size: 14px; }

/* ---------- bo'lim kartalari ranglari ----------
   Asosiy bo'limlar (Xomashyo, Klinker, Sement): sement-grafit + to'q sariq
   Ichki bo'limlar (Tegirmon A, Tegirmon B): sanoat yashil-moviy
   Dozator kartalari o'z (MCGS qizil/ko'k) rangida qoladi. */
.grp-mcgs.lvl-top { --g-h1: #4a525c; --g-h2: #2b3138; --g-strip: #353c45; --g-line: #5d6670; --g-acc: #ffb020; --g-val: #ffd36b;
  --g-body1: #dcdedf; --g-body2: #c4c8cc; --g-mix: #e6e7e8; --g-frame: #3a3f45; --g-glow: rgba(255, 176, 32, .35); }
.grp-mcgs.lvl-sub { --g-h1: #13806d; --g-h2: #0b5548; --g-strip: #0e6253; --g-line: #3fa48f; --g-acc: #a6ffe9; --g-val: #8ff5dc;
  --g-body1: #d3e4e0; --g-body2: #bcd3ce; --g-mix: #e0ece9; --g-frame: #23433d; --g-glow: rgba(63, 200, 170, .35); }
.grp-mcgs.lvl-top, .grp-mcgs.lvl-sub { border-color: var(--g-frame); box-shadow: 0 0 0 1px #000 inset, 0 0 0 2px var(--g-glow), 0 8px 22px rgba(0,0,0,.35); }
.grp-mcgs.lvl-top .m-head, .grp-mcgs.lvl-sub .m-head { background: linear-gradient(var(--g-h1), var(--g-h2)); }
.grp-mcgs.lvl-top .m-name, .grp-mcgs.lvl-sub .m-name { color: var(--g-acc); }
.grp-mcgs.lvl-top .m-title { color: var(--g-acc); }
.grp-mcgs.lvl-sub .m-title { color: #fff; }
.grp-mcgs.lvl-top .m-top, .grp-mcgs.lvl-sub .m-top { background: var(--g-strip); }
.grp-mcgs.lvl-top .m-cell, .grp-mcgs.lvl-sub .m-cell { border-right-color: var(--g-line); }
.grp-mcgs.lvl-top .m-r .m-val, .grp-mcgs.lvl-sub .m-r .m-val { color: var(--g-val); }
.grp-mcgs.lvl-top .m-body, .grp-mcgs.lvl-sub .m-body { background: linear-gradient(var(--g-body1), var(--g-body2)); }
.grp-mcgs.lvl-top .m-modes, .grp-mcgs.lvl-sub .m-modes { background: var(--g-mix); }
.grp-mcgs.lvl-top .m-foot, .grp-mcgs.lvl-sub .m-foot { background: linear-gradient(var(--g-h2), var(--g-h1)); }
.grp-card:hover .grp-mcgs.lvl-top { outline-color: #ffb020; }
.grp-card:hover .grp-mcgs.lvl-sub { outline-color: #3fc8aa; }

/* ---- KXT Control System (Portland, Siemens TP700) kartasi — HMI ekrani ko'rinishida ---- */
.kxt2 { --k-bg: #1638c4; --k-bg2: #0f2aa0; --k-cell: #1a2f9e; --k-line: #e9eefc;
  background: radial-gradient(ellipse at 50% 35%, #1e46da, var(--k-bg2)); color: #fff; border: 6px solid #3b4046; border-radius: 6px;
  overflow: hidden; user-select: none; box-shadow: 0 0 0 1px #000 inset, 0 8px 22px rgba(0,0,0,.35);
  font-family: Arial, "Segoe UI", sans-serif; }
.k-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 10px 2px; }
.k-logo { display: flex; flex-direction: column; align-items: center; line-height: 1; padding: 3px 6px; border: 1px solid rgba(255,255,255,.25); }
.k-logo b { font-family: "KaiTi", "STKaiti", "SimSun", serif; font-size: 15px; letter-spacing: .12em; }
.k-logo span { font-size: 9px; letter-spacing: .06em; margin-top: 2px; }
.k-title { text-align: center; min-width: 0; line-height: 1.15; }
.k-title b { font-size: 17px; }
.k-title .m-share { font-size: 13px; color: #ffe14a; font-weight: 700; }
.k-title small { display: block; font-size: 11px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-clock { display: flex; flex-direction: column; align-items: flex-end; font-size: 11px; font-weight: 700; line-height: 1.2; }
.k-clock b { font-size: 12px; }
.k-body { display: grid; grid-template-columns: 44% 1fr; gap: 6px; align-items: center; padding: 2px 10px 8px; }
.k-left { position: relative; }
.k-gauge { display: block; width: 100%; height: auto; }
.g-face { fill: #f4f4f2; stroke: #c9ccd4; stroke-width: 1.5; }
.g-band { fill: none; stroke-width: 7; }
.g-band.ok { stroke: #19a83a; } .g-band.warn { stroke: #f39a1e; } .g-band.hi { stroke: #e0262b; }
.g-tick { stroke: #555; stroke-width: 1; } .g-tick.mj { stroke: #222; stroke-width: 1.6; }
.g-lab { font: 11px Arial, sans-serif; fill: #222; text-anchor: middle; dominant-baseline: middle; }
.g-needle { transform-origin: 100px 100px; transition: transform .8s ease; }
.g-needle.set polygon { fill: #ffe14a; stroke: #8a7400; stroke-width: .8; }      /* Flow Set — sariq (HMI dagi sariq belgi) */
.g-needle.cur polygon { fill: #2ee04a; stroke: #0b6b1c; stroke-width: .8; }      /* Current flow — yashil */
.g-needle.stale { opacity: .25; }
.g-read { font: 700 10px Arial, sans-serif; text-anchor: middle; }
.g-read.cur { fill: #7dff95; } .g-read.set { fill: #ffe14a; }
.g-hub { fill: #e3141b; stroke: #8a0006; stroke-width: 1; }
.k-pump { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); min-width: 42%; padding: 4px 10px; border-radius: 50%;
  text-align: center; font-size: 12px; font-weight: 700; border: 1px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); white-space: nowrap; }
.k-pump.run { background: #2ee04a; color: #0b3d12; } .k-pump.stop { background: #e3141b; color: #fff; }
.k-pump.off { background: #9aa0aa; color: #1b1f26; }
.k-tbl { display: grid; gap: 3px; }
.k-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) minmax(0, 46%); align-items: stretch; gap: 4px; }
.k-row > i { align-self: center; width: 12px; height: 12px; }
.k-sq.g { background: #2ee04a; border: 1px solid #fff; } .k-sq.y { background: #ffe14a; border: 1px solid #fff; }
.k-row > span, .k-v { border: 1.5px solid var(--k-line); background: var(--k-cell); padding: 2px 6px; font-weight: 700; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-v { text-align: right; display: flex; justify-content: flex-end; align-items: baseline; gap: 1px; }
.k-v .m-val { font-variant-numeric: tabular-nums; }
.k-v .m-unit { font-style: normal; font-size: 12px; }
.k-v.k-txt { justify-content: center; }
.k-v .m-val.stale { opacity: .55; }
.k-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 8px; font: 11px "Courier New", monospace;
  background: rgba(0, 0, 0, .28); border-top: 1px solid rgba(255,255,255,.25); }
.k-foot .m-today b { font-size: 13px; }
.k-foot .m-esp { opacity: .75; }
.k-foot .m-age { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; text-align: right; }
.k-foot .m-age .err { color: #fff3a0; }
a.card:hover .kxt2 { outline: 2px solid #3f6bb3; }
.kxt2.big .k-title b { font-size: 22px; }
.kxt2.big .k-row > span, .kxt2.big .k-v { font-size: 17px; padding: 4px 10px; }
.kxt2.big .k-v .m-unit { font-size: 15px; }
.kxt2.big .k-pump { font-size: 15px; }
.kxt2.big .k-tbl { gap: 5px; }
.kxt2.big .k-foot { font-size: 12px; padding: 5px 10px; }
@media (max-width: 720px) { .k-body { grid-template-columns: 1fr; } .k-left { max-width: 260px; margin: 0 auto; } }

/* ESP32 sozlash bloki */
.esp-box { margin-top: 14px; padding: 12px; border: 1px dashed #3f6bb3; border-radius: 8px; background: rgba(57, 135, 229, .06); }
.esp-box h4 { margin: 0 0 8px; font-size: 13px; }
.esp-kv { display: grid; grid-template-columns: 140px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; margin: 4px 0; }
.esp-kv > span { color: var(--muted, #9aa7b8); font-size: 12px; font-family: ui-monospace, Consolas, monospace; }
.esp-kv code { background: #0b1424; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; overflow-wrap: anywhere; user-select: all; }
.modal .stack > *, .modal .field { min-width: 0; } .modal select, .modal input { max-width: 100%; min-width: 0; }
label.field.check { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px; align-self: end; padding-bottom: 6px; } label.field.check > input { width: auto; }
.grp-mix .mix-sep { opacity: .5; padding: 0 2px; }

/* ================= v1.4: Ishlab chiqarish xaritasi va Dozalash aniqligi ================= */
.btn.nav-an.on { border-color: var(--accent); background: rgba(57,135,229,.16); color: #fff; }
.an-kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.an-kpis .kpi { position: relative; overflow: hidden; }
.an-kpis .kpi small { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.an-kpis .kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .7; }
.an-kpis .kpi.k-good::before { background: var(--ok); } .an-kpis .kpi.k-warn::before { background: var(--warn); }
.an-kpis .kpi.k-bad::before { background: var(--bad); } .an-kpis .kpi.k-na::before { background: var(--muted); }
.an-kpis .kpi.k-good b { color: #7ef0ae; } .an-kpis .kpi.k-warn b { color: #ffd36b; } .an-kpis .kpi.k-bad b { color: #ff9a9d; }
.an-two { align-items: start; }
.an-foot { margin: 14px 2px 0; line-height: 1.5; }
.an-tip { position: fixed; z-index: 300; max-width: 340px; white-space: normal; line-height: 1.45; }
.an-tip .mc-tip-r span { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }

/* issiqlik xaritasi */
.an-scale { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.an-scale i { width: 120px; height: 10px; border-radius: 3px; display: inline-block; }
.an-hm-wrap { overflow-x: auto; }
.an-hm { min-width: 860px; display: grid; gap: 3px; }
.an-hm-row { display: grid; grid-template-columns: 74px repeat(24, minmax(0, 1fr)) 150px; gap: 3px; align-items: stretch; }
.an-hm-head b { font-size: 10.5px; font-weight: 500; color: var(--muted); text-align: center; }
.an-hm-head span.r { font-size: 11px; color: var(--muted); padding-left: 8px; }
.an-hm-day { font-size: 12px; color: var(--text-2); white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.an-hm-day b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.an-hm-day.we { color: #ffb36b; }
.an-hm .c { display: grid; place-items: center; height: 24px; border-radius: 4px; background: rgba(35,49,80,.35); font-style: normal; overflow: hidden;
  transition: transform .08s; cursor: default; }
.an-hm .c em { font-style: normal; font-size: 10px; font-weight: 600; color: rgba(5,12,26,.85); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.an-hm .c.zero { background: rgba(35,49,80,.28); }
.an-hm .c.none { background: transparent; }
.an-hm .c.fut { background: repeating-linear-gradient(135deg, rgba(113,130,156,.14) 0 3px, transparent 3px 7px); }
.an-hm .c.cur { outline: 2px solid #ffd54a; outline-offset: -2px; }
.an-hm .c[data-i]:hover { transform: scale(1.18); position: relative; z-index: 2; box-shadow: 0 2px 10px rgba(0,0,0,.5); }
.an-hm-tot { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 0 6px 0 8px; font-size: 12px; }
.an-hm-tot i { position: absolute; left: 8px; top: 5px; bottom: 5px; border-radius: 3px; background: rgba(57,135,229,.22); max-width: calc(100% - 8px); }
.an-hm-tot b { position: relative; font-variant-numeric: tabular-nums; font-weight: 600; }
.an-hm-tot small { position: relative; color: var(--muted); }
.an-hm-prof { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.an-hm-prof .p { height: 34px; display: flex; align-items: flex-end; background: rgba(35,49,80,.2); border-radius: 3px; overflow: hidden; }
.an-hm-prof .p u { display: block; width: 100%; background: linear-gradient(#6ec4ff, #2a6fc4); border-radius: 3px 3px 0 0; }
@media (max-width: 1400px) { .an-hm .c em { display: none; } }

/* smenalar grafigi */
.an-shbar .legend { margin-bottom: 4px; }
.an-svg { width: 100%; height: 210px; display: block; }
.an-svg .g { stroke: var(--chart-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.an-svg text { fill: var(--chart-axis); font-size: 10.5px; font-family: var(--font); }
.an-svg .yl { text-anchor: end; } .an-svg .xl { text-anchor: middle; }
.an-svg rect { rx: 2; transition: opacity .1s; } .an-svg rect.part { opacity: .5; } .an-svg rect:hover { opacity: .8; stroke: #fff; stroke-width: 1; }
.an-tbl td, .an-tbl th { white-space: nowrap; }
.an-tbl tr.sep td { padding-top: 14px; font-size: 12px; color: var(--text-2); border-bottom: 1px solid var(--line); }
.an-tbl tr.ex td { opacity: .72; }
.an-bar-td { min-width: 170px; }
.an-bar { display: inline-block; width: 90px; height: 8px; border-radius: 4px; background: rgba(35,49,80,.6); margin-right: 8px; vertical-align: middle; overflow: hidden; }
.an-bar i { display: block; height: 100%; background: linear-gradient(90deg, #2a6fc4, #6ec4ff); border-radius: 4px; }
.an-spark { width: 84px; height: 22px; display: block; }
.an-spark polyline { fill: none; stroke: #6ec4ff; stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* ish holati xronologiyasi */
.sw.st-r, .an-tl u.st-r { background: #2fbf71; }
.sw.st-s, .an-tl u.st-s { background: #e0a000; }
.sw.st-n, .an-tl u.st-n { background: repeating-linear-gradient(135deg, #3a4558 0 3px, #262f3e 3px 6px); }
.an-tl { display: grid; gap: 4px; }
.an-tl-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 48px; gap: 10px; align-items: center; }
.an-tl-name { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.an-tl-name a { color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-tl-name small { color: var(--muted); font-size: 11px; }
.an-tl-bar { position: relative; height: 18px; background: rgba(35,49,80,.35); border-radius: 4px; overflow: hidden; }
.an-tl-bar u { position: absolute; top: 0; bottom: 0; min-width: 1px; }
.an-tl-bar u:hover { filter: brightness(1.35); box-shadow: inset 0 0 0 1px #fff; }
.an-tl-bar .tk { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(10,16,28,.55); z-index: 1; pointer-events: none; }
.an-tl-axis .an-tl-bar { background: none; height: 16px; overflow: visible; }
.an-tl-axis .an-tl-bar b { position: absolute; transform: translateX(-50%); font-size: 10.5px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.an-tl-row > .r { text-align: right; font-size: 12px; }

/* aniqlik kartalari */
.an-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; margin-top: 14px; }
.an-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
  border-top: 3px solid var(--muted); }
.an-card.good { border-top-color: var(--ok); } .an-card.warn { border-top-color: var(--warn); } .an-card.bad { border-top-color: var(--bad); }
.an-card-h { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.an-card-h a { color: var(--text); font-weight: 600; font-size: 15px; }
.an-card-b { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; align-items: center; }
.an-ring .bg { fill: none; stroke: rgba(35,49,80,.8); stroke-width: 9; }
.an-ring .fg { fill: none; stroke-width: 9; stroke-linecap: round; stroke: var(--muted); transition: stroke-dasharray .5s; }
.an-ring.good .fg { stroke: var(--ok); } .an-ring.warn .fg { stroke: var(--warn); } .an-ring.bad .fg { stroke: var(--bad); }
.an-ring .v { fill: var(--text); font-size: 19px; font-weight: 700; text-anchor: middle; font-family: var(--font); }
.an-ring .l { fill: var(--muted); font-size: 9.5px; text-anchor: middle; font-family: var(--font); }
.an-stats { display: grid; gap: 2px; font-size: 12.5px; }
.an-st { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted rgba(35,49,80,.8); padding: 1px 0; }
.an-st span { color: var(--muted); white-space: nowrap; }
.an-st b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.an-st .up { color: #ffb36b; } .an-st .down { color: #8fc8ff; }
.an-hist { width: 100%; height: 78px; display: block; }
.an-hist .tolband { fill: rgba(47,191,113,.10); }
.an-hist rect.in { fill: #2fbf71; } .an-hist rect.out { fill: #e0a000; } .an-hist rect.edge { fill: #e5484d; }
.an-hist rect:not(.tolband):hover { opacity: .75; }
.an-hist .zero { stroke: rgba(230,236,245,.5); stroke-width: 1; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; }
.an-hist .xl { fill: var(--chart-axis); font-size: 9.5px; text-anchor: middle; font-family: var(--font); }
.an-hist-empty { height: 78px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 6px; }
.an-bal { display: grid; gap: 1px; padding: 6px 9px; border-radius: 7px; font-size: 12px; background: #1a2740; border: 1px solid #2b4170; color: var(--text-2); cursor: default; }
.an-bal b { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.an-bal.good { background: #0f2b1d; border-color: #1f6b40; color: #9ff0c2; }
.an-bal.warn { background: #2e2410; border-color: #6b5417; color: #f1d58a; }
.an-bal.bad { background: #331418; border-color: #6e2a31; color: #ffb3b6; }
.an-bal.na { opacity: .7; }
.an-note { margin: 0; } .an-note.warn { color: #f1d58a; }
.an-method { margin-top: 14px; line-height: 1.55; color: var(--text-2); }
@media (max-width: 720px) {
  .an-tl-row { grid-template-columns: 96px minmax(0, 1fr) 36px; gap: 6px; }
  .an-cards { grid-template-columns: 1fr; }
  .an-card-b { grid-template-columns: 80px minmax(0, 1fr); }
}
.an-hm .c.nodata { background: repeating-linear-gradient(135deg, rgba(229,72,77,.22) 0 3px, rgba(35,49,80,.25) 3px 7px); }
.an-hm .c.gap { box-shadow: inset 0 -3px 0 #e0a000; }
.an-hm-tot .gapmark { color: #ffd36b; margin-right: auto; padding-left: 4px; }
.an-tip-warn { color: #ffd36b; }
.an-tbl td.an-low { color: #ffd36b; }
@media (max-width: 720px) { .an-kpis { grid-template-columns: 1fr 1fr; } .an-kpis .kpi b { font-size: 20px; } }
