.tickets-wrap {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 18px;
  align-items: start;
}

.tickets-card {
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 14px;
  background: rgba(20, 34, 53, 0.9);
  padding: 16px;
}

.tickets-card-head h2 {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.05rem;
}

.tickets-card-head p {
  margin: 6px 0 0;
  color: rgba(223, 234, 250, 0.62);
  font-size: 0.8rem;
}

.tickets-card-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.tickets-wrap > .tickets-card:last-child {
  position: relative;
  overflow: hidden;
  border-color: rgba(56, 189, 248, 0.34);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(56, 189, 248, 0.12), transparent 48%),
    linear-gradient(165deg, rgba(16, 31, 52, 0.95), rgba(8, 20, 37, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 20px 40px rgba(3, 10, 22, 0.4);
}

.tickets-card-head-row h2 {
  letter-spacing: 0.02em;
}

.tickets-filters select {
  min-width: 190px;
  border-radius: 12px;
  border-color: rgba(56, 189, 248, 0.36);
  background: rgba(4, 14, 26, 0.9);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.ticket-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket-form-grid {
  display: grid;
  grid-template-columns: 1fr 210px;
  gap: 10px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(223, 234, 250, 0.62);
  font-size: 0.72rem;
}

.field input,
.field textarea,
.field select,
.tickets-filters select,
.ticket-actions-row select,
.ticket-actions-row input,
.ticket-comment-row input,
.ticket-upload-row input {
  width: 100%;
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 10px;
  background: rgba(10, 20, 34, 0.7);
  color: #eaf2ff;
  padding: 9px 10px;
  font-size: 0.84rem;
}

.ticket-message {
  min-height: 18px;
  margin: 0;
  color: rgba(223, 234, 250, 0.62);
  font-size: 0.8rem;
}

.ticket-message.is-ok { color: #86efac; }
.ticket-message.is-error { color: #fda4af; }

.tickets-list {
  margin-top: 12px;
  max-height: 75vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}

.ticket-item {
  position: relative;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(11, 26, 44, 0.94), rgba(8, 21, 37, 0.94));
  padding: 14px;
  box-shadow: 0 10px 24px rgba(2, 10, 21, 0.32);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.ticket-item::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 3px;
  background: rgba(56, 189, 248, 0.65);
}

.ticket-item[data-ticket-status="open"]::before {
  background: #22c55e;
}

.ticket-item[data-ticket-status="in_progress"]::before {
  background: #38bdf8;
}

.ticket-item[data-ticket-status="waiting"]::before {
  background: #f59e0b;
}

.ticket-item[data-ticket-status="done"]::before {
  background: #9ca3af;
}

.ticket-item:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.48);
  box-shadow: 0 14px 28px rgba(2, 10, 21, 0.4);
}

.ticket-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.ticket-item-title {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.22rem;
  line-height: 1.15;
}

.ticket-item-meta {
  margin-top: 4px;
  color: rgba(223, 234, 250, 0.72);
  font-size: 0.88rem;
}

.ticket-description {
  margin: 12px 0;
  font-size: 1rem;
  line-height: 1.42;
  white-space: pre-wrap;
}

.ticket-pill {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  padding: 5px 10px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ticket-pill.status-open { background: rgba(34, 197, 94, 0.2); }
.ticket-pill.status-in_progress { background: rgba(56, 189, 248, 0.24); }
.ticket-pill.status-waiting { background: rgba(245, 158, 11, 0.26); }
.ticket-pill.status-done { background: rgba(156, 163, 175, 0.3); }
.ticket-pill.priority-low { border-color: rgba(74, 222, 128, 0.5); }
.ticket-pill.priority-medium { border-color: rgba(34, 211, 238, 0.5); }
.ticket-pill.priority-high { border-color: rgba(251, 146, 60, 0.6); }
.ticket-pill.priority-urgent { border-color: rgba(248, 113, 113, 0.7); }

.ticket-attachments {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ticket-attachment-btn,
.ticket-mini-btn,
.tickets-btn-primary {
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: #eaf2ff;
  font-size: 0.76rem;
  padding: 6px 10px;
  cursor: pointer;
}

.tickets-btn-primary {
  background: linear-gradient(135deg, #0f172a, #14b8a6);
  border-color: transparent;
  color: #fff;
}

.ticket-actions-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.ticket-comment-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.ticket-upload-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.ticket-upload-picker {
  min-width: 0;
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 10px;
  background: rgba(10, 20, 34, 0.62);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ticket-upload-input {
  width: 100%;
  min-width: 0;
  font-size: 0.78rem;
  color: rgba(223, 234, 250, 0.78);
}

.ticket-upload-input::file-selector-button {
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.12);
  color: #eaf2ff;
  padding: 6px 10px;
  margin-right: 10px;
  cursor: pointer;
  font-size: 0.78rem;
}

.ticket-upload-help {
  flex: 0 0 auto;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(223, 234, 250, 0.62);
}

.ticket-mini-btn:disabled,
.tickets-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.ticket-history {
  margin-top: 12px;
  border-top: 1px dashed rgba(56, 189, 248, 0.24);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ticket-history-item {
  font-size: 0.84rem;
  color: rgba(223, 234, 250, 0.62);
}

.ticket-history-item strong {
  color: #eaf2ff;
  font-weight: 600;
}

.ticket-empty {
  text-align: center;
  color: rgba(223, 234, 250, 0.62);
  padding: 16px;
}

@media (max-width: 1080px) {
  .tickets-wrap {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .ticket-form-grid,
  .ticket-actions-row,
  .ticket-comment-row,
  .ticket-upload-row { grid-template-columns: 1fr; }

  .tickets-filters select {
    min-width: 0;
    width: 100%;
  }

  .ticket-item-title {
    font-size: 1.08rem;
  }

  .ticket-item-meta {
    font-size: 0.8rem;
  }

  .ticket-description {
    font-size: 0.92rem;
  }

  .ticket-upload-picker {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
}

/* Light mode overrides */
:root:not(.dark-mode) .tickets-card {
  border-color: rgba(37, 99, 235, 0.2);
  background: rgba(255, 255, 255, 0.92);
}

:root:not(.dark-mode) .tickets-wrap > .tickets-card:last-child {
  border-color: rgba(37, 99, 235, 0.24);
  background:
    radial-gradient(130% 90% at 100% 0%, rgba(14, 165, 233, 0.12), transparent 44%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(241, 246, 255, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 16px 34px rgba(37, 99, 235, 0.12);
}

:root:not(.dark-mode) .tickets-card-head p,
:root:not(.dark-mode) .field label,
:root:not(.dark-mode) .ticket-item-meta,
:root:not(.dark-mode) .ticket-history-item,
:root:not(.dark-mode) .ticket-empty,
:root:not(.dark-mode) .ticket-message {
  color: rgba(19, 34, 58, 0.64);
}

:root:not(.dark-mode) .field input,
:root:not(.dark-mode) .field textarea,
:root:not(.dark-mode) .field select,
:root:not(.dark-mode) .tickets-filters select,
:root:not(.dark-mode) .ticket-actions-row select,
:root:not(.dark-mode) .ticket-actions-row input,
:root:not(.dark-mode) .ticket-comment-row input,
:root:not(.dark-mode) .ticket-upload-row input {
  border-color: rgba(37, 99, 235, 0.22);
  background: rgba(248, 251, 255, 0.95);
  color: #13223a;
}

:root:not(.dark-mode) .ticket-item {
  border-color: rgba(37, 99, 235, 0.22);
  background: linear-gradient(180deg, rgba(253, 254, 255, 0.96), rgba(247, 250, 255, 0.96));
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
}

:root:not(.dark-mode) .ticket-item:hover {
  border-color: rgba(37, 99, 235, 0.36);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.13);
}

:root:not(.dark-mode) .ticket-attachment-btn,
:root:not(.dark-mode) .ticket-mini-btn {
  border-color: rgba(37, 99, 235, 0.24);
  background: rgba(37, 99, 235, 0.06);
  color: #13223a;
}

:root:not(.dark-mode) .ticket-upload-picker {
  border-color: rgba(37, 99, 235, 0.22);
  background: rgba(248, 251, 255, 0.95);
}

:root:not(.dark-mode) .ticket-upload-input {
  color: rgba(19, 34, 58, 0.72);
}

:root:not(.dark-mode) .ticket-upload-input::file-selector-button {
  border-color: rgba(37, 99, 235, 0.3);
  background: rgba(37, 99, 235, 0.12);
  color: #13223a;
}

:root:not(.dark-mode) .ticket-upload-help {
  color: rgba(19, 34, 58, 0.58);
}

:root:not(.dark-mode) .ticket-history {
  border-top-color: rgba(37, 99, 235, 0.24);
}

:root:not(.dark-mode) .ticket-history-item strong,
:root:not(.dark-mode) .ticket-item-title,
:root:not(.dark-mode) .ticket-description {
  color: #13223a;
}
