/*
 * The portal frame: the dark side menu (brand, screen search, menus under headings), the white top bar (work queues,
 * user menu), the content area, and the sign-in page. The look follows design/new-look-mockup.html.
 */

/* ─── Frame ─── */
.shell {
  min-height: 100vh;
  background: var(--color-page);
}
.skip-link {
  position: fixed;
  top: -40px;
  left: 8px;
  z-index: calc(var(--z-sidebar) + 1);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-ink);
  color: var(--color-on-accent);
}
.skip-link:focus {
  top: 8px;
}
.main {
  min-height: 100vh;
  padding: calc(var(--header-height) + var(--space-5)) var(--space-5) var(--space-5);
  transition: margin-left 200ms ease;
  outline: none;
}
.shell.sidebar-open .main {
  margin-left: var(--sidebar-width);
}
.scrim {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-sidebar) - 1);
  border: 0;
  background: rgb(15 23 42 / 45%);
}
@media (max-width: 768px) {
  /* On phones the side menu slides over the page; the content stays put (and the top bar, below). */
  .shell.sidebar-open .main {
    margin-left: 0;
  }
  .main {
    padding-inline: var(--space-4);
  }
}

/* ─── Brand (side menu top, and the header while the menu is closed) ─── */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 12px;
  background: var(--color-success);
  color: #ffffff;
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}
.brand-name {
  color: var(--color-sidebar-text-active);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.brand-sub {
  margin-top: 3px;
  overflow: hidden;
  color: var(--color-sidebar-text-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-brand .brand-name {
  color: var(--color-text-strong);
}
.header-brand .brand-sub {
  color: var(--color-text-subtle);
}
/* With the side menu open (desktop) the brand is in the menu, not the header. */
.shell.sidebar-open .header-brand {
  display: none;
}

/* ─── Header (top bar) ─── */
.header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--header-height);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--color-border-header);
  background: var(--color-header-bg, rgb(255 255 255 / 92%));
  backdrop-filter: blur(8px);
  transition: left 200ms ease;
}
.shell.sidebar-open .header {
  left: var(--sidebar-width);
}
@media (max-width: 768px) {
  .shell.sidebar-open .header {
    left: 0;
  }
}
/* Offline notice, just under the top bar. */
.offline-bar {
  position: fixed;
  top: var(--header-height);
  right: 0;
  left: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 16px;
  background: #fffbeb;
  border-bottom: 1px solid rgb(245 158 11 / 40%);
  color: #92400e;
  font-size: var(--font-size-sm);
  font-weight: 500;
}
.shell.sidebar-open .offline-bar {
  left: var(--sidebar-width);
}
.shell.is-offline .main {
  padding-top: calc(var(--header-height) + 34px + var(--space-5));
}
@media (max-width: 768px) {
  .shell.sidebar-open .offline-bar {
    left: 0;
  }
}
.header-toggle {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-subtle);
  cursor: pointer;
}
.header-toggle:hover {
  background: var(--color-default-soft);
  color: var(--color-text-strong);
}
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}
.header-divider {
  width: 1px;
  height: 32px;
  margin: 0 var(--space-2);
  background: var(--color-border);
}
.user-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--color-text-subtle);
  cursor: pointer;
}
.user-button:hover,
.user-button[aria-expanded="true"] {
  background: var(--color-default-soft);
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-ink);
  color: var(--color-on-accent);
  font-size: var(--font-size-sm);
  font-weight: 600;
}
.user-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}
.user-name {
  max-width: 160px;
  overflow: hidden;
  color: var(--color-text-strong);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role-line {
  color: var(--color-text-muted);
  font-size: 11px;
}
.user-role {
  margin: 0 0 4px;
  padding: 6px 12px 8px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-subtle);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
@media (max-width: 900px) {
  .user-text {
    display: none;
  }
}
@media (max-width: 640px) {
  .header {
    gap: var(--space-2);
    padding: 0 var(--space-3);
  }
  .header-brand .brand-text,
  .header-divider {
    display: none;
  }
}
@media (max-width: 480px) {
  .header-brand {
    display: none;
  }
  .user-button > .icon,
  .user-button > .fa-icon {
    display: none;
  }
}

/* ─── Work queues: an icon button per step with a count badge (Check, CRO, Call, BM/RM, Disbursement) ─── */
.queue-strip {
  margin-left: 0;
}
.queue-list {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.queue-list li {
  display: flex;
}
.queue-item-wrapper {
  position: relative;
  display: flex;
}
.queue-step {
  --tone: #94a3b8;
  --popup-tone: #a9d86e;
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--color-text-subtle);
  font: inherit;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
}
.queue-step[data-tone="success"],
.queue-popup[data-tone="success"] {
  --tone: #78cd51;
  --popup-tone: #a9d86e;
}
.queue-step[data-tone="warning"],
.queue-popup[data-tone="warning"] {
  --tone: #f59e0b;
  --popup-tone: #fbb23e;
}
.queue-step[data-tone="danger"],
.queue-popup[data-tone="danger"] {
  --tone: #f43f5e;
  --popup-tone: #ff6c60;
}
.queue-step[data-tone="primary"],
.queue-popup[data-tone="primary"] {
  --tone: #8b5cf6;
  --popup-tone: #8075c4;
}
.queue-step[data-tone="info"],
.queue-popup[data-tone="info"] {
  --tone: #0ea5e9;
  --popup-tone: #58c9f3;
}
.queue-icon {
  display: inline-flex;
}
/* The count badge on the top-right corner, in the step's colour; hidden while the queue is empty. */
.queue-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid #ffffff;
  border-radius: 9px;
  background: var(--tone);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.queue-step[data-state="empty"] .queue-count {
  display: none;
}
.queue-step:hover,
.queue-step.queue-step-open {
  background: var(--color-default-soft);
  color: var(--tone);
}
.queue-step:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}
/* The queue being worked on: the icon in its colour on a tint. */
.queue-step[aria-current="page"],
.queue-step[aria-current="page"]:hover {
  background: color-mix(in srgb, var(--tone) 14%, #fff);
  color: var(--tone);
}
/* The name only shows on hover (the title). */
.queue-label {
  display: none;
}

/* ─── Queue Popup Card (Modern SaaS Redesign) ─── */
.queue-popup {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 1000;
  width: 320px;
  padding: 14px 14px 12px;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 12px 32px -4px rgba(15, 23, 42, 0.16), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  border: 1px solid #e2e8f0;
  animation: queuePopupFade 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: default;
  text-align: left;
}
.queue-popup[hidden] {
  display: none !important;
}

/* Invisible bridge between button and popup so mouse smoothly moves between them */
.queue-popup::after {
  content: "";
  position: absolute;
  top: -12px;
  left: 0;
  right: 0;
  height: 12px;
  background: transparent;
}

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

/* Caret diamond pointing up to the trigger button */
.queue-popup::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 13px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-top: 1px solid #cbd5e1;
  border-left: 1px solid #cbd5e1;
  transform: rotate(45deg);
  z-index: 2;
}

