:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f3f6);
  --card: var(--tg-theme-bg-color, #ffffff);
  --ink: var(--tg-theme-text-color, #16202e);
  --muted: var(--tg-theme-hint-color, #6b7686);
  --accent: var(--tg-theme-button-color, #2f6fed);
  --accent-ink: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--ink) 12%, transparent);
  --ok: #2f8f5b; --warn: #b7791f; --bad: #d0412f; --info: #2f6fed;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 0 calc(24px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
.wrap { max-width: 560px; margin: 0 auto; padding: 12px 16px; }

nav.top { display: flex; gap: 8px; margin-bottom: 14px; }
nav.top a {
  flex: 1; text-align: center; padding: 10px 8px; border-radius: 10px;
  background: var(--card); color: var(--ink); font-weight: 600; font-size: 15px;
}
nav.top a.on { background: var(--accent); color: var(--accent-ink); }
nav.top a.admin { flex: 0 0 auto; padding-inline: 14px; }

h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 14px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card { background: var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; padding: 48px 16px; }

.msg { border-radius: 12px; padding: 11px 14px; margin-bottom: 10px; font-size: 15px; background: var(--card); border-left: 4px solid var(--info); }
.msg.success { border-color: var(--ok); }
.msg.warning, .msg.error { border-color: var(--bad); }

/* forma */
.field { margin-bottom: 16px; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--bad); font-size: 14px; }
input[type=text], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 48px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=file] { width: 100%; font: inherit; padding: 12px; background: var(--card); border: 1px dashed var(--line); border-radius: 10px; }

.room-fixed { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.room-fixed small { display: block; color: var(--muted); font-weight: 400; }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chips label { position: relative; margin: 0; }
.chips input { position: absolute; opacity: 0; inset: 0; }
.chips span {
  display: block; text-align: center; padding: 11px 2px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 600;
}
.chips input:checked + span { color: #fff; border-color: transparent; }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.chips .p-critical input:checked + span { background: var(--bad); }
.chips .p-high input:checked + span { background: #e0702d; }
.chips .p-medium input:checked + span { background: var(--warn); }
.chips .p-low input:checked + span { background: var(--muted); }

button.primary {
  width: 100%; border: 0; border-radius: 12px; padding: 15px; min-height: 52px;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; cursor: pointer;
}
button.primary[disabled] { opacity: .6; }

/* arizalar ro'yxati */
a.ticket { display: block; color: inherit; }
.ticket .row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ticket .num { font-weight: 700; }
.ticket .desc { margin: 4px 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--ink); }
.badge.s-new { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.badge.s-accepted, .badge.s-in_progress { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge.s-waiting { background: color-mix(in srgb, #7a4fd0 18%, transparent); color: #7a4fd0; }
.badge.s-resolved { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.late { background: var(--bad); color: #fff; }

dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 15px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.thumbs a.video { display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; background: var(--bg); font-weight: 600; }
ul.timeline { list-style: none; margin: 0; padding: 0; }
ul.timeline li { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; font-size: 15px; }
ul.timeline li::before { content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
ul.timeline time { color: var(--muted); font-size: 13px; display: block; }
