:root {
  --portal-bg: #0b0b0e;
  --portal-surface: rgba(255, 255, 255, 0.03);
  --portal-surface-hover: rgba(255, 255, 255, 0.055);
  --portal-surface-strong: rgba(18, 18, 24, 0.85);
  --portal-border: rgba(255, 255, 255, 0.08);
  --portal-border-strong: rgba(255, 255, 255, 0.14);
  --portal-accent: #a855f7;
  --portal-accent-hover: #9333ea;
  --portal-accent-soft: rgba(168, 85, 247, 0.16);
  --portal-text: #f4f4f5;
  --portal-text-muted: #9ca3af;
  --portal-text-dim: #71717a;
  --portal-success: #22c55e;
  --portal-warning: #f59e0b;
  --portal-danger: #ef4444;
  --portal-info: #38bdf8;
  --portal-radius: 20px;
  --portal-radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body.portal-body {
  background-color: var(--portal-bg);
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 0%, rgba(168, 85, 247, 0.15) 0%, transparent 60%);
  background-size: 24px 24px, 100% 100%;
  background-attachment: fixed;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--portal-text);
  margin: 0;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.portal-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

/* Glass Card */
.portal-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 1.5rem;
}

.portal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--portal-border);
}

.portal-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--portal-text);
}

/* Top Portal Bar */
.portal-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.75rem;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--portal-border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--portal-text);
}

.portal-brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.35), rgba(168, 85, 247, 0.1));
  border: 1px solid rgba(168, 85, 247, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d8b4fe;
  font-size: 1rem;
}

.portal-brand-name {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.portal-brand-sub {
  font-size: 0.78rem;
  color: var(--portal-text-muted);
}

.portal-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.portal-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--portal-border);
  font-size: 0.82rem;
  color: var(--portal-text-muted);
}

.portal-user-pill strong {
  color: var(--portal-text);
  font-weight: 500;
}

/* Status Dot */
.portal-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #86efac;
  font-size: 0.78rem;
  font-weight: 500;
}

.portal-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--portal-success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

/* Buttons */
.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  font-family: inherit;
}

.portal-btn-primary {
  background: var(--portal-accent);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
}

.portal-btn-primary:hover {
  background: var(--portal-accent-hover);
  color: #ffffff;
  transform: translateY(-1px);
}

.portal-btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--portal-text);
  border-color: var(--portal-border-strong);
}

.portal-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.portal-btn-ghost {
  background: transparent;
  color: var(--portal-text-muted);
  border-color: var(--portal-border);
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

.portal-btn-ghost:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.portal-btn-full {
  width: 100%;
  padding: 0.78rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

/* Header Section */
.portal-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.portal-page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.portal-page-header p {
  margin: 0;
  color: var(--portal-text-muted);
  font-size: 0.95rem;
}

/* KPI Grid */
.portal-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.portal-kpi-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--portal-border);
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.portal-kpi-label {
  font-size: 0.8rem;
  color: var(--portal-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.portal-kpi-value {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-top: 0.5rem;
  line-height: 1.1;
}

.portal-kpi-sub {
  font-size: 0.78rem;
  color: var(--portal-text-dim);
  margin-top: 0.35rem;
}

/* Charts Grid */
.portal-charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.portal-chart-wrap {
  position: relative;
  height: 240px;
}

/* Badges */
.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-priority-low {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.badge-priority-medium {
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.28);
}

.badge-priority-high {
  background: rgba(249, 115, 22, 0.16);
  color: #fdba74;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-priority-critical {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.32);
}

.badge-status-new {
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.28);
}

.badge-status-in_progress {
  background: rgba(168, 85, 247, 0.16);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.32);
}

.badge-status-resolved {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.badge-status-closed {
  background: rgba(161, 161, 170, 0.14);
  color: #d4d4d8;
  border: 1px solid rgba(161, 161, 170, 0.25);
}

/* Ticket Queue Table */
.portal-table-wrap {
  overflow-x: auto;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.portal-table th {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--portal-text-dim);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--portal-border);
}

.portal-table td {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  font-size: 0.9rem;
}

.portal-table tbody tr {
  transition: background 0.18s ease;
}

.portal-table tbody tr:hover {
  background: var(--portal-surface-hover);
}

.portal-table tbody tr:last-child td {
  border-bottom: none;
}

.ticket-id-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: #c084fc;
  font-weight: 600;
}

