:root {
  --bg-0: #101316;
  --bg-1: #1b2126;
  --ink-0: #f3f4f6;
  --ink-1: #b7c0c7;
  --line: #2a323a;
  --brand: #84bd00;
  --brand-2: #98d214;
  --danger: #ff5f5f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Exo 2", "Segoe UI", sans-serif;
  color: var(--ink-0);
  background:
    radial-gradient(circle at 20% 20%, rgba(132, 189, 0, 0.17), transparent 30%),
    radial-gradient(circle at 90% 80%, rgba(132, 189, 0, 0.12), transparent 28%),
    linear-gradient(135deg, var(--bg-0), var(--bg-1));
  background-attachment: fixed;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 40% 25%, #000 30%, transparent 90%);
}

.layout {
  width: min(1120px, 100% - 2rem);
  margin: 1.5rem auto 2rem;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1rem;
  align-items: start;
}

.top-bar {
  width: min(1120px, 100% - 2rem);
  margin: 1rem auto 0;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.top-bar-left,
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.top-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.current-user {
  color: var(--ink-1);
  font-size: 0.9rem;
}

.logout-btn {
  background: transparent;
  color: var(--ink-0);
  border: 1px solid #3d4750;
  padding: 0.5rem 0.8rem;
}

.logout-btn:hover {
  box-shadow: none;
  border-color: var(--brand);
}

.card {
  background: rgba(12, 16, 19, 0.72);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.hero {
  grid-column: 1 / -1;
  display: flex;
  gap: 1.2rem;
  width: min(820px, 100%);
  margin-inline: auto;
  align-items: center;
  padding: 1.3rem;
  animation: reveal 0.7s ease-out both;
}

.hero-logo {
  width: 92px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.eyebrow {
  margin: 0;
  font-family: "PT Mono", monospace;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--brand-2);
}

h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.4rem, 3.2vw, 2rem);
  font-weight: 800;
}

.lead {
  margin: 0.55rem 0 0;
  color: var(--ink-1);
}

.form-card {
  grid-column: 1 / -1;
  width: min(820px, 100%);
  margin-inline: auto;
  padding: 1.2rem;
  animation: reveal 0.85s ease-out both;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-title h2 {
  margin: 0;
  font-size: 1.15rem;
}

.section-title span {
  font-family: "PT Mono", monospace;
  color: var(--brand-2);
  font-size: 0.78rem;
}

.issue-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.form-group h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.form-group-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--ink-1);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #36404a;
  background: rgba(18, 23, 28, 0.95);
  color: var(--ink-0);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  outline: none;
  transform: translateY(-1px);
}

.span-2 {
  grid-column: span 2;
}

.photo-upload {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.photo-buttons {
  display: flex;
  gap: 0.6rem;
}

.photo-btn {
  flex: 1;
  padding: 0.8rem;
  font-size: 0.9rem;
  text-align: center;
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.photo-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: 0;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  padding: 0;
  cursor: pointer;
}

.actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-top: 0.2rem;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1.1rem;
  font: 700 0.95rem/1 "Exo 2", sans-serif;
  color: #0f130a;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(132, 189, 0, 0.32);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

#form-status {
  min-height: 1.2rem;
  font-size: 0.9rem;
}

#form-status.error {
  color: var(--danger);
}

#form-status.success {
  color: var(--brand-2);
}

#login-status {
  min-height: 1.2rem;
  font-size: 0.9rem;
}

#login-status.error {
  color: var(--danger);
}

.auth-layout {
  width: min(1120px, 100% - 2rem);
  margin: 2rem auto;
  min-height: calc(100vh - 4rem);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(460px, 100%);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  animation: reveal 0.7s ease-out both;
}

.auth-logo {
  width: 100px;
  height: auto;
  object-fit: contain;
}

.auth-form {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.remember-row {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
}

.remember-row input {
  width: auto;
}

.brand-card {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  animation: reveal 1s ease-out both;
}

.brand-card img {
  border-radius: 12px;
  width: 100%;
  max-width: 220px;
}

.brand-card p {
  margin: 0;
  color: var(--ink-1);
  line-height: 1.45;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    align-items: flex-start;
  }
}

