/* ============================================================
   Server Admin — toza oq dashboard + qora sidebar (yashil aksent)
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f6f7f9; --card: #ffffff; --border: #e6e8ec; --border2: #d5d9e0;
  --text: #0f172a; --muted: #6b7280; --muted2: #9aa1ac;
  --green: #16a34a; --green2: #22c55e; --green-bg: #e9f9ef;
  --blue: #3b82f6; --blue-bg: #eaf2fe; --purple: #8b5cf6; --purple-bg: #f1ecfe;
  --orange: #f59e0b; --orange-bg: #fdf3e2; --red: #ef4444; --red-bg: #feecec;
  --side: #0b0d10; --side2: #15181d; --side-text: #c8cdd5;
  --sh: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --r: 14px;
}
body.dark {
  --bg: #0d0f13; --card: #14171c; --border: #23262d; --border2: #2f333b;
  --text: #f1f5f9; --muted: #98a0ad; --muted2: #6b7280;
  --green-bg: rgba(34,197,94,.12); --blue-bg: rgba(59,130,246,.13);
  --purple-bg: rgba(139,92,246,.14); --orange-bg: rgba(245,158,11,.13); --red-bg: rgba(239,68,68,.13);
  --sh: 0 1px 3px rgba(0,0,0,.4);
}
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 'Inter', -apple-system, sans-serif; min-height: 100vh; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
button { font-family: inherit; }

/* ---------- LOGIN ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-card { width: 100%; max-width: 388px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 38px 32px; text-align: center; box-shadow: 0 8px 40px rgba(16,24,40,.08); }
.login-mark { width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 16px; background: var(--side); color: #fff; display: grid; place-items: center; font-size: 27px; }
.login-card h1 { font-size: 23px; font-weight: 800; letter-spacing: -.4px; }
.sub { color: var(--muted); font-size: 13px; margin: 4px 0 24px; }
.passkey-btn { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; padding: 13px; border: none; border-radius: 11px; background: var(--green); color: #fff; font-size: 14.5px; font-weight: 700; cursor: pointer; transition: background .15s, transform .15s; }
.passkey-btn:hover { background: #15803d; transform: translateY(-1px); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted2); font-size: 11px; margin: 18px 0 14px; text-transform: uppercase; letter-spacing: 1.2px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.field { text-align: left; margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, select.input { width: 100%; padding: 11px 13px; background: var(--card); border: 1px solid var(--border2); border-radius: 10px; color: var(--text); font-size: 14px; outline: none; transition: border .15s, box-shadow .15s; }
.input:focus { border-color: var(--green2); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; background: var(--card); border: 1px solid var(--border2); border-radius: 10px; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn:hover { border-color: var(--muted2); background: var(--bg); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: #15803d; border-color: #15803d; }
.btn-dark { background: var(--side); border-color: var(--side); color: #fff; }
.btn-dark:hover { background: #1c2027; border-color: #1c2027; }
.btn-danger { color: var(--red); border-color: #f3c1c1; }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 14.5px; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.pw-toggle button { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; margin-top: 12px; text-decoration: underline; }
.err-msg { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }
.warn-msg { color: var(--orange); font-size: 12px; margin-top: 6px; }

/* ---------- LAYOUT ---------- */
.app { display: none; }
.app.active { display: flex; min-height: 100vh; }
.side { width: 232px; flex-shrink: 0; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-logo { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; color: #fff; font-size: 15.5px; }
.side-logo .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--green); display: grid; place-items: center; font-size: 16px; }
.side-logo b span { color: var(--green2); }
.nav { flex: 1; padding: 4px 12px; overflow-y: auto; }
.nav-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px; color: #5c6470; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; cursor: pointer; color: var(--side-text); font-size: 13.5px; font-weight: 500; margin-bottom: 2px; transition: background .13s, color .13s; user-select: none; }
.nav a:hover { background: var(--side2); color: #fff; }
.nav a.active { background: var(--side2); color: #fff; box-shadow: inset 2px 0 0 var(--green2); }
.nic { display: inline-flex; width: 18px; height: 18px; opacity: .85; }
.nic svg { width: 18px; height: 18px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid #1d2128; }
.uav { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.uinfo { flex: 1; min-width: 0; line-height: 1.25; }
.uinfo b { color: #fff; font-size: 13px; display: block; }
.uinfo small { color: #7d8590; font-size: 11px; }
.side-user button { background: none; border: none; color: #7d8590; cursor: pointer; padding: 6px; border-radius: 8px; }
.side-user button:hover { color: #fff; background: var(--side2); }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 26px; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.search-box { display: flex; align-items: center; gap: 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 13px; width: min(420px, 100%); color: var(--muted); }
.search-box input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 13.5px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.clock { color: var(--muted); font-size: 12.5px; }
.icon-btn { position: relative; display: grid; place-items: center; width: 36px; height: 36px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; color: var(--muted); cursor: pointer; transition: all .15s; }
.icon-btn:hover { color: var(--text); border-color: var(--border2); }
.bell-badge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; border-radius: 10px; display: grid; place-items: center; }
.bell-wrap { position: relative; }
.bell-panel { position: absolute; right: 0; top: 44px; width: 320px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(16,24,40,.14); overflow: hidden; z-index: 60; }
.bell-head { padding: 12px 16px; font-weight: 700; font-size: 13px; border-bottom: 1px solid var(--border); }
.bell-item { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.bell-item:last-child { border-bottom: none; }
.bell-item small { color: var(--muted); display: block; font-size: 11px; }
.host-chip { display: inline-flex; align-items: center; gap: 7px; background: var(--green-bg); color: var(--green); border-radius: 20px; padding: 7px 13px; font-size: 12px; font-weight: 700; }
.pdot { width: 7px; height: 7px; border-radius: 50%; background: var(--green2); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

main { padding: 24px 26px 40px; max-width: 1240px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 18px; }
.page-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- KARTALAR ---------- */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.g21 { grid-template-columns: 2fr 1fr; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--sh); }
.card h3 { font-size: 14.5px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.card-head h3 { margin-bottom: 0; }

/* Stat karta */
.stat { position: relative; padding-bottom: 8px; overflow: hidden; }
.stat-top { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-title { font-size: 13px; font-weight: 600; color: var(--muted); }
.itile { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; }
.itile svg { width: 19px; height: 19px; }
.itile.gr { background: var(--green-bg); color: var(--green); }
.itile.bl { background: var(--blue-bg); color: var(--blue); }
.itile.pu { background: var(--purple-bg); color: var(--purple); }
.itile.or { background: var(--orange-bg); color: var(--orange); }
.stat-val { font-size: 27px; font-weight: 800; letter-spacing: -.6px; margin-top: 6px; }
.stat-sub { font-size: 12px; color: var(--muted); margin: 3px 0 8px; }
.stat-sub .up { color: var(--green); font-weight: 700; }
.stat-sub .down { color: var(--red); font-weight: 700; }
.spark { width: calc(100% + 40px); height: 42px; display: block; margin: 0 -20px -8px; }

/* Katta grafik */
.range-pills { display: flex; gap: 6px; }
.pill { padding: 6px 13px; border-radius: 9px; border: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.pill.active { background: var(--side); border-color: var(--side); color: #fff; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.bigchart { width: 100%; height: 300px; display: block; }
.axis-txt { font-size: 10.5px; fill: var(--muted2); }
.grid-line { stroke: var(--border); stroke-dasharray: 3 4; }

/* Donut + progress */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-center { font-size: 24px; font-weight: 800; }
.dlegend { flex: 1; min-width: 130px; display: flex; flex-direction: column; gap: 9px; font-size: 12.5px; }
.dlegend > div { display: flex; align-items: center; justify-content: space-between; }
.dlegend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.dlegend b { font-weight: 700; }
.goal { margin-bottom: 13px; }
.goal-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.goal-top b { font-weight: 700; }
.gbar { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.gbar i { display: block; height: 100%; background: var(--green2); border-radius: 6px; transition: width .6s; }
.gbar.warn i { background: var(--orange); } .gbar.crit i { background: var(--red); }

/* Xizmatlar */
.svc { display: inline-flex; align-items: center; gap: 8px; padding: 8px 15px; background: var(--bg); border: 1px solid var(--border); border-radius: 22px; font-size: 12.5px; font-weight: 600; margin: 3px 6px 3px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.dot.on { background: var(--green2); }

/* ---------- JADVAL ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }
.badge { display: inline-block; padding: 4px 11px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.on { background: var(--green-bg); color: var(--green); }
.badge.off { background: var(--red-bg); color: var(--red); }
.badge.ssl { background: var(--green-bg); color: var(--green); }
.badge.nossl { background: var(--orange-bg); color: var(--orange); }
.row-actions { display: flex; gap: 6px; }
.text-muted { color: var(--muted); }

/* ---------- Terminal / log ---------- */
.term { background: #0c0e12; border: 1px solid #23262d; border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.term-head { display: flex; align-items: center; gap: 6px; padding: 9px 14px; border-bottom: 1px solid #23262d; font-size: 11px; color: #8b93a3; }
.term-head i { width: 10px; height: 10px; border-radius: 50%; }
.term-head i:nth-child(1) { background: #ff5f57; } .term-head i:nth-child(2) { background: #febc2e; } .term-head i:nth-child(3) { background: #28c840; }
.term-head span { margin-left: 8px; }
pre.logbox { padding: 13px 16px; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; line-height: 1.6; overflow: auto; max-height: 44vh; white-space: pre-wrap; word-break: break-all; color: #a7f3c0; }
pre.logbox.err { color: #fca5a5; }
pre.logbox.neutral { color: #cbd5e1; }
.term-input { display: flex; gap: 10px; }
.term-input .input { font-family: ui-monospace, Menlo, monospace; }

/* ---------- Modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal-bg.active { display: grid; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: 100%; max-width: 780px; max-height: 85vh; overflow: auto; box-shadow: 0 24px 70px rgba(16,24,40,.25); }
.modal h3 { margin-bottom: 14px; font-size: 16px; font-weight: 800; }
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--green2); border-radius: 12px; padding: 12px 18px; font-size: 13px; font-weight: 500; box-shadow: 0 10px 34px rgba(16,24,40,.16); animation: slideIn .25s; max-width: 380px; }
.toast.err { border-left-color: var(--red); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 15px; background: var(--bg); border: 1px solid var(--border); border-radius: 11px; margin-bottom: 8px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 6px; }

@media (max-width: 900px) {
  .side { width: 64px; }
  .side-logo b, .nav-label, .uinfo, .nav a { font-size: 0; }
  .nav a { justify-content: center; gap: 0; padding: 12px 0; }
  .nav-label { padding: 8px 0; }
  .side-user { justify-content: center; }
  .side-user .uav, .side-user button { display: grid; }
  main { padding: 16px 14px 30px; }
  .clock, .search-box { display: none; }
  .g21 { grid-template-columns: 1fr; }
}

/* ============================================================
   TERMINAL (xterm.js) — desktop + telefon
   ============================================================ */
.termx { background: #0c0e12; border: 1px solid #23262d; border-radius: 14px; overflow: hidden; box-shadow: var(--sh); display: flex; flex-direction: column; }
.termx-bar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid #1e2229; background: #101318; flex-wrap: wrap; }
.tdots { display: flex; gap: 6px; }
.tdots i { width: 10px; height: 10px; border-radius: 50%; }
.tdots i:nth-child(1) { background: #ff5f57; } .tdots i:nth-child(2) { background: #febc2e; } .tdots i:nth-child(3) { background: #28c840; }
.termx-tabs { display: flex; gap: 5px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.termx-tabs::-webkit-scrollbar { display: none; }
.ttab { display: flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 8px; border: 1px solid transparent; background: #191d24; color: #98a0ad; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ttab small { font-size: 9px; color: #3f4650; }
.ttab.on { background: #22c55e1f; border-color: #22c55e55; color: #6ee79b; }
.ttab.on small { color: #22c55e; }
.termx-actions { display: flex; gap: 5px; }
.tbtn { padding: 5px 10px; border-radius: 8px; border: 1px solid #262b33; background: #171b21; color: #b9c0cb; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.tbtn:hover { background: #212730; color: #fff; }
.tbtn-ai { background: linear-gradient(135deg, #d97757, #b85c3e); border-color: #d9775766; color: #fff; }
.tbtn-ai:hover { background: linear-gradient(135deg, #e08a6d, #c86a4a); }
.termx-body { position: relative; }
.xterm-host { height: calc(100vh - 300px); min-height: 260px; padding: 8px 6px 4px 10px; }
.termx .xterm .xterm-viewport { background: transparent !important; }
.termx .xterm-viewport::-webkit-scrollbar { width: 8px; }
.termx .xterm-viewport::-webkit-scrollbar-thumb { background: #2f333b; border-radius: 6px; }
.termx-state { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); padding: 7px 14px; border-radius: 9px; background: #171b21ee; border: 1px solid #262b33; color: #b9c0cb; font-size: 12px; display: flex; align-items: center; gap: 8px; z-index: 5; }
.termx-state.warn { border-color: #f59e0b66; color: #ffcc66; }
.termx-keys { display: flex; gap: 5px; padding: 7px 8px; border-top: 1px solid #1e2229; background: #101318; overflow-x: auto; scrollbar-width: none; }
.termx-keys::-webkit-scrollbar { display: none; }
.termx-keys button { flex: 0 0 auto; min-width: 40px; padding: 8px 10px; border-radius: 8px; border: 1px solid #262b33; background: #171b21; color: #b9c0cb; font: 600 12.5px ui-monospace, Menlo, monospace; cursor: pointer; -webkit-user-select: none; user-select: none; }
.termx-keys button:active { background: #22c55e2a; color: #6ee79b; }
.termx-keys button.on { background: #22c55e2a; border-color: #22c55e66; color: #6ee79b; }
.termx-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 12px; border-top: 1px solid #1e2229; background: #0e1116; font-size: 11.5px; color: #6b7280; }
.termx-foot .text-muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Menlo, monospace; }

/* To'liq ekran — telefonda ayniqsa qulay */
.termx.full { position: fixed; inset: 0; z-index: 900; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.termx.full .termx-body { flex: 1; }
.termx.full .xterm-host { height: 100%; }

@media (max-width: 900px) {
  .xterm-host { height: calc(100vh - 330px); min-height: 200px; padding: 6px 4px 2px 7px; }
  .termx-bar { padding: 6px 8px; }
  .termx-keys button { min-width: 38px; padding: 9px 9px; }
  .termx-foot { font-size: 10.5px; }
  main { padding-bottom: 20px; }
}
.termx-load { display: flex; align-items: center; gap: 10px; }
.termx-foot .term-load-warn { color: #ffcc66; font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
