:root {
  --color-primary: #69466e;
  --color-primary-light: #c88bce;
  --color-primary-dark: #2f2232;
  --color-accent: #9f8270;
  --color-bg: #f1eef4;
  --color-surface: rgba(255, 255, 255, 0.8);
  --color-surface-strong: rgba(255, 255, 255, 0.92);
  --color-text: #171119;
  --color-text-secondary: #5e5361;
  --color-border: rgba(75, 49, 80, 0.14);
  --color-shadow: rgba(56, 37, 60, 0.14);
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;

  --font-primary: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;

  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(200,139,206,0.22), transparent 28%),
    radial-gradient(circle at bottom right, rgba(159,130,112,0.18), transparent 28%),
    linear-gradient(180deg, #f5f3f7 0%, #ece8ef 100%);
  color: var(--color-text);
  font-family: var(--font-primary);
}

button,
input,
select,
textarea {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.glass-card,
.panel-card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.74)),
    linear-gradient(135deg, rgba(255,255,255,0.78), rgba(255,255,255,0.48));
  border: 1px solid rgba(255,255,255,0.86);
  box-shadow:
    0 20px 52px var(--color-shadow),
    inset 0 1px 0 rgba(255,255,255,0.92);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
}

.glass-card::before,
.panel-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.36), transparent 24%),
    radial-gradient(circle at top left, rgba(255,255,255,0.26), transparent 36%);
  pointer-events: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.72rem 0.95rem;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  box-shadow: 0 14px 28px rgba(105,70,110,0.24);
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-secondary {
  color: var(--color-text);
  background: rgba(255,255,255,0.84);
  border: 1px solid rgba(75,49,80,0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
}

.btn-ghost {
  color: var(--color-text-secondary);
  background: transparent;
}

.btn-danger-soft {
  color: #9f3048;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.14);
}

.btn[disabled],
.btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.8rem 1rem;
  border-radius: 14px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 14px 32px rgba(0,0,0,0.14);
  pointer-events: auto;
  animation: toastIn 0.3s ease forwards;
  max-width: 360px;
}

.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-error); }
.toast.warning { background: var(--color-warning); color: #111; }
.toast.info { background: var(--color-info); }
.toast.hiding { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

.admin-shell {
  display: grid;
  min-height: 100vh;
  gap: 1rem;
  padding: 1rem;
}

.admin-sidebar {
  position: sticky;
  top: 1rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.15rem;
  min-height: calc(100vh - 2rem);
  padding: 1rem;
  border-radius: 26px;
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: inherit;
  text-decoration: none;
}

.admin-brand img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.admin-brand span {
  display: block;
  font-size: 0.68rem;
  color: var(--color-text-secondary);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.admin-brand strong,
.admin-topbar h1,
.overview-copy h2,
.panel-head h3,
.editor-block-head h4,
.auth-card h2 {
  font-family: var(--font-display);
}

.sidebar-nav {
  display: grid;
  gap: 0.55rem;
  align-content: start;
}

.nav-tab {
  min-height: 46px;
  padding: 0.8rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 16px;
  text-align: left;
  color: var(--color-text-secondary);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.nav-tab:hover,
.nav-tab.is-active {
  color: var(--color-text);
  background: rgba(255,255,255,0.78);
  border-color: rgba(75,49,80,0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.92);
}

.sidebar-footer {
  display: grid;
}

.admin-main {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.admin-topbar {
  display: grid;
  gap: 0.5rem;
  padding: 0.2rem 0.2rem 0;
}

.topbar-kicker,
.section-kicker,
.block-kicker {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.admin-topbar h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.02;
}

.topbar-support,
.empty-state,
.inline-field span,
label span,
.selected-ticket-meta,
.selection-summary,
.entity-meta,
.ticket-meta-line,
.recent-ticket-item p {
  color: var(--color-text-secondary);
}

.panel-section {
  display: none;
  gap: 1rem;
}

.panel-section.is-active {
  display: grid;
}

.panel-card {
  border-radius: 28px;
  padding: 1rem;
}

.overview-card {
  display: grid;
  gap: 1rem;
}

.overview-copy h2 {
  font-size: clamp(1.55rem, 2.5vw, 2.05rem);
  line-height: 1.04;
  margin: 0.2rem 0 0.45rem;
}

.overview-copy p {
  max-width: 58ch;
  line-height: 1.55;
  color: var(--color-text-secondary);
}

.stats-grid {
  display: grid;
  gap: 0.8rem;
}

.stat-card {
  padding: 1rem;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,255,255,0.82));
  border: 1px solid rgba(255,255,255,0.92);
  box-shadow:
    0 16px 36px rgba(63,43,68,0.08),
    inset 0 1px 0 rgba(255,255,255,0.94);
}

.stat-card span {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: 0.35rem;
}

.stat-card strong {
  font-size: clamp(1.55rem, 4vw, 2.25rem);
  line-height: 1;
}

.dashboard-workspace,
.services-workspace {
  display: grid;
  gap: 1rem;
}

.workspace-column,
.services-column {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.list-panel,
.editor-panel,
.form-panel {
  display: grid;
  gap: 0.9rem;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.85rem;
}

.panel-head-tight {
  align-items: center;
}

.panel-head h3,
.editor-block-head h4 {
  font-size: 1.22rem;
  line-height: 1.05;
}

.panel-head-meta {
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 800;
}

.ticket-toolbar {
  display: grid;
  gap: 0.75rem;
}

.inline-field,
label {
  display: grid;
  gap: 0.45rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.84rem 0.95rem;
  border-radius: 16px;
  border: 1px solid rgba(75,49,80,0.14);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.88));
  color: var(--color-text);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.94),
    0 8px 18px rgba(74, 51, 79, 0.045);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.ticket-card-list,
.entity-list {
  display: grid;
  gap: 0.75rem;
}

.ticket-card,
.entity-card,
.service-card-row,
.recent-ticket-item {
  border-radius: 18px;
  padding: 0.9rem;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.88), rgba(255,255,255,0.7));
  border: 1px solid rgba(255,255,255,0.88);
  box-shadow:
    0 12px 30px rgba(63,43,68,0.07),
    inset 0 1px 0 rgba(255,255,255,0.92);
}