@media (max-width: 680px) {
  .layout {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .top-bar {
    flex-direction: column;
    align-items: center;
  }

  .top-bar-right {
    width: 100%;
    justify-content: space-between;
  }

  .hero,
  .form-card {
    width: 100%;
  }

  .form-group-fields {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ── Навигация ──────────────────────────────────────── */

.nav-link {
  color: var(--brand-2);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  transition: background 0.15s;
}

.nav-link:hover {
  background: rgba(132, 189, 0, 0.12);
}

/* ── Фильтр ─────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-bar label {
  flex: 1;
  min-width: 120px;
}

.filter-btn {
  padding: 0.65rem 1rem;
  white-space: nowrap;
}

/* ── Список обращений ───────────────────────────────── */

.issues-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.issue-card {
  background: rgba(18, 23, 28, 0.8);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.issue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.issue-id {
  font-family: "PT Mono", monospace;
  font-size: 0.8rem;
  color: var(--brand-2);
}

.issue-date {
  font-size: 0.8rem;
  color: var(--ink-1);
}

.issue-defect {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.issue-desc {
  font-size: 0.85rem;
  color: var(--ink-1);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  font-size: 0.78rem;
  color: var(--ink-1);
}

.issue-meta span {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.issue-card,
.issue-header,
.issue-id,
.issue-date,
.issue-defect,
.issue-desc,
.issue-problem {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.issue-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.issue-action-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-0);
  background: rgba(132, 189, 0, 0.15);
  border: 1px solid var(--brand);
  cursor: pointer;
  transition: background 0.15s;
}

.issue-action-btn:hover {
  background: rgba(132, 189, 0, 0.3);
}

.issue-action-btn.danger {
  background: rgba(255, 95, 95, 0.12);
  border-color: var(--danger);
  color: var(--danger);
}

.issue-action-btn.danger:hover {
  background: rgba(255, 95, 95, 0.25);
}

.status-change-select {
  padding: 0.25rem 0.4rem;
  font-size: 0.72rem;
  border-radius: 6px;
  background: var(--bg-1);
  color: var(--ink-0);
  border: 1px solid var(--line);
  cursor: pointer;
  max-width: 10rem;
}

.status-change-select:focus {
  border-color: var(--brand);
  outline: none;
}

.status-control {
  margin-top: 0.8rem;
}

.status-control .issues-status {
  min-height: 1.2rem;
  margin-top: 0.25rem;
}

@media (max-width: 680px) {
  .issue-actions {
    flex-wrap: wrap;
  }

  .issue-action-btn {
    flex: 1 1 calc(50% - 0.25rem);
    text-align: center;
  }
}

@media (max-width: 420px) {
  .issue-action-btn {
    flex-basis: 100%;
  }
}

.issues-status {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-1);
  margin-top: 0.6rem;
}

.issues-status.error {
  color: var(--danger);
}

.load-more-btn {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.7rem;
  font-size: 0.9rem;
}

/* ── Главное меню ───────────────────────────────────── */

.main-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.pwa-panel {
  display: grid;
  gap: 0.65rem;
}

.pwa-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.pwa-actions .secondary-btn {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.75rem;
  border-color: #46515a;
  font: 700 0.95rem/1.2 "Exo 2", sans-serif;
  text-align: center;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.pwa-actions .secondary-btn:hover {
  transform: translateY(-1px);
  border-color: var(--brand);
  background: rgba(132, 189, 0, 0.12);
}

.pwa-panel .issues-status:not(:empty) {
  margin-top: 0.65rem;
}

.main-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0.9rem 1rem;
  text-align: center;
  border-radius: 12px;
  text-decoration: none;
  font: 700 0.95rem/1.2 "Exo 2", sans-serif;
  color: var(--ink-0);
  background: rgba(18, 23, 28, 0.85);
  border: 1px solid #36404a;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.main-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: none;
  border-color: var(--brand);
  background: rgba(132, 189, 0, 0.12);
}

.qr-codes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.qr-code-card {
  display: grid;
  justify-items: center;
  gap: 0.7rem;
  margin: 0;
  padding: 1rem;
  border: 1px solid #36404a;
  border-radius: 8px;
  background: rgba(18, 23, 28, 0.65);
}

.qr-code-card img {
  display: block;
  width: min(180px, 100%);
  aspect-ratio: 1;
  padding: 0.45rem;
  background: #fff;
}

.qr-code-card figcaption {
  color: var(--ink-0);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}

/* ── Ошибки и улучшения ─────────────────────────────── */

.feedback-layout {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.feedback-create-card,
.feedback-list-card,
.feedback-detail-card {
  grid-column: auto;
  width: 100%;
}

.feedback-detail-card {
  grid-column: 1 / -1;
}

.feedback-image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.feedback-image-preview-item {
  max-width: 100%;
  padding: 0.35rem 0.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-1);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feedback-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.feedback-list-item {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.75rem;
  overflow: hidden;
  border: 1px solid #36404a;
  border-radius: 8px;
  background: rgba(18, 23, 28, 0.85);
  color: var(--ink-0);
  text-align: left;
}

.feedback-list-item:hover,
.feedback-list-item.is-selected {
  border-color: var(--brand);
  background: rgba(132, 189, 0, 0.1);
  box-shadow: none;
}

.feedback-list-item span {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink-1);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feedback-detail-meta {
  margin: 0 0 0.6rem;
  color: var(--ink-1);
  font-size: 0.84rem;
}

.feedback-detail-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.feedback-images-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-top: 1rem;
}

.feedback-images-list a {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.feedback-images-list img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feedback-discussion {
  margin-top: 1rem;
}

/* ── Замечания ──────────────────────────────────────────────── */

.remark-create-card {
  max-width: 860px;
}

.remark-photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.remark-photo-preview-item {
  display: flex;
  max-width: 100%;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-1);
  font-size: 0.78rem;
}

.remark-photo-preview-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remark-photo-remove {
  flex: 0 0 auto;
  padding: 0.25rem 0.45rem;
  border: 1px solid #46515a;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-0);
  font-size: 0.72rem;
}

.remark-photo-remove:hover {
  border-color: var(--danger);
  background: rgba(255, 95, 95, 0.12);
  box-shadow: none;
}

.remarks-layout {
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
}

.remarks-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.remark-list-item {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.75rem;
  overflow: hidden;
  border: 1px solid #36404a;
  border-radius: 8px;
  background: rgba(18, 23, 28, 0.85);
  color: var(--ink-0);
  text-align: left;
}

.remark-list-item:hover,
.remark-list-item.is-selected {
  border-color: var(--brand);
  background: rgba(132, 189, 0, 0.1);
  box-shadow: none;
}

.remark-list-item span {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink-1);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remark-meta {
  margin-bottom: 0.7rem;
  color: var(--ink-1);
  font-size: 0.84rem;
}

.remark-view-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.remark-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.remark-photo {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.remark-photo img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.remark-edit-form {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 680px) {
  .filter-bar {
    flex-direction: column;
  }

  .filter-bar label {
    min-width: 100%;
  }

  .feedback-layout {
    display: flex;
  }

  .remarks-layout {
    display: flex;
  }

  .qr-codes-grid {
    grid-template-columns: 1fr;
  }

  .pwa-actions {
    grid-template-columns: 1fr;
  }
}

/* ── Аналитика ─────────────────────────────────────── */

.analytics-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.analytics-filter-card {
  grid-column: 1 / -1;
  padding: 1.1rem;
  background:
    linear-gradient(135deg, rgba(16, 21, 25, 0.95), rgba(18, 25, 20, 0.95)),
    radial-gradient(circle at right top, rgba(132, 189, 0, 0.2), transparent 45%);
}

.analytics-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.analytics-filter-actions {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.secondary-btn {
  background: rgba(18, 23, 28, 0.88);
  color: var(--ink-0);
  border: 1px solid #3d4750;
  border-radius: 12px;
  text-decoration: none;
}

.secondary-btn:hover {
  box-shadow: none;
  border-color: var(--brand);
}

.analytics-kpi-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.kpi-card {
  padding: 0.9rem 1rem;
  background: linear-gradient(160deg, rgba(20, 25, 30, 0.95), rgba(18, 34, 22, 0.92));
  border-color: #31423a;
}

.kpi-card p {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-card strong {
  margin-top: 0.4rem;
  display: block;
  font-size: clamp(1.25rem, 3.2vw, 1.8rem);
  color: #d8f48c;
}

.analytics-panel {
  padding: 1rem;
}

.analytics-panel-wide {
  grid-column: 1 / -1;
}

.analytics-table-panel {
  width: calc(100vw - 2rem);
  max-width: 1800px;
  justify-self: center;
}

.analytics-chart-switch {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.analytics-chart-switch-buttons {
  display: flex;
  gap: 0.45rem;
}

.secondary-btn.is-active {
  border-color: var(--brand);
  background: rgba(132, 189, 0, 0.14);
}

.chart-canvas-wrap {
  position: relative;
  min-height: 320px;
}

.chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.bar-item {
  border: 1px solid rgba(132, 189, 0, 0.2);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  background: rgba(16, 22, 26, 0.8);
}

.bar-item-header {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.35rem;
}

.bar-label {
  font-size: 0.88rem;
  color: var(--ink-0);
}

.bar-value {
  font-size: 0.78rem;
  color: var(--ink-1);
  white-space: nowrap;
}

.bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #84bd00, #d3f96d);
}

.bar-fill--rank-1 {
  background: linear-gradient(90deg, #d53939, #ff7b7b);
}

.bar-fill--rank-2 {
  background: linear-gradient(90deg, #d39a00, #ffd75a);
}

.timeline-chart {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.timeline-row {
  display: grid;
  grid-template-columns: 120px 1fr 210px;
  align-items: center;
  gap: 0.7rem;
}

.timeline-date {
  font-family: "PT Mono", monospace;
  color: var(--ink-1);
  font-size: 0.78rem;
}

.timeline-track {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.timeline-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(132, 189, 0, 0.8), rgba(132, 189, 0, 0.35));
}

.timeline-meta {
  text-align: right;
  font-size: 0.78rem;
  color: var(--ink-1);
}

.chart-empty {
  margin: 0.3rem 0;
  color: var(--ink-1);
  font-size: 0.88rem;
}

.analytics-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(16, 22, 26, 0.78);
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 2200px;
}

.analytics-table th,
.analytics-table td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  vertical-align: top;
  font-size: 0.84rem;
}

.analytics-table th {
  position: sticky;
  top: 0;
  background: rgba(18, 23, 28, 0.96);
  color: var(--brand-2);
  z-index: 1;
}

.analytics-table td {
  color: var(--ink-0);
}

.analytics-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.analytics-row-clickable {
  cursor: pointer;
  transition: background 0.12s;
}

.analytics-row-clickable:hover td {
  background: rgba(132, 189, 0, 0.1) !important;
}

.analytics-table-desc {
  max-width: 980px;
  white-space: normal;
}

.analytics-table-footer {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
}

.load-more-btn {
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .analytics-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-row {
    grid-template-columns: 96px 1fr;
  }

  .timeline-meta {
    grid-column: 1 / -1;
    text-align: left;
    padding-left: 96px;
  }
}

@media (max-width: 680px) {
  .analytics-filter-grid {
    grid-template-columns: 1fr;
  }

  .analytics-kpi-grid {
    grid-template-columns: 1fr;
  }

  .timeline-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .timeline-meta {
    padding-left: 0;
  }

  .chart-canvas-wrap {
    min-height: 260px;
  }

  .analytics-table-panel {
    width: 100%;
  }

  .analytics-table-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .load-more-btn {
    width: 100%;
  }
}

/* Compatibility for current create_issue photo UI */
.photo-upload-controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.photo-input-hidden {
  display: none;
}

.photo-limit-note {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.82rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
}

.photo-card {
  background: rgba(18, 23, 28, 0.8);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.photo-card .photo-thumb {
  width: 100%;
  height: 96px;
  border: 0;
  border-radius: 0;
}

.photo-card-body {
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.photo-name {
  font-size: 0.75rem;
  color: var(--ink-1);
  line-height: 1.2;
  min-height: 1.8em;
}

.photo-delete-btn {
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  color: var(--danger);
  background: rgba(255, 95, 95, 0.12);
}

.photo-delete-btn:hover {
  background: rgba(255, 95, 95, 0.25);
}

/* ── Админка: управление аккаунтами ──────────────────── */

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(16, 22, 26, 0.78);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  font-size: 0.84rem;
}

.admin-table th {
  background: rgba(18, 23, 28, 0.96);
  color: var(--brand-2);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.admin-table td {
  color: var(--ink-0);
}

.admin-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.admin-table tbody tr:hover {
  background: rgba(132, 189, 0, 0.08);
}

.admin-table .role-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(132, 189, 0, 0.14);
  border: 1px solid rgba(132, 189, 0, 0.3);
}

.admin-table .status-active {
  color: var(--brand-2);
}

.admin-table .status-blocked {
  color: var(--danger);
}

.admin-table .col-actions {
  width: 80px;
  text-align: center;
}

.btn-delete-row {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: rgba(255, 95, 95, 0.1);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-delete-row:hover {
  background: rgba(255, 95, 95, 0.25);
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.account-form .form-group-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.account-status {
  min-height: 1.2rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.account-status.error {
  color: var(--danger);
}

.account-status.success {
  color: var(--brand-2);
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  place-items: center;
}

.modal-overlay.is-open {
  display: grid;
}

.modal-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-card p {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

.modal-cancel {
  background: rgba(18, 23, 28, 0.88);
  color: var(--ink-0);
  border: 1px solid #3d4750;
}

.modal-cancel:hover {
  border-color: var(--brand);
  box-shadow: none;
}

.modal-confirm-delete {
  background: rgba(255, 95, 95, 0.15);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.modal-confirm-delete:hover {
  background: rgba(255, 95, 95, 0.3);
  box-shadow: none;
}

.modal-confirm-activate {
  background: rgba(132, 189, 0, 0.16);
  color: var(--brand-2);
  border: 1px solid var(--brand);
}

.modal-confirm-activate:hover {
  background: rgba(132, 189, 0, 0.28);
  box-shadow: none;
}

@media (max-width: 680px) {
  .account-form .form-group-fields {
    grid-template-columns: 1fr;
  }

  .admin-header {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ── Просмотр обращения ─────────────────────────────── */

.view-issue-layout {
  width: min(1280px, 100% - 2rem);
}

.view-issue-shell {
  width: min(980px, 100%);
  padding: 1.35rem 1.45rem;
  background:
    linear-gradient(160deg, rgba(18, 24, 29, 0.92), rgba(18, 28, 23, 0.9)),
    radial-gradient(circle at top right, rgba(132, 189, 0, 0.14), transparent 45%);
  border-color: rgba(132, 189, 0, 0.22);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.view-issue-content {
  background: rgba(13, 18, 22, 0.72);
  border: 1px solid rgba(132, 189, 0, 0.24);
  border-radius: 14px;
  padding: 1.1rem 1.15rem;
  color: #eef3f7;
  font-size: 0.96rem;
  line-height: 1.62;
}

.view-issue-shell .section-title h2 {
  color: #f4f8fb;
  letter-spacing: 0.01em;
}

.view-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem 1.2rem;
  margin-bottom: 1.2rem;
}

.view-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.view-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.view-section {
  margin: 0;
  padding: 0.8rem 0;
}

.view-section + .view-section {
  border-top: 1px solid rgba(132, 189, 0, 0.18);
}

.view-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.view-text {
  color: var(--ink-0);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.discussion-panel {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(132, 189, 0, 0.22);
  border-radius: 12px;
  background: rgba(10, 14, 17, 0.55);
}

.discussion-header h3 {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: var(--brand-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.discussion-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.discussion-empty {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.86rem;
}

.discussion-item {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: rgba(17, 22, 27, 0.65);
}

.discussion-item-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  color: var(--ink-1);
}

.discussion-item-meta strong {
  color: var(--ink-0);
}

.discussion-item-text {
  font-size: 0.88rem;
  color: var(--ink-0);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.discussion-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.discussion-form textarea {
  min-height: 86px;
  resize: vertical;
}

/* ── Sidebar обсуждений ─────────────────────────────── */

.discussion-sidebar-toggle {
  position: relative;
  min-height: 34px;
  padding: 0.4rem 0.65rem;
  border: 1px solid #3d4750;
  background: transparent;
  color: var(--ink-0);
  font: inherit;
  font-size: 0.82rem;
}

.discussion-sidebar-toggle:hover {
  border-color: var(--brand);
  box-shadow: none;
}

.discussion-sidebar-total,
.discussion-sidebar-item-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.discussion-sidebar-total {
  margin-left: 0.4rem;
}

.discussion-sidebar-total[hidden] {
  display: none;
}

.discussion-sidebar {
  position: fixed;
  z-index: 180;
  top: 0;
  right: 0;
  width: min(360px, calc(100% - 1rem));
  height: 100dvh;
  padding: 1rem;
  border-left: 1px solid var(--line);
  background: #151b20;
  box-shadow: -14px 0 34px rgba(0, 0, 0, 0.38);
  transform: translateX(105%);
  transition: transform 0.2s ease;
}

.discussion-sidebar.is-open {
  transform: translateX(0);
}

.discussion-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.discussion-sidebar-header h2 {
  margin: 0;
  font-size: 1rem;
}

.discussion-sidebar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.discussion-sidebar-mark-all-read,
.discussion-sidebar-close {
  border: 0;
  background: transparent;
  color: var(--ink-1);
  font: inherit;
  font-size: 0.8rem;
}

.discussion-sidebar-mark-all-read:not(:disabled) {
  color: var(--brand);
  cursor: pointer;
}

.discussion-sidebar-mark-all-read:disabled {
  color: var(--ink-3);
  cursor: default;
}

.discussion-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: calc(100dvh - 4.6rem);
  padding-top: 0.75rem;
  overflow-y: auto;
}

.discussion-sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem;
  border: 1px solid #303b45;
  border-radius: 8px;
  color: var(--ink-0);
  text-decoration: none;
}

.discussion-sidebar-item:hover {
  border-color: var(--brand);
  background: rgba(132, 189, 0, 0.08);
}

.discussion-sidebar-item.has-unread {
  border-color: rgba(255, 95, 95, 0.7);
}

.discussion-sidebar-item-details {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.18rem;
}

.discussion-sidebar-item-details strong {
  font-size: 0.88rem;
}

.discussion-sidebar-item-details span,
.discussion-sidebar-empty {
  color: var(--ink-1);
  font-size: 0.78rem;
}

.discussion-sidebar-empty {
  margin: 0;
}

.issues-status.success {
  color: var(--brand-2);
}

@media (max-width: 680px) {
  .view-issue-shell {
    padding: 1rem 0.9rem;
  }

  .view-issue-content {
    padding: 0.92rem 0.84rem;
    font-size: 0.94rem;
    line-height: 1.56;
  }

  .view-fields {
    grid-template-columns: 1fr;
  }

  .discussion-panel {
    padding: 0.85rem 0.8rem;
  }
}

/* ── Фото: кликабельные карточки ─────────────────────── */

.photo-card-clickable {
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.photo-card-clickable:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
}

/* ── Лайтбокс ───────────────────────────────────────── */

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 200;
  place-items: center;
}

.lightbox-overlay.is-open {
  display: grid;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  user-select: none;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  color: var(--ink-0);
  font-size: 2rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  line-height: 1;
  border-radius: 8px;
  transition: background 0.15s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  transform: none;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--ink-0);
  font-size: 2rem;
  cursor: pointer;
  padding: 0.5rem 0.8rem;
  border-radius: 12px;
  transition: background 0.15s;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.lightbox-counter {
  position: absolute;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--ink-1);
  font-size: 0.85rem;
  font-family: "PT Mono", monospace;
}

@media (max-width: 680px) {
  .lightbox-nav {
    font-size: 1.5rem;
    padding: 0.4rem 0.6rem;
  }

  .lightbox-prev {
    left: 0.5rem;
  }

  .lightbox-next {
    right: 0.5rem;
  }
}

/* ── Динамический список (виновные, руководители) ────── */

.dynamic-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dynamic-list-item {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.dynamic-list-item select,
.dynamic-list-item input {
  flex: 1;
}

.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 1px rgba(255, 95, 95, 0.45);
}

input.input-error,
textarea.input-error {
  background: rgba(255, 95, 95, 0.05) !important;
}

select.input-error {
  background: rgba(18, 23, 28, 0.95) !important;
  color: var(--ink-0) !important;
}

.dynamic-list-item .remove-item-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: rgba(255, 95, 95, 0.1);
  cursor: pointer;
  transition: background 0.15s;
}

.dynamic-list-item .remove-item-btn:hover {
  background: rgba(255, 95, 95, 0.25);
}

.add-item-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  color: var(--brand);
  background: transparent;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.3rem;
  transition: background 0.15s, transform 0.15s;
}

.add-item-btn:hover {
  background: rgba(132, 189, 0, 0.15);
  transform: scale(1.1);
}