.ticket-title-link {
  color: var(--portal-text);
  font-weight: 600;
  text-decoration: none;
  display: block;
  margin-bottom: 0.2rem;
}

.ticket-title-link:hover {
  color: #d8b4fe;
}

.ticket-excerpt {
  color: var(--portal-text-muted);
  font-size: 0.82rem;
  margin: 0;
}

.ticket-meta-sub {
  font-size: 0.78rem;
  color: var(--portal-text-dim);
}

/* Empty State */
.portal-empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
}

.portal-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  margin: 0 auto 1rem;
  background: var(--portal-accent-soft);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #d8b4fe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.portal-empty h3 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.portal-empty p {
  margin: 0 auto 1.25rem;
  max-width: 420px;
  color: var(--portal-text-muted);
  font-size: 0.9rem;
}

/* Alerts / Messages */
.portal-alert {
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--portal-border);
  background: rgba(255, 255, 255, 0.04);
}

.portal-alert-success {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
  color: #bbf7d0;
}

.portal-alert-error,
.portal-alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.32);
  color: #fecaca;
}

/* Forms */
.portal-form-group {
  margin-bottom: 1.25rem;
}

.portal-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  color: #e4e4e7;
  margin-bottom: 0.45rem;
}

.portal-input,
.portal-textarea,
.portal-select,
.portal-file {
  width: 100%;
  background: rgba(10, 10, 14, 0.7);
  border: 1px solid var(--portal-border-strong);
  border-radius: 10px;
  color: var(--portal-text);
  padding: 0.72rem 0.95rem;
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.portal-input:focus,
.portal-textarea:focus,
.portal-select:focus {
  outline: none;
  border-color: var(--portal-accent);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.portal-input::placeholder,
.portal-textarea::placeholder {
  color: var(--portal-text-dim);
}

.portal-help-text {
  font-size: 0.78rem;
  color: var(--portal-text-dim);
  margin-top: 0.35rem;
}

.portal-field-error {
  color: #fca5a5;
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.portal-radio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.portal-radio-option {
  position: relative;
}

.portal-radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.portal-radio-option label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--portal-border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--portal-text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.portal-radio-option input[type="radio"]:checked + label {
  border-color: var(--portal-accent);
  background: var(--portal-accent-soft);
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.portal-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

/* Detail Layout */
.portal-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.portal-meta-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-meta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.86rem;
}

.portal-meta-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.portal-meta-key {
  color: var(--portal-text-dim);
}

.portal-meta-val {
  color: var(--portal-text);
  font-weight: 500;
  text-align: right;
}

.portal-description-body {
  color: #e4e4e7;
  font-size: 0.95rem;
  line-height: 1.75;
}

.portal-attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.portal-attachment-card {
  display: block;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--portal-border);
  background: rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.portal-attachment-card:hover {
  border-color: rgba(168, 85, 247, 0.45);
  transform: translateY(-2px);
}

.portal-attachment-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

/* Auth Card (Login / Logged Out) */
.portal-auth-wrap {
  min-height: calc(100vh - 6rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.portal-auth-card {
  width: 100%;
  max-width: 440px;
  padding: 2.25rem;
}

.portal-auth-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.portal-auth-header h1 {
  margin: 0.9rem 0 0.4rem;
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.portal-auth-header p {
  margin: 0;
  color: var(--portal-text-muted);
  font-size: 0.9rem;
}

.portal-auth-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--portal-border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--portal-text-dim);
}

.portal-auth-footer a {
  color: #c084fc;
  text-decoration: none;
}

.portal-auth-footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 960px) {
  .portal-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .portal-charts-grid,
  .portal-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .portal-kpi-grid,
  .portal-form-row {
    grid-template-columns: 1fr;
  }
  .portal-radio-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .portal-auth-card {
    padding: 1.6rem;
  }
}
