/* Away Mini App — tekis, to'rtburchak uslub (spaces.im ruhida). Mobil: pastki navbar, desktop: sidebar */
:root {
  --bg: #eceef2;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --bar: #f7f8fa;
  --text: #1b1d22;
  --muted: #6b7180;
  --line: #e1e4ea;
  --accent: #2f8fdd;
  --accent-2: #6c5ce7;
  --accent-soft: #e6f1fb;
  --on-accent: #ffffff;
  --ok: #1fa45a;
  --ok-soft: #e4f6ec;
  --warn: #d48806;
  --warn-soft: #fdf4e1;
  --danger: #e0394f;
  --danger-soft: #fde8eb;
  --r: 4px;
  --r-lg: 6px;
  --sidebar: 260px;
  --appbar: 54px;
  --bottombar: 60px;
}
[data-theme="dark"] {
  --bg: #17181b;
  --surface: #222327;
  --surface-2: #2a2c31;
  --bar: #2a2c31;
  --text: #e8e9ec;
  --muted: #989ba4;
  --line: #33353b;
  --accent: #4fa8ee;
  --accent-2: #8e7cf5;
  --accent-soft: #1d2d3d;
  --ok: #3ccf7e;
  --ok-soft: #173326;
  --warn: #f0b23c;
  --warn-soft: #33290f;
  --danger: #ff6b7d;
  --danger-soft: #3a1b21;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
svg.lucide { width: 20px; height: 20px; stroke-width: 2; flex: none; }
svg.lucide.sm { width: 16px; height: 16px; }

/* ---------- Yuklanish chizig'i ---------- */
.loadbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity .2s; }
.loadbar.on { opacity: 1; }
.loadbar::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  animation: lb 1.1s ease-in-out infinite;
}
@keyframes lb { from { left: -40%; } to { left: 100%; } }

/* ---------- Karkas ---------- */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 10px 10px calc(var(--bottombar) + 24px + env(safe-area-inset-bottom)); }
.no-bottombar .content { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.sidebar { display: none; width: var(--sidebar); flex: none; position: sticky; top: 0; height: 100vh; background: var(--surface);
  border-right: 1px solid var(--line); flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; height: var(--appbar); padding: 0 16px; font-weight: 800; font-size: 17px;
  border-bottom: 1px solid var(--line); background: var(--bar); }
.logo { width: 30px; height: 30px; border-radius: var(--r); display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.logo svg.lucide { width: 18px; height: 18px; }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.side-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 14px 16px 6px; }
.side-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 16px; border: none; background: none; cursor: pointer;
  color: var(--text); text-align: left; border-left: 3px solid transparent; }
