/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Style Guide ===== */
:root {
  --color-primary: #dce1e8;
  --color-secondary: #ffffff;
  --color-accent-light: #f5a623;
  --color-accent-dark: #d4791a;
  --accent-gradient: linear-gradient(to top, var(--color-accent-light), var(--color-accent-dark));

  /* Theme typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-heading: 32px;
  --font-size-subtitle: 20px;
  --font-size-body: 14px;
  --font-size-small: 12px;

  /* Theme text colors */
  --text-primary: #1a1a1a;
  --text-secondary: #444444;
  --text-muted: #666666;

  --sidebar-width: 260px;
  --sidebar-collapsed: 60px;
  --sidebar-transition: 0.25s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  background: var(--color-primary);
  overflow: hidden;
}

/* ===== Layout ===== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ===== Top Header ===== */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  min-height: 50px;
  padding: 0 20px;
  z-index: 100;
  margin-top: 10px;
}

.top-header .logo {
  margin-bottom: 0;
}

/* ===== User Menu ===== */
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.user-avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.06);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.user-avatar-btn:hover {
  border-color: var(--color-accent-light);
  box-shadow: 0 0 0 2px rgba(245, 166, 35, 0.2);
}

.user-avatar-btn:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: 2px;
}

.user-avatar-placeholder {
  color: #666;
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ===== User Dropdown ===== */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--color-secondary);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 24px 20px;
  z-index: 200;
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.user-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.user-dropdown-photo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.user-dropdown-photo {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
}

.user-dropdown-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.user-dropdown-photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.06);
  color: #aaa;
  border-radius: 50%;
}

.user-dropdown-photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
}

.user-dropdown-photo:hover .user-dropdown-photo-overlay {
  opacity: 1;
}

.user-dropdown-info {
  text-align: center;
  margin-bottom: 16px;
}

.user-dropdown-name {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.user-dropdown-username {
  font-size: 13px;
  color: #888;
  margin-bottom: 8px;
}

.user-dropdown-role {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(245, 166, 35, 0.15);
  color: var(--color-accent-dark);
}

.user-dropdown-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin: 12px 0;
}

.user-dropdown-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  transition: background 0.15s;
}

.user-dropdown-action:hover {
  background: rgba(0, 0, 0, 0.04);
}

