:root {
  --primary: #ff7a18;
  --primary-foreground: #fff8f1;
  --secondary: #6c63ff;
  --secondary-foreground: #f4f2ff;
  --dark: #1f1f1f;
  --accent: #37474f;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --text: #1f1f1f;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-soft: 0 10px 30px rgba(19, 10, 54, 0.08);
  --shadow-card: 0 15px 45px rgba(15, 14, 36, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  width: 100%;
}

body.no-scroll {
  overflow: hidden;
}

a {
  color: inherit;
}

.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

.app-header {
  background: var(--dark);
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
}

.app-header__brand {
  display: flex;
  align-items: center;
  min-width: 180px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.brand__mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topnav {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  position: relative;
  width: 100%;
}

.topnav__list {
  list-style: none;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  width: 100%;
  justify-content: flex-end;
}

.topnav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
  background: transparent;
}

.topnav__link:hover {
  background: rgba(255, 255, 255, 0.15);
}

.topnav__link.is-active {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 25px rgba(255, 122, 24, 0.35);
}

.topnav__toggle {
  display: none;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  border-radius: var(--radius-md);
  padding: 0.4rem 0.9rem;
  gap: 0.3rem;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
}

.topnav__toggle span {
  width: 18px;
  height: 2px;
  background: var(--dark);
  display: block;
}

.topnav__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 90;
}

.topnav__backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.btn--ghost.emergency-audio {
  background: #f44336;
  border: none;
  box-shadow: 0 12px 25px rgba(244, 67, 54, 0.25);
}

.btn--ghost.emergency-audio.is-active {
  background: var(--secondary);
  box-shadow: 0 12px 25px rgba(108, 99, 255, 0.35);
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}

.admin-nav__link {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--dark);
  background: #fff;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
}

.admin-nav__link:hover {
  background: rgba(0, 0, 0, 0.05);
}

.admin-nav__link.is-active {
  background: var(--secondary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 28px rgba(108, 99, 255, 0.25);
}

.admin-nav__link--ghost {
  border-style: dashed;
}

.admin-nav__spacer {
  flex: 1;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.08);
}

.user-chip__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--secondary);
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #fff;
}

.app-main {
  flex: 1;
  padding: clamp(1.5rem, 3vw, 3.5rem);
  width: 100%;
  min-height: 0;
  overflow-y: auto;
}

.app-main > * {
  width: 100%;
}

.app-footer {
  padding: 1.5rem 2rem;
  background: #fff;
  text-align: center;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  width: 100%;
}

.page {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page--auth {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  align-items: center;
}

.page__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.page__title {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  color: var(--dark);
}

.page__subtitle {
  margin: 0;
  color: rgba(0, 0, 0, 0.6);
}

.page__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
}

.card--elevated {
  box-shadow: var(--shadow-card);
}

.card--gradient {
  background: linear-gradient(135deg, rgba(255, 122, 24, 0.08), rgba(108, 99, 255, 0.08));
}

.card__title {
  margin-top: 0;
  font-size: 1.15rem;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 15px 35px rgba(255, 122, 24, 0.3);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 45px rgba(255, 122, 24, 0.35);
}

.btn:active {
  transform: translateY(0);
}

.btn--secondary {
  background: var(--secondary);
  box-shadow: 0 15px 35px rgba(108, 99, 255, 0.3);
}

.btn--ghost {
  background: transparent;
  color: #fff;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn--outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: none;
}

.btn--sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.input-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.input-control,
.textarea-control,
.select-control {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-control:focus,
.textarea-control:focus,
.select-control:focus {
  border-color: var(--secondary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
}

.textarea-control {
  min-height: 140px;
  resize: vertical;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--primary {
  background: rgba(255, 122, 24, 0.15);
  color: var(--primary);
}

.badge--secondary {
  background: rgba(108, 99, 255, 0.15);
  color: var(--secondary);
}

.badge--neutral {
  background: rgba(31, 31, 31, 0.1);
  color: var(--dark);
}

.badge--success {
  background: rgba(33, 150, 83, 0.15);
  color: #1b5e20;
}

.badge--danger {
  background: rgba(244, 67, 54, 0.15);
  color: #c62828;
}

.badge--warning {
  background: rgba(255, 179, 0, 0.18);
  color: #e65100;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-card__value {
  font-size: 2rem;
  font-weight: 700;
}

.component-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.component-group__block {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stats-grid .stat-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-soft);
}

.stats-grid .stat-card strong {
  font-size: 2rem;
  line-height: 1;
}

.card--tabs {
  padding: 0;
}

.card--tabs .tabs {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(0, 0, 0, 0.01);
  flex-wrap: wrap;
}

.tab {
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  color: rgba(0, 0, 0, 0.6);
  transition: background 0.2s ease, color 0.2s ease;
}

.tab:hover {
  background: rgba(0, 0, 0, 0.05);
}

.tab--active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 30px rgba(255, 122, 24, 0.25);
}

.card--tabs .tab-content {
  padding: 1.5rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 30, 0.65);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal:target {
  display: flex;
}

.modal__content {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.modal__close {
  display: inline-flex;
  margin-top: 1rem;
  color: var(--secondary);
  font-weight: 600;
}


.toast p {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: rgba(0, 0, 0, 0.65);
}

.alert {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

.alert--error {
  background: rgba(244, 67, 54, 0.12);
  color: #c62828;
  border: 1px solid rgba(244, 67, 54, 0.2);
}

.responsive-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  text-align: left;
}

.data-table th {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: rgba(0, 0, 0, 0.5);
}

.data-table tr:hover td {
  background: rgba(108, 99, 255, 0.05);
}

.ticket-row td {
  transition: background 0.2s ease;
}

.ticket-row--emergency td {
  background: rgba(230, 57, 70, 0.08);
  border-bottom-color: rgba(230, 57, 70, 0.18);
}

.ticket-row--emergency:hover td {
  background: rgba(230, 57, 70, 0.15);
}

.badge--pulse {
  position: relative;
  animation: badgePulse 1.2s infinite;
}

@keyframes badgePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(244, 67, 54, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(244, 67, 54, 0);
  }
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem 1rem;
}

.emergency-banner {
  background: radial-gradient(circle at top left, rgba(244, 67, 54, 0.2), rgba(255, 122, 24, 0.15));
  border: 1px solid rgba(244, 67, 54, 0.4);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  box-shadow: 0 20px 45px rgba(244, 67, 54, 0.15);
}

.emergency-banner__info {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.emergency-banner__icon {
  font-size: 2.5rem;
}

.emergency-banner__actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-end;
}

.emergency-banner__legend {
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.65);
  text-align: right;
}

