:root {
  color-scheme: dark;
  --ticket-blue: #4fc3f7;
  --ticket-blue-soft: #91dcff;
  --ticket-border: rgba(79, 195, 247, 0.3);
  --ticket-panel: rgba(7, 16, 32, 0.91);
  --ticket-muted: #a9bbcf;
}

.tickets-main {
  box-sizing: border-box;
  display: grid;
  gap: 22px;
  margin: 0 auto;
  max-width: 1320px;
  padding: 46px 20px 60px;
  position: relative;
  width: 100%;
  z-index: 5;
  text-align: left;
}

.tickets-hero,
.ticket-sidebar,
.ticket-workspace {
  backdrop-filter: blur(8px);
  background: var(--ticket-panel);
  border: 1px solid var(--ticket-border);
  border-radius: 16px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.32), 0 0 20px rgba(79, 195, 247, 0.08);
}

.tickets-hero {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 24px 28px;
}

.tickets-hero h1,
.tickets-hero p,
.ticket-sidebar h2,
.ticket-sidebar p,
.ticket-detail-header h2,
.ticket-detail-header p {
  margin: 0;
}

.tickets-hero h1 {
  color: #fff;
  font-size: clamp(1.65rem, 4vw, 2.35rem);
  margin: 5px 0 9px;
}

.tickets-hero > div > p:last-child,
.ticket-sidebar-header p,
.ticket-detail-header p,
.attachment-help,
.reply-limit {
  color: var(--ticket-muted);
  line-height: 1.5;
}

.eyebrow {
  color: var(--ticket-blue-soft);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  margin: 0;
  text-transform: uppercase;
}

.tickets-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(270px, 350px) minmax(0, 1fr);
  min-height: 650px;
}

.ticket-sidebar {
  align-content: start;
  display: grid;
  gap: 13px;
  padding: 20px;
}

