/* Ensure main nav items and auth area sit on one row */
.nav-bar .main-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-bar .main-nav > a,
.nav-bar .main-nav > .nav-item-dropdown,
.nav-bar .main-nav > .auth-area {
  display: inline-flex;
  align-items: center;
}

.nav-bar .main-nav .auth-area {
  margin-left: 0;
  white-space: nowrap;
}

.nav-bar .main-nav .nav-portal-link {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  text-decoration: none;
  color: inherit;
}

@media (max-width: 767px) {
  .nav-bar .main-nav {
    gap: 0.5rem;
    flex-wrap: wrap;
  }
}

/* Portal theme inspired by the provided dashboard reference */
:root {
  --portal-bg: #f1f3f7;
  --portal-surface: #ffffff;
  --portal-border: #dbe1ea;
  --portal-text: #2f3640;
  --portal-muted: #7a8394;
  --portal-blue: #0f6bd8;
  --portal-blue-dark: #084f9e;
  --portal-red: #ea2525;
  --portal-left-width: 220px;
  --portal-right-width: 260px;
}

.portal-shell {
  display: grid;
  grid-template-columns: var(--portal-left-width) 1fr;
  min-height: 100vh;
  background: var(--portal-bg);
  color: var(--portal-text);
}

.portal-sidebar {
  background: #fafafa;
  border-right: 1px solid var(--portal-border);
  padding: 1.1rem 0.85rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: start;
  overflow-y: auto;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.1rem;
  padding: 0.35rem 0.35rem 0.7rem;
  border-bottom: 1px solid var(--portal-border);
}

.portal-brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--portal-border);
}

.portal-brand-title {
  font-size: 0.93rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.portal-brand-subtitle {
  font-size: 0.72rem;
  color: var(--portal-muted);
}

.portal-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
}

.portal-nav a {
  color: #596272;
  text-decoration: none;
  font-weight: 600;
  padding: 0.72rem 0.72rem;
  border-radius: 8px;
  transition: background-color 0.2s, color 0.2s;
}

.portal-nav a.active,
.portal-nav a:hover {
  background: #fff;
  color: #101821;
}

.portal-sidebar-logout {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid var(--portal-border);
}

.portal-logout-btn {
  width: 100%;
  border: 1px solid #cfd7e4;
  background: #fff;
  border-radius: 8px;
  padding: 0.7rem 0.72rem;
  font-weight: 700;
  color: #3e4959;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.portal-logout-btn:hover {
  background: #fdf1f1;
  border-color: #e8b8b8;
  color: #a32121;
}

.portal-stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.portal-topbar {
  background: var(--portal-surface);
  border-bottom: 1px solid var(--portal-border);
}

.portal-topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
}

.portal-search-wrap {
  max-width: 520px;
}

.portal-search {
  width: 100%;
  border: 1px solid var(--portal-border);
  border-radius: 999px;
  background: #f8fafc;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
}

.portal-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-icon-btn {
  border: 1px solid var(--portal-border);
  background: #fff;
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #445065;
}

.portal-user {
  font-size: 0.9rem;
  font-weight: 700;
  color: #273246;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--portal-border);
  border-radius: 999px;
  background: #fff;
}

.portal-workspace {
  display: grid;
  grid-template-columns: 1fr var(--portal-right-width);
  gap: 0;
  min-height: 0;
}

.portal-content {
  min-width: 0;
  padding: 1rem;
}

.portal-right-rail {
  border-left: 1px solid var(--portal-border);
  background: #f8f9fc;
  padding: 0.9rem;
}

.portal-rail-card {
  background: #fff;
  border: 1px solid var(--portal-border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.portal-rail-card h4 {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #6d7789;
  margin: 0 0 0.6rem;
  text-transform: uppercase;
}

.portal-rail-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-rail-card li {
  padding: 0.36rem 0;
  border-bottom: 1px solid #eff3f8;
  font-size: 0.88rem;
}

.portal-rail-card li:last-child {
  border-bottom: 0;
}

.portal-client-header {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.portal-client-hero {
  background: linear-gradient(120deg, var(--portal-blue), var(--portal-blue-dark));
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem;
}

.portal-client-avatar {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 800;
  background: #fff;
  color: var(--portal-red);
}

.portal-client-hero h2 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
}

.portal-client-hero p {
  margin: 0.2rem 0 0;
  color: #dce9ff;
  font-size: 0.9rem;
}

.portal-client-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--portal-border);
  background: #fff;
}

.portal-tab {
  border: 0;
  background: transparent;
  color: #7a8394;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 0.45rem 0.55rem;
  border-bottom: 2px solid transparent;
}

