/* === FONTS === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* === ROOT VARIABLES === */
:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --accent: #f97316;
  --accent-light: #fbbf24;
  --bg: #f0f4ff;
  --sidebar-bg: #0f172a;
  --sidebar-width: 260px;
  --card-radius: 14px;
  --transition: all .3s cubic-bezier(.4,0,.2,1);
}

/* === BASE === */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: #1e293b; }

/* === GRADIENT HELPERS === */
.grad-blue { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); }
.grad-amber { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%); }
.grad-mix  { background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%); }

/* === SIDEBAR === */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--sidebar-bg);
  overflow-y: auto; z-index: 1040;
  transition: var(--transition);
  display: flex; flex-direction: column;
}
.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-brand .brand-icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff; flex-shrink: 0;
}
.sidebar-brand .brand-text { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.2; }
.sidebar-brand .brand-sub  { color: rgba(255,255,255,.45); font-size: .72rem; }

.sidebar-section { padding: .75rem 1rem .35rem; color: rgba(255,255,255,.3); font-size: .68rem; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; }

.sidebar nav a {
  display: flex; align-items: center; gap: .85rem;
  padding: .65rem 1.25rem; color: rgba(255,255,255,.65);
  text-decoration: none; font-size: .875rem; font-weight: 500;
  border-radius: 8px; margin: 2px 10px;
  transition: var(--transition); position: relative;
}
.sidebar nav a:hover, .sidebar nav a.active {
  color: #fff; background: rgba(59,130,246,.25);
}
.sidebar nav a.active {
  background: linear-gradient(90deg, rgba(59,130,246,.35), rgba(59,130,246,.1));
}
.sidebar nav a.active::before {
  content: ''; position: absolute; left: 0; top: 20%; height: 60%; width: 3px;
  background: linear-gradient(var(--primary-light), var(--accent));
  border-radius: 0 3px 3px 0;
}
.sidebar nav a i { width: 18px; text-align: center; font-size: .95rem; opacity: .8; }
.sidebar nav a.active i { opacity: 1; }
.sidebar-footer {
  margin-top: auto; padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* === TOPBAR === */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-width); right: 0;
  height: 64px; background: #fff; z-index: 1030;
  display: flex; align-items: center; padding: 0 1.5rem;
  box-shadow: 0 1px 0 #e2e8f0; gap: 1rem;
  transition: var(--transition);
}
.topbar .topbar-title { font-weight: 700; font-size: 1rem; color: #0f172a; flex: 1; }
.topbar .topbar-actions { display: flex; align-items: center; gap: .75rem; }
.topbar .user-chip {
  display: flex; align-items: center; gap: .6rem;
  padding: .4rem .85rem; border-radius: 50px;
  background: var(--bg); cursor: pointer;
  font-size: .85rem; font-weight: 500;
}
.topbar .user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}
.sidebar-toggle {
  display: none; background: none; border: none;
  font-size: 1.25rem; color: #64748b; cursor: pointer; padding: .25rem .5rem;
}

/* === MAIN CONTENT === */
.wrapper { display: flex; }
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: 64px;
  padding: 1.75rem;
  min-height: calc(100vh - 64px);
  flex: 1;
  transition: var(--transition);
}

