:root {
  --bg: #0b0b0c;
  --panel: #121214;
  --card: #18181b;
  --card-2: #1f1f23;
  --line: #27272b;
  --text: #f4f4f5;
  --muted: #8b8b93;
  --dim: #5f5f67;
  --red: #dc2626;
  --red-2: #ef4444;
  --red-soft: rgba(220, 38, 38, .14);
  --green: #22c55e;
  --yellow: #eab308;
  --blue: #3b82f6;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input { font: inherit; color: inherit; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
a { color: inherit; }

/* ── иконки ── */
[data-icon] { display: inline-flex; width: 16px; height: 16px; flex: none; }
[data-icon] svg { width: 100%; height: 100%; }

/* ── кнопки ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card-2); cursor: pointer; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #26262b; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-2); }
.btn-ghost { background: transparent; }
.btn-green { background: rgba(34, 197, 94, .14); border-color: rgba(34, 197, 94, .35); color: #4ade80; }
.btn-green:hover { background: rgba(34, 197, 94, .22); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--card-2); color: var(--text); }

/* ── каркас ── */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.brand b { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--red); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--bg);
}
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); }
.nav-title {
  color: var(--dim); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: 6px 6px 0;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .nav-title { margin-top: 12px; padding-bottom: 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: #c9c9cf; cursor: pointer; user-select: none; white-space: nowrap;
}
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.on { background: var(--red-soft); color: #fff; }
.nav a.on [data-icon] { color: var(--red-2); }
.nav em {
  margin-left: auto; font-style: normal; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; display: grid; place-items: center;
}
.nav em:empty { display: none; }
.me {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.me-text { flex: 1; min-width: 0; }
.me-text b, .me-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--muted); font-size: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--red); color: #fff; font-weight: 600; font-size: 13px;
}

.main { min-width: 0; padding: 0 28px 40px; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 22px;
}
.top h1 { margin: 0; font-size: 22px; font-weight: 700; }
.top p { margin: 2px 0 0; color: var(--muted); }
.warn {
  border: 1px solid rgba(234, 179, 8, .35); background: rgba(234, 179, 8, .08); color: #fde047;
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px;
}

