:root {
  color-scheme: light;
  --surface: #ffffff;
  --surface-muted: #f6f7f9;
  --surface-elevated: #ffffff;
  --text: #171b21;
  --text-muted: #5d6673;
  --border: #dde2e8;
  --input-bg: #ffffff;
  --input-border: #cfd6df;
  --table-row-hover: #f9fafb;
  --focus-base: #ffffff;
  --brand-color: #1f6feb;
  --brand-accent: #17a673;
  --success-surface: #d1fae5;
  --success-text: #065f46;
  --danger-surface: #fee2e2;
  --danger-text: #991b1b;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --surface: #161a20;
  --surface-muted: #0f1217;
  --surface-elevated: #1d232b;
  --text: #eef2f7;
  --text-muted: #a7b0bd;
  --border: #303844;
  --input-bg: #11161d;
  --input-border: #3a4654;
  --table-row-hover: #202731;
  --focus-base: #0f1217;
  --success-surface: #123729;
  --success-text: #9ee6c4;
  --danger-surface: #402022;
  --danger-text: #fecaca;
}

html {
  font-size: 14px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--surface-muted);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--brand-color);
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem var(--focus-base), 0 0 0 0.25rem color-mix(in srgb, var(--brand-color), transparent 70%);
}

.btn-brand {
  color: #ffffff;
  background: var(--brand-color);
  border-color: var(--brand-color);
}