.user-dropdown-action.signout {
  color: #d44;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 16px 0 16px 12px;
  transition: width var(--sidebar-transition), min-width var(--sidebar-transition);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
  min-width: var(--sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-right: 12px;
}

.sidebar-collapse-row {
  display: flex;
  justify-content: flex-end;
  padding-right: 12px;
  margin-bottom: 12px;
}

.sidebar.collapsed .sidebar-collapse-row {
  justify-content: center;
  padding-right: 0;
}

.logo {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
}

.logo-360 {
  background: linear-gradient(135deg, var(--color-accent-light), var(--color-accent-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Logo is now in top-header, no sidebar collapse rules needed */

.collapse-btn {
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #555;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s, background 0.15s;
}

.collapse-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

.sidebar.collapsed .collapse-btn {
  transform: rotate(180deg);
}

/* ===== Nav Items ===== */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Sticky back-button: when the sidebar is showing a department/docs sub-nav,
   the back link is rendered as a bare .nav-item (NOT wrapped in .nav-group)
   as the first child of .sidebar-nav. Pin it to the top so users can always
   escape the sub-nav even on short viewports where the sub-nav scrolls. */
.sidebar-nav > .nav-item:first-child {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-primary);
}

/* ===== Nav Groups ===== */
.nav-group {
  margin-bottom: 8px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 12px 4px;
  background: none;
  border: none;
  cursor: pointer;
  user-select: none;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(0, 0, 0, 0.35);
  text-transform: uppercase;
}

.nav-group-chevron {
  color: rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-group.collapsed .nav-group-chevron {
  transform: rotate(-90deg);
}

.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}

.nav-group.collapsed .nav-group-items {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}


/* When sidebar is collapsed (icon-only), hide group headers and show all items */
.sidebar.collapsed .nav-group-header {
  display: none;
}

.sidebar.collapsed .nav-group.collapsed .nav-group-items {
  max-height: 500px;
  opacity: 1;
  pointer-events: auto;
}

.sidebar.collapsed .nav-group {
  margin-bottom: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: #444;
  text-decoration: none;
  font-size: 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: visible;
  position: relative;
  margin-right: 0;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* ===== Department Dashboard Layout ===== */
.dept-dashboard-layout {
  display: flex;
  gap: 16px;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.dept-dashboard-main {
  flex: 4;
  min-width: 0;
  display: flex;
}

.dept-dashboard-side {
  flex: 1;
  min-width: 0;
  display: flex;
}

/* Proposal dashboard: side column stacks two sheets vertically */
.proposal-side-col {
  flex-direction: column;
  gap: 16px;
}

.proposal-side-col .dept-sheet-card {
  flex: 1;
  min-height: 0;
}

/* ===== Department Sheet Cards ===== */
.dept-sheet-card {
  background: #ffffff;
  border: 0.5px solid #e1e1e1;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.dept-sheet-card-compact {
  padding: 14px 16px;
}

.dept-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.dept-sheet-card-compact .dept-sheet-header {
  margin-bottom: 10px;
}

.dept-sheet-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dept-sheet-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.dept-sheet-card-compact .dept-sheet-title {
  font-size: 13px;
}

.dept-sheet-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(245, 166, 35, 0.12);
  color: var(--color-accent-light);
  font-size: 10px;
  font-weight: 600;
}

/* Dept tab wrapper — stacks month selector above sheet content */
.dept-tab-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  min-height: 0;
}

/* Month selector above dept sheets */
.dept-month-selector {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-bottom: 12px;
  flex-shrink: 0;
  background: var(--card-bg, #fff);
  border: 1px solid rgba(128, 128, 128, 0.15);
  border-radius: 8px;
  overflow: hidden;
}

.dept-month-nav {
  background: none;
  border: none;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  font-size: 11px;
  padding: 8px 12px;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
}

.dept-month-nav:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent-color, #3b82f6);
}

.dept-month-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  min-width: 130px;
  text-align: center;
  white-space: nowrap;
  padding: 6px 4px;
  border-left: 1px solid rgba(128, 128, 128, 0.12);
  border-right: 1px solid rgba(128, 128, 128, 0.12);
}

.dept-sheet-search {
  padding: 6px 12px;
  border: 1px solid rgba(128, 128, 128, 0.15);
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--font-family);
  background: var(--color-secondary);
  color: var(--text-primary);
  outline: none;
  width: 180px;
  transition: border-color 0.2s ease;
}

.dept-sheet-search:focus {
  border-color: var(--color-accent-light);
}

.dept-sheet-search::placeholder {
  color: var(--text-muted);
}

.dept-sheet-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Responsive: stack on smaller screens */
@media (max-width: 900px) {
  .dept-dashboard-layout {
    flex-direction: column;
  }
  .dept-dashboard-side {
    flex: none;
  }
}

.nav-item:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: -2px;
}

.collapse-btn:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: 2px;
}

.nav-item.active {
  background: #ffffff;
  color: #1a1a1a;
  font-weight: 500;
  border-radius: 10px;
}

.nav-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}

/* ===== Sidebar Footer ===== */
.sidebar-footer {
  margin-top: auto;
  padding-right: 12px;
}

.sidebar.collapsed .sidebar-footer {
  padding-right: 0;
}

/* ===== Content Area ===== */
.content-area {
  flex: 1;
  padding: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.card {
  width: 100%;
  height: 100%;
  background: var(--color-secondary);
  border-radius: 20px;
  padding: 0;
  overflow-y: auto;
  color: var(--text-primary);
  font-size: var(--font-size-body);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.dashboard-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 10px;
}

.dashboard-content:has(.page-placeholder) {
  align-items: center;
  justify-content: center;
}

.page-placeholder {
  color: var(--text-muted);
  font-size: var(--font-size-heading);
  font-weight: 300;
  font-style: italic;
}

/* ===== Animations ===== */
@keyframes slideUpFadeIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pageExit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Entrance animations */
.top-header {
  animation: slideUpFadeIn 0.4s ease backwards;
}

.sidebar {
  animation: slideUpFadeIn 0.5s ease backwards;
}

.card {
  animation: slideUpFadeIn 0.5s ease 0.1s backwards;
}

/* Page transition classes */
.dashboard-content.page-exit {
  animation: pageExit 0.2s ease forwards;
}

.dashboard-content.page-enter {
  animation: pageEnter 0.25s ease forwards;
}

@media (prefers-reduced-motion: reduce) {
  .top-header,
  .sidebar,
  .card {
    animation: none;
  }
  .dashboard-content.page-exit,
  .dashboard-content.page-enter {
    animation-duration: 0.01ms;
  }
}

/* ===== Department Sidebar ===== */
.dept-sidebar {
  width: var(--sidebar-width);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 16px 0 16px 12px;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width var(--sidebar-transition);
}

.dept-sidebar .msg-sidebar-title {
  color: #1a1a1a;
}

.dept-sidebar .msg-back-btn {
  color: #555;
  background: rgba(0, 0, 0, 0.06);
}

.dept-sidebar .msg-back-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

.dept-sidebar-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px 0 0;
}

