/* Komplayens murojaatlari — Ta'lim sifatini ta'minlash milliy agentligi uslubi */
:root {
  --ink: #0E2A47;
  --ink-2: #3B4A5C;
  --muted: #5A6878;
  --line: #DDE4EA;
  --line-strong: #CBD5DF;
  --line-soft: #E7ECF1;
  --canvas: #F3F6F8;
  --surface: #FFFFFF;
  --surface-2: #F5F7FA;
  --hover: #F1F5F8;
  --accent: #0F6E78;
  --accent-hover: #0B5A63;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3F2F0;
  --accent-text: #0B5A63;
  --mint: #19AE8B;
  --mint-hover: #2BC39E;
  --mint-ink: #0B2239;
  --navy: #0E2A47;
  --navy-2: #1C4470;
  --rail-text: #C9D6E3;
  --rail-muted: #8FA3B8;
  --warn: #95580A;
  --warn-fill: #C47A0A;
  --warn-soft: #FBEFD9;
  --danger: #B42830;
  --danger-fill: #C62F36;
  --danger-soft: #FBE4E5;
  --note: #FFF7DB;
  --note-line: #D9C27A;
  --tg: #2A8BC9; --tg-soft: #E1F1FB; --tg-text: #1A5F8A;
  --mail: #6B5BA8; --mail-soft: #EEEBFA; --mail-text: #4F3FA0;
  --wa: #1F9D55;
  --manual: #6E7781;
  --out: #0F6E78;
  --out-ink: #FFFFFF;
  --focus: #2F6CA8;
  --radius-s: 8px;
  --radius-m: 10px;
  --radius-l: 14px;
  --shadow-pop: 0 12px 32px rgba(14, 42, 71, .18);
  --shadow-btn: 0 1px 0 rgba(14, 42, 71, .12), inset 0 1px 0 rgba(255, 255, 255, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E6ECF2; --ink-2: #C3CDD8; --muted: #93A1B0; --line: #2A3A4C; --line-strong: #3A4C60; --line-soft: #223142;
    --canvas: #0F1A26; --surface: #152231; --surface-2: #1A2939; --hover: #1F3043;
    --accent: #3FB3A1; --accent-hover: #5CC4B3; --accent-ink: #06201C; --accent-soft: #173A3A; --accent-text: #7FD8C4;
    --navy: #0A1726; --navy-2: #1C3A5E;
    --warn: #E0A54A; --warn-fill: #E0A54A; --warn-soft: #3A2D17; --danger: #EF6F76; --danger-soft: #3D1E21;
    --note: #2F2B1A; --note-line: #5B5130; --tg-soft: #17324A; --tg-text: #8CCBF0; --mail-soft: #2A2545; --mail-text: #C3B8F5;
    --out: #1F5C54; --out-ink: #F1FAF8; --focus: #6CA8E0; --shadow-pop: 0 12px 32px rgba(0,0,0,.5);
    --shadow-btn: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #E6ECF2; --ink-2: #C3CDD8; --muted: #93A1B0; --line: #2A3A4C; --line-strong: #3A4C60; --line-soft: #223142;
  --canvas: #0F1A26; --surface: #152231; --surface-2: #1A2939; --hover: #1F3043;
  --accent: #3FB3A1; --accent-hover: #5CC4B3; --accent-ink: #06201C; --accent-soft: #173A3A; --accent-text: #7FD8C4;
  --navy: #0A1726; --navy-2: #1C3A5E;
  --warn: #E0A54A; --warn-fill: #E0A54A; --warn-soft: #3A2D17; --danger: #EF6F76; --danger-soft: #3D1E21;
  --note: #2F2B1A; --note-line: #5B5130; --tg-soft: #17324A; --tg-text: #8CCBF0; --mail-soft: #2A2545; --mail-text: #C3B8F5;
  --out: #1F5C54; --out-ink: #F1FAF8; --focus: #6CA8E0; --shadow-pop: 0 12px 32px rgba(0,0,0,.5);
  --shadow-btn: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 15px/1.5 "Golos Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--accent-text); }
svg.ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- tugmalar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--radius-m); cursor: pointer; font-weight: 600; font-size: 14px; line-height: 1;
  white-space: nowrap; color: var(--ink); text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:hover { background: var(--hover); border-color: #AEBBC8; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--focus); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: var(--shadow-btn); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.mint { background: var(--mint); color: var(--mint-ink); border-color: var(--mint); }
.btn.mint:hover { background: var(--mint-hover); border-color: var(--mint-hover); }
.btn.mint:focus-visible { box-shadow: 0 0 0 3px var(--navy), 0 0 0 5px #FFFFFF; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent-text); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--danger); border-color: #E8B4B7; }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.primary.danger-fill { background: var(--danger-fill); border-color: var(--danger-fill); color: #fff; }
.btn.primary.danger-fill:hover { background: #A8232A; border-color: #A8232A; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-s); }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.wide { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: progress; transform: none; }
.btn.primary:disabled { background: #C9D3DC; border-color: #C9D3DC; color: var(--muted); opacity: 1; box-shadow: none; }
a.btn.primary { color: var(--accent-ink); }
.link { background: none; border: 0; padding: 0; color: var(--accent-text); cursor: pointer; font-weight: 500; font-size: 13px; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.link:hover { text-decoration-color: currentColor; }
.link.danger-link { color: var(--danger); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-m);
  background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.out { border-color: var(--line-strong); background: var(--surface); }
.icon-btn.on-dark { width: 36px; height: 36px; color: var(--rail-text); }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .link + .link { margin-left: 14px; }

/* ---------- maydonlar */
input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-m);
  padding: 8px 12px; min-height: 40px; transition: border-color .15s, box-shadow .15s;
}
input:not([type=checkbox]):not([type=file]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
label > input, label > select, label > textarea { color: var(--ink); font-size: 15px; font-weight: 400; }
select:disabled, input:disabled { opacity: .65; cursor: not-allowed; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }

/* ---------- kirish */
.login { min-height: 100%; display: flex; flex-wrap: wrap; background: var(--canvas); }
.login-brand {
  flex: 1 1 520px; min-height: 100vh; position: relative; overflow: hidden;
  background: var(--navy); color: #fff; padding: 56px 64px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 48px;
}
.login-motif { position: absolute; right: -120px; bottom: -60px; width: 640px; fill: #fff; opacity: .07; pointer-events: none; }
.agency { display: flex; align-items: center; gap: 18px; position: relative; }
.agency img { display: block; width: 72px; height: auto; }
.agency-sep { width: 1px; align-self: stretch; background: rgba(255, 255, 255, .22); }
.agency-name { font-size: 14px; line-height: 1.35; font-weight: 500; color: var(--rail-text); max-width: 270px; }
.login-pitch { position: relative; display: grid; gap: 20px; max-width: 540px; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #7FD8C4; }
.eyebrow > span:first-child { width: 24px; height: 2px; background: var(--mint); }
.login-pitch h1 { font-size: 44px; line-height: 1.12; letter-spacing: -0.01em; }
.login-pitch p { margin: 0; font-size: 17px; line-height: 1.55; color: var(--rail-text); }
.login-chips { position: relative; display: flex; flex-wrap: wrap; gap: 10px; }
.login-chips > span {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16); font-size: 14px; color: #E6EDF4;
}
.login-side { flex: 1 1 480px; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.login-card { width: min(420px, 100%); display: grid; gap: 20px; }
.login-head { display: grid; gap: 8px; }
.login-head h2 { font-size: 30px; line-height: 1.2; }
.login-head p { margin: 0; }
.login-logo-sm { display: none; }
.login-logo-sm img { display: block; width: 56px; height: auto; margin-bottom: 8px; }
.login-card input:not([type=checkbox]) { min-height: 48px; }
.pwd-wrap { position: relative; display: block; }
.pwd-wrap input { padding-right: 52px !important; }
.pwd-wrap .icon-btn { position: absolute; right: 4px; top: 4px; }
.pwd-wrap .icon-btn[aria-pressed="true"] { color: var(--accent-text); }
.login-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: #E9F1F7; color: #24405E; font-size: 13px; line-height: 1.5; }
.login-note svg { margin-top: 1px; }
.login-foot { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- asosiy tuzilma */
.app { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 256px 380px minmax(0, 1fr); }

/* yon menyu — agentlik rangi */
.rail { background: var(--navy); color: #fff; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px; overflow-y: auto; }
.rail > * { flex-shrink: 0; }
.rail-head { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.rail-head img { width: 46px; height: auto; display: block; flex: none; }
.org { font-weight: 700; line-height: 1.2; font-size: 15px; }
.rail-sub { font-size: 12px; color: var(--rail-muted); line-height: 1.3; }
.rail .btn.mint { height: 44px; }
.folders { display: grid; gap: 2px; }
.folders button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px;
  background: none; border: 0; padding: 0 10px; border-radius: 9px; cursor: pointer; text-align: left;
  color: var(--rail-text); font-size: 14px; font-weight: 500; transition: background .15s, color .15s;
}
.folders button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.folders button.active { background: var(--navy-2); color: #fff; font-weight: 600; }
.folders button:focus-visible { outline-color: #fff; outline-offset: -2px; }
.folders .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folders .n {
  min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, .1); color: #E6EDF4;
}
.folders .n:empty { display: none; }
.folders button.active .n { background: #fff; color: #0E2A47; }
.folders .n.alert, .folders button.active .n.alert { background: #C62F36; color: #fff; }
.folders .n.warn, .folders button.active .n.warn { background: #F5B544; color: #0B2239; }
.folders.secondary { border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 14px; }
.rail-section { display: grid; gap: 10px; padding: 0 6px; }
.rail-title { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--rail-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .18); background: transparent; color: var(--rail-text); font-size: 13px; font-weight: 500; cursor: pointer;
}
.chip:hover { border-color: rgba(255, 255, 255, .4); color: #fff; }
.chip.active { background: #fff; border-color: #fff; color: #0E2A47; font-weight: 600; }
.rail-foot { margin-top: auto; display: grid; gap: 14px; }
.channel-state { display: grid; gap: 6px; font-size: 12px; padding: 0 6px; }
.channel-state div { display: flex; gap: 8px; align-items: center; color: var(--rail-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--manual); }
.dot.ok { background: #3CD39A; } .dot.err { background: #FF7A80; } .dot.off { background: transparent; border: 1px solid var(--rail-muted); }
.user-card { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .06); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #2F6CA8; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none; }
.user-meta { display: grid; min-width: 0; flex: 1; line-height: 1.35; }
.user-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 12px; color: var(--rail-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-scrim { display: none; }

/* kanal belgisi */
.ch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ch::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--manual); }
.ch.telegram::before { background: var(--tg); border-radius: 50%; }
.ch.email::before { background: var(--mail); }
.ch.whatsapp::before { background: var(--wa); border-radius: 50%; }
.chip .ch::before { background: #C9D6E3; }
.chip .ch.telegram::before { background: #6CC0EE; }
.chip .ch.email::before { background: #B8AEF0; }
.chip .ch.whatsapp::before { background: #5BD08C; }

/* ---------- ro'yxat */
.list-pane { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.list-head { display: flex; align-items: center; gap: 10px; padding: 20px 18px 12px; }
.list-head h2 { font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { height: 24px; padding: 0 9px; border-radius: 999px; background: var(--line-soft); color: var(--ink-2); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; flex: none; }
.count:empty { display: none; }
.search { margin: 0 18px 14px; position: relative; color: var(--muted); }
.search svg { position: absolute; left: 12px; top: 11px; pointer-events: none; }
.search input#search { padding-left: 38px; background: var(--surface-2); border-color: var(--line); }
.tickets { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; border-top: 1px solid var(--line-soft); }
.ticket { padding: 14px 18px 14px 26px; border-bottom: 1px solid var(--line-soft); cursor: pointer; position: relative; display: grid; gap: 6px; transition: background .12s; }
.ticket:hover { background: var(--surface-2); }
.ticket:focus-visible { outline-offset: -2px; }
.ticket.sel { background: var(--accent-soft); }
.ticket.sel::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.ticket.unread::before { content: ""; position: absolute; left: 11px; top: 21px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.ticket .row1 { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.ticket .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket.unread .who { font-weight: 700; }
.ticket .when { font-size: 12px; color: var(--muted); flex: none; }
.ticket .subj { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket.unread .subj { font-weight: 500; color: var(--ink); }
.ticket .prev { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.ticket .row3 { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; font-size: 12px; color: var(--muted); }
.ticket .row3 > * { white-space: nowrap; }
.ticket .num { font-weight: 600; color: var(--ink-2); margin-right: 2px; }
.ticket .who-assignee::before { content: "· "; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; font-size: 12px; padding: 0 8px; border-radius: 6px; background: var(--line-soft); color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.tag.high { background: var(--danger-soft); color: var(--danger); }
.tag.anon { background: #2B3D52; color: #fff; }
.tag.num-tag { background: var(--navy); color: #fff; }
.tag.chan-telegram { background: var(--tg-soft); color: var(--tg-text); }
.tag.chan-email { background: var(--mail-soft); color: var(--mail-text); }
.tag.chan-whatsapp { background: #DDF3E6; color: #16703D; }
.tag.status-new { background: var(--accent-soft); color: var(--accent-text); }
.tag.status-in_progress { background: var(--warn-soft); color: var(--warn); }
.tag.status-waiting { background: var(--tg-soft); color: var(--tg-text); }
.tag.status-closed { background: var(--line-soft); color: var(--muted); }
.tag.role-admin { background: var(--accent-soft); color: var(--accent-text); }
.tag.role-director { background: var(--warn-soft); color: var(--warn); }
.list-empty { padding: 40px 24px; text-align: center; color: var(--muted); }
#moreBtn { margin: 12px 18px; width: auto; }

/* Muddat chizig'i — interfeysning asosiy elementi */
.deadline { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.deadline .track { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.deadline .fill { height: 100%; background: var(--accent); border-radius: 3px; }
.deadline .lbl { font-size: 12px; font-weight: 600; color: var(--accent-text); min-width: 78px; text-align: right; }
.deadline.soon .fill { background: var(--warn-fill); } .deadline.soon .lbl { color: var(--warn); }
.deadline.over .fill { background: var(--danger-fill); } .deadline.over .lbl { color: var(--danger); font-weight: 700; }
.deadline.done .fill { background: var(--muted); opacity: .45; } .deadline.done .lbl { color: var(--muted); font-weight: 500; }

/* ---------- suhbat */
.thread-pane { min-width: 0; min-height: 0; display: flex; }
.empty-state { margin: auto; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.empty-state img { display: block; width: 88px; height: auto; opacity: .35; }
.thread { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 312px; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.thread-head { grid-column: 1 / -1; background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px 22px; display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; }
.thread-head .titles { min-width: 0; flex: 1 1 320px; display: grid; gap: 6px; }
.thread-head .tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.thread-head h2 { font-size: 20px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-head .sub { font-size: 13px; color: var(--muted); }
.thread-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); display: grid; gap: 2px;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: var(--radius-s);
  background: none; cursor: pointer; text-align: left; font-size: 14px; font-weight: 500; color: var(--ink);
}
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-soft); }
.conv { display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: min(640px, 80%); display: grid; gap: 5px; }
.msg .bubble { padding: 12px 15px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.msg .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.msg.in { align-self: flex-start; }
.msg.in .bubble { background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.out { align-self: flex-end; }
.msg.out .meta { justify-content: flex-end; }
.msg.out .bubble { background: var(--out); color: var(--out-ink); border-top-right-radius: 4px; }
.msg.out.failed .bubble { background: var(--danger-soft); color: var(--ink); border: 1px solid var(--danger); }
.msg.note { align-self: stretch; max-width: none; }
.msg.note .bubble { background: var(--note); border: 1px dashed var(--note-line); border-radius: var(--radius-m); }
.msg.system { align-self: center; max-width: 560px; text-align: center; justify-items: center; }
.msg.system .bubble { background: var(--line-soft); padding: 4px 12px; border-radius: 999px; font-size: 12px; color: var(--muted); }
.msg.system .meta { justify-content: center; }
.err-line { color: var(--danger); font-weight: 500; }
.files { display: flex; flex-wrap: wrap; gap: 6px; }
.msg.out .files { justify-content: flex-end; }
.file { display: inline-flex; align-items: center; gap: 8px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 0 12px; font-size: 13px; color: var(--ink); text-decoration: none; max-width: 280px; }
.file svg { color: var(--focus); flex: none; }
.file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file:hover { border-color: var(--accent); }
.file small { color: var(--muted); flex: none; }
.thumb { display: block; border-radius: var(--radius-m); border: 1px solid var(--line); max-width: 220px; max-height: 180px; object-fit: cover; }

/* javob yozish */
.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 14px 18px 16px; display: grid; gap: 10px; }
.composer.note-mode { background: var(--note); }
.composer-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.tabs { display: inline-flex; padding: 3px; border-radius: var(--radius-m); background: var(--line-soft); gap: 2px; }
.tabs button { height: 32px; padding: 0 14px; border: 0; border-radius: var(--radius-s); background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(14, 42, 71, .14); }
.composer textarea { min-height: 84px; max-height: 40vh; }
.composer .bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.composer .bar .grow { flex: 1; }
.composer .bar label.btn { display: inline-flex; flex-direction: row; color: var(--ink); font-size: 14px; }
.composer #sendBtn { height: 44px; padding: 0 20px; margin-left: auto; }
.check { display: inline-flex; flex-direction: row; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); cursor: pointer; font-weight: 400; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; }
.pending-files:empty { display: none; }
.pending-files .file button { background: none; border: 0; padding: 0 0 0 4px; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }
.hint { font-size: 12px; color: var(--muted); }
.notice { font-size: 13px; color: var(--warn); background: var(--warn-soft); border-radius: var(--radius-s); padding: 8px 12px; }

/* yon panel */
.side { border-left: 1px solid var(--line); background: var(--canvas); overflow-y: auto; padding: 16px; display: grid; gap: 14px; align-content: start; }
.side > div, .side .fields, .side label { min-width: 0; }
.side input, .side select { min-width: 0; }
.side .inline-row { flex-wrap: wrap; }
.side .inline-row > * { flex: 1 1 130px; }
.side > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; align-content: start; }
.side h3 { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.side .fields { display: grid; gap: 12px; }
.contact { display: grid; gap: 2px; font-size: 14px; overflow-wrap: anywhere; }
.contact .name { font-weight: 600; font-size: 15px; }
.contact a { color: var(--accent-text); }
.tg-profile { display: inline-flex; align-items: center; gap: 6px; }
.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.mini-list button { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: var(--accent-text); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.history { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 10px; font-size: 13px; }
.history li { position: relative; }
.history li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.history li:first-child::before { border-color: var(--accent); }
.history .t { color: var(--muted); font-size: 12px; }
.inline-row { display: flex; gap: 10px; }
.inline-row > * { flex: 1; min-width: 0; }

/* ---------- sahifalar: hisobot, xodimlar */
.page { grid-column: 2 / -1; overflow-y: auto; padding: 28px 32px 48px; background: var(--canvas); }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin-bottom: 20px; }
.page-head h2 { font-size: 24px; }
.page-title { display: flex; align-items: center; gap: 8px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters label { min-width: 150px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.2; }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi.alert { border-color: #E8B4B7; }
.kpi.alert .v { color: var(--danger); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 18px 20px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; }
.bars { display: grid; gap: 8px; }
.bars .b { display: grid; grid-template-columns: 150px 1fr 40px; gap: 10px; align-items: center; font-size: 14px; }
.bars .b span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bt { height: 10px; background: var(--line-soft); border-radius: 5px; overflow: hidden; }
.bars .bf { height: 100%; background: var(--accent); border-radius: 5px; }
.bars .n { text-align: right; font-weight: 600; }
.daily { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; }
.daily div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.daily-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; font-size: 14px; }
table.grid th, table.grid td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid th { font-weight: 600; color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; background: var(--surface-2); }
table.grid td.num, table.grid th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

/* ---------- modal va xabarnoma */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(10, 23, 38, .5); }
#modalForm { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 24px 26px; }
#modalForm label:not(.check) { grid-template-columns: minmax(0, 1fr); }
#modalForm input[type=file] { width: 100%; min-width: 0; max-width: 100%; font-size: 14px; }
#modalForm h3 { font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: var(--radius-m); font-weight: 500; box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger-fill); color: #fff; }

/* ---------- moslashuvchan
   Kompyuter: > 1180px — 3 ustun (menyu, ro'yxat, suhbat)
   Planshet:  761–1180px — menyu chiqib-kiruvchi, 2 ustun (ro'yxat, suhbat)
   Telefon:   <= 760px — bitta ustun, ro'yxat va suhbat almashib ochiladi */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.only-mobile { display: none; }
.back-btn { display: none; }
@media (max-width: 1600px) {
  .app { grid-template-columns: 248px 340px minmax(0, 1fr); }
  .thread { grid-template-columns: minmax(0, 1fr) 288px; }
  .composer .bar .hint { display: none; }
}
@media (max-width: 1280px) {
  .thread { grid-template-columns: minmax(0, 1fr) 272px; }
}
@media (max-width: 1180px) {
  /* Planshet va telefon: chap panel doim ko'rinadi, ixcham (faqat belgilar). ☰ — to'liq ochish */
  .app { grid-template-columns: 68px clamp(280px, 36vw, 360px) minmax(0, 1fr); }
  .rail { grid-column: 1; grid-row: 1; }
  .list-pane { grid-column: 2; grid-row: 1; }
  .thread-pane { grid-column: 3; grid-row: 1; }
  .page { grid-column: 2 / -1; grid-row: 1; padding: 24px; }
  .rail:not(.open) {
    padding: max(14px, env(safe-area-inset-top)) 8px max(14px, env(safe-area-inset-bottom)); gap: 12px; align-items: stretch;
    padding-left: max(8px, env(safe-area-inset-left)); scrollbar-width: none;
  }
  .rail:not(.open)::-webkit-scrollbar { display: none; }
  .rail:not(.open) .rail-head { justify-content: center; padding: 0; }
  .rail:not(.open) .rail-head img { width: 38px; }
  .rail:not(.open) .rail-head > div,
  .rail:not(.open) .rail-section,
  .rail:not(.open) .folders .lbl,
  .rail:not(.open) .channel-state,
  .rail:not(.open) .user-meta { display: none; }
  .rail:not(.open) #newTicketBtn { font-size: 0; gap: 0; padding: 0; height: 48px; }
  .rail:not(.open) .folders button { justify-content: center; padding: 0; min-height: 48px; position: relative; }
  .rail:not(.open) .folders button .ic { width: 22px; height: 22px; }
  .rail:not(.open) .folders .n {
    position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px;
  }
  .rail:not(.open) .folders.secondary { padding-top: 12px; }
  .rail:not(.open) .user-card { flex-direction: column; padding: 8px 0; gap: 6px; background: none; }
  .rail.open {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 30; box-shadow: var(--shadow-pop);
    padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
  }
  .rail.open + .rail-scrim { display: block; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 25; background: rgba(10, 23, 38, .45); }
  .only-mobile { display: inline-flex; }
  .thread { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(0, 1fr); }
  .side { border-left: 0; border-bottom: 1px solid var(--line); grid-row: 2; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); max-height: 36vh; overflow-x: hidden; }
  .conv { grid-row: 3; }
}
@media (max-width: 1080px) {
  .login-brand { min-height: auto; padding: 40px 32px; }
  .login-pitch h1 { font-size: 34px; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 60px minmax(0, 1fr); }
  .list-pane, .thread-pane { grid-column: 2; }
  .page { grid-column: 2; }
  .rail:not(.open) { padding-left: max(6px, env(safe-area-inset-left)); padding-right: 6px; }
  .rail:not(.open) .rail-head img { width: 34px; }
  .rail:not(.open) .folders button { min-height: 46px; }
  .back-btn { display: inline-flex; }
  .list-pane { border-right: 0; }
  .app.has-thread .list-pane { display: none; }
  .app:not(.has-thread) .thread-pane { display: none; }
  .list-head { padding: 12px 12px 10px; }
  .search { margin: 0 12px 12px; }
  .ticket { padding: 12px 14px 12px 24px; }
  .page { padding: 16px 12px 32px; padding-bottom: max(32px, env(safe-area-inset-bottom)); }
  .page-head h2 { font-size: 20px; }
  .filters { width: 100%; }
  .filters label { min-width: 0; flex: 1 1 140px; }
  .filters .btn { flex: 1 1 auto; }
  .table-wrap table.grid { min-width: 560px; }
  .thread-pane { overflow-y: auto; display: block; -webkit-overflow-scrolling: touch; }
  .thread { display: flex; flex-direction: column; min-height: 100%; }
  .thread-head { position: sticky; top: 0; z-index: 5; padding: 10px 12px; gap: 10px; }
  .thread-head h2 { font-size: 16px; white-space: normal; }
  .thread-head .titles { flex-basis: 0; }
  .thread-head .actions { width: 100%; }
  .thread-head .actions > .btn { flex: 1 1 auto; }
  .conv { order: 2; }
  .side { order: 3; max-height: none; grid-template-columns: 1fr; border-top: 1px solid var(--line); padding: 12px; }
  .messages { padding: 14px 12px; overflow: visible; min-height: 40vh; }
  .composer { padding: 12px 12px max(14px, env(safe-area-inset-bottom)); }
  .composer .hint { display: none; }
  .composer #sendBtn { flex: 1 1 100%; margin-left: 0; }
  .msg { max-width: 92%; }
  .thumb { max-width: 100%; }
  .file { max-width: 100%; }
  .bars .b { grid-template-columns: 110px 1fr 34px; }
  .inline-row { flex-direction: column; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panels { grid-template-columns: 1fr; }
  .kpi .v { font-size: 24px; }
  /* iPhone maydonga bosilganda sahifani kattalashtirmasligi uchun shrift 16px */
  input:not([type=checkbox]):not([type=file]), select, textarea,
  label > input, label > select, label > textarea { font-size: 16px; }
  dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); overflow-y: auto; }
  #modalForm { padding: 20px 16px; }
  .modal-actions .btn { flex: 1 1 auto; }
  .toast { bottom: max(16px, env(safe-area-inset-bottom)); }
  .login-brand { display: none; }
  .login-logo-sm { display: block; }
  .login-side { min-height: 100vh; min-height: 100dvh; padding: 32px 18px; }
  .login-head h2 { font-size: 26px; }
}
@media (max-width: 380px) {
  .thread-head .actions > .btn { padding: 0 10px; font-size: 13px; }
  .kpis { grid-template-columns: 1fr; }
}
/* Sensorli ekranlar (telefon, planshet): barmoq bilan bosishga qulay o'lchamlar */
@media (pointer: coarse) {
  .btn.sm { height: 40px; }
  .chip { height: 36px; padding: 0 14px; }
  .icon-btn.on-dark { width: 44px; height: 44px; }
  .rail:not(.open) .icon-btn.on-dark { width: 40px; height: 40px; }
  .folders button { min-height: 46px; }
  .tabs button { height: 38px; }
  .link { padding: 8px 0; }
  .row-actions .link + .link { margin-left: 16px; }
  .ticket:hover { background: none; }
  .ticket.sel:hover { background: var(--accent-soft); }
}
/* Eski brauzerlar (Safari < 15.4): <dialog> o'rniga oddiy oyna */
dialog:not([open]) { display: none; }
dialog.dlg-fallback[open] {
  display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 60; margin: 0;
  max-height: 90vh; overflow-y: auto;
}
body.dlg-open::after { content: ""; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 55; background: rgba(10, 23, 38, .5); }
/* ---------- Ta'lim sifati hamjamiyati paneli */
.tag.role-hamjamiyat { background: var(--tg-soft); color: var(--tg-text); }
.bot-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-left: 6px; white-space: nowrap; }
.bot-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.bot-pill.on { background: var(--accent-soft); color: var(--accent-text); }
.bot-pill.off { background: var(--danger-soft); color: var(--danger); }
.hj-tabs { display: flex; max-width: 100%; overflow-x: auto; margin-bottom: 18px; scrollbar-width: thin; }
.hj-tabs button { white-space: nowrap; flex: none; }
.hj-tabs .cnt { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.hj-filters { margin-bottom: 8px; }
.hj-filters .grow { flex: 1 1 220px; }
.hj-list { display: grid; gap: 12px; }
.hj-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 16px 18px; display: grid; gap: 10px; min-width: 0; }
.hj-card-head { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.hj-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.hj-post { max-height: 9.5em; overflow: auto; }
.hj-author { font-size: 13px; line-height: 1.45; }
.hj-answer { background: var(--accent-soft); border-radius: var(--radius-m); padding: 10px 12px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.hj-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag.hj-st-new { background: var(--accent-soft); color: var(--accent-text); }
.tag.hj-st-review { background: var(--warn-soft); color: var(--warn); }
.tag.hj-st-accepted { background: #DDF3E6; color: #16703D; }
.tag.hj-st-declined { background: var(--line-soft); color: var(--muted); }
.hj-bulk { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 12px; }
.hj-table td { vertical-align: top; }
.hj-comments { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.hj-comments li { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; display: grid; gap: 4px; }
.hj-c-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; line-height: 1.4; }
.hj-card summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent-text); }
.hj-form { display: grid; gap: 12px; align-content: start; }
.hj-form h3 { margin-bottom: 0; }
.hj-h { font-size: 16px; margin: 24px 0 12px; }
.hj-preview { background: var(--surface-2); border-radius: var(--radius-m); padding: 12px; white-space: pre-wrap; max-height: 40vh; overflow: auto; overflow-wrap: anywhere; }
.app.hj-only .list-pane, .app.hj-only .thread-pane { display: none !important; }
@media (min-width: 1181px) { .app.hj-only { grid-template-columns: 256px minmax(0, 1fr); } .app.hj-only .page { grid-column: 2; } }
@media (max-width: 1180px) { .app.hj-only { grid-template-columns: 68px minmax(0, 1fr); } .app.hj-only .page { grid-column: 2; } }
@media (max-width: 760px) {
  .app.hj-only { grid-template-columns: 60px minmax(0, 1fr); }
  .hj-card { padding: 12px; }
  .hj-c-head { flex-direction: column; gap: 2px; }
  .hj-table { min-width: 620px; }
}
/* ---------- tizim tanlash */
.chooser { gap: 14px; }
.choose-card {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; padding: 18px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.choose-card:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(14, 42, 71, .1); }
.choose-card:active { transform: translateY(1px); }
.choose-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--focus); }
.choose-ic { width: 52px; height: 52px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.choose-ic.m { background: var(--navy); color: #fff; }
.choose-ic.h { background: var(--accent-soft); color: var(--accent-text); }
.choose-txt { display: grid; gap: 3px; flex: 1; min-width: 0; }
.choose-txt b { font-size: 16px; }
.choose-txt small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.choose-go { color: var(--muted); }
.back-link { justify-self: start; font-size: 14px; }

/* ---------- a'zo kartochkasi */
body.drawer-open { overflow: hidden; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 40; }
.drawer-scrim { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(10, 23, 38, .45); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--canvas);
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column; overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.drawer-panel > * { flex-shrink: 0; }
.drawer-head { display: flex; gap: 14px; align-items: flex-start; padding: 20px 20px 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.drawer-title { flex: 1; min-width: 0; display: grid; gap: 8px; }
.drawer-title h2 { font-size: 19px; overflow-wrap: anywhere; }
.drawer-title .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.member-info { margin: 0; padding: 14px 20px; display: grid; gap: 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.member-info div { display: grid; grid-template-columns: 120px 1fr; gap: 10px; font-size: 14px; }
.member-info dt { color: var(--muted); }
.member-info dd { margin: 0; overflow-wrap: anywhere; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 20px 0; }
.drawer-actions:empty { display: none; }
.drawer-tabs { margin: 14px 20px 12px; }
.drawer-body { padding: 0 20px 20px; display: grid; gap: 12px; }
.dm-thread { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow-y: auto; padding: 4px 2px; }
.dm { display: grid; gap: 3px; max-width: 86%; }
.dm .bubble { padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; font-size: 14px; }
.dm time { font-size: 11px; color: var(--muted); }
.dm.in { align-self: flex-start; }
.dm.in .bubble { background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 4px; }
.dm.out { align-self: flex-end; justify-items: end; }
.dm.out .bubble { background: var(--out); color: var(--out-ink); border-top-right-radius: 4px; }
.dm.system { align-self: center; max-width: 100%; justify-items: center; text-align: center; }
.dm.system span { background: var(--line-soft); color: var(--muted); padding: 4px 12px; border-radius: 999px; font-size: 12px; }
.dm-kind { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; opacity: .8; margin-bottom: 3px; }
.dm-compose { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.dm-compose textarea { min-height: 52px; }
.hj-mem { font-weight: 700; font-size: inherit; text-align: left; color: var(--accent-text); }

/* ---------- guruh chati */
.tabs.seg { margin-bottom: 14px; }
.gchat-wrap { display: grid; gap: 10px; }
.gchat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 14px; height: min(62vh, 640px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.gm { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; display: grid; gap: 4px; position: relative; }
.gm.post { border-left-color: var(--navy-2); background: var(--surface-2); border-radius: 0 10px 10px 0; padding: 10px 12px; }
.gm.agency { border-left-color: var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; padding: 8px 12px; }
.gm-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 13px; }
.gm-head > span:first-child { font-weight: 700; }
.gm-head time { margin-left: auto; font-size: 11px; color: var(--muted); }
.gq { font-size: 12px; color: var(--muted); border-left: 2px solid var(--line-strong); padding-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-reply { justify-self: start; font-size: 12px; }
.gchat-compose { grid-template-columns: 1fr auto; }
.greply-to { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-radius: var(--radius-s); padding: 6px 10px; }
@media (max-width: 760px) {
  .drawer-panel { width: 100vw; }
  .member-info div { grid-template-columns: 96px 1fr; }
  .dm-compose, .gchat-compose { grid-template-columns: 1fr; }
  .gchat { height: 58vh; }
}
/* ---------- hamjamiyat: umumiy ko'rinish */
.hj-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.hj-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 16px 18px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.hj-stat .v { font-size: 30px; font-weight: 700; line-height: 1.15; }
.hj-stat .k { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.hj-stat .s { font-size: 12.5px; color: var(--muted); }
.hj-stat .cov-track { margin-top: 10px; }
.hj-alerts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.hj-alert { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--warn-fill); background: var(--warn-soft); color: var(--warn); font-size: 14px; font-weight: 500; }
.hj-alert b { font-weight: 700; }
.hj-alert span { margin-left: 2px; }
.hj-alert:hover { filter: brightness(1.05); box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.hj-alerts.ok span { font-size: 13px; color: var(--accent-text); background: var(--accent-soft); border-radius: 999px; padding: 8px 14px; }
.hj-panels { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; gap: 6px; }
.hbar-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.hbar-top span { min-width: 0; overflow-wrap: anywhere; }
.hbar-top b { flex: none; }
.cov-track { height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.cov-track.big { height: 6px; }
.cov-fill { height: 100%; border-radius: 4px; background: var(--accent); min-width: 0; }
.zero { color: var(--muted) !important; font-weight: 400 !important; }
.hj-cov-panel { margin-top: 16px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 14px; }
.panel-head h3 { margin: 0; }
.cov-table { table-layout: fixed; min-width: 640px; }
.cov-table col.c-reg { width: 30%; }
.cov-table col.c-num { width: 13%; }
.cov-table col.c-cov { width: 30%; }
.cov-table td, .cov-table th { padding: 11px 14px; }
.cov-table tbody td:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cov-table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; }
.frac { white-space: nowrap; font-variant-numeric: tabular-nums; }
.frac b { font-weight: 700; color: var(--ink); }
.frac span { color: var(--muted); margin-left: 3px; font-size: 13px; }
.frac.zero b { color: var(--muted); font-weight: 400; }
.cov { display: flex; align-items: center; gap: 10px; }
.cov .cov-track { flex: 1; max-width: 220px; }
.m-pct { display: none; font-size: 12px; font-weight: 600; color: var(--accent-text); }
.cov-pct { width: 40px; text-align: right; font-weight: 600; font-size: 13px; color: var(--accent-text); flex: none; }
@media (max-width: 1180px) { .hj-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .hj-stats { gap: 8px; }
  .hj-stat { padding: 12px 14px; }
  .hj-stat .v { font-size: 24px; }
  .hj-panels { grid-template-columns: 1fr; }
  .table-wrap table.cov-table { min-width: 0; table-layout: auto; }
  .cov-table .ty { display: none; }
  .cov-table td, .cov-table th { padding: 10px 8px; }
  .cov-table tbody td:first-child { white-space: normal; }
  .cov-table col { width: auto !important; }
  .cov-table .cv { display: none; }
  .cov-table .m-pct { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media (prefers-color-scheme: dark) {
  .login-note { background: var(--surface-2); color: var(--ink-2); }
  .btn:hover { border-color: var(--line-strong); }
}

/* ---- Hamjamiyat: rasm va fayllar */
.hj-files { display: grid; gap: 8px; min-width: 0; }
.hj-files:empty { display: none; }
.hj-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.hj-thumb { position: relative; width: 112px; height: 112px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--canvas); cursor: zoom-in; flex: none; }
.hj-thumb img, .hj-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.hj-thumb:hover { border-color: var(--accent); }
.hj-thumb:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hj-thumb .play { position: absolute; inset: 0; margin: auto; width: 38px; height: 38px; border-radius: 50%; background: rgba(14, 42, 71, .72); color: #fff; display: grid; place-items: center; font-size: 15px; padding-left: 3px; }
.hj-files.compact .hj-thumb { width: 84px; height: 84px; }
.hj-thumb.big { width: 100%; height: auto; aspect-ratio: 4 / 3; }
.hj-thumb.off { display: grid; place-items: center; cursor: default; color: var(--muted); font-size: 12px; text-align: center; padding: 10px; }
.hj-file { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; width: fit-content; min-width: 0; padding: 7px 12px 7px 7px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px; }
a.hj-file:hover { border-color: var(--accent); background: var(--hover); }
.hj-file .fn { display: grid; min-width: 0; line-height: 1.3; }
.hj-file .fn, .hj-file .fn small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hj-file .fn small { color: var(--muted); font-size: 12px; }
.hj-file.off { color: var(--muted); }
.hj-file.audio { padding: 4px 6px; gap: 4px; }
.hj-file audio { height: 36px; max-width: 260px; }
.fx { display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 4px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 700; letter-spacing: .02em; flex: none; }
.hj-ftable .fx { min-width: 34px; height: 24px; margin-right: 6px; font-size: 10px; vertical-align: middle; }
.hj-ftable audio { height: 32px; max-width: 200px; vertical-align: middle; margin-right: 6px; }
.dm .bubble .hj-files { margin-bottom: 6px; }
.dm .bubble .hj-files:last-child { margin-bottom: 0; }
.dm.out .bubble .hj-file { color: var(--ink); }
.gm .hj-files { margin-top: 2px; }

.hj-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.hj-gitem { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; display: grid; align-content: start; }
.hj-gitem .hj-thumb.big { border: 0; border-radius: 0; border-bottom: 1px solid var(--line); }
.hj-gitem figcaption { display: grid; gap: 3px; padding: 10px 12px 12px; font-size: 13px; min-width: 0; }
.hj-gitem figcaption > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; justify-self: start; max-width: 100%; }
.hj-gitem figcaption a.link { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; }

.avatar.photo { padding: 0; border: 0; overflow: hidden; cursor: zoom-in; }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lightbox { position: fixed; inset: 0; z-index: 400; background: rgba(6, 18, 32, .9); display: grid; grid-template-rows: auto 1fr; }
.lightbox[hidden] { display: none; }
body.lb-open { overflow: hidden; }
.lb-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #fff; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb-name .muted { color: #A9B8C8; font-weight: 400; margin-left: 6px; }
.lb-bar .icon-btn { color: #fff; }
.lb-fig { margin: 0; min-height: 0; display: grid; grid-template-rows: 1fr auto; place-items: center; padding: 0 64px 18px; }
.lb-fig img, .lb-fig video { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 6px; background: #000; }
.lb-fig figcaption { color: #E6EDF3; max-width: 720px; text-align: center; padding-top: 10px; white-space: pre-wrap; font-size: 14px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 64px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .12); color: #fff; font-size: 34px; cursor: pointer; }
.lb-nav:hover { background: rgba(255, 255, 255, .22); }
.lb-nav.prev { left: 10px; }
.lb-nav.next { right: 10px; }
@media (max-width: 760px) {
  .hj-thumb { width: 88px; height: 88px; }
  .hj-files.compact .hj-thumb { width: 72px; height: 72px; }
  .hj-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .hj-gitem figcaption { padding: 8px 10px 10px; font-size: 12px; }
  .lb-fig { padding: 0 8px 12px; }
  .lb-bar { flex-wrap: wrap; }
  .lb-bar .lb-name { flex-basis: calc(100% - 50px); order: -1; }
  .lb-nav { top: auto; bottom: 14px; transform: none; height: 46px; }
  .hj-file audio { max-width: 200px; }
}
.hj-files { white-space: normal; }
@media (max-width: 760px) {
  .hj-gitem figcaption a.link { white-space: normal; }
  .lightbox .lb-fig { padding-bottom: 76px; }
  .lightbox .lb-fig figcaption { padding-top: 12px; }
}

/* ---- Hamjamiyat: kanal postlari */
.hj-posts-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.hj-posts-head .tabs.seg { margin-bottom: 0; }
.hj-draft label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.hj-draft textarea { font-size: 15px; line-height: 1.55; resize: vertical; }
.hj-draft .cnt-chars { justify-self: end; font-weight: 400; }
.hj-note { margin: 0; padding: 8px 12px; border-radius: var(--radius-m); background: var(--note); border: 1px solid var(--note-line); font-size: 13px; color: var(--ink); }
.hj-src-box { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--radius-m); background: var(--canvas); border: 1px solid var(--line-soft); font-size: 14px; }
.hj-src { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.hj-src li { overflow-wrap: anywhere; }
.hj-src q { display: block; margin-top: 3px; color: var(--muted); font-style: italic; font-size: 13px; }
.hj-src q::before { content: "«"; } .hj-src q::after { content: "»"; }
.hj-src-box .check { font-weight: 400; color: var(--ink); }
.hj-preview .hj-src { white-space: normal; margin-top: 4px; }
.hj-draft label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.hj-draft label.check input { width: auto; margin: 0; }
.hj-cover { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 14px; align-items: start; }
.hj-cover-img { padding: 0; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--canvas); aspect-ratio: 16 / 9; cursor: zoom-in; display: grid; place-items: center; }
.hj-cover-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hj-cover-img.off, .hj-cover-img.noimg { cursor: default; color: var(--muted); font-size: 13px; }
.hj-cover-img.noimg img { display: none; }
.hj-cover-img.noimg::after { content: "Muqova tayyorlanmoqda…"; }
.hj-cover-opts { display: grid; gap: 8px; align-content: start; }
.tabs.seg.sm { margin: 0; width: fit-content; }
.tabs.seg.sm button { padding: 6px 12px; font-size: 13px; }
.tg-post { max-width: 420px; margin: 0 auto; border-radius: 14px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(14, 42, 71, .08); }
.tg-post img { width: 100%; display: block; aspect-ratio: 16 / 9; object-fit: cover; }
.tg-body { padding: 10px 14px 12px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; max-height: 46vh; overflow: auto; }
.tg-body a { color: var(--tg); }
.tg-tag { color: var(--tg); }
@media (max-width: 760px) { .hj-cover { grid-template-columns: 1fr; } }
.tg-body { white-space: pre-wrap; }

/* ---- Savollar: odam bo'yicha chat */
.qa-wrap { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); min-height: 520px; height: calc(100vh - 230px); overflow: hidden; }
.qa-side { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; }
.qa-filters { display: grid; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.qa-filters select, .qa-filters input { width: 100%; }
.qa-people { overflow-y: auto; flex: 1; min-height: 0; }
.qa-person { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line-soft); background: none; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.qa-person:hover { background: var(--hover); }
.qa-person.active { background: var(--accent-soft); }
.qa-pmain { display: grid; min-width: 0; }
.qa-pname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa-porg, .qa-plast { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa-plast { color: var(--ink-2); }
.qa-pside { display: grid; justify-items: end; gap: 4px; font-size: 11px; color: var(--muted); }
.qa-pside .cnt { background: var(--accent); color: var(--accent-ink); border-radius: 999px; min-width: 20px; padding: 1px 6px; text-align: center; font-weight: 700; font-size: 11px; }
.qa-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.qa-empty { margin: auto; }
.qa-chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.qa-chat-title { display: grid; min-width: 0; flex: 1; }
.qa-chat-title .link { font-weight: 700; text-align: left; justify-self: start; }
.qa-chat-title .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa-back { display: none; }
.qa-chat-head > .tag { flex: none; }
.qa-thread { flex: 1; max-height: none; min-height: 0; padding: 14px; background: var(--canvas); }
.qa-item .bubble { border-left: 3px solid var(--line-strong); }
.qa-item.open .bubble { border-left-color: var(--warn-fill); }
.qa-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; white-space: normal; }
.qa-ref { font-size: 12px; }
.qa-replyref { display: block; font-size: 12px; opacity: .85; margin-bottom: 4px; color: inherit; }
.qa-compose { display: grid; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line); }
.qa-hint { margin: 0; }
.qa-chat > .notice { margin: 10px 14px; }
@media (max-width: 900px) {
  .qa-wrap { grid-template-columns: 1fr; height: calc(100vh - 200px); }
  .qa-wrap .qa-chat { display: none; }
  .qa-wrap.has-sel .qa-side { display: none; }
  .qa-wrap.has-sel .qa-chat { display: flex; }
  .qa-back { display: inline-flex; }
  .qa-chat-head > .tag { display: none; }
}

.qa-viewbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.qa-item time .link { font-size: 11px; }
.qa-replybar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius-s); }
.qa-replybar[hidden] { display: none; }
.qa-rb-text { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa-rb-text span { color: var(--muted); }
.qa-item .bubble { cursor: default; }
.qa-compose { grid-template-columns: minmax(0, 1fr); }
.qa-compose select { min-width: 0; width: 100%; }
.hj-review { display: grid; gap: 3px; padding: 8px 12px; border-left: 3px solid var(--warn-fill); background: var(--warn-soft); border-radius: var(--radius-s); font-size: 13px; color: var(--ink); }
.hj-review.done { border-left-color: var(--accent); background: var(--accent-soft); }
.hj-time { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.hj-time input { padding: 2px 6px; width: auto; min-height: 0; font-size: 13px; }
.hj-diff { display: grid; gap: 6px; max-height: 50vh; overflow: auto; font-size: 14px; line-height: 1.5; }
.hj-diff del { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; padding: 0 2px; border-radius: 3px; }
.hj-diff ins { background: var(--accent-soft); color: var(--accent-text); text-decoration: none; padding: 0 2px; border-radius: 3px; }

/* Savollar: botni bloklaganlar */
.qa-blkbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--danger-soft); font-size: 13px; }
.qa-blkbar .btn { flex: none; }
.qa-blk { margin-right: 4px; }
.notice .btn.sm { margin-left: 8px; vertical-align: middle; }