/* Header tags & badge */
.queue-popup-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.queue-popup-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}
.queue-popup-step {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.queue-popup[data-tone="success"] .queue-popup-step {
  background: #ecfdf5;
  color: #047857;
  border-color: rgba(16, 185, 129, 0.3);
}
.queue-popup[data-tone="warning"] .queue-popup-step {
  background: #fffbeb;
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.3);
}
.queue-popup[data-tone="danger"] .queue-popup-step {
  background: #fef2f2;
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.3);
}
.queue-popup[data-tone="primary"] .queue-popup-step {
  background: #eef2ff;
  color: #4338ca;
  border-color: rgba(99, 102, 241, 0.3);
}
.queue-popup[data-tone="info"] .queue-popup-step {
  background: #f0f9ff;
  color: #0369a1;
  border-color: rgba(14, 165, 233, 0.3);
}

.queue-popup-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  border: 1px solid #e2e8f0;
}

/* Title */
.queue-popup-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

/* Action list body and items */
.queue-popup-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.queue-popup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border-radius: 9px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.queue-popup-item:hover,
.queue-popup-item:focus-visible {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  outline: none;
}
.queue-popup[data-tone="success"] .queue-popup-item:hover {
  background: #f0fdf4;
  border-color: #86efac;
}
.queue-popup[data-tone="warning"] .queue-popup-item:hover {
  background: #fffbeb;
  border-color: #fde68a;
}
.queue-popup[data-tone="danger"] .queue-popup-item:hover {
  background: #fef2f2;
  border-color: #fecaca;
}
.queue-popup[data-tone="primary"] .queue-popup-item:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}
.queue-popup[data-tone="info"] .queue-popup-item:hover {
  background: #f0f9ff;
  border-color: #bae6fd;
}
/* A screen the user may not open: shown, but not a link. */
.queue-popup .queue-popup-item.queue-popup-item-locked,
.queue-popup .queue-popup-item.queue-popup-item-locked:hover {
  opacity: 0.55;
  cursor: not-allowed;
  background: inherit;
  border-color: transparent;
  transform: none;
}
.queue-popup-item-locked .queue-popup-item-arrow {
  font-size: 11px;
}

.queue-popup-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.queue-popup-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #3b82f6;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.queue-popup-item-texts {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.queue-popup-item-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-popup-item-sub {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-popup-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}
.queue-popup-item-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.2);
  font-variant-numeric: tabular-nums;
}
.queue-popup-item-count[hidden] {
  display: none !important;
}
.queue-popup-item-arrow {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  transition: transform 0.15s ease, color 0.15s ease;
}
.queue-popup-item:hover .queue-popup-item-arrow {
  color: #334155;
  transform: translateX(2px);
}

