:root,
[data-bs-theme="light"] {
  --nf-bg: #f3f5f8;
  --nf-surface: #ffffff;
  --nf-surface-2: #f8fafc;
  --nf-border: #e5e9f0;
  --nf-text: #1f2937;
  --nf-muted: #6b7280;
  --nf-accent: #0f766e;
  --nf-accent-soft: rgba(15, 118, 110, 0.12);
  --nf-sidebar: #0f172a;
  --nf-sidebar-text: #cbd5e1;
  --nf-sidebar-active: #ffffff;
  --nf-shadow: 0 0.35rem 1rem rgba(15, 23, 42, 0.06);
  --nf-topbar: rgba(255, 255, 255, 0.85);
  --nf-radius: 0.9rem;
  --nf-sidebar-width: 260px;
}

[data-bs-theme="dark"] {
  --nf-bg: #0b1220;
  --nf-surface: #121a2b;
  --nf-surface-2: #182235;
  --nf-border: #243044;
  --nf-text: #e5eefb;
  --nf-muted: #94a3b8;
  --nf-accent: #2dd4bf;
  --nf-accent-soft: rgba(45, 212, 191, 0.14);
  --nf-sidebar: #070d18;
  --nf-sidebar-text: #9fb0c7;
  --nf-sidebar-active: #ffffff;
  --nf-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.35);
  --nf-topbar: rgba(18, 26, 43, 0.88);
}

html, body {
  height: 100%;
}

body {
  background: var(--nf-bg);
  color: var(--nf-text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.app-body {
  overflow-x: hidden;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.app-sidebar {
  width: var(--nf-sidebar-width);
  background:
    radial-gradient(circle at top left, rgba(45, 212, 191, 0.12), transparent 40%),
    linear-gradient(180deg, #111827 0%, var(--nf-sidebar) 100%);
  color: var(--nf-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.35rem 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 10px;
  background: #fff;
  padding: 3px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.brand-title {
  color: #fff;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
}

.sidebar-nav {
  padding: 1rem 0.85rem;
  flex: 1;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.35rem 0.85rem 0.55rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.2rem;
  border-radius: 0.7rem;
  color: var(--nf-sidebar-text);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sidebar-link i {
  font-size: 1.1rem;
  width: 1.25rem;
  text-align: center;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(20, 184, 166, 0.85));
  color: var(--nf-sidebar-active);
  box-shadow: 0 0.35rem 1rem rgba(15, 118, 110, 0.28);
}

.sidebar-group {
  margin-bottom: 0.2rem;
}

.sidebar-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.sidebar-toggle.active-parent {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.submenu-caret {
  font-size: 0.85rem;
  transition: transform 0.2s ease;
  opacity: 0.8;
}

.sidebar-group.open .submenu-caret {
  transform: rotate(180deg);
}

.sidebar-submenu {
  display: none;
  padding: 0.2rem 0 0.35rem 0.55rem;
  margin: 0.15rem 0 0.35rem 0.85rem;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-submenu.show {
  display: block;
}

.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.1rem;
  border-radius: 0.6rem;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-sublink i {
  font-size: 0.95rem;
  width: 1.1rem;
  text-align: center;
}

.sidebar-sublink:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.sidebar-sublink.active {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(20, 184, 166, 0.85));
  color: #fff;
  box-shadow: 0 0.25rem 0.75rem rgba(15, 118, 110, 0.25);
}

.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.app-main {
  margin-left: var(--nf-sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: var(--nf-topbar);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--nf-border);
}

.topbar-title {
  font-weight: 650;
  font-size: 1.05rem;
}

.topbar-subtitle {
  font-size: 0.78rem;
}

.app-content {
  padding: 1.35rem 1.5rem 2rem;
}

.page-header {
  margin-bottom: 1.25rem;
}

.app-card {
  background: var(--nf-surface);
  border: 1px solid var(--nf-border);
  border-radius: var(--nf-radius);
  box-shadow: var(--nf-shadow);
  color: var(--nf-text);
}

.summary-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.summary-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--nf-accent) 35%, var(--nf-border));
  box-shadow: 0 0.65rem 1.4rem rgba(15, 23, 42, 0.1);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--nf-border);
  background: var(--nf-surface);
  color: var(--nf-text);
  border-radius: 0.7rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  border-radius: 0.7rem;
  padding: 0.65rem 0.85rem;
  transition: background 0.15s ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

[data-bs-theme="light"] .theme-icon-light,
[data-bs-theme="dark"] .theme-icon-dark {
  display: none;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--nf-border);
  background: var(--nf-surface);
  color: var(--nf-text);
  border-radius: 999px;
  padding: 0.3rem 0.75rem 0.3rem 0.3rem;
}

.user-chip::after {
  margin-left: 0.15rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--nf-accent-soft);
  color: var(--nf-accent);
  font-weight: 700;
}

.user-meta {
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.user-name {
  font-size: 0.86rem;
  font-weight: 600;
}

.user-role {
  font-size: 0.72rem;
  color: var(--nf-muted);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--nf-text);
  --bs-table-border-color: var(--nf-border);
  --bs-table-hover-bg: var(--nf-surface-2);
}

.table > :not(caption) > * > * {
  background-color: transparent;
  color: inherit;
}

.form-control,
.form-select {
  background-color: var(--nf-surface);
  border-color: var(--nf-border);
  color: var(--nf-text);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--nf-accent);
  box-shadow: 0 0 0 0.2rem var(--nf-accent-soft);
}

.btn-primary {
  --bs-btn-bg: #0f766e;
  --bs-btn-border-color: #0f766e;
  --bs-btn-hover-bg: #0d9488;
  --bs-btn-hover-border-color: #0d9488;
  --bs-btn-active-bg: #0f766e;
  --bs-btn-active-border-color: #0f766e;
}

[data-bs-theme="dark"] .btn-primary {
  --bs-btn-bg: #14b8a6;
  --bs-btn-border-color: #14b8a6;
  --bs-btn-color: #042f2e;
  --bs-btn-hover-bg: #2dd4bf;
  --bs-btn-hover-border-color: #2dd4bf;
  --bs-btn-hover-color: #042f2e;
}

.dropdown-menu {
  background: var(--nf-surface);
  border-color: var(--nf-border);
  color: var(--nf-text);
}

.dropdown-item {
  color: var(--nf-text);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--nf-surface-2);
  color: var(--nf-text);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
  z-index: 1035;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
}