.portal-tab.active {
  color: #d81717;
  border-bottom-color: #d81717;
}

.portal-card {
  background: #fff;
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.portal-section-title {
  margin: 0 0 0.9rem;
  font-size: 1.18rem;
}

.portal-table-wrap {
  overflow-x: auto;
}

.portal-file-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.portal-file-table th,
.portal-file-table td {
  text-align: left;
  padding: 0.68rem;
  border-bottom: 1px solid #edf1f6;
  vertical-align: top;
}

.portal-file-table th {
  color: #7a8394;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.portal-file-table td {
  font-size: 0.9rem;
}

.portal-row-btn {
  border: 1px solid #d8deea;
  border-radius: 8px;
  background: #fff;
  color: #3d4860;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.28rem 0.55rem;
  margin-right: 0.35rem;
}

.portal-row-btn:hover:enabled {
  background: #f7f9fd;
}

.portal-note-list {
  margin: 0.6rem 0 0;
  padding-left: 1rem;
}

.portal-note-list li {
  margin-bottom: 0.5rem;
}

.portal-note-editor {
  margin-top: 0.6rem;
}

.portal-notes-area {
  padding: 0.2rem 0;
}

.portal-muted {
  color: var(--portal-muted);
  font-size: 0.83rem;
}

.portal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 0.8rem;
}

.portal-form-grid .form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: #445065;
  margin-bottom: 0.35rem;
}

.portal-form-grid .form-control {
  border: 1px solid var(--portal-border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.92rem;
  padding: 0.55rem 0.65rem;
}

.portal-form-grid .validation-message {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

@media (max-width: 1200px) {
  .portal-workspace {
    grid-template-columns: 1fr;
  }

  .portal-right-rail {
    border-left: 0;
    border-top: 1px solid var(--portal-border);
  }
}

@media (max-width: 900px) {
  .portal-shell {
    grid-template-columns: 1fr;
  }

  .portal-form-grid {
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes off-screen drawer on mobile */
  .portal-sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    width: 260px;
    height: 100vh;
    z-index: 1100;
    border-right: 1px solid var(--portal-border);
    border-bottom: 0;
    overflow-y: auto;
    transition: left 0.28s ease;
  }

  .portal-shell.sidebar-open .portal-sidebar {
    left: 0;
  }

  /* Keep logout button visible — not pushed to very bottom on mobile */
  .portal-sidebar-logout {
    margin-top: 1.5rem;
  }

  /* Backdrop shown when sidebar is open */
  .portal-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1099;
  }

  /* Close button inside sidebar */
  .portal-sidebar-close-btn {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--portal-muted);
    cursor: pointer;
    padding: 0.4rem 0.5rem 0;
    text-align: right;
  }

  .portal-topbar-inner {
    grid-template-columns: 1fr;
  }

  .portal-search-wrap {
    max-width: 100%;
  }

  .portal-content {
    padding: 0.75rem;
  }
}

/* Hamburger button in portal topbar — hidden on desktop */
.portal-hamburger-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.portal-hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--portal-text, #2f3640);
  transition: 0.2s;
}

@media (max-width: 900px) {
  .portal-hamburger-btn {
    display: flex;
  }

  .portal-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  /* Hide close button on desktop */
  .portal-sidebar-close-btn {
    display: block;
  }
}

/* Hide close button on desktop */
.portal-sidebar-close-btn {
  display: none;
}

/* Separate visual shell for Client and Partner portals */
.pc-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  background: #f6f8fb;
  color: #1f2937;
}

.pc-sidebar {
  background: #eef2f6;
  border-right: 1px solid #d7dee8;
  padding: 1rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.pc-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-bottom: 1px solid #d7dee8;
  padding-bottom: 0.85rem;
  margin-bottom: 0.75rem;
}

.pc-brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #d8deea;
  padding: 0.25rem;
}

.pc-brand-title {
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: 0.03em;
}

.pc-brand-subtitle {
  font-size: 0.72rem;
  color: #5e6a79;
  margin-top: 0.15rem;
}

.pc-menu {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.pc-sidebar-logout {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid #d7dee8;
}

.pc-menu-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #2e3b4b;
  text-align: left;
  font-size: 1rem;
  padding: 0.62rem 0.65rem;
}

.pc-menu-item.active {
  background: #dce8f5;
  border-color: #cad7e6;
}

.pc-stage {
  min-width: 0;
  padding: 1.1rem;
}

.pc-content {
  max-width: 1140px;
}

.pc-dashboard {
  width: 100%;
}

.pc-page-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2.2vw, 2.6rem);
  line-height: 1.1;
}

