:root {
  --navy-900: #0a1e2c;
  --navy-800: #0f2b3d;
  --navy-700: #0f3b5c;
  --blue-600: #2c6e9e;
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --line: #e2e8f0;
  --page: #f1f5f9;
  --panel: #ffffff;
}

* { box-sizing: border-box; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--page);
  color: var(--ink-900);
  overflow-x: hidden;
}

.portal-page {
  min-height: 100vh;
}

.portal-header {
  min-height: 76px;
  background: linear-gradient(95deg, var(--navy-900), var(--navy-700));
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .85rem 1.35rem;
  position: sticky;
  top: 0;
  z-index: 1040;
  box-shadow: 0 12px 30px -24px rgba(15, 23, 42, .8);
}

.portal-header-brand {
  flex: 0 0 auto;
  min-width: 245px;
}

.portal-logo {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  color: #fff;
}

.portal-logo:hover { color: #fff; }

.portal-logo-mark {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .95rem;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.22);
  font-weight: 800;
}

.portal-logo strong {
  display: block;
  font-size: 1.12rem;
  line-height: 1.1;
  letter-spacing: .01em;
}

.portal-logo small {
  display: block;
  color: rgba(255,255,255,.75);
  font-size: .73rem;
  margin-top: .12rem;
}

.portal-header-nav {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: .3rem;
  overflow-x: auto;
  padding-bottom: .1rem;
}

.portal-header-nav a {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  color: rgba(255,255,255,.78);
  text-decoration: none;
  border-radius: .75rem;
  padding: .58rem .78rem;
  white-space: nowrap;
  font-size: .88rem;
  font-weight: 700;
  transition: background .2s ease, color .2s ease;
}

.portal-header-nav a:hover,
.portal-header-nav a.active {
  color: #fff;
  background: rgba(255,255,255,.14);
}

.portal-header-user {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.portal-header-user small {
  color: rgba(255,255,255,.72);
}

.dashboard-wrapper {
  display: flex;
  min-height: calc(100vh - 76px);
}

.sidebar {
  width: 280px;
  background: linear-gradient(180deg, var(--navy-800) 0%, var(--navy-900) 100%);
  color: #e2e8f0;
  flex-shrink: 0;
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.75rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-header .logo {
  display: block;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.25;
}

.sidebar-header .logo small {
  display: block;
  margin-top: .25rem;
  color: rgba(255,255,255,.72);
  font-size: .72rem;
  font-weight: 500;
}

.sidebar-nav {
  padding: 1.25rem 1rem;
}

.sidebar .nav-item { margin-bottom: .25rem; }

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .72rem 1rem;
  color: #cbd5e1;
  border-radius: .75rem;
  font-size: .92rem;
  font-weight: 600;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

.sidebar .nav-link i {
  width: 24px;
  font-size: 1.15rem;
}

.sidebar .nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  transform: translateX(2px);
}

.sidebar .nav-link.active {
  background: var(--blue-600);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0,0,0,.18);
}

.sidebar .logout-link { color: #fecaca; }
.nav-divider { height: 1px; margin: 1rem 0; background: rgba(255,255,255,.08); }

.main-content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.top-bar {
  background: #fff;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.page-title h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink-900);
  margin: 0;
}

.breadcrumb-text {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: var(--ink-500);
  font-size: .82rem;
  margin-top: .1rem;
}

.user-dropdown {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--blue-600), var(--navy-700));
  font-weight: 800;
}

.portal-header .user-avatar {
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);
}

.content-area {
  flex: 1;
  padding: 2rem;
}

.metric,
.stat-card,
.panel,
.panel-modern,
.modern-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: 0 14px 30px -22px rgba(15, 23, 42, .38);
}

.metric {
  padding: 1.25rem;
  height: 100%;
  transition: transform .2s ease, box-shadow .2s ease;
}

.metric:hover,
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 34px -24px rgba(15, 23, 42, .42);
}

.metric .value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.panel {
  padding: 1.25rem;
  overflow: hidden;
}

.panel-modern { overflow: hidden; }

.panel-header {
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: #fafcff;
}

.panel-header h2,
.panel h2,
.modern-card h2 {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0;
}

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
}

.table thead th,
.table-custom th {
  background: #f8fafc;
  color: #475569;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 800;
  padding: .95rem 1rem;
  border-bottom: 1px solid var(--line);
}

.table td,
.table-custom td {
  padding: .95rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #eef2f7;
  font-size: .92rem;
}

.table-hover tbody tr:hover td,
.table-custom tbody tr:hover td { background: #fafcff; }

.form-label {
  font-weight: 700;
  color: var(--ink-700);
}

.required::after {
  content: " *";
  color: #dc2626;
}

.form-control,
.form-select {
  border-radius: .75rem;
  border-color: var(--line);
  padding: .65rem .85rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 .2rem rgba(44,110,158,.16);
}

.btn {
  border-radius: .75rem;
  font-weight: 700;
}

.btn-primary,
.btn-primary-modern {
  background: linear-gradient(95deg, #1e4a76, #0f3b5c);
  border: none;
}

.btn-primary:hover,
.btn-primary-modern:hover {
  background: linear-gradient(95deg, #163d5e, #0c2e48);
  box-shadow: 0 8px 18px rgba(30,74,118,.22);
}

.badge {
  border-radius: 999px;
  padding: .38rem .68rem;
}

.alert {
  border-radius: 1rem;
  border: 1px solid transparent;
}

.portal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  padding: 1.2rem 2rem;
  background: linear-gradient(95deg, var(--navy-900), var(--navy-700));
  color: #e2e8f0;
  border-top: 1px solid rgba(255,255,255,.08);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: .85rem;
}

.footer-mark {
  width: 42px;
  height: 42px;
  border-radius: .9rem;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
}

.footer-title {
  color: #fff;
  font-weight: 800;
  line-height: 1.15;
}

.footer-subtitle {
  font-size: .82rem;
  color: rgba(226,232,240,.76);
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .55rem .9rem;
  font-size: .86rem;
}

.footer-meta span {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.login-page {
  min-height: 100vh;
  background: #f8fafc;
  color: var(--ink-900);
}

.login-footer {
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: .8rem;
  color: #475569;
}

@media (max-width: 992px) {
  .portal-header {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
    gap: .8rem;
  }
  .portal-header-brand,
  .portal-header-nav,
  .portal-header-user {
    width: 100%;
  }
  .portal-header-user {
    justify-content: space-between;
  }
  .dashboard-wrapper { display: block; }
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    top: auto;
  }
  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    gap: .35rem;
    padding: .85rem 1rem;
  }
  .sidebar .nav-item { flex: 0 0 auto; }
  .sidebar .nav-link { white-space: nowrap; }
  .nav-divider { display: none; }
}

@media (max-width: 768px) {
  .top-bar,
  .portal-footer {
    align-items: flex-start;
    flex-direction: column;
  }
  .content-area { padding: 1rem; }
  .footer-meta { justify-content: flex-start; }
  .user-dropdown { width: 100%; justify-content: space-between; }
}