.dept-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #444;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.dept-sidebar-item:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1a1a1a;
}

.dept-sidebar-item.active {
  background: var(--color-accent-light);
  color: #fff;
}

/* ===== Department Dashboard Layout ===== */
.dept-dashboard-layout {
  display: flex;
  gap: 16px;
  height: 100%;
  min-height: 0;
}

.dept-dashboard-main {
  flex: 4;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dept-dashboard-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dept-dashboard-half {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ===== Department Sheet Card ===== */
.dept-sheet-card {
  background: rgba(128, 128, 128, 0.06);
  border: 1px solid rgba(128, 128, 128, 0.1);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.dept-sheet-card-compact {
  font-size: 13px;
}

.dept-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.1);
  flex-shrink: 0;
}

.dept-sheet-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dept-sheet-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.dept-sheet-count {
  font-size: 11px;
  font-weight: 600;
  background: rgba(128, 128, 128, 0.1);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* Dept tab wrapper — stacks month selector above sheet content */
.dept-tab-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  min-height: 0;
}

/* Month selector above dept sheets */
.dept-month-selector {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-bottom: 12px;
  flex-shrink: 0;
  background: var(--card-bg, #fff);
  border: 1px solid rgba(128, 128, 128, 0.15);
  border-radius: 8px;
  overflow: hidden;
}

.dept-month-nav {
  background: none;
  border: none;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  font-size: 11px;
  padding: 8px 12px;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
}

.dept-month-nav:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent-color, #3b82f6);
}

.dept-month-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  min-width: 130px;
  text-align: center;
  white-space: nowrap;
  padding: 6px 4px;
  border-left: 1px solid rgba(128, 128, 128, 0.12);
  border-right: 1px solid rgba(128, 128, 128, 0.12);
}

.dept-sheet-search {
  padding: 6px 12px;
  border: 1px solid rgba(128, 128, 128, 0.2);
  border-radius: 8px;
  font-size: 13px;
  background: rgba(128, 128, 128, 0.04);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  width: 200px;
}

.dept-sheet-search::placeholder {
  color: var(--text-muted);
}

.dept-sheet-search:focus {
  border-color: var(--color-accent-light);
}