/* ── карточки ── */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.stat-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.stat-head [data-icon] { width: 18px; height: 18px; }
.stat-val { font-size: 30px; font-weight: 700; margin: 10px 0 6px; letter-spacing: -.01em; }
.stat-sub { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.up { color: var(--green); font-weight: 600; }
.c-red { color: var(--red-2); } .c-green { color: var(--green); } .c-yellow { color: var(--yellow); } .c-blue { color: var(--blue); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.card h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.card .hint { margin: 2px 0 16px; color: var(--muted); font-size: 12.5px; }

/* заявка */
.tasks { display: flex; flex-direction: column; gap: 12px; }
.tasks.wide { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.task { background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.task-title { font-weight: 600; font-size: 15px; }
.task-meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.task-steam { margin-top: 10px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.task-steam code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; overflow: hidden; text-overflow: ellipsis; }
.task-steam a { color: var(--muted); font-size: 12.5px; text-decoration: none; }
.task-steam a:hover { color: var(--text); }
.task-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.task-amount { font-size: 18px; font-weight: 700; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.progress { margin-top: 12px; }
.progress-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.bar { height: 6px; border-radius: 3px; background: #2a2a2f; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--red); border-radius: 3px; }
.w-0 { width: 4%; } .w-50 { width: 50%; } .w-90 { width: 90%; } .w-100 { width: 100%; }
.bar.ok i { background: var(--green); }

.pill { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.st-active { background: var(--red); color: #fff; }
.st-taken { background: rgba(234, 179, 8, .16); color: #facc15; }
.st-done { background: rgba(34, 197, 94, .16); color: #4ade80; }
.st-paid { background: rgba(59, 130, 246, .16); color: #60a5fa; }
.st-rejected { background: #2a2a2f; color: var(--muted); }

/* активность */
.feed { display: flex; flex-direction: column; gap: 16px; }
.feed-item { display: flex; gap: 12px; }
.feed-item .avatar { width: 32px; height: 32px; font-size: 12px; }
.feed-text { min-width: 0; }
.feed-text a, .feed-text .hl { color: var(--red-2); }
.feed-text small { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }

.empty { color: var(--muted); text-align: center; padding: 36px 10px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* таблицы */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
tr.me-row td { background: var(--red-soft); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; color: #c9c9cf; }
.chip.on { background: var(--red); border-color: var(--red); color: #fff; }

/* формы */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.field input, .inline-form input {
  height: 40px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); outline: 0; min-width: 0;
}
.field input:focus, .inline-form input:focus { border-color: var(--red); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-width: 64px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--red-soft); border-color: var(--red); color: #fff; }
.form-err { color: var(--red-2); min-height: 18px; margin: 0 0 10px; font-size: 13px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 200px; }
.wallet-box { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); margin-bottom: 16px; min-width: 0; }
.wallet-box code { font-size: 14px; overflow-wrap: anywhere; }

/* модалка */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 18px; }

/* тосты */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; max-width: calc(100vw - 32px); }
.toast { background: var(--card-2); border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 10px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.toast.err { border-left-color: var(--red); }

/* экран входа */
.gate, .gate-body .gate { max-width: 420px; margin: 14vh auto 0; padding: 32px 24px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.gate .logo { margin: 0 auto 14px; width: 48px; height: 48px; font-size: 20px; }
.gate h2 { margin: 0 0 8px; }
.gate p { color: var(--muted); margin: 0 0 20px; }
.gate-body { padding: 0 16px; }

/* ── адаптив ── */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; gap: 12px; }
  .side > .nav-title { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav .nav-title { display: none; }
  .nav a { background: var(--card); flex: none; }
  .me { margin-top: 0; }
  .main { padding: 0 16px 32px; }
  .top { padding: 16px 0 14px; margin-bottom: 16px; }
  .top h1 { font-size: 19px; }
  .card { padding: 16px; }
  .stat-val { font-size: 24px; }
}
@media (max-width: 420px) {
  .cards { gap: 10px; }
  .card { padding: 14px; }
  .tasks.wide { grid-template-columns: 1fr; }
}
.narrow { max-width: 640px; }
.mb { margin-bottom: 16px; }

/* ── чат по заявке (Telegram Web App) ── */
.chat-body { height: 100vh; height: 100dvh; overflow: hidden; }
.chat { height: 100%; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--bg); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chat-title { flex: 1; min-width: 0; }
.chat-title b, .chat-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title small { color: var(--muted); font-size: 12.5px; }
.chat-card { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; background: var(--panel); }
.chat-card code { color: var(--text); }
.chat-card b { color: var(--text); }
.chat-card .dot { color: var(--dim); }
.chat-list { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.chat-day { align-self: center; color: var(--dim); font-size: 12px; margin: 8px 0 4px; }
.chat-empty { margin: auto; max-width: 300px; text-align: center; color: var(--muted); padding: 20px; }
.msg { display: flex; }
.msg.mine { justify-content: flex-end; }
.bubble { max-width: min(80%, 520px); background: var(--card-2); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 8px 12px 6px; }
.msg.mine .bubble { background: var(--red); border-color: var(--red); border-radius: 14px 14px 4px 14px; }
.msg-who { color: var(--red-2); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-time { text-align: right; font-size: 11px; color: var(--muted); margin-top: 2px; }
.msg.mine .msg-time { color: rgba(255, 255, 255, .7); }
.chat-closed { padding: 14px 16px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); background: var(--panel); }
.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.chat-input textarea { flex: 1; min-width: 0; resize: none; max-height: 140px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); outline: 0; line-height: 1.4; font: inherit; color: var(--text); }
.chat-input textarea:focus { border-color: var(--red); }
.chat-input .btn { width: 40px; height: 40px; padding: 0; flex: none; }
@media (max-width: 760px) { .chat { border: 0; } }
.chat { position: relative; }
.chat-input .icon-btn { width: 38px; height: 40px; flex: none; }
.chat-input.uploading { opacity: .6; pointer-events: none; }
.bubble.has-img { padding: 4px 4px 6px; }
.bubble.has-img .msg-who, .bubble.has-img .msg-text, .bubble.has-img .msg-time { padding: 0 8px; }
.msg-img { display: block; max-width: 100%; max-height: 320px; min-height: 60px; border-radius: 10px; cursor: zoom-in; background: rgba(255, 255, 255, .04); margin-bottom: 4px; }
.msg-text.muted { color: var(--muted); font-size: 13px; padding: 6px 8px; }
.emoji-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; padding: 8px 10px; max-height: 188px; overflow-y: auto; border-top: 1px solid var(--line); background: var(--panel); }
.emoji { height: 40px; border: 0; border-radius: 8px; background: transparent; font-size: 22px; cursor: pointer; line-height: 1; }
.emoji:hover { background: var(--card-2); }
.chat-drop { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(11, 11, 12, .85); border: 2px dashed var(--red); border-radius: 12px; color: var(--text); font-weight: 600; pointer-events: none; }
.viewer { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .9); cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* отклонение и чёрный список */
.field textarea { padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); outline: 0; font: inherit; color: var(--text); resize: vertical; min-height: 76px; }
.field textarea:focus { border-color: var(--red); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .chip { height: 28px; font-size: 12.5px; }
.check { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; cursor: pointer; color: #d4d4d8; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--red); }
.reason { margin: 10px 0 0; padding: 9px 12px; border-radius: 9px; background: rgba(239, 68, 68, .08); border: 1px solid rgba(239, 68, 68, .25); font-size: 13px; color: #e4e4e7; }
.reason small { display: block; color: var(--muted); margin-bottom: 3px; }
.bl-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: rgba(239, 68, 68, .16); color: #f87171; font-size: 11.5px; font-weight: 600; }
.bl-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(200px, 2fr) auto; gap: 10px; }
.bl-form input { height: 40px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); outline: 0; color: var(--text); font: inherit; }
.bl-form input:focus { border-color: var(--red); }
.bl-search { width: 100%; max-width: 360px; height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); outline: 0; color: var(--text); font: inherit; margin-bottom: 12px; }
td.bl-reason { max-width: 380px; white-space: normal; }
@media (max-width: 820px) { .bl-form { grid-template-columns: 1fr; } }