.sidebar-backdrop.show {
  opacity: 1;
  visibility: visible;
}

/* Login */
.login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--nf-accent) 18%, transparent), transparent 35%),
    radial-gradient(circle at 85% 10%, rgba(59, 130, 246, 0.12), transparent 30%),
    linear-gradient(180deg, var(--nf-bg) 0%, var(--nf-surface-2) 100%);
}

.login-theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  padding: 0;
  z-index: 10;
  background: var(--nf-surface);
  border: 1px solid var(--nf-border);
  color: var(--nf-text);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--nf-surface);
  border: 1px solid var(--nf-border);
  border-radius: 1.15rem;
  box-shadow: var(--nf-shadow);
  padding: 2rem;
}

.login-card .brand-mark {
  margin: 0 auto;
}

.login-logo {
  display: block;
  margin: 0 auto;
  max-width: 280px;
  width: 100%;
  height: auto;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-105%);
  }

  .app-sidebar.show {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
  }
}

/* SweetAlert theme alignment */
.swal2-popup {
  background: var(--nf-surface) !important;
  color: var(--nf-text) !important;
  border: 1px solid var(--nf-border);
  border-radius: 1rem !important;
}

.swal2-title,
.swal2-html-container {
  color: var(--nf-text) !important;
}

.chart-box {
  position: relative;
  width: 100%;
}

.chart-box-sm {
  height: 180px;
}

.ticket-no {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--nf-accent);
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.white-space-pre {
  white-space: pre-wrap;
}

.detail-list dt {
  color: var(--nf-muted);
  font-weight: 500;
  margin-bottom: 0.55rem;
}

.detail-list dd {
  margin-bottom: 0.55rem;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-item {
  display: flex;
  gap: 0.85rem;
}

.timeline-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--nf-accent-soft);
  color: var(--nf-accent);
  font-weight: 700;
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
  background: var(--nf-surface-2);
  border: 1px solid var(--nf-border);
  border-radius: 0.8rem;
  padding: 0.85rem 1rem;
}

.timeline-item.internal .timeline-content {
  border-style: dashed;
  background: color-mix(in srgb, #f59e0b 8%, var(--nf-surface));
}

.edit-message-btn {
  color: var(--nf-muted) !important;
  text-decoration: none !important;
}

.edit-message-btn:hover {
  color: var(--nf-accent) !important;
}

.edited-label {
  color: var(--nf-muted);
  font-style: italic;
}