.ticket-sidebar-header {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.ticket-sidebar h2 { color: var(--ticket-blue-soft); font-size: 1.15rem; }
.ticket-sidebar-header p { font-size: 0.78rem; margin-top: 5px; }
.filter-label { color: #d9edfa; font-size: 0.78rem; font-weight: 700; }

button,
input,
textarea,
select {
  box-sizing: border-box;
  font: inherit;
}

input,
textarea,
select {
  background: rgba(5, 12, 25, 0.9);
  border: 1px solid rgba(79, 195, 247, 0.42);
  border-radius: 9px;
  color: #fff;
  padding: 10px 12px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #82e9ff;
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.15);
  outline: none;
}

textarea { line-height: 1.55; resize: vertical; width: 100%; }

.primary-action,
.secondary-action,
.icon-button,
.file-picker,
.dialog-close,
.remove-file,
.attachment-button {
  align-items: center;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  text-decoration: none;
}

.primary-action {
  background: var(--ticket-blue);
  border: 1px solid var(--ticket-blue);
  color: #04111d;
  min-height: 42px;
  padding: 10px 17px;
}

.primary-action:hover:not(:disabled) { background: #82e9ff; }
.primary-action:disabled { cursor: not-allowed; opacity: 0.48; }

.secondary-action,
.file-picker,
.attachment-button {
  background: rgba(79, 195, 247, 0.08);
  border: 1px solid rgba(79, 195, 247, 0.48);
  color: #c9f1ff;
  padding: 9px 13px;
}

.secondary-action:hover,
.file-picker:hover,
.attachment-button:hover { background: rgba(79, 195, 247, 0.18); }

.danger-action { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
.danger-action:hover { background: rgba(239, 68, 68, 0.16); }

.icon-button,
.dialog-close,
.remove-file {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.32);
  color: #cbd5e1;
}

.icon-button { font-size: 1.15rem; height: 36px; width: 36px; }
.dialog-close { font-size: 1.35rem; height: 38px; width: 38px; }
.remove-file { font-size: 1rem; height: 27px; padding: 0; width: 27px; }

.ticket-list { display: grid; gap: 9px; max-height: 520px; overflow-y: auto; padding-right: 3px; }

.ticket-list-item {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(148, 163, 184, 0.19);
  border-radius: 11px;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 7px;
  padding: 13px;
  text-align: left;
  width: 100%;
}

.ticket-list-item:hover,
.ticket-list-item.is-active {
  background: rgba(79, 195, 247, 0.1);
  border-color: rgba(79, 195, 247, 0.55);
}

.ticket-list-item strong { color: #f8fafc; overflow-wrap: anywhere; }
.ticket-list-row { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
.ticket-list-meta { color: #9fb3c9; font: 0.75rem/1.4 Arial, sans-serif; }

.ticket-status {
  border: 1px solid;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 4px 8px;
  text-transform: uppercase;
}

.ticket-status[data-status="open"] { background: rgba(34, 197, 94, 0.13); border-color: rgba(74, 222, 128, 0.4); color: #86efac; }
.ticket-status[data-status="closed"] { background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.36); color: #cbd5e1; }

.ticket-workspace { min-width: 0; overflow: hidden; }
.ticket-empty { align-content: center; display: grid; min-height: 620px; padding: 30px; place-items: center; text-align: center; }
.ticket-empty span { color: var(--ticket-blue); font-size: 3rem; text-shadow: 0 0 18px rgba(79, 195, 247, 0.7); }
.ticket-empty h2 { color: #fff; margin: 14px 0 7px; }
.ticket-empty p { color: var(--ticket-muted); margin: 0; }

.ticket-detail-header {
  align-items: start;
  border-bottom: 1px solid rgba(79, 195, 247, 0.22);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 21px 24px;
}

.ticket-heading-line { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.ticket-detail-header h2 { color: #fff; overflow-wrap: anywhere; }
.ticket-detail-header p { font: 0.82rem/1.5 Arial, sans-serif; margin-top: 7px; }

.ticket-messages {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 470px;
  min-height: 310px;
  overflow-y: auto;
  padding: 24px;
}

.ticket-message { align-self: flex-start; max-width: min(76%, 720px); }
.ticket-message.is-mine { align-self: flex-end; }
.message-label { color: #9db3c8; display: flex; font: 0.74rem Arial, sans-serif; gap: 9px; margin: 0 4px 5px; }
.ticket-message.is-mine .message-label { justify-content: flex-end; }

.message-bubble {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 5px 14px 14px 14px;
  color: #e7eef7;
  font: 0.94rem/1.55 Arial, sans-serif;
  overflow-wrap: anywhere;
  padding: 12px 14px;
  white-space: pre-wrap;
}

.ticket-message.is-mine .message-bubble { background: rgba(14, 116, 144, 0.28); border-color: rgba(79, 195, 247, 0.42); border-radius: 14px 5px 14px 14px; }
.ticket-message.is-admin .message-bubble { box-shadow: inset 3px 0 0 #c084fc; }

.message-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.attachment-button { gap: 7px; max-width: 230px; padding: 7px 10px; }
.attachment-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-preview { border: 1px solid rgba(79, 195, 247, 0.3); border-radius: 8px; display: block; margin-top: 8px; max-height: 180px; max-width: min(100%, 280px); object-fit: contain; }

.ticket-composer { border-top: 1px solid rgba(79, 195, 247, 0.22); display: grid; gap: 9px; padding: 18px 24px 22px; }
.ticket-composer > label,
.new-ticket-form > label { color: #e1f3fd; font-size: 0.8rem; font-weight: 800; }
.composer-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.composer-actions .primary-action { margin-left: auto; }
.reply-limit { font: 0.76rem Arial, sans-serif; }
.reply-limit.is-blocked { color: #fca5a5; }
.attachment-help { font: 0.72rem Arial, sans-serif; margin: 0; }

.selected-files { display: grid; gap: 6px; }
.selected-file { align-items: center; background: rgba(255, 255, 255, 0.04); border-radius: 7px; color: #cbd9e7; display: flex; font: 0.78rem Arial, sans-serif; gap: 9px; padding: 7px 9px; }
.selected-file span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-file small { color: #8fa5bb; margin-left: auto; white-space: nowrap; }

.ticket-loading,
.ticket-list-empty { color: var(--ticket-muted); font: 0.84rem/1.5 Arial, sans-serif; padding: 24px 8px; text-align: center; }

dialog {
  background: #091326;
  border: 1px solid rgba(79, 195, 247, 0.54);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72);
  color: #fff;
  max-width: 650px;
  padding: 0;
  width: calc(100% - 28px);
}

dialog::backdrop { backdrop-filter: blur(4px); background: rgba(0, 0, 0, 0.76); }
.new-ticket-form { display: grid; gap: 10px; padding: 25px; }
.dialog-heading { align-items: start; display: flex; gap: 18px; justify-content: space-between; margin-bottom: 4px; }
.dialog-heading h2 { color: #fff; margin: 5px 0 0; }
.dialog-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 5px; }
.dialog-actions .primary-action { margin-left: auto; }

.visually-hidden { clip: rect(0 0 0 0); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }

@media (max-width: 820px) {
  .tickets-main { padding: 28px 12px 44px; }
  .tickets-layout { grid-template-columns: 1fr; }
  .ticket-list { max-height: 310px; }
  .ticket-empty { min-height: 360px; }
  .ticket-message { max-width: 88%; }
}

@media (max-width: 560px) {
  .tickets-hero { align-items: stretch; flex-direction: column; padding: 20px; }
  .ticket-detail-header { align-items: stretch; flex-direction: column; }
  .ticket-messages { padding: 18px 14px; }
  .ticket-message { max-width: 94%; }
  .ticket-composer { padding: 16px 14px 18px; }
  .composer-actions .primary-action,
  .dialog-actions .primary-action { margin-left: 0; width: 100%; }
  .file-picker { flex: 1; }
}
