/* Pult. Ranglar server stoykasidagi chiroqlar mantig'ida: yashil = soz, sariq = ishlayapti yoki e'tibor kerak, qizil = nosoz. */
:root {
  --bg: #0e1917; --surface: #152422; --raised: #1d302d; --well: #0a1312; --line: #253a36;
  --text: #e9f2ec; --muted: #93aba3; --faint: #6f8b83;
  --amber: #ffb347; --amber-ink: #2b1b00; --green: #62d9a2; --red: #ff7a6b;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r-lg: 16px; --r: 10px; --r-sm: 6px;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 var(--sans); -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
#app { height: 100%; height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
a { color: var(--amber); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
::selection { background: #ffb34744; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ---------- chiroq ---------- */
.lamp { width: 9px; height: 9px; border-radius: 50%; flex: none; background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.lamp.ok { background: var(--green); box-shadow: 0 0 0 3px #62d9a222; }
.lamp.busy { background: var(--amber); box-shadow: 0 0 0 3px #ffb34722; animation: blink 1.1s ease-in-out infinite; }
.lamp.bad { background: var(--red); box-shadow: 0 0 0 3px #ff7a6b22; }
@keyframes blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .lamp.busy, .draft::after { animation: none !important; } }

/* ---------- tugma va maydonlar ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border: 0; border-radius: var(--r); background: var(--raised); font-weight: 500; white-space: nowrap; }
.btn:hover { background: #24403b; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--amber); color: var(--amber-ink); font-weight: 600; }
.btn.primary:hover { background: #ffc266; }
.btn.danger { color: var(--red); }
.btn.quiet { background: transparent; color: var(--muted); }
.btn.quiet:hover { background: var(--raised); color: var(--text); }
.btn.icon { padding: 0; width: 40px; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.input { width: 100%; min-height: 44px; padding: 10px 12px; background: var(--well); border: 1px solid var(--line); border-radius: var(--r); outline: none; }
.input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px #ffb34726; }
select.input { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393aba3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13.5px; color: var(--muted); }
.field .hint { margin-top: 6px; font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; cursor: pointer; user-select: none; }
.check input { width: 20px; height: 20px; accent-color: var(--amber); margin: 0; }
@media (max-width: 899px) { .input, .composer textarea { font-size: 16px; } } /* iOS maydonga bosganda kattalashtirmasin */

/* ---------- kirish ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: calc(24px + var(--st)) 24px calc(24px + var(--sb)); }
.login { width: 100%; max-width: 360px; }
.login-mark { width: 56px; height: 56px; border-radius: 14px; display: block; margin-bottom: 20px; }
.login h1 { font-size: 26px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 6px; }
.login > p { color: var(--muted); margin-bottom: 26px; }
.login .err { min-height: 22px; margin: -4px 0 10px; color: var(--red); font-size: 14px; }

/* ---------- qobiq ---------- */
.app { height: 100%; display: grid; grid-template-columns: 84px minmax(0, 1fr); }
.rail { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 14px 8px; background: var(--surface); }
.rail-mark { width: 40px; height: 40px; border-radius: 10px; margin: 2px auto 16px; display: block; }
.rail a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; border-radius: var(--r);
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500; }
.rail a svg { width: 22px; height: 22px; }
.rail a:hover { color: var(--text); background: var(--raised); }
.rail a.on { color: var(--text); background: var(--raised); }
.rail .count { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--amber); color: var(--amber-ink); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.view { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .rail { order: 2; flex-direction: row; gap: 0; padding: 6px 6px calc(6px + var(--sb)); border-top: 1px solid var(--line); }
  .rail-mark { display: none; }
  .rail a { flex: 1; padding: 7px 2px; font-size: 11.5px; }
  .app.detail-open .rail { display: none; }
}

/* ---------- sahifa sarlavhasi ---------- */
.pane-head { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: calc(10px + var(--st)) 20px 10px; flex: none; }
.pane-head h1 { font-size: 21px; font-weight: 600; letter-spacing: -.01em; flex: 1; min-width: 0; }
.conn { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.page { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.page-body { padding: 4px 20px calc(28px + var(--sb)); }
@media (max-width: 899px) { .pane-head { padding-left: 16px; padding-right: 16px; } .page-body { padding-left: 16px; padding-right: 16px; } }

/* ---------- ikki panel ---------- */
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.pane-list { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.pane-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px calc(12px + var(--sb)); }
.pane-detail { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
@media (max-width: 899px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .pane-list { border-right: 0; }
  .split.has-detail .pane-list, .split:not(.has-detail) .pane-detail { display: none; }
}
.empty { margin: auto; padding: 32px 24px; max-width: 340px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; }

/* ---------- ro'yxat ---------- */
.item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px; min-height: 56px; border: 0; border-radius: var(--r);
  background: transparent; text-align: left; }
.item:hover { background: var(--surface); }
.item.sel { background: var(--raised); }
.item-body { flex: 1; min-width: 0; }
.item-title { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { display: block; font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-trail { flex: none; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--faint); }
.item.unread .item-title { font-weight: 600; }
.item.unread .item-sub { color: var(--text); }
.mark { width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--raised);
  font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.item.sel .mark { background: var(--bg); }
.group { background: var(--surface); border-radius: var(--r-lg); padding: 4px; }
.group .item:hover { background: var(--raised); }
.group .item.static:hover { background: transparent; }
.item.static { align-items: center; }
.section-title { margin: 26px 4px 10px; font-size: 14px; font-weight: 500; color: var(--muted); }
.section-title:first-child { margin-top: 6px; }
.note { margin: 10px 4px 0; font-size: 13.5px; color: var(--muted); }

/* ---------- xabar tasmasi (bildirishnomani yoqish taklifi) ---------- */
.banner { display: flex; align-items: center; gap: 10px; margin: 0 4px 10px; padding: 12px 12px 12px 14px; border-radius: var(--r); background: var(--surface); font-size: 14px; }
.banner p { flex: 1; min-width: 0; }
.banner .btn { min-height: 34px; padding: 0 12px; }

/* ---------- server holati ---------- */
.server-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 899px) { .server-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; } }
.server-grid > section { min-width: 0; }
.host { margin: 0 4px 12px; font-size: 14px; color: var(--muted); }
.host b { color: var(--text); font-weight: 500; }
.gauges { background: var(--surface); border-radius: var(--r-lg); padding: 6px 18px; }
.gauge { padding: 14px 0; }
.gauge + .gauge { border-top: 1px solid var(--line); }
.gauge-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.gauge-name { font-weight: 500; }
.gauge-val { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.gauge-sub { margin-top: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* bo'laklarga bo'lingan o'lchagich — stoykadagi LED qatoriga o'xshaydi */
.meter { height: 10px; margin-top: 10px; background: var(--well);
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 7px, transparent 7px 10px); mask-image: repeating-linear-gradient(90deg, #000 0 7px, transparent 7px 10px); }
.meter i { display: block; height: 100%; background: var(--green); transition: width .4s; }
.meter i.warn { background: var(--amber); }
.meter i.crit { background: var(--red); }
canvas.spark { display: block; width: 100%; height: 32px; margin-top: 10px; }
.net { display: flex; gap: 18px; font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.net span { display: inline-flex; align-items: center; gap: 6px; }
.net i { width: 8px; height: 8px; border-radius: 2px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar .input { min-height: 40px; flex: 1; min-width: 150px; max-width: 280px; }
.toolbar select.input { flex: none; width: auto; min-width: 0; }
.seg { display: inline-flex; padding: 3px; border-radius: var(--r); background: var(--surface); flex: none; }
.seg button { min-height: 34px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--raised); color: var(--text); }
.cols { display: flex; padding: 0 16px 6px; font-size: 12.5px; color: var(--faint); }
.cols span:first-child { flex: 1; }
.cols span + span, .item .cell { width: 64px; text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.item .cell { font-size: 14px; color: var(--text); }
.item .cell.hot { color: var(--amber); }

/* ---------- oynacha: kompyuterda markazda, telefonda pastdan chiqadi ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: #050b0acc; }
.sheet { width: 100%; max-width: 460px; max-height: 90dvh; overflow-y: auto; padding: 22px; border-radius: var(--r-lg); background: var(--surface); }
.sheet.wide { max-width: 920px; }
.sheet h2 { font-size: 19px; font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
.sheet h2 + * { margin-top: 14px; }
.sheet-text { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.sheet-actions { display: grid; gap: 8px; margin-top: 18px; }
.sheet dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.sheet dt { color: var(--muted); }
.sheet dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 899px) {
  .sheet-bg { place-items: end stretch; padding: 0; }
  .sheet { max-width: none; border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 22px 18px calc(18px + var(--sb)); }
  .sheet-foot { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
}
pre.logs { margin: 0; padding: 12px; max-height: 62dvh; overflow: auto; border-radius: var(--r); background: var(--well);
  font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.agent-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.agent-pick button { padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--well); text-align: left; }
.agent-pick button.on { border-color: var(--amber); }
.agent-pick b { display: block; font-weight: 600; }
.agent-pick small { color: var(--muted); font-size: 13px; }
.picker { margin-top: 8px; max-height: 210px; overflow: auto; border-radius: var(--r); background: var(--well); padding: 4px; }
.picker button { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; font-family: var(--mono); font-size: 14px; }
.picker button:hover { background: var(--raised); }
.linkbtn { margin-top: 8px; padding: 0; border: 0; background: none; color: var(--amber); font-size: 14px; }

/* ---------- qalqib chiquvchi xabar ---------- */
#toasts { position: fixed; top: calc(12px + var(--st)); left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--raised); box-shadow: 0 12px 40px #000a; font-size: 14.5px; }
.toast .lamp { margin-top: 6px; }
.toast b { display: block; font-weight: 600; }
.toast span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
button.toast { border: 0; width: 100%; text-align: left; }

/* ---------- chat va terminal sarlavhasi ---------- */
.detail-head { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: calc(8px + var(--st)) 12px 8px 20px; border-bottom: 1px solid var(--line); flex: none; position: relative; }
.detail-head .back { display: none; }
.detail-title { flex: 1; min-width: 0; }
.detail-title b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-title span { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 899px) { .detail-head { padding-left: 4px; padding-right: 6px; gap: 4px; } .detail-head .back { display: inline-flex; } .detail-head .seg button { padding: 0 11px; } }
.menu { position: absolute; right: 10px; top: calc(100% - 4px); z-index: 30; min-width: 250px; padding: 6px; border-radius: var(--r); background: var(--raised); box-shadow: 0 16px 48px #000b; }
.menu button { display: block; width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; }
.menu button:hover { background: #2a4640; }
.menu button.danger { color: var(--red); }

/* ---------- chat ---------- */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 20px 8px; }
.msgs-in { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 899px) { .msgs { padding: 16px 14px 8px; } }
.msg { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 86%; padding: 9px 14px; border-radius: 16px 16px 4px 16px; background: var(--raised); white-space: pre-wrap; }
.msg.assistant > :first-child { margin-top: 0; }
.msg.assistant > :last-child { margin-bottom: 0; }
.msg.assistant p, .msg.assistant ul, .msg.assistant ol { margin: 0 0 10px; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; }
.msg.assistant ul, .msg.assistant ol { padding-left: 22px; }
.msg.assistant pre { margin: 0 0 10px; padding: 12px; overflow-x: auto; border-radius: var(--r); background: var(--well); font: 13px/1.5 var(--mono); }
.msg.assistant code { font-family: var(--mono); font-size: .9em; padding: 1px 5px; border-radius: 4px; background: var(--surface); }
.msg.assistant pre code { padding: 0; background: none; font-size: inherit; }
.msg.assistant table { display: block; overflow-x: auto; border-collapse: collapse; margin-bottom: 10px; }
.msg.assistant td, .msg.assistant th { padding: 6px 10px; border: 1px solid var(--line); text-align: left; }
.msg.assistant blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.draft::after { content: ""; display: inline-block; width: 8px; height: 16px; margin-left: 2px; vertical-align: -2px; background: var(--amber); animation: blink 1s steps(2) infinite; }
.tool { border-radius: var(--r); background: var(--surface); font-size: 13.5px; }
.tool summary { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 12px; cursor: pointer; list-style: none; }
.tool summary::-webkit-details-marker { display: none; }
.tool summary b { font-weight: 500; flex: none; }
.tool summary span:last-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-family: var(--mono); font-size: 12.5px; }
.tool pre { margin: 0; padding: 10px 12px; max-height: 320px; overflow: auto; border-top: 1px solid var(--line); font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.msg.meta { align-self: center; font-size: 12.5px; color: var(--faint); text-align: center; }
.msg.alert { padding: 10px 14px; border-radius: var(--r); background: var(--surface); border-left: 3px solid var(--amber); font-size: 14px; white-space: pre-wrap; }
.msg.alert.bad { border-left-color: var(--red); }
.composer { flex: none; padding: 8px 20px calc(12px + var(--sb)); }
.composer-in { max-width: 780px; margin: 0 auto; }
.composer-box { display: flex; align-items: flex-end; gap: 6px; padding: 6px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); }
.composer-box:focus-within { border-color: var(--amber); }
.composer textarea { flex: 1; min-width: 0; max-height: 180px; min-height: 40px; padding: 9px 4px 9px 12px; border: 0; outline: 0; resize: none; background: transparent; line-height: 1.45; }
.composer .send { width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--amber); color: var(--amber-ink); }
.composer .send:disabled { background: var(--raised); color: var(--faint); cursor: default; }
.composer .send.stop { background: var(--red); color: #2b0a05; }
.composer .send svg { width: 20px; height: 20px; }
.composer .mode { display: block; margin: 8px 12px 0; padding: 0; border: 0; background: none; font-size: 13px; color: var(--muted); }
.composer .mode:hover { color: var(--text); }
.composer .locked { padding: 12px 14px; border-radius: var(--r); background: var(--surface); font-size: 14px; color: var(--muted); }
.composer .locked div { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
@media (max-width: 899px) { .composer { padding: 6px 10px calc(10px + var(--sb)); } }

/* ---------- terminal ---------- */
.term { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--well); }
.term-box { flex: 1; min-height: 0; padding: 8px 4px 0 10px; }
.term-box .xterm { height: 100%; }
.xterm .xterm-viewport { background: transparent !important; }
.keys { display: none; gap: 6px; padding: 8px 8px calc(8px + var(--sb)); overflow-x: auto; scrollbar-width: none; background: var(--surface); }
.keys::-webkit-scrollbar { display: none; }
.keys button { flex: none; min-width: 46px; height: 40px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--raised); font-family: var(--mono); font-size: 14px; }
.keys button.on { background: var(--amber); color: var(--amber-ink); }
@media (pointer: coarse) { .keys { display: flex; } } /* yordamchi tugmalar faqat sensorli ekranda */