.side-item:hover { background: var(--surface-2); }
.side-item.active { background: var(--accent-soft); border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.side-item .ell { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.side-item .dot.off { background: var(--muted); opacity: .5; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.side-user:hover { background: var(--surface-2); }
.side-user .who { min-width: 0; }
.side-user b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.appbar { position: sticky; top: 0; z-index: 20; height: var(--appbar); display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.appbar .titles { flex: 1; min-width: 0; }
.appbar h1 { font-size: 16.5px; margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 36px; height: 36px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2);
  display: grid; place-items: center; cursor: pointer; flex: none; color: var(--text); }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn.ghost { background: none; border-color: transparent; }

.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); height: calc(var(--bottombar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: none; background: none;
  color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; border-top: 2px solid transparent; }
.tab.active { color: var(--accent); border-top-color: var(--accent); background: var(--accent-soft); }

@media (min-width: 860px) {
  .sidebar { display: flex; }
  .bottombar { display: none; }
  .content, .no-bottombar .content { padding: 16px 20px 40px; }
  .appbar { padding: 0 20px; }
  .mobile-only { display: none !important; }
}
@media (max-width: 859px) { .desktop-only { display: none !important; } }

/* ---------- Bloklar ---------- */
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.block + .block, .block + .gap, .gap + .block, .gap + .gap { margin-top: 10px; }
.gap { margin-top: 10px; }
.block.pad { padding: 14px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--bar);
  border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.head .more { color: var(--accent); cursor: pointer; display: inline-flex; align-items: center; gap: 2px; background: none; border: none; font-weight: 800; font-size: 12.5px; text-transform: uppercase; }
.head .count { color: var(--muted); font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* Plitkalar (spaces uslubi) */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile-btn { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px 6px 14px; min-height: 108px;
  text-align: center; font-weight: 600; font-size: 13px; transition: background .12s, border-color .12s; }
.tile-btn:hover { border-color: var(--accent); }
.tile-btn:active { background: var(--surface-2); }
.tile-btn svg.lucide { width: 34px; height: 34px; stroke-width: 1.8; }
.tile-btn .cnt { position: absolute; top: 6px; right: 6px; min-width: 20px; padding: 1px 6px; border-radius: 2px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.tile-btn .cnt.ok { background: var(--ok); }
.tile-btn .cnt.warn { background: var(--warn); }

/* Ro'yxat qatorlari */
.li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-height: 54px; cursor: pointer; position: relative; }
.li + .li { border-top: 1px solid var(--line); }
.li:hover { background: var(--surface-2); }
.li.static { cursor: default; }
.li.static:hover { background: none; }
.li .body { flex: 1; min-width: 0; }
.li .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .s.multi { white-space: pre-wrap; word-break: break-word; }
.li .chev { color: var(--muted); }

.av { width: 40px; height: 40px; border-radius: var(--r); flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; object-fit: cover; }
.av.lg { width: 60px; height: 60px; font-size: 24px; }
.av.xs { width: 24px; height: 24px; font-size: 11px; }
.sq { width: 36px; height: 36px; border-radius: var(--r); display: grid; place-items: center; flex: none; }
.sq svg.lucide { width: 19px; height: 19px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 2px; font-size: 11.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; text-transform: uppercase; letter-spacing: .02em; }
.badge svg.lucide { width: 12px; height: 12px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.off { background: var(--surface-2); color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: var(--r);
  border: 1px solid transparent; font-weight: 700; cursor: pointer; background: var(--accent); color: var(--on-accent); white-space: nowrap; }
.btn:active { filter: brightness(.95); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.block-w { width: 100%; }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.outline { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 13px; }

/* Profil / bot sarlavhasi */
.cover { position: relative; padding: 16px 14px; display: flex; align-items: center; gap: 14px; color: #fff;
  background: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 100%); }
.cover h2 { margin: 0; font-size: 19px; }
.cover p { margin: 2px 0 0; opacity: .9; font-size: 13.5px; }
.cover .av { border: 2px solid rgba(255, 255, 255, .5); }

/* Statistika */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 12px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.stat .l svg.lucide { width: 14px; height: 14px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding: 12px 14px 8px; }
.chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; min-width: 0; }
.chart .fill { width: 100%; max-width: 26px; min-height: 2px; border-radius: 2px 2px 0 0; background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.chart .d, .chart .n { font-size: 10px; color: var(--muted); }

/* Switch */
.switch { position: relative; width: 44px; height: 26px; flex: none; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 3px; background: var(--line); transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 2px; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* Forma */
.field { padding: 12px 14px; }
.field + .field { border-top: 1px solid var(--line); }
.field > label, .field .lbl { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .help { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.field.inline { display: flex; align-items: center; gap: 12px; }
.field.inline .lbl { flex: 1; margin: 0; font-weight: 500; }
.input { width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 100px; resize: vertical; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--surface-2); padding: 7px 11px; border-radius: var(--r); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg.full button { flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; gap: 3px; padding: 4px 5px 4px 9px; border-radius: 2px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; }
.tag button { border: none; background: none; color: inherit; cursor: pointer; display: grid; padding: 0; }
.tag svg.lucide { width: 14px; height: 14px; }

.savebar { position: sticky; bottom: calc(var(--bottombar) + 8px + env(safe-area-inset-bottom)); z-index: 15; margin-top: 10px; display: flex; gap: 8px;
  padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px -10px rgba(0, 0, 0, .35); }
.no-bottombar .savebar { bottom: calc(8px + env(safe-area-inset-bottom)); }
@media (min-width: 860px) { .savebar { bottom: 12px; } }
.savebar .btn { flex: 1; }

.search { position: relative; }
.search svg.lucide { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; }
.search .input { padding-left: 38px; background: var(--surface); }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 14px; }
.empty .sq { margin: 0 auto 10px; width: 50px; height: 50px; background: var(--surface-2); }
.empty b { display: block; color: var(--text); margin-bottom: 2px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 0 0; }
.note { display: flex; gap: 10px; padding: 11px 14px; font-size: 13.5px; background: var(--warn-soft); color: var(--warn); border-radius: var(--r); }
.note.info { background: var(--accent-soft); color: var(--accent); }
.note.ok { background: var(--ok-soft); color: var(--ok); }

.skeleton { border-radius: var(--r); height: 80px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%; animation: sh 1.1s infinite; }
.skeleton + .skeleton { margin-top: 10px; }
@keyframes sh { to { background-position: -200% 0; } }
.fade-in { animation: fi .18s ease-out; }
@keyframes fi { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--bottombar) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 24px); padding: 10px 14px; border-radius: var(--r);
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5); }
.toast.err { background: var(--danger); color: #fff; }
.toast[hidden] { display: none; }
.no-bottombar .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 860px) { .toast { bottom: 20px; } }