.emergency-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.emergency-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  border-left: 4px solid rgba(244, 67, 54, 0.6);
}

.emergency-panel__column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.emergency-panel__history {
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.emergency-log__list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 320px;
  overflow-y: auto;
}

.emergency-log__item {
  border-radius: var(--radius-md);
  border: 1px solid rgba(244, 67, 54, 0.15);
  padding: 0.75rem 1rem;
  background: rgba(244, 67, 54, 0.04);
}

.emergency-log__header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.emergency-log__details {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.65);
}

.emergency-pill {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.emergency-pill span {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(244, 67, 54, 0.12);
  color: #b71c1c;
}

.muted {
  color: rgba(0, 0, 0, 0.5);
  font-size: 0.85rem;
}

.timeline {
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  left: 8px;
  width: 2px;
  background: rgba(108, 99, 255, 0.2);
}

.timeline__item {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.timeline__item--comment {
  align-items: flex-start;
}

.timeline__indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--secondary);
  position: relative;
  margin-top: 4px;
}

.timeline__indicator--comment {
  background: var(--primary);
}

.timeline__item--emergency {
  border-left: 3px solid rgba(244, 67, 54, 0.3);
  padding-left: 0.75rem;
}

.timeline__indicator--emergency {
  background: #f44336;
  color: #fff;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 6px rgba(244, 67, 54, 0.15);
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.report-list__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.report-list__item:last-child {
  border-bottom: none;
}

.report-list__metric {
  text-align: right;
}

.report-list__metric span {
  font-size: 1.25rem;
  font-weight: 600;
}

.progress {
  display: flex;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.05);
  min-height: 40px;
}

.progress__bar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.comment-card {
  background: rgba(108, 99, 255, 0.05);
  border: 1px solid rgba(108, 99, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 1rem;
  width: 100%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.comment-card__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.comment-card__tags {
  display: flex;
  gap: 0.5rem;
}

.comment-card__meta {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.45);
}

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.attachment-card {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.attachment-card__actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.attachment-card__actions a {
  font-weight: 600;
  color: var(--secondary);
  text-decoration: none;
  font-size: 0.9rem;
}

.dynamic-fields-card {
  margin-top: 1.5rem;
}

.dynamic-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.dynamic-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.dynamic-field textarea {
  min-height: 120px;
}

.sla-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.sla-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sla-item__status {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sla-badge {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.comment-form {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comment-form__upload small {
  display: block;
  margin-top: 0.25rem;
}

.checkbox-control {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.95rem;
}

.form-ticket .form-grid {
  margin-bottom: 1rem;
}

@media (max-width: 1024px) {
  .app-header {
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
    align-items: stretch;
  }

  .app-header__brand {
    width: 100%;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .topnav {
    width: 100%;
    padding: 0;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5rem;
  }

  .topnav__toggle {
    display: inline-flex;
  }

  .topnav__list {
    flex-direction: column;
    width: min(320px, 85vw);
    max-width: 360px;
    height: 100vh;
    margin: 0;
    padding: 2.5rem 1.5rem;
    background: var(--dark);
    border-radius: 0;
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    z-index: 100;
    gap: 0.75rem;
    display: none;
    overflow-y: auto;
  }

  .topnav__list.is-open {
    transform: translateX(0);
    display: flex;
  }

  .topnav__link {
    width: 100%;
    border-radius: var(--radius-md);
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
  }

}

@media (min-width: 1025px) {
  .topnav__backdrop {
    display: none !important;
  }
}