.dept-sheet-container {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

/* Proposal grid layout */
.proposal-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  grid-template-rows: 1fr;
  gap: 16px;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.proposal-grid--booking {
  grid-template-columns: 4fr 1fr;
}

.proposal-grid-left {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.proposal-grid-left .dept-sheet-card {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.proposal-grid-left .dept-sheet-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.proposal-grid-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.proposal-grid-right .dept-sheet-card {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.proposal-grid-right .dept-sheet-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

@media (max-width: 1024px) {
  .proposal-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .dept-dashboard-layout {
    flex-direction: column;
  }
  .dept-sheet-search {
    width: 100%;
  }
  .dept-month-selector {
    justify-content: center;
  width: fit-content;
  }
}

/* ===== Client Dashboard ===== */

.client-dashboard {
  padding: 0 4px 24px;
  /* Client dashboard is the only admin view that should scroll internally.
     Tab sheets scroll inside their own .dept-sheet-container; the page shell
     (.dashboard-content) keeps overflow: hidden. This rule gives the client
     dashboard its own scroll so long content (form data cards + JSON block)
     doesn't get clipped. */
  height: 100%;
  overflow-y: auto;
}

/* Sidebar dashboard (shown when viewing a client) */
.sidebar-dashboard-section {
  padding: 4px 16px;
}

.sidebar-dashboard-sep {
  height: 1px;
  background: rgba(128, 128, 128, 0.12);
  margin: 6px 16px;
}

.sidebar-dashboard-section-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary, #94a3b8);
  padding: 4px 16px 4px;
}

.sidebar-dashboard-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #1e293b);
  margin-bottom: 1px;
  word-break: break-word;
  line-height: 1.3;
}

.sidebar-dashboard-subtitle {
  font-size: 11px;
  color: var(--text-secondary, #64748b);
  margin-bottom: 4px;
}

.sidebar-dashboard-fields-wrap {
  padding: 0 16px;
}

.sidebar-dashboard-field {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0;
  font-size: 11px;
  line-height: 1.4;
}

.sidebar-dashboard-label {
  color: var(--text-secondary, #64748b);
  flex-shrink: 0;
}

.sidebar-dashboard-value {
  color: var(--text-primary, #1e293b);
  text-align: right;
  word-break: break-word;
  font-weight: 500;
}

.sidebar-dashboard-contact {
  padding: 4px 16px 6px;
}

.sidebar-dashboard-contact-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 2px;
}

.sidebar-dashboard-contact-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
}

.sidebar-dashboard-contact-detail {
  font-size: 11px;
  color: var(--text-secondary, #64748b);
  line-height: 1.4;
}

.sidebar-dashboard-status {
  padding: 4px 16px 2px;
}

.sidebar-dashboard-meta {
  font-size: 11px;
  color: var(--text-secondary, #64748b);
  padding: 1px 16px;
}

.sidebar-editable {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 3px;
  transition: background 0.15s;
}

.sidebar-editable:hover {
  background: rgba(59, 130, 246, 0.1);
}

.sidebar-inline-input {
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
  text-align: right;
  border: 1px solid var(--accent-color, #3b82f6);
  border-radius: 3px;
  padding: 0 3px;
  width: 100%;
  outline: none;
  background: var(--card-bg, #fff);
}

.client-dashboard-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.client-dashboard-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary, #222);
  margin: 0;
}

.client-dashboard-trash-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.client-dashboard-trash-btn:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.08);
  border-color: rgba(231, 76, 60, 0.2);
}

.client-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.client-dashboard-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.client-dashboard-card-wide {
  grid-column: 1 / -1;
}

.client-dashboard-card-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #64748b);
  margin: 0 0 14px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.client-dashboard-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.client-dashboard-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-color-light, rgba(0,0,0,0.04));
}

.client-dashboard-field:last-child {
  border-bottom: none;
}

.client-dashboard-label {
  color: var(--text-secondary, #64748b);
  flex-shrink: 0;
  margin-right: 12px;
}

.client-dashboard-value {
  color: var(--text-primary, #1e293b);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

.client-dashboard-editable {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;
  transition: background 0.15s;
}

.client-dashboard-editable:hover {
  background: rgba(59, 130, 246, 0.08);
}

.client-dashboard-inline-input {
  font: inherit;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
  text-align: right;
  border: 1px solid var(--accent-color, #3b82f6);
  border-radius: 4px;
  padding: 1px 4px;
  width: 100%;
  outline: none;
  background: var(--card-bg, #fff);
}

.cell-saving {
  opacity: 0.6;
}

.client-dashboard-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.client-dashboard-card-header .client-dashboard-card-title {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.client-dashboard-card-header + .client-dashboard-fields {
  padding-top: 10px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  margin-top: 10px;
}

.client-dashboard-delete-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.client-dashboard-delete-btn:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

.client-dashboard-add-contact-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg, #fff);
  border: 2px dashed var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 24px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  min-height: 100px;
}

.client-dashboard-add-contact-btn:hover {
  border-color: var(--accent-color, #3b82f6);
  color: var(--accent-color, #3b82f6);
  background: rgba(59, 130, 246, 0.04);
}

/* Confirm modal */
.confirm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.confirm-modal {
  background: var(--card-bg, #fff);
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.confirm-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary, #1e293b);
  margin: 0 0 8px 0;
}

.confirm-modal-message {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  margin: 0 0 20px 0;
  line-height: 1.5;
}

.confirm-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.confirm-modal-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}

.confirm-modal-cancel {
  background: var(--hover-bg, #f1f5f9);
  color: var(--text-primary, #334155);
}

.confirm-modal-cancel:hover {
  background: #e2e8f0;
}

.confirm-modal-confirm {
  background: #e74c3c;
  color: #fff;
}

.confirm-modal-confirm:hover {
  background: #c0392b;
}

/* Dashboard month tabs */
.dashboard-tab-bar {
  display: flex;
  gap: 4px;
  padding: 0 0 10px 0;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.dashboard-tab {
  padding: 4px 12px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 16px;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.dashboard-tab:hover {
  background: rgba(59, 130, 246, 0.06);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--text-primary, #334155);
}

.dashboard-tab.active {
  background: var(--accent-color, #3b82f6);
  border-color: var(--accent-color, #3b82f6);
  color: #fff;
}

.dashboard-tab-content {
  min-height: 40px;
}

.client-dashboard-json {
  background: var(--code-bg, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  padding: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary, #334155);
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.action-view {
  color: var(--accent-color, #3b82f6);
}

.action-view:hover {
  background: rgba(59, 130, 246, 0.1);
}

.action-delete {
  color: var(--text-secondary, #94a3b8);
}

.action-delete:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.08);
}

/* === Dashboard Left Column === */
.client-dashboard-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* === Dashboard Right Column === */
.client-dashboard-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* === File Upload Card === */
.cd-upload-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cd-upload-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary, #64748b);
  margin: 0 0 12px 0;
}

.cd-upload-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(59, 130, 246, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 8px;
  margin-bottom: 10px;
}

.cd-upload-file-icon {
  flex-shrink: 0;
  color: var(--accent-color, #3b82f6);
}

.cd-upload-file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.cd-upload-file-download {
  flex-shrink: 0;
  color: var(--accent-color, #3b82f6);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.cd-upload-file-download:hover {
  background: rgba(59, 130, 246, 0.1);
}

.cd-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 14px;
  border: 2px dashed var(--border-color, #e2e8f0);
  border-radius: 8px;
  background: none;
  color: var(--text-secondary, #94a3b8);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  font-family: var(--font-family);
}

.cd-upload-btn:hover {
  border-color: var(--accent-color, #3b82f6);
  color: var(--accent-color, #3b82f6);
  background: rgba(59, 130, 246, 0.04);
}

.cd-upload-btn.uploading {
  opacity: 0.6;
  pointer-events: none;
}

/* === Dashboard Messenger === */
.cd-messenger {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cd-messenger-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.cd-messenger-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary, #64748b);
  margin: 0;
}

.cd-messenger-people-btn {
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

.cd-messenger-people-btn:hover {
  color: var(--text-primary, #1e293b);
  background: rgba(0, 0, 0, 0.04);
}

.cd-messenger-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 180px;
  max-height: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.015);
}

.cd-messenger-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #94a3b8);
  font-size: 13px;
  min-height: 100px;
}

/* Bubbles — reuse messaging patterns */
.cd-bubble {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 82%;
  animation: slideUpFadeIn 0.2s ease backwards;
}

.cd-bubble-own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cd-bubble-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.cd-bubble-body {
  background: #e8ecf1;
  border-radius: 10px;
  padding: 7px 11px;
  min-width: 50px;
}

.cd-bubble-own .cd-bubble-body {
  background: #1e3a5f;
  color: #fff;
}

.cd-bubble-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1px;
}

.cd-bubble-sender {
  font-size: 11px;
  font-weight: 600;
  color: #333;
}

.cd-bubble-own .cd-bubble-sender {
  color: rgba(255, 255, 255, 0.85);
}

.cd-bubble-time {
  font-size: 10px;
  color: #999;
}

.cd-bubble-own .cd-bubble-time {
  color: rgba(255, 255, 255, 0.65);
}

.cd-bubble-content {
  font-size: 13px;
  color: #222;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}

.cd-bubble-own .cd-bubble-content {
  color: #fff;
}

.cd-bubble-attachment {
  margin-top: 4px;
}

.cd-bubble-attachment a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--accent-color, #3b82f6);
  text-decoration: none;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
}

.cd-bubble-own .cd-bubble-attachment a {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

/* Messenger input bar */
.cd-messenger-input {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  background: var(--card-bg, #fff);
}

.cd-messenger-textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-family);
  color: var(--text-primary, #1e293b);
  background: rgba(0, 0, 0, 0.02);
  outline: none;
  min-height: 36px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.15s;
}

.cd-messenger-textarea:focus {
  border-color: var(--accent-color, #3b82f6);
}

.cd-messenger-textarea::placeholder {
  color: var(--text-secondary, #94a3b8);
}

.cd-messenger-btn {
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.cd-messenger-btn:hover {
  color: var(--accent-color, #3b82f6);
  background: rgba(59, 130, 246, 0.08);
}

.cd-messenger-btn.active {
  color: var(--accent-color, #3b82f6);
}

/* Mention dropdown inside messenger */
.cd-mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
}

.cd-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #1e293b);
  transition: background 0.1s;
}

.cd-mention-item:hover {
  background: rgba(59, 130, 246, 0.06);
}

.cd-mention-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.cd-mention-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* === Team List === */
.cd-team {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cd-team-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary, #64748b);
  margin: 0 0 14px 0;
}

.cd-team-list {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.cd-team-member {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 60px;
}

.cd-team-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid var(--border-color, #e2e8f0);
}

.cd-team-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cd-team-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cd-team-role {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #94a3b8);
  text-align: center;
}

@media (max-width: 768px) {
  .client-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Responsive — 8 tiers ===== */

/* Tier 2: Desktop (1440px) */
@media (max-width: 1440px) {
  :root {
    --sidebar-width: 250px;
  }
}

/* Tier 3: Small desktop (1280px) */
@media (max-width: 1280px) {
  :root {
    --sidebar-width: 240px;
  }
  .card {
    padding: 0 10px 10px;
  }
}

/* Tier 4: Laptop (1024px) */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
  .logo {
    font-size: 18px;
  }
  .card {
    padding: 0 30px 30px;
    border-radius: 18px;
  }
  .content-area {
    padding: 10px;
  }
}

/* Tier 5: Tablet landscape (900px) */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 200px;
  }
  .logo {
    font-size: 17px;
  }
  .card {
    padding: 0 24px 24px;
    border-radius: 16px;
  }
}

/* Mobile hamburger button — hidden on desktop, shown on mobile */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 0;
  padding: 6px 8px;
  margin-right: 6px;
  color: var(--text-primary, #1e293b);
  cursor: pointer;
  border-radius: 6px;
}
.mobile-menu-btn:hover { background: rgba(0,0,0,0.06); }

/* Mobile sidebar backdrop */
.mobile-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 998;
}
body.sidebar-open .mobile-sidebar-backdrop { display: block; }

/* Tier 6: Tablet portrait (768px) — slide-in drawer pattern.
   Replaces the prior icon-only collapsed strip, which silently
   disappeared on real mobile viewports because the collapse toggle
   was display:none and the sidebar parent had no explicit visibility. */
@media (max-width: 768px) {
  .top-header {
    padding: 0 12px;
    height: 44px;
    min-height: 44px;
  }
  .mobile-menu-btn { display: inline-flex; align-items: center; }

  .sidebar {
    position: fixed;
    top: 44px;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 80vw;
    min-width: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 999;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    overflow-y: auto;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Inside the open drawer we want full labels back, not icon-only */
  .nav-label { opacity: 1; width: auto; }
  .nav-item { justify-content: flex-start; padding: 10px 16px; gap: 12px; }
  .nav-group-header { display: flex; }
  .sidebar-collapse-row { display: none; }
  .collapse-btn { display: none; }

  .logo-text { display: inline; }
  .logo-360 { font-size: 16px; }

  .card {
    padding: 0 20px 20px;
    border-radius: 14px;
  }
  .content-area {
    padding: 8px;
  }
}

/* Tier 7: Large phone (480px) */
@media (max-width: 480px) {
  :root {
    --sidebar-collapsed: 50px;
  }
  .top-header {
    padding: 0 10px;
    height: 40px;
    min-height: 40px;
  }
  .user-avatar-btn {
    width: 32px;
    height: 32px;
  }
  .user-dropdown {
    width: 260px;
  }
  .sidebar {
    padding: 10px 0 10px 6px;
  }
  .card {
    padding: 0 16px 16px;
    border-radius: 12px;
  }
  .content-area {
    padding: 6px;
  }
  .page-placeholder {
    font-size: 24px;
  }
}

/* Tier 8: Small phone (360px) */
@media (max-width: 360px) {
  :root {
    --sidebar-collapsed: 44px;
  }
  .top-header {
    padding: 0 8px;
  }
  .user-dropdown {
    width: 240px;
    right: -8px;
  }
  .sidebar {
    padding: 8px 0 8px 4px;
  }
  .card {
    padding: 0 12px 12px;
    border-radius: 10px;
  }
  .content-area {
    padding: 4px;
  }
  .nav-icon svg {
    width: 16px;
    height: 16px;
  }
  .page-placeholder {
    font-size: 20px;
  }
}

/* ============================================================
   Mobile Phase 1 — shell-level touch-target minimums.
   Applies below 768px. The 480px / 360px tiers above may shrink
   some controls further; that's intentional (smaller viewport ⇒
   tighter layout) but never below WCAG minimums.
   ============================================================ */
@media (max-width: 768px) {
  .collapse-btn {
    width: 36px;
    height: 36px;
  }
  .user-avatar-btn {
    width: 40px;
    height: 40px;
  }
}