/* === PAGE HEADER === */
.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
}
.page-header h4 { font-size: 1.35rem; font-weight: 700; color: #0f172a; margin: 0; }
.page-header p  { font-size: .875rem; color: #64748b; margin: .25rem 0 0; }

/* === STAT CARDS === */
.stat-card {
  background: #fff; border-radius: var(--card-radius);
  padding: 1.5rem; position: relative; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  border: 1px solid #e8edf5;
  transition: var(--transition);
  animation: fadeUp .5s ease both;
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(30,64,175,.12);
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%;
  background: linear-gradient(var(--primary), var(--accent));
  border-radius: 4px 0 0 4px;
}
.stat-card .stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #fff; margin-bottom: 1rem;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: #0f172a; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .5px; margin-top: .25rem; }
.stat-card .stat-change { font-size: .78rem; margin-top: .5rem; }

/* === CARDS === */
.card {
  border: 1px solid #e8edf5; border-radius: var(--card-radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  animation: fadeUp .5s ease both;
}
.card-header {
  background: #fff; border-bottom: 1px solid #f1f5f9;
  padding: 1rem 1.25rem; font-weight: 600; font-size: .925rem;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}
.card-header.gradient-header {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; border: none;
}

/* === BUTTONS === */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light)) !important;
  border: none !important; font-weight: 600 !important;
  transition: var(--transition) !important;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1a34a0, #2563eb) !important;
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(30,64,175,.35) !important;
}
.btn-warning, .btn-amber {
  background: linear-gradient(135deg, var(--accent), var(--accent-light)) !important;
  border: none !important; color: #fff !important; font-weight: 600 !important;
}
.btn-warning:hover {
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(249,115,22,.35) !important;
}
.btn-outline-primary { border-color: var(--primary-light) !important; color: var(--primary) !important; }
.btn-outline-primary:hover { background: var(--primary-light) !important; color: #fff !important; }

/* === TABLES === */
.table thead th {
  background: #f8faff; color: #64748b;
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; border-bottom: 1px solid #e2e8f0; padding: .85rem 1rem;
}
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: #f8faff; }
.table td { padding: .85rem 1rem; vertical-align: middle; font-size: .875rem; border-color: #f1f5f9; }

/* === FORMS === */
.form-control, .form-select {
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: .875rem; padding: .6rem .85rem;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-label { font-size: .8rem; font-weight: 600; color: #374151; margin-bottom: .4rem; }

/* === BADGES === */
.badge { font-weight: 600; font-size: .72rem; padding: .35em .65em; border-radius: 6px; }

/* === ANIMATIONS === */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: .8; }
  100% { transform: scale(1.5); opacity: 0; }
}
.anim-delay-1 { animation-delay: .1s; }
.anim-delay-2 { animation-delay: .2s; }
.anim-delay-3 { animation-delay: .3s; }
.anim-delay-4 { animation-delay: .4s; }

/* === FLASH ALERTS === */
.flash-container { position: fixed; top: 80px; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.flash-alert {
  min-width: 280px; padding: .85rem 1.1rem; border-radius: 10px;
  font-size: .875rem; font-weight: 500; display: flex; align-items: center; gap: .6rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  animation: slideInRight .35s cubic-bezier(.4,0,.2,1) both;
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.flash-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.flash-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.flash-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }
.flash-warning { background: #fef3c7; color: #92400e; border-left: 4px solid #f59e0b; }

/* === LOGIN PAGE === */
.login-page-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e40af 50%, #f97316 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.login-page-bg::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-blob-1, .login-blob-2 {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .35;
  animation: blob 8s ease-in-out infinite;
}
.login-blob-1 { width: 500px; height: 500px; background: var(--primary-light); top: -150px; right: -100px; }
.login-blob-2 { width: 400px; height: 400px; background: var(--accent); bottom: -100px; left: -100px; animation-delay: 4s; }
@keyframes blob { 0%,100%{transform:translate(0,0) scale(1)} 33%{transform:translate(20px,-20px) scale(1.05)} 66%{transform:translate(-10px,15px) scale(.95)} }

.login-card {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,.95); backdrop-filter: blur(20px);
  border-radius: 20px; box-shadow: 0 25px 60px rgba(0,0,0,.35);
  animation: fadeUp .6s ease both;
  position: relative; z-index: 1;
  border: 1px solid rgba(255,255,255,.3);
}
.login-card-header {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  padding: 2.5rem 2rem 2rem; border-radius: 20px 20px 0 0; text-align: center; color: #fff;
}
.login-card-header .hosp-icon {
  width: 70px; height: 70px; background: rgba(255,255,255,.2);
  border-radius: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto 1rem; backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.3);
  animation: fadeUp .6s .2s ease both;
}
.login-card-body { padding: 2rem; }

/* === HERO GRADIENT BANNER === */
.hero-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--accent) 100%);
  border-radius: var(--card-radius); color: #fff; padding: 1.75rem 2rem; margin-bottom: 1.5rem;
  position: relative; overflow: hidden;
  animation: fadeUp .4s ease both;
}
.hero-banner::after {
  content: '';
  position: absolute; right: -30px; top: -30px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.hero-banner::before {
  content: '';
  position: absolute; right: 60px; bottom: -40px;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.hero-banner h3 { font-weight: 800; font-size: 1.4rem; margin-bottom: .25rem; position: relative; z-index: 1; }
.hero-banner p  { opacity: .85; font-size: .875rem; margin: 0; position: relative; z-index: 1; }

/* === PROGRESS BAR ANIMATED === */
.progress-bar-animated-custom {
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
  animation: progressAnim 1.5s ease both;
}
@keyframes progressAnim { from { width: 0; } }

/* === DOCUMENT / PRINT === */
.document-wrapper {
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 0;
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.letter-paper {
  max-width: 800px; margin: 0 auto;
  padding: 40px 50px; font-family: 'Times New Roman', serif;
  font-size: 13pt; line-height: 1.8; color: #000;
}
.letter-header { border-bottom: 3px double #1e40af; padding-bottom: 16px; margin-bottom: 24px; }
.letter-footer { border-top: 1px solid #ccc; margin-top: 48px; padding-top: 16px; }
.letter-signature img { max-height: 70px; }

/* === MOBILE OVERLAY === */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* === RESPONSIVE === */
@media (max-width: 991.98px) {
  .sidebar {
    left: calc(-1 * var(--sidebar-width));
    box-shadow: none;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 30px rgba(0,0,0,.3);
  }
  .topbar { left: 0 !important; }
  .main-content { margin-left: 0 !important; }
  .sidebar-toggle { display: block; }
}
@media (max-width: 767.98px) {
  .main-content { padding: 1rem; }
  .hero-banner { padding: 1.25rem 1.25rem; }
  .hero-banner h3 { font-size: 1.15rem; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .page-header h4 { font-size: 1.1rem; }
  .table-responsive { font-size: .82rem; }
}

/* === PRINT === */
@media print {
  .sidebar, .topbar, .no-print, .page-header, nav { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .letter-paper { padding: 20px; }
  body { background: #fff !important; }
}

/* === UTILITY === */
.cursor-pointer { cursor: pointer; }
.text-primary-custom { color: var(--primary) !important; }
.text-accent { color: var(--accent) !important; }
.bg-primary-soft { background: rgba(59,130,246,.08) !important; }
.border-primary-light { border-color: var(--primary-light) !important; }
.rounded-xl { border-radius: 14px !important; }
.shadow-soft { box-shadow: 0 4px 20px rgba(0,0,0,.06) !important; }

/* === UPLOAD PREVIEW === */
.upload-zone {
  border: 2px dashed #cbd5e1; border-radius: 12px; padding: 2rem;
  text-align: center; cursor: pointer; transition: var(--transition);
  background: #f8faff;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary-light);
  background: rgba(59,130,246,.04);
}
.upload-preview {
  max-width: 180px; max-height: 80px;
  border-radius: 8px; display: none; margin: .75rem auto 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

/* === KANBAN / STATUS PIPELINE === */
.pipeline-stages { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; }
.pipeline-stage { flex: 0 0 auto; }
.pipeline-badge {
  padding: .45rem 1rem; border-radius: 50px; font-size: .78rem; font-weight: 700;
  white-space: nowrap;
}

/* === SECTION TABS === */
.nav-tabs .nav-link { font-weight: 500; color: #64748b; border: none; border-bottom: 2px solid transparent; padding: .6rem 1rem; }
.nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: none; }
.nav-tabs { border-bottom: 1px solid #e2e8f0; }

/* === TOOLTIP-STYLE HELP TEXT === */
.field-hint { font-size: .75rem; color: #94a3b8; margin-top: .2rem; }