.pc-page-header p {
  margin: 0.4rem 0 0;
  color: #566172;
}

.pc-action-grid {
  margin-top: 1.1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.pc-action-card {
  background: #fff;
  border: 1px solid #d7dee8;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(21, 30, 44, 0.05);
}

.pc-action-card h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 2.15rem);
  line-height: 1.1;
}

.pc-action-card p {
  margin: 0.55rem 0 0.9rem;
  color: #556173;
}

.pc-primary-btn {
  border: 1px solid #c7d0dc;
  background: #fff;
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-weight: 700;
  color: #2a3749;
}

.pc-content-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1rem;
}

.pc-panel {
  background: #fff;
  border: 1px solid #d7dee8;
  border-radius: 12px;
  padding: 1rem;
}

.pc-panel h3 {
  margin: 0;
  font-size: 1.8rem;
}

.pc-muted {
  margin: 0.2rem 0 0.9rem;
  color: #556173;
}

.pc-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.pc-metric-card {
  border: 1px solid #dbe2ec;
  border-radius: 10px;
  padding: 0.6rem;
  text-align: center;
}

.pc-metric-card span {
  display: block;
  font-size: 0.85rem;
  color: #485669;
}

.pc-metric-card strong {
  font-size: 1.95rem;
  line-height: 1;
}

.pc-data-grid {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 0.75rem;
}

.pc-inner-panel {
  border-top: 1px solid #e5ebf2;
  padding-top: 0.55rem;
}

.pc-inner-panel h4 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.pc-table {
  width: 100%;
  border-collapse: collapse;
}

.pc-table th,
.pc-table td {
  border-bottom: 1px solid #e8edf3;
  padding: 0.45rem;
  text-align: left;
  font-size: 0.86rem;
}

.pc-table th {
  color: #49586b;
  font-weight: 700;
}

.pc-chart-mock {
  border: 1px solid #dbe2ec;
  border-radius: 10px;
  min-height: 190px;
  display: grid;
  place-items: center;
  color: #4d596a;
  background:
    linear-gradient(to top right, rgba(145, 169, 197, 0.25), rgba(145, 169, 197, 0.06)),
    repeating-linear-gradient(
      to bottom,
      transparent,
      transparent 31px,
      rgba(157, 171, 186, 0.18) 31px,
      rgba(157, 171, 186, 0.18) 32px
    );
}

.pc-alert-panel h3 {
  font-size: 2rem;
  line-height: 1.05;
}

.pc-alert-item {
  border-top: 1px solid #e3eaf3;
  padding: 0.7rem 0;
}

.pc-alert-item p {
  margin: 0;
}

.pc-alert-item strong {
  font-size: 1.3rem;
}

.pc-footer {
  margin-top: 1.05rem;
  border-top: 1px solid #dbe2ec;
  padding-top: 0.65rem;
  color: #505d6d;
  font-size: 0.94rem;
}

.pc-footer p {
  margin: 0.12rem 0;
}

@media (max-width: 1200px) {
  .pc-content-grid {
    grid-template-columns: 1fr;
  }

  .pc-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .pc-shell {
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes off-screen drawer on mobile */
  .pc-sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    width: 260px;
    height: 100vh;
    z-index: 1100;
    overflow-y: auto;
    transition: left 0.28s ease;
  }

  .pc-shell.sidebar-open .pc-sidebar {
    left: 0;
  }

  /* Keep logout button visible — not pushed to very bottom on mobile */
  .pc-sidebar-logout {
    margin-top: 1.5rem;
  }

  .pc-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1099;
  }

  .pc-sidebar-close-btn {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: #5e6a79;
    cursor: pointer;
    padding: 0.4rem 0.5rem 0;
    text-align: right;
  }

  .pc-menu {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pc-action-grid,
  .pc-data-grid {
    grid-template-columns: 1fr;
  }

  .pc-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pc-panel h3,
  .pc-alert-panel h3 {
    font-size: 1.4rem;
  }

  .pc-metric-card strong {
    font-size: 1.55rem;
  }
}

/* Mobile bar with hamburger for pc-shell — only visible on mobile */
.pc-mobile-bar {
  display: none;
  padding: 0.6rem 0.75rem;
  background: #eef2f6;
  border-bottom: 1px solid #d7dee8;
}

.pc-hamburger-btn {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 4px;
}

.pc-hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: #2e3b4b;
  transition: 0.2s;
}

/* Hide close button on desktop */
.pc-sidebar-close-btn {
  display: none;
}

@media (max-width: 920px) {
  .pc-mobile-bar {
    display: flex;
    align-items: center;
  }

  .pc-sidebar-close-btn {
    display: flex;
  }
}