.ticket-card {
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.ticket-card:hover {
  transform: translateY(-1px);
}

.ticket-card.is-selected {
  border-color: rgba(105,70,110,0.22);
  box-shadow:
    0 16px 34px rgba(63,43,68,0.1),
    0 0 0 1px rgba(105,70,110,0.1),
    inset 0 1px 0 rgba(255,255,255,0.94);
}

.ticket-card-top,
.ticket-card-actions,
.entity-card-footer,
.service-card-footer {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
}

.ticket-card-top strong,
.entity-card strong,
.service-card-row strong,
.recent-ticket-item strong {
  display: block;
  line-height: 1.14;
}

.ticket-card p,
.entity-card p,
.service-card-row p,
.recent-ticket-item p {
  margin-top: 0.2rem;
  line-height: 1.45;
}

.ticket-meta-stack {
  display: grid;
  gap: 0.12rem;
  margin-top: 0.6rem;
}

.ticket-meta-line {
  font-size: 0.8rem;
}

.ticket-card-actions,
.entity-card-actions {
  margin-top: 0.7rem;
  flex-wrap: wrap;
}

.action-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(75,49,80,0.12);
  background: rgba(255,255,255,0.84);
  color: var(--color-primary);
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.action-chip.danger {
  color: #a03248;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0.32rem 0.68rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.new {
  background: rgba(245, 158, 11, 0.16);
  color: #9d6800;
}

.badge.confirmed {
  background: rgba(59, 130, 246, 0.15);
  color: #225fb8;
}

.badge.complete {
  background: rgba(16, 185, 129, 0.16);
  color: #0a8b63;
}

.selected-ticket-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.88), rgba(255,255,255,0.72));
  border: 1px solid rgba(255,255,255,0.88);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.92),
    0 12px 28px rgba(63,43,68,0.06);
}

.selected-ticket-header strong {
  display: block;
  font-size: 1rem;
  line-height: 1.15;
}

.editor-stack {
  display: grid;
  gap: 1rem;
}

.editor-grid {
  display: grid;
  gap: 0.9rem;
}

.editor-block {
  display: grid;
  gap: 0.8rem;
  padding: 0.95rem;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.88), rgba(255,255,255,0.7));
  border: 1px solid rgba(255,255,255,0.9);
  box-shadow:
    0 12px 30px rgba(63,43,68,0.06),
    inset 0 1px 0 rgba(255,255,255,0.92);
}

.editor-block-full {
  grid-column: 1 / -1;
}

.editor-block-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.75rem;
}

.two-cols {
  display: grid;
  gap: 0.75rem;
}

.status-pill-row,
.service-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.status-pill,
.service-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.6rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(75,49,80,0.12);
  background: rgba(255,255,255,0.88);
  color: var(--color-text);
  font-size: 0.77rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.status-pill:hover,
.service-chip:hover {
  transform: translateY(-1px);
}

.status-pill.is-active,
.service-chip.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  box-shadow: 0 12px 24px rgba(105,70,110,0.18);
}

.service-chip-groups {
  display: grid;
  gap: 0.75rem;
}

.service-chip-group {
  display: grid;
  gap: 0.55rem;
}

.service-chip-group-title {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.selection-summary {
  padding: 0.95rem 1rem;
  border-radius: 20px;
  border: 1px solid rgba(75,49,80,0.08);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,255,255,0.68));
  font-size: 0.84rem;
  line-height: 1.5;
}

.selection-summary strong {
  color: var(--color-text);
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  padding: 0.9rem;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,255,255,0.82));
  border: 1px solid rgba(255,255,255,0.92);
  box-shadow:
    0 16px 30px rgba(63,43,68,0.1),
    inset 0 1px 0 rgba(255,255,255,0.96);
}

.form-stack {
  display: grid;
  gap: 0.85rem;
}

.entity-card,
.service-card-row {
  display: grid;
  gap: 0.6rem;
}

.entity-card-footer,
.service-card-footer {
  align-items: center;
}

.entity-meta {
  font-size: 0.8rem;
}

.service-group {
  display: grid;
  gap: 0.65rem;
}

.service-group-title {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(12, 9, 13, 0.32);
  backdrop-filter: blur(12px);
}

.auth-overlay.hidden {
  display: none !important;
}

.auth-card {
  width: min(100%, 430px);
  border-radius: 28px;
  padding: 1.5rem;
}

.auth-card h2 {
  margin: 0.15rem 0 0.95rem;
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1.04;
}

.helix-powered {
  text-align: center;
  padding: 0.35rem 1rem 1rem;
}

.helix-powered a {
  font-size: 10px;
  color: #8a828f;
  opacity: 0.45;
  text-decoration: none;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}

@media (min-width: 768px) {
  .admin-shell {
    grid-template-columns: 280px 1fr;
  }

  .admin-topbar {
    padding: 0.25rem 0.15rem 0;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .ticket-toolbar {
    grid-template-columns: 1.2fr 0.8fr;
  }

  .dashboard-workspace {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .services-workspace {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .admin-shell {
    grid-template-columns: 290px 1fr;
  }

  .panel-card {
    padding: 1.1rem;
  }
}