/* Footer */
.queue-popup-footer {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 11px;
}
.queue-popup-link {
  color: #6366f1;
  text-decoration: none;
  font-weight: 600;
  font-size: 11px;
  transition: color 0.15s ease;
}
.queue-popup-link:hover {
  color: #4338ca;
  text-decoration: underline;
}
@media (max-width: 640px) {
  .queue-list {
    gap: 2px;
  }
  .queue-step {
    width: 34px;
    height: 34px;
  }
}
@media (max-width: 480px) {
  .queue-step {
    width: 30px;
    height: 30px;
  }
  .queue-count {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    line-height: 12px;
  }
}

/* Queue pop-ups open under the bar, aligned to their button's right edge so they stay on screen. */
.queue-popup {
  left: auto;
  right: calc(-8px - var(--queue-shift, 0px));
}
.queue-popup::before {
  left: auto;
  right: calc(22px + var(--queue-shift, 0px));
}

/* ─── Side menu ─── */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  transform: translateX(-100%);
  transition: transform 200ms ease;
}
.shell.sidebar-open .sidebar {
  transform: none;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  height: var(--header-height);
  flex: none;
  padding: 0 20px;
  border-bottom: 1px solid var(--color-sidebar-line);
}
.sidebar-search {
  flex: none;
  padding: 12px;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-sidebar-line) transparent;
}
.sidebar ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.menu-heading {
  padding: 16px 12px 6px;
  color: var(--color-sidebar-text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 1px 0;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-sidebar-text);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.side-link > .icon,
.side-link > .fa-icon {
  width: 16px;
  color: var(--color-sidebar-leaf);
  text-align: center;
}
.side-link:hover:not(:disabled) {
  background: var(--color-sidebar-hover);
  color: var(--color-sidebar-text-active);
}
/* The open menu: white text; the current screen's own link: green tint. */
.side-link.active {
  color: var(--color-sidebar-text-active);
}
.side-link.active > .icon,
.side-link.active > .fa-icon {
  color: var(--color-success);
}
a.side-link.active {
  background: var(--color-sidebar-active);
}
.side-link:disabled {
  cursor: default;
  opacity: 0.45;
}
.side-link .chevron {
  margin-left: auto;
  color: var(--color-sidebar-text-muted);
}
.sidebar .sub-list {
  margin: 2px 0 6px 20px;
  padding: 2px 0 2px 12px;
  border-left: 1px solid var(--color-sidebar-line);
}
.leaf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 1px 0;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-sidebar-leaf);
  font-size: var(--font-size-sm);
  line-height: 1.35;
  text-align: left;
}
a.leaf:hover,
.leaf.group-toggle:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-sidebar-text-active);
}
.leaf.active {
  background: var(--color-sidebar-active);
  color: var(--color-sidebar-text-active);
  font-weight: 500;
}
.leaf.group-toggle {
  cursor: pointer;
}
.leaf.inactive {
  cursor: default;
  opacity: 0.45;
}
.nested-list {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--color-sidebar-line);
}

/* Screen search inside the side menu. */
.nav-search {
  position: relative;
  display: flex;
  align-items: center;
}
.nav-search .icon,
.nav-search .fa-icon {
  position: absolute;
  left: 12px;
  color: var(--color-sidebar-text-muted);
}
.nav-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-sidebar-search);
  color: var(--color-sidebar-search-text);
  font-size: var(--font-size-sm);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.nav-search input::placeholder {
  color: var(--color-sidebar-text-muted);
}
.nav-search input:focus {
  border-color: rgb(20 184 166 / 60%);
  background: var(--color-sidebar-search);
  outline: none;
}

/* ─── Dashboard ─── */
.dashboard {
  display: flex;
  min-height: calc(100vh - var(--header-height) - 80px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  text-align: center;
}
.dashboard-company {
  color: var(--color-text-strong);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.dashboard-welcome {
  margin: 0;
  color: var(--color-text-subtle);
  font-size: var(--font-size-md);
}

/* ─── Sign-in page ─── */
.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: var(--space-5);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgb(120 205 81 / 18%), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgb(14 165 233 / 12%), transparent 60%),
    var(--color-ink);
}
.login-card {
  width: min(100%, 380px);
  padding: 32px 30px 26px;
  border-radius: 20px;
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-modal);
}
.login-brand {
  margin: 0 0 4px;
  color: var(--color-text-strong);
  font-size: var(--font-size-xl);
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}
.login-title {
  margin-bottom: var(--space-5);
  color: var(--color-text-subtle);
  font-size: var(--font-size-md);
  text-align: center;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.login-form input {
  min-height: 40px;
}
.login-form .btn {
  width: 100%;
  margin-top: var(--space-2);
  padding-block: 10px;
}
.login-footer {
  margin: var(--space-5) 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-align: center;
}
