:root {
  color-scheme: dark;
  --font-main: "Segoe UI Variable Text", "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  --bg: #1b2533;
  --panel: #253246;
  --panel-soft: #2f3e55;
  --text: #eef4fb;
  --muted: #b3bfd0;
  --line: #3d4d66;
  --blue: #5c93ff;
  --blue-dark: #3974e8;
  --cyan: #2dd4bf;
  --green: #48c78e;
  --amber: #f4b95f;
  --red: #f17474;
  --open-bg: #4a3032;
  --open-line: #e26b68;
  --open-pill: #5a3638;
  --progress-bg: #4a3f27;
  --progress-line: #f4b95f;
  --progress-pill: #5c4a2b;
  --resolved-bg: #2b473b;
  --resolved-line: #48c78e;
  --resolved-pill: #315745;
  --shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
  --soft-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(92, 147, 255, 0.16), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(45, 212, 191, 0.12), transparent 26rem),
    linear-gradient(135deg, #1a2432 0%, #202c3d 48%, #182532 100%);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 44px);
  background: rgba(27, 37, 51, 0.9);
  border-bottom: 1px solid rgba(43, 58, 79, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: linear-gradient(135deg, #142033, #1769e0);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(23, 105, 224, 0.25);
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 650;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a,
button,
.button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #2a3850;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.nav a:hover,
button:hover,
.button:hover {
  border-color: #40536e;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}

button.primary,
.button.primary {
  border-color: var(--blue);
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #fff;
  box-shadow: 0 12px 28px rgba(45, 112, 232, 0.24);
}

button.primary:hover,
.button.primary:hover {
  border-color: var(--blue-dark);
  box-shadow: 0 16px 34px rgba(23, 105, 224, 0.32);
}

button.danger {
  border-color: rgba(226, 107, 104, 0.55);
  background: #5a3638;
  color: #ffd1cf;
}

button.danger:hover {
  border-color: rgba(226, 107, 104, 0.85);
  background: #6a3a3d;
}

button.sound-on {
  border-color: rgba(72, 199, 142, 0.55);
  background: #315745;
  color: #9ff0c8;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 10px 18px;
  border: 1px solid rgba(43, 58, 79, 0.9);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(32, 44, 61, 0.98), rgba(41, 73, 120, 0.94)),
    #202c3d;
  color: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero.compact {
  margin-bottom: 12px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 8px;
  padding: 3px 9px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #d8e6ff;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.hero h2 {
  width: min(720px, 100%);
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 650;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 10px;
  flex: 0 0 auto;
}

.stat {
  min-width: 92px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.open-stat {
  border-color: rgba(226, 107, 104, 0.58);
  background: rgba(74, 42, 45, 0.82);
}

.open-stat span,
.open-stat small {
  color: #ffaaa6;
}

.resolved-stat {
  border-color: rgba(72, 199, 142, 0.58);
  background: rgba(33, 66, 54, 0.82);
}

.resolved-stat span,
.resolved-stat small {
  color: #9ff0c8;
}

.stat span {
  display: block;
  font-size: 21px;
  line-height: 1;
  font-weight: 650;
}

.stat small {
  display: block;
  margin-top: 4px;
  color: #c7d7ef;
  font-weight: 600;
  font-size: 11px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(290px, 390px) 1fr;
  gap: 20px;
  align-items: start;
}

.layout.single {
  display: block;
}

.panel,
.ticket {
  background: rgba(37, 50, 70, 0.96);
  border: 1px solid rgba(43, 58, 79, 0.9);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.panel {
  padding: 20px;
}

.form-panel {
  margin-bottom: 18px;
  padding: 0;
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.ticket-toggle {
  width: 100%;
  min-height: 64px;
  justify-content: flex-start;
  padding: 14px 18px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

.ticket-toggle:hover {
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.ticket-toggle span:last-child {
  display: grid;
  gap: 2px;
}

.ticket-toggle strong {
  font-size: 18px;
  font-weight: 650;
}

.ticket-toggle small {
  color: var(--muted);
  font-size: 13px;
}

.ticket-toggle::after {
  content: "Rozbalit";
  margin-left: auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue);
  background: #1e2c44;
  font-size: 12px;
  font-weight: 650;
}

.form-panel:not(.collapsed) .ticket-toggle::after {
  content: "Sbalit";
}

.form-wrap {
  padding: 0 18px 18px;
}

.form-panel.collapsed .form-wrap {
  display: none;
}

.title-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #243957;
  color: var(--blue);
  font-size: 20px;
  font-weight: 650;
}

.panel h2,
.section-head h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 650;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.section-head p span {
  display: inline-flex;
  min-width: 28px;
  justify-content: center;
  padding: 2px 7px;
  border: 1px solid rgba(92, 147, 255, 0.38);
  border-radius: 999px;
  background: rgba(30, 44, 68, 0.7);
  color: #d8e6ff;
  font-weight: 650;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #c8d4e4;
  font-size: 14px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  background: #1f2b3c;
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(23, 105, 224, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: #718096;
}

textarea {
  min-height: 124px;
  resize: vertical;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.message {
  display: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
}

.message.show {
  display: block;
}

.message.ok {
  background: #19382d;
  color: #a7f3d0;
}

.message.err {
  background: #3a2225;
  color: var(--red);
}

.tickets {
  display: grid;
  gap: 12px;
}

.ticket {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.ticket::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  background: var(--open-line);
}

.ticket:has(.pill.open) {
  border-color: rgba(223, 106, 92, 0.45);
  background:
    linear-gradient(90deg, rgba(74, 48, 50, 0.95), rgba(37, 50, 70, 0.97) 45%),
    var(--panel);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

.ticket:has(.pill.resolved)::before {
  background: var(--resolved-line);
}

.ticket:has(.pill.in_progress)::before {
  background: var(--progress-line);
}

.ticket:has(.pill.resolved) {
  border-color: rgba(23, 166, 115, 0.42);
  background:
    linear-gradient(90deg, rgba(43, 71, 59, 0.98), rgba(37, 50, 70, 0.97) 45%),
    var(--panel);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.ticket:has(.pill.in_progress) {
  border-color: rgba(244, 185, 95, 0.5);
  background:
    linear-gradient(90deg, rgba(74, 63, 39, 0.98), rgba(37, 50, 70, 0.97) 45%),
    var(--panel);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.ticket.new-ticket {
  animation: newTicketPulse 1.05s ease-in-out infinite;
}

.attention-label {
  padding: 4px 8px;
  border: 1px solid rgba(92, 147, 255, 0.55);
  border-radius: 999px;
  background: rgba(92, 147, 255, 0.18);
  color: #d8e6ff;
  font-size: 12px;
  font-weight: 650;
}

.empty-label {
  visibility: hidden;
}

@keyframes newTicketPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(92, 147, 255, 0.15), 0 12px 30px rgba(0, 0, 0, 0.22);
    filter: brightness(1);
  }

  50% {
    box-shadow: 0 0 0 4px rgba(92, 147, 255, 0.24), 0 16px 36px rgba(92, 147, 255, 0.18);
    filter: brightness(1.13);
  }
}

.ticket-head {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto minmax(180px, 320px) auto auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 62px;
  padding: 14px 17px 13px;
  border: 0;
  border-bottom: 1px solid rgba(43, 58, 79, 0.72);
  border-radius: 8px 8px 0 0;
  background: transparent;
  text-align: left;
  box-shadow: none;
  transform: none;
}

.ticket-head:hover {
  border-color: transparent;
  border-bottom-color: rgba(43, 58, 79, 0.72);
  box-shadow: none;
  transform: none;
}

.summary-solution {
  min-width: 0;
  max-width: 320px;
  overflow: hidden;
  padding: 6px 10px;
  border: 1px solid rgba(72, 199, 142, 0.34);
  border-radius: 999px;
  background: rgba(43, 71, 59, 0.68);
  color: #baf7d7;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(92, 147, 255, 0.38);
  border-radius: 8px;
  background: rgba(30, 44, 68, 0.72);
  color: #d8e6ff;
  font-size: 13px;
  font-weight: 650;
}

.ticket h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.28;
  font-weight: 650;
}

.ticket-head small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.ticket-open-toggle::after {
  content: "Rozbalit";
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.ticket:not(.collapsed) .ticket-open-toggle::after {
  content: "Sbalit";
}

.ticket-details {
  padding: 0 17px 17px;
}

.ticket.collapsed .ticket-head {
  border-bottom-color: transparent;
  border-radius: 8px;
}

.ticket.collapsed .ticket-details {
  display: none;
}

.admin-ticket .ticket-details {
  display: grid;
  gap: 14px;
}

.admin-ticket .ticket-section,
.admin-ticket .comments,
.admin-ticket .comment-form,
.admin-ticket .admin-actions {
  margin-top: 0;
}

.admin-ticket .ticket-info {
  margin-top: 14px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
}

.meta b {
  color: #c8d4e4;
  font-weight: 650;
}

.ticket-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.ticket-info span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(43, 58, 79, 0.82);
  border-radius: 8px;
  background: rgba(31, 43, 60, 0.66);
  color: #dce6f2;
  font-size: 13px;
}

.ticket-info b {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.ticket-section {
  margin-top: 12px;
}

.ticket-section > strong {
  display: block;
  margin-bottom: 6px;
  color: #c8d4e4;
  font-size: 13px;
  font-weight: 650;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.pill.open {
  background: var(--open-pill);
  color: #ffaaa6;
  border: 1px solid rgba(223, 106, 92, 0.35);
}

.pill.resolved {
  background: var(--resolved-pill);
  color: var(--green);
  border: 1px solid rgba(23, 166, 115, 0.32);
}

.pill.in_progress {
  background: var(--progress-pill);
  color: #ffd58a;
  border: 1px solid rgba(244, 185, 95, 0.38);
}

.desc {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid rgba(43, 58, 79, 0.85);
  border-radius: 8px;
  background: rgba(31, 43, 60, 0.66);
  color: #dce6f2;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.solution {
  padding: 12px;
  border: 1px solid rgba(72, 199, 142, 0.42);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: rgba(43, 71, 59, 0.78);
}

.solution strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.solution small {
  display: block;
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.comments {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.comments > strong {
  font-size: 14px;
}

.comment {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1f2b3c;
}

.comment.admin {
  border-color: rgba(72, 199, 142, 0.42);
  background: rgba(43, 71, 59, 0.78);
}

.comment.user {
  border-color: rgba(92, 147, 255, 0.38);
  background: rgba(43, 59, 86, 0.78);
}

.comment-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.comment-head span {
  color: var(--text);
  font-weight: 650;
}

.comment p {
  margin: 6px 0 0;
  color: #dce6f2;
  white-space: pre-wrap;
}

.comment-form {
  display: grid;
  grid-template-columns: minmax(130px, 180px) 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  align-items: start;
}

.comment-form button {
  grid-column: 2;
  justify-self: end;
}

.comment-form textarea {
  min-height: 72px;
}

.admin-comment {
  grid-template-columns: 1fr auto;
  align-items: stretch;
}

.admin-comment button {
  grid-column: auto;
  justify-self: end;
  align-self: end;
}

.empty {
  padding: 34px;
  border: 1px dashed #40536e;
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  background: rgba(37, 50, 70, 0.72);
}

.login {
  width: min(430px, calc(100% - 32px));
  margin: 28px auto 70px;
}

.admin-actions {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 140px auto auto;
  gap: 10px;
  margin-top: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  align-items: start;
}

.admin-actions textarea {
  min-height: 74px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .layout,
  .grid-two,
  .comment-form,
  .admin-comment,
  .ticket-info,
  .admin-actions {
    grid-template-columns: 1fr;
  }

  .comment-form button {
    grid-column: auto;
    justify-self: stretch;
  }

  .admin-comment button {
    justify-self: stretch;
  }

  .form-panel {
    margin-bottom: 14px;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats {
    width: 100%;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  main {
    width: min(100% - 20px, 1180px);
    margin-top: 16px;
  }

  .hero {
    padding: 10px 12px;
  }

  .hero h2 {
    font-size: 20px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .ticket-head {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: start;
  }

  .summary-solution {
    grid-column: 2 / -1;
    max-width: none;
    justify-self: stretch;
  }

  .ticket-head .pill,
  .ticket-open-toggle::after {
    grid-column: 2;
  }

  .attention-label {
    grid-column: 3;
  }
}