.btn-brand:hover,
.btn-brand:focus {
  color: #ffffff;
  background: color-mix(in srgb, var(--brand-color), #000000 12%);
  border-color: color-mix(in srgb, var(--brand-color), #000000 12%);
}

.btn-outline-secondary {
  color: var(--text);
  border-color: var(--border);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  color: var(--text);
  background: var(--surface-elevated);
  border-color: var(--text-muted);
}

.btn-link {
  color: var(--brand-color);
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-nav {
  min-height: 72px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  margin-right: 2rem;
  color: var(--text);
  text-decoration: none;
}

.brand-lockup:hover {
  color: var(--text);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #ffffff;
  background: var(--brand-color);
  font-weight: 700;
}

.brand-name,
.brand-tagline {
  display: block;
}

.brand-name {
  max-width: 34rem;
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-tagline {
  max-width: 34rem;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar .nav-link {
  color: var(--text-muted);
  font-weight: 500;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
  color: var(--text);
}

.navbar-toggler {
  border-color: var(--border);
}

.navbar-toggler-icon {
  filter: var(--navbar-icon-filter, none);
}

html[data-theme="dark"] .navbar-toggler-icon {
  --navbar-icon-filter: invert(1) grayscale(1) brightness(1.7);
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  margin-right: 0.5rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus {
  color: var(--text);
  background: var(--surface-elevated);
  border-color: var(--text-muted);
}

.theme-toggle:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 0.1rem var(--focus-base), 0 0 0 0.25rem color-mix(in srgb, var(--brand-color), transparent 70%);
}

.theme-toggle-icon {
  position: relative;
  display: block;
  width: 17px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.theme-toggle-icon::before,
.theme-toggle-icon::after {
  position: absolute;
  content: "";
}

.theme-toggle-icon::before {
  inset: -6px;
  border-radius: inherit;
  background:
    linear-gradient(currentColor, currentColor) center top / 2px 4px no-repeat,
    linear-gradient(currentColor, currentColor) center bottom / 2px 4px no-repeat,
    linear-gradient(90deg, currentColor, currentColor) left center / 4px 2px no-repeat,
    linear-gradient(90deg, currentColor, currentColor) right center / 4px 2px no-repeat;
  opacity: 0;
  transition: opacity 150ms ease;
}

.theme-toggle-icon::after {
  width: 12px;
  height: 12px;
  top: -4px;
  right: -5px;
  border-radius: 999px;
  background: var(--surface);
  transition: opacity 150ms ease, transform 150ms ease;
}

.theme-toggle[data-theme-active="dark"] .theme-toggle-icon::before {
  opacity: 1;
}

.theme-toggle[data-theme-active="dark"] .theme-toggle-icon::after {
  opacity: 0;
  transform: scale(0.4);
}

.app-main {
  padding: 2.5rem 0 4rem;
}

.app-footer {
  padding: 1.25rem 0;
  color: var(--text-muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.app-footer a {
  color: var(--text-muted);
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--brand-color);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
}

.welcome-hero-banner {
  position: relative;
  width: 100vw;
  min-height: min(620px, calc(100vh - 250px));
  margin: -2.5rem 0 2rem calc(50% - 50vw);
  overflow: hidden;
  color: #ffffff;
  background:
    linear-gradient(90deg, rgba(7, 20, 22, 0.9) 0%, rgba(7, 20, 22, 0.72) 38%, rgba(7, 20, 22, 0.18) 70%, rgba(7, 20, 22, 0.1) 100%),
    url("../images/atp-support-banner.jpg") center center / cover no-repeat;
}

.welcome-hero-inner {
  display: flex;
  align-items: center;
  min-height: inherit;
}

.welcome-copy {
  max-width: 720px;
  padding: 4rem 0;
  animation: welcome-rise 600ms ease-out both;
}

.welcome-copy h1 {
  max-width: 780px;
  margin: 0 0 1.5rem;
  color: #ffffff;
  font-size: clamp(2.5rem, 7vw, 5rem);
  line-height: 0.98;
}

.welcome-hero-banner .eyebrow {
  color: #99f6e4;
}

.btn-hero-outline {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.72);
}

.btn-hero-outline:hover,
.btn-hero-outline:focus {
  color: #102a2a;
  background: #ffffff;
  border-color: #ffffff;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.welcome-workflow,
.ticket-table-wrap,
.empty-state,
.ticket-form,
.ticket-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.welcome-workflow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--border);
  animation: welcome-rise 600ms 180ms ease-out both;
}

.welcome-workflow > div {
  padding: 1.25rem;
  background: var(--surface);
}

.workflow-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-bottom: 0.75rem;
  border-radius: 999px;
  color: var(--brand-color);
  background: color-mix(in srgb, var(--brand-color), transparent 90%);
  font-weight: 700;
}

.welcome-workflow strong {
  display: block;
  margin-bottom: 0.35rem;
}

.welcome-workflow p,
.empty-state p {
  margin: 0;
  color: var(--text-muted);
}

@keyframes welcome-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty-state {
  padding: 2rem;
}

.empty-state h2 {
  margin: 0 0 0.5rem;
}

.empty-state .btn {
  margin-top: 1.25rem;
}

.ticket-table-wrap {
  overflow: hidden;
}

.ticket-table {
  margin: 0;
  --bs-table-bg: var(--surface);
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--table-row-hover);
  --bs-table-hover-color: var(--text);
}

.ticket-table th {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.ticket-title {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.ticket-title:hover {
  color: var(--brand-color);
}

.ticket-description {
  display: -webkit-box;
  max-width: 680px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.9rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-open {
  color: #075985;
  background: #e0f2fe;
}

.status-inprogress {
  color: #854d0e;
  background: #fef3c7;
}

.status-resolved {
  color: #166534;
  background: #dcfce7;
}

.status-closed {
  color: #4b5563;
  background: #e5e7eb;
}

html[data-theme="dark"] .status-open {
  color: #7dd3fc;
  background: #082f49;
}

html[data-theme="dark"] .status-inprogress {
  color: #fde68a;
  background: #3f2f12;
}

html[data-theme="dark"] .status-resolved {
  color: #86efac;
  background: #14351f;
}

html[data-theme="dark"] .status-closed {
  color: #cbd5e1;
  background: #2a313c;
}

.ticket-form {
  max-width: 820px;
  padding: 1.5rem;
}

.ticket-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-control,
.form-select {
  color: var(--text);
  background: var(--input-bg);
  border-color: var(--border);
  border-radius: 8px;
}

.form-control:focus,
.form-select:focus {
  color: var(--text);
  background: var(--input-bg);
  border-color: var(--brand-color);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.watcher-select {
  min-height: 9rem;
}

.form-check-input {
  background-color: var(--input-bg);
  border-color: var(--input-border);
}

.form-check-input:checked {
  background-color: var(--brand-color);
  border-color: var(--brand-color);
}

.form-label,
.form-check-label {
  color: var(--text);
}

.text-danger {
  color: var(--danger-text) !important;
}

.alert-success {
  color: var(--success-text);
  background: var(--success-surface);
  border-color: color-mix(in srgb, var(--success-text), transparent 70%);
}

.alert-danger {
  color: var(--danger-text);
  background: var(--danger-surface);
  border-color: color-mix(in srgb, var(--danger-text), transparent 70%);
}

.ticket-detail {
  overflow: hidden;
}

.ticket-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid var(--border);
}

.ticket-meta div {
  padding: 1rem 1.25rem;
  border-right: 1px solid var(--border);
}

.ticket-meta div:last-child {
  border-right: 0;
}

.ticket-meta dt {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.ticket-meta dd {
  margin: 0.35rem 0 0;
}

.meta-subtext {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.ticket-watchers {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.ticket-watchers h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.ticket-watchers p {
  margin: 0;
  color: var(--text-muted);
}

.watcher-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.watcher-pill {
  display: inline-flex;
  flex-direction: column;
  gap: 0.1rem;
  max-width: 260px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  font-weight: 700;
}

.watcher-pill span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-body {
  padding: 1.5rem;
}

.ticket-body h2 {
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
}

.ticket-body p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.admin-summary div {
  padding: 1rem 1.25rem;
  background: var(--surface);
}

.admin-summary span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.admin-summary strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.75rem;
  line-height: 1;
}

.admin-users-wrap {
  margin-top: 1rem;
}

.admin-create-form {
  max-width: none;
  margin-bottom: 1.5rem;
}

.admin-create-form h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.admin-create-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-create-actions,
.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.admin-row-actions {
  justify-content: flex-end;
}

.admin-users-table td {
  vertical-align: top;
}

.role-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  min-width: 360px;
}

.role-check {
  min-width: 150px;
  margin: 0;
}

.approval-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.approval-approved {
  color: #166534;
  background: #dcfce7;
}

.approval-pending {
  color: #854d0e;
  background: #fef3c7;
}

html[data-theme="dark"] .approval-approved {
  color: #86efac;
  background: #14351f;
}

html[data-theme="dark"] .approval-pending {
  color: #fde68a;
  background: #3f2f12;
}

@media (max-width: 991.98px) {
  .brand-name,
  .brand-tagline {
    max-width: calc(100vw - 145px);
  }

  .navbar-collapse {
    padding: 1rem 0;
  }

  .welcome-hero-banner {
    min-height: 520px;
    background-position: 58% center;
  }

  .admin-summary {
    grid-template-columns: 1fr;
  }

  .admin-create-grid {
    grid-template-columns: 1fr;
  }

  .ticket-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767.98px) {
  .welcome-workflow {
    grid-template-columns: 1fr;
  }

  .page-heading {
    flex-direction: column;
  }

  .ticket-meta {
    grid-template-columns: 1fr;
  }

  .ticket-meta div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .ticket-meta div:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .welcome-copy,
  .welcome-workflow {
    animation: none;
  }
}
