:root {
  --shell-bg: #f5f7fb;
  --shell-panel: #ffffff;
  --shell-panel-soft: #f8fbff;
  --shell-sidebar: linear-gradient(180deg, #edf5ff 0%, #ffffff 100%);
  --shell-border: #d9e4f2;
  --shell-border-strong: #c8d6ea;
  --shell-title: #1b2944;
  --shell-copy: #55657f;
  --shell-muted: #8ea0bb;
  --shell-primary: #2d5cff;
  --shell-primary-deep: #2347d6;
  --shell-cyan: #39b9ff;
  --shell-danger: #ef4444;
  --shell-shadow: 0 10px 28px rgba(44, 73, 132, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--shell-bg);
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(61, 149, 255, 0.08), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, var(--shell-bg) 100%);
  color: var(--shell-copy);
  font-family: "Manrope", sans-serif;
  overflow-x: hidden;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  transition: grid-template-columns 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 16px;
  border-right: 1px solid var(--shell-border);
  border-radius: 0 30px 30px 0;
  background: var(--shell-sidebar);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.45);
  overflow: visible;
  transition:
    width 0.36s cubic-bezier(0.22, 1, 0.36, 1),
    padding 0.36s cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 0.36s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.36s ease;
}

.sidebar-brand {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 28px;
  text-decoration: none;
  transition: gap 0.3s ease, margin 0.3s ease;
}

.brand-logo {
  width: 156px;
  height: auto;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
}

.brand-badge {
  flex: 0 0 auto;
}

.brand-badge-has-image {
  padding: 0;
  overflow: hidden;
  background: #fff;
}

.brand-badge-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  transition: opacity 0.22s ease, transform 0.28s ease;
}

.brand-copy strong {
  color: var(--shell-title);
  font-size: 1.05rem;
}

.brand-copy small {
  color: var(--shell-muted);
}

.sidebar-nav {
  display: grid;
  gap: 14px;
}

.nav-pill {
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 22px;
  text-decoration: none;
  color: #1642dc;
  overflow: hidden;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    padding 0.3s ease,
    gap 0.3s ease,
    border-radius 0.3s ease;
}

.nav-pill:hover {
  background: rgba(45, 92, 255, 0.06);
  transform: translateX(2px);
}

.nav-pill.active {
  color: #fff;
  background: linear-gradient(135deg, #4f67f7 0%, #3552e8 100%);
  box-shadow: 0 18px 36px rgba(53, 82, 232, 0.26);
}

.nav-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid var(--shell-border);
  background: #fff;
}

.nav-pill.active .nav-icon {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.12);
}

.nav-icon svg {
  width: 20px;
  height: 20px;
}

.nav-pill span:last-child {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.28s ease;
}

.sidebar-toggle {
  position: absolute;
  right: -18px;
  bottom: 118px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--shell-border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--shell-title);
  box-shadow: 0 10px 24px rgba(44, 73, 132, 0.16);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.sidebar-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 14px 30px rgba(44, 73, 132, 0.2);
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.mobile-bottom-nav {
  display: none;
}

.mobile-bottom-spacer {
  display: none;
}

.app-main {
  min-width: 0;
  overflow-x: hidden;
  transition: padding 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-collapsed .app-shell {
  grid-template-columns: 96px minmax(0, 1fr);
}

.sidebar-collapsed .app-sidebar {
  padding-left: 14px;
  padding-right: 14px;
}

.sidebar-collapsed .sidebar-brand {
  gap: 0;
  margin-bottom: 34px;
  justify-content: center;
  align-items: center;
}

.sidebar-collapsed .brand-logo {
  display: none;
}

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .nav-pill span:last-child {
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
}

.sidebar-collapsed .brand-copy {
  width: 0;
  overflow: hidden;
}

.sidebar-collapsed .nav-pill span:last-child {
  width: 0;
  max-width: 0;
}

.sidebar-collapsed .sidebar-nav {
  justify-items: center;
}

.sidebar-collapsed .nav-pill {
  width: 58px;
  min-height: 58px;
  max-width: 58px;
  justify-content: center;
  padding: 10px;
  gap: 0;
  border-radius: 18px;
}

.sidebar-collapsed .nav-icon {
  margin: 0;
}

.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 34px 18px;
  border-bottom: 1px solid var(--shell-border);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
}

.topbar-copy h1,
.topbar-copy p {
  margin: 0;
}

.eyebrow,
.section-kicker,
.card-kicker,
.detail-label,
.crm-table thead th,
.row-detail h4 {
  color: #7f93b2;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.75rem;
  font-weight: 800;
}

.topbar-copy h1 {
  margin-top: 4px;
  color: var(--shell-title);
  font-size: 1.4rem;
  font-weight: 800;
}

.topbar-user-menu {
  position: relative;
  flex: 0 0 auto;
}

.topbar-user-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.topbar-user {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(260px, calc(100vw - 48px));
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-direction: column;
  color: var(--shell-title);
  padding: 14px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 36px rgba(27, 41, 68, 0.14);
  z-index: 90;
}

.user-name {
  font-weight: 700;
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.user-role {
  color: var(--shell-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.user-avatar {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #364766, #1f2a44);
  color: #fff;
  font-weight: 800;
  overflow: hidden;
}

.user-avatar-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.user-link {
  width: 100%;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  justify-content: center;
}

.logout-form {
  margin: 0;
  width: 100%;
}

.profile-summary-grid {
  margin-bottom: 24px;
}

.page-shell {
  padding: 28px 30px 40px;
}

.hero-card,
.crm-card,
.panel {
  border: 1px solid var(--shell-border);
  border-radius: 30px;
  background: var(--shell-panel);
  box-shadow: var(--shell-shadow);
}

.hero-card {
  margin-bottom: 24px;
  padding: 34px;
  background: linear-gradient(90deg, #eef6ff 0%, #ffffff 70%);
}

.page-heading {
  margin: 6px 0 12px;
  color: var(--shell-title);
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.page-intro {
  margin: 0;
  max-width: 860px;
  color: var(--shell-copy);
  font-size: 1.05rem;
  line-height: 1.7;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.card-grid > *,
.page-shell > *,
.section-header > *,
.list-head > *,
.topbar > *,
.topbar-copy,
.hero-card > * {
  min-width: 0;
}

.crm-card,
.panel {
  padding: 26px;
}

.crm-card h3 {
  margin: 6px 0 8px;
  color: var(--shell-title);
  font-size: 1.5rem;
}

.metric {
  margin: 0 0 20px;
  color: var(--shell-primary);
  font-size: 2rem;
  font-weight: 800;
}

.section-header,
.card-actions,
.header-actions,
.form-actions,
.list-head,
.search-form,
.table-tools,
.pagination {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.section-header,
.list-head,
.pagination {
  align-items: center;
  justify-content: space-between;
}

.section-header {
  margin-bottom: 18px;
}

.section-header h2 {
  margin: 6px 0 8px;
  color: var(--shell-title);
  font-size: 2rem;
}

.section-header p {
  margin: 0;
}

.ui-btn,
.btn,
.page-link {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 16px;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.ui-btn:hover,
.btn:hover,
.page-link:hover {
  transform: translateY(-1px);
}

.ui-btn:disabled,
.btn:disabled {
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ui-btn-primary,
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--shell-cyan), var(--shell-primary));
  box-shadow: 0 14px 28px rgba(45, 92, 255, 0.2);
}

.ui-btn-primary:disabled,
.btn-primary:disabled {
  color: #7f93b2;
  background: #edf2fb;
  border-color: #d9e4f2;
  box-shadow: none;
}

.ui-btn-secondary,
.btn-neutral,
.page-link {
  color: var(--shell-title);
  background: #fff;
  border-color: var(--shell-border);
}

.page-link.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.page-status {
  color: var(--shell-title);
  font-weight: 700;
}

.panel-full {
  max-width: none;
}

.panel-list {
  overflow: visible;
}

.crm-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.form-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  align-items: center;
  margin-top: 10px;
}

.form-actions .btn,
.form-actions .ui-btn {
  min-width: 170px;
  min-height: 56px;
  padding: 0 24px;
  border-radius: 18px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.form-actions .btn-primary {
  box-shadow: 0 18px 32px rgba(45, 92, 255, 0.22);
}

.form-actions .btn-neutral {
  background: #fff;
  border-color: var(--shell-border);
  box-shadow: 0 10px 24px rgba(27, 41, 68, 0.06);
}

.form-actions .btn:hover,
.form-actions .ui-btn:hover {
  transform: translateY(-2px);
}

.form-actions .btn:disabled,
.form-actions .ui-btn:disabled {
  transform: none;
}

.field-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-wrap label {
  color: var(--shell-title);
  font-weight: 700;
}

.field-wide {
  grid-column: 1 / -1;
}

.crm-input {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 1px solid var(--shell-border);
  border-radius: 18px;
  background: #fff;
  color: var(--shell-title);
  font: inherit;
}

.crm-input:focus {
  outline: 0;
  border-color: var(--shell-primary);
  box-shadow: 0 0 0 4px rgba(45, 92, 255, 0.1);
}

.crm-input-readonly {
  display: flex;
  align-items: center;
  background: #f7faff;
  color: var(--shell-copy);
  border-style: dashed;
}

.field-label {
  color: var(--shell-title);
  font-weight: 700;
}

.helptext,
.field-error {
  font-size: 0.9rem;
  line-height: 1.5;
}

.helptext {
  color: var(--shell-muted);
}

.field-error {
  color: var(--shell-danger);
}

.profile-panel {
  padding: 32px;
}

.profile-form {
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

.profile-section-header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(217, 228, 242, 0.85);
}

.profile-section-header h3 {
  margin: 6px 0 0;
  color: var(--shell-title);
  font-size: 1.2rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.profile-photo-field {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid var(--shell-border);
  border-radius: 22px;
  background: linear-gradient(135deg, #f7fbff 0%, #ffffff 100%);
}

.profile-photo-preview {
  width: 78px;
  height: 78px;
  flex: 0 0 78px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(135deg, #364766, #1f2a44);
  box-shadow: 0 12px 24px rgba(27, 41, 68, 0.14);
}

.profile-photo-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.profile-photo-fallback {
  color: #fff;
  font-size: 1.7rem;
  font-weight: 800;
}

.profile-photo-input-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.crm-file-input {
  padding: 12px;
}

.crm-file-input::file-selector-button {
  margin-right: 12px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--shell-cyan), var(--shell-primary));
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.profile-form-actions {
  justify-content: flex-end;
  margin-top: 0;
}

.organization-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 24px;
  margin-bottom: 24px;
}

.organization-summary-card,
.organization-invite-card {
  min-width: 0;
}

.organization-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.organization-logo-block {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.organization-logo-preview {
  width: 104px;
  height: 104px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(135deg, #364766, #1f2a44);
  box-shadow: 0 14px 28px rgba(27, 41, 68, 0.14);
}

.organization-logo-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.organization-logo-fallback {
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
}

.organization-logo-form {
  min-width: 0;
}

.organization-logo-actions {
  justify-content: flex-start;
  margin-top: 0;
}

.organization-meta-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid var(--shell-border);
  border-radius: 22px;
  background: linear-gradient(135deg, #f7fbff 0%, #ffffff 100%);
}

.organization-meta-label {
  color: var(--shell-muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.organization-invite-form {
  grid-template-columns: minmax(0, 1fr);
}

.organization-invitations {
  display: grid;
  gap: 16px;
}

.organization-invitation-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--shell-border);
  border-radius: 22px;
  background: linear-gradient(135deg, #f7fbff 0%, #ffffff 100%);
}

.organization-invitation-card p {
  margin: 8px 0 0;
}

.organization-invitation-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.password-toggle-wrap {
  position: relative;
  width: 100%;
}

.password-toggle-input {
  padding-right: 56px;
}

.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--shell-muted);
  cursor: pointer;
  transform: translateY(-50%);
  transition: background 0.18s ease, color 0.18s ease;
}

.password-toggle-btn:hover {
  background: #f5f8ff;
  color: var(--shell-title);
}

.password-toggle-btn:focus-visible {
  outline: 0;
  background: #f5f8ff;
  box-shadow: 0 0 0 3px rgba(45, 92, 255, 0.14);
  color: var(--shell-title);
}

.password-toggle-btn svg {
  width: 18px;
  height: 18px;
}

.password-toggle-btn .icon-eye-off {
  display: none;
}

.password-toggle-btn.is-visible .icon-eye {
  display: none;
}

.password-toggle-btn.is-visible .icon-eye-off {
  display: block;
}

.crm-textarea {
  min-height: 120px;
  resize: vertical;
}

.field-error {
  color: #c53030;
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
  z-index: 1;
}

.crm-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  isolation: isolate;
  overflow: visible;
}

.crm-table tbody,
.crm-table tr,
.crm-table td {
  overflow: visible;
}

.crm-table th,
.crm-table td {
  padding: 18px 12px;
  border-bottom: 1px solid var(--shell-border);
  text-align: left;
  vertical-align: top;
}

.crm-table thead th {
  background: #f9fbff;
}

.crm-table tbody tr:last-child td {
  border-bottom: 0;
}

.expand-col {
  width: 52px;
  text-align: center;
}

.data-row {
  cursor: pointer;
}

.data-row:hover td {
  background: #fbfdff;
}

.detail-row {
  display: none;
}

.detail-row.open {
  display: table-row;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--shell-border);
  border-radius: 12px;
  background: #fff;
  color: var(--shell-copy);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-expand {
  transition: transform 0.18s ease;
}

.data-row.open .icon-expand {
  transform: rotate(180deg);
}

.actions-cell {
  position: sticky;
  overflow: visible;
  right: 0;
  background: #fff;
  z-index: 30;
  text-align: center;
  width: 92px;
}

.data-row.menu-open,
.data-row.menu-open td,
.data-row.menu-open .actions-cell {
  position: relative;
  z-index: 120;
  overflow: visible;
}

.row-detail {
  margin: 8px 0 0;
  padding: 20px;
  border: 1px solid var(--shell-border);
  border-radius: 24px;
  background: var(--shell-panel-soft);
}

.row-detail h4 {
  margin: 0 0 12px;
}

.detail-label {
  margin: 0;
}

.detail-value {
  display: block;
  color: var(--shell-title);
  word-break: break-word;
}

.report-panel {
  margin-top: 24px;
}

.inline-report-panel {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--shell-border);
}

.report-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.inline-report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.inline-report-head h5 {
  margin: 8px 0 0;
  color: var(--shell-title);
  font-size: 1.2rem;
}

.report-panel-head h3 {
  margin: 8px 0 0;
  color: var(--shell-title);
  font-size: 1.5rem;
}

.report-status-pill,
.report-month-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(26, 166, 92, 0.12);
  color: #16834a;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.report-status-pill {
  min-height: 38px;
  padding: 0 16px;
  font-size: 0.78rem;
}

.report-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--shell-border);
  border-radius: 24px;
  background: #fff;
}

.report-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
}

.report-table th,
.report-table td {
  padding: 16px 18px;
  text-align: left;
}

.report-table thead th {
  color: #7f93b2;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  font-weight: 800;
  border-bottom: 1px solid var(--shell-border);
  background: #f8fbff;
}

.report-table tbody td {
  color: var(--shell-title);
  border-bottom: 1px solid rgba(217, 228, 242, 0.8);
}

.report-table tbody tr:last-child td {
  border-bottom: 0;
}

.report-month-status {
  min-width: 88px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.72rem;
}

.row-menu {
  display: inline-block;
  position: relative;
}

.row-menu-panel,
.column-toggle-form {
  position: absolute;
  min-width: 220px;
  padding: 10px;
  border: 1px solid var(--shell-border);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(27, 41, 68, 0.16);
  z-index: 400;
}

.row-menu-panel {
  min-width: 180px;
  position: absolute;
  padding: 8px;
  border-radius: 22px;
  box-shadow:
    0 24px 48px rgba(27, 41, 68, 0.16),
    0 4px 12px rgba(27, 41, 68, 0.08);
  z-index: 1200;
}

.row-menu-panel[hidden] {
  display: none;
}

.row-menu-panel.open {
  animation: menu-pop 0.16s ease-out;
}

.column-toggle-form {
  top: calc(100% + 10px);
  left: 0;
}

.row-action-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  padding: 12px 14px;
  color: var(--shell-title);
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.row-action-link:hover {
  background: #f5f8ff;
}

.row-action-link svg {
  width: 15px;
  height: 15px;
}

.delete-link {
  color: #c53030;
}

.icon-kebab.is-active,
.icon-btn:hover {
  border-color: #bfd0ea;
  background: #f7faff;
}

@keyframes menu-pop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes auth-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.inline-form {
  margin: 0;
}

.primary-contact strong {
  display: block;
  color: var(--shell-title);
}

.primary-contact small {
  display: block;
  margin-top: 2px;
  color: var(--shell-copy);
}

.empty-row {
  text-align: center;
  color: var(--shell-muted);
}

.messages {
  margin-bottom: 16px;
}

.message {
  padding: 14px 18px;
  border: 1px solid var(--shell-border);
  border-radius: 18px;
  background: #fff;
}

.message.success {
  border-color: #b7e4cb;
  background: #f2fff7;
}

.message.error {
  border-color: #f0c7c7;
  background: #fff7f7;
}

.message.info {
  border-color: #c6daf7;
  background: #f5f9ff;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth-card {
  width: min(100%, 460px);
  padding: 32px;
  border: 1px solid var(--shell-border);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shell-shadow);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  text-decoration: none;
}

.auth-copy h1,
.auth-copy p {
  margin: 0;
}

.auth-copy h1 {
  margin-top: 8px;
  color: var(--shell-title);
  font-size: 2rem;
}

.auth-copy p {
  color: var(--shell-copy);
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.auth-social-stack {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.auth-social-btn {
  width: 100%;
  justify-content: center;
}

.auth-social-note {
  margin: 0;
  color: var(--shell-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.auth-inline-link-row {
  margin-top: 4px;
}

.auth-inline-link {
  color: var(--shell-primary);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
}

.auth-inline-link:hover {
  text-decoration: underline;
}

.auth-modal[hidden] {
  display: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(6px);
}

.auth-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  margin: min(10vh, 72px) auto 0;
  padding: 28px;
  border: 1px solid rgba(217, 228, 242, 0.8);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24);
}

.auth-modal-copy {
  margin-bottom: 18px;
}

.auth-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--shell-border);
  border-radius: 14px;
  background: #fff;
  color: var(--shell-title);
  cursor: pointer;
}

.auth-modal-close svg {
  width: 18px;
  height: 18px;
}

.auth-form .field-wrap {
  gap: 10px;
}

.auth-form .helptext {
  display: block;
  margin-top: 6px;
  color: var(--shell-muted);
  font-size: 0.84rem;
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
}

.auth-submit-loading {
  gap: 10px;
}

.auth-submit-spinner {
  width: 18px;
  height: 18px;
  display: none;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: #ffffff;
  border-radius: 999px;
  flex: 0 0 18px;
  animation: auth-spin 0.8s linear infinite;
}

.auth-form.is-submitting .auth-submit-spinner {
  display: inline-flex;
}

.auth-form.is-submitting .auth-submit {
  cursor: wait;
  opacity: 0.92;
}

.auth-form.is-submitting .crm-input {
  opacity: 0.75;
}

.users-table td,
.users-table th {
  vertical-align: middle;
}

.user-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.user-status.active {
  color: #166534;
  background: #ecfdf3;
}

.user-status.inactive {
  color: #991b1b;
  background: #fef2f2;
}

.user-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: #2347d6;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 6px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.column-toggle {
  position: relative;
}

.column-toggle-form {
  width: min(360px, 92vw);
}

.column-toggle-form p {
  margin: 0 0 12px;
}

.column-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.column-toggle-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--shell-title);
}

.column-toggle-actions {
  display: flex;
  justify-content: flex-end;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1360px) {
  .page-shell {
    padding: 24px 24px 36px;
  }

  .topbar {
    padding: 20px 24px 16px;
  }

  .hero-card {
    padding: 30px;
  }

  .crm-card,
  .panel {
    padding: 22px;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: sticky;
    top: 0;
    z-index: 70;
    height: auto;
    padding: 16px 16px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--shell-border);
    border-radius: 0 0 28px 28px;
    background: linear-gradient(180deg, rgba(237, 245, 255, 0.97) 0%, rgba(255, 255, 255, 0.95) 100%);
    backdrop-filter: blur(14px);
  }

  .sidebar-brand {
    margin-bottom: 16px;
  }

  .sidebar-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 4px 2px 8px;
  }

  .nav-pill {
    min-height: 58px;
    min-width: 0;
    width: 100%;
    padding: 10px 12px;
    border-radius: 18px;
  }

  .nav-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
  }

  .nav-pill span:last-child {
    font-size: 0.95rem;
  }

  .sidebar-toggle {
    display: none;
  }
}

@media (min-width: 641px) and (max-width: 1100px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 16px;
    padding-top: 16px;
    padding-bottom: 14px;
  }

  .topbar-copy {
    min-width: 0;
    flex: 1 1 auto;
  }

  .topbar-copy h1 {
    font-size: 1.2rem;
  }

  .topbar-user {
    width: min(260px, calc(100vw - 48px));
  }

  .user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 780px) {
  .topbar,
  .page-shell {
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding-top: 18px;
    padding-bottom: 14px;
  }

  .topbar-copy h1 {
    font-size: 1.15rem;
  }

  .hero-card,
  .panel,
  .crm-card {
    border-radius: 24px;
    padding: 22px;
  }

  .page-heading {
    font-size: clamp(1.8rem, 8vw, 2.4rem);
  }

  .page-intro {
    font-size: 0.98rem;
    line-height: 1.65;
  }

  .section-header h2 {
    font-size: 1.6rem;
  }

  .crm-table {
    min-width: 860px;
  }

  .crm-table th,
  .crm-table td {
    padding: 16px 10px;
  }

  .actions-cell {
    width: 78px;
  }

  .crm-form {
    grid-template-columns: 1fr;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-photo-field {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-actions {
    justify-content: stretch;
  }

  .profile-form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .organization-layout,
  .organization-meta-grid,
  .organization-logo-block {
    grid-template-columns: 1fr;
  }

  .organization-invitation-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-actions .btn,
  .form-actions .ui-btn {
    width: 100%;
  }

  .field-wide {
    grid-column: auto;
  }

  .search-form {
    width: 100%;
  }

  .search-select,
  .search-input {
    flex: 1 1 100%;
  }
}

@media (min-width: 641px) and (max-width: 780px) {
  .sidebar-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-pill {
    justify-content: flex-start;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .topbar-user {
    width: auto;
    max-width: 42%;
  }
}

@media (max-width: 640px) {
  .app-sidebar {
    padding: 12px 12px 10px;
    border-radius: 0 0 20px 20px;
  }

  .sidebar-brand {
    gap: 10px;
    margin-bottom: 12px;
    padding-left: 2px;
    padding-right: 2px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 1.05rem;
  }

  .brand-copy strong {
    font-size: 0.92rem;
  }

  .brand-copy small {
    font-size: 0.72rem;
  }

  .sidebar-nav {
    display: none;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
  }

  .topbar-user-menu {
    margin-left: auto;
  }

  .topbar-user {
    width: min(220px, calc(100vw - 28px));
    max-width: none;
    min-width: 0;
  }

  .user-meta {
    flex: 1 1 auto;
  }

  .user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
  }

  .user-role {
    font-size: 0.68rem;
  }

  .user-avatar {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }

  .topbar-copy {
    min-width: 0;
    flex: 1 1 auto;
  }

  .topbar-copy .eyebrow {
    font-size: 0.64rem;
    letter-spacing: 0.16em;
  }

  .topbar-copy h1 {
    margin-top: 3px;
    font-size: 1.15rem;
  }

  .page-shell {
    padding: 16px 14px 24px;
  }

  .hero-card,
  .panel,
  .crm-card {
    padding: 18px;
    border-radius: 22px;
  }

  .card-grid,
  .column-toggle-grid {
    grid-template-columns: 1fr;
  }

  .report-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-report-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .crm-table {
    min-width: 760px;
  }

  .crm-table th,
  .crm-table td {
    padding: 14px 10px;
  }

  .actions-cell {
    position: static;
    right: auto;
    width: auto;
    min-width: 110px;
    background: transparent;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .row-menu-panel,
  .column-toggle-form {
    min-width: min(220px, calc(100vw - 36px));
    border-radius: 18px;
  }

  .row-action-link {
    padding: 12px 12px;
    border-radius: 14px;
  }

  .form-actions {
    gap: 10px;
  }

  .form-actions .btn,
  .form-actions .ui-btn {
    min-width: 0;
    min-height: 50px;
    padding: 0 18px;
    border-radius: 16px;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 120;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(217, 228, 242, 0.68);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(22px);
    box-shadow: 0 -8px 24px rgba(27, 41, 68, 0.08);
  }

  .mobile-bottom-spacer {
    display: block;
    height: calc(var(--mobile-bottom-nav-height, 0px) + 16px);
    flex: 0 0 auto;
  }

  .mobile-bottom-link {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 2px;
    border-radius: 14px;
    color: #7284a1;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
  }

  .mobile-bottom-link.active {
    color: var(--shell-primary);
    background: rgba(45, 92, 255, 0.08);
  }

  .mobile-bottom-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-bottom-icon svg {
    width: 18px;
    height: 18px;
  }

  .mobile-bottom-link span:last-child {
    max-width: 100%;
    overflow: hidden;
    font-size: 0.58rem;
    font-weight: 800;
    line-height: 1.1;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 12px 12px 10px;
  }

  .topbar-copy .eyebrow {
    display: none;
  }

  .topbar-copy h1 {
    font-size: 1.05rem;
  }

  .topbar-user {
    width: min(210px, calc(100vw - 24px));
    padding: 12px;
  }

  .mobile-bottom-nav {
    gap: 4px;
    padding: 7px 8px calc(14px + env(safe-area-inset-bottom));
  }

  .mobile-bottom-link {
    padding: 6px 1px;
    border-radius: 12px;
  }

  .mobile-bottom-link span:last-child {
    font-size: 0.54rem;
  }

  .user-link {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.84rem;
  }

  .hero-card,
  .panel,
  .crm-card {
    padding: 16px;
    border-radius: 20px;
  }

  .page-shell {
    padding: 14px 12px 24px;
  }

  .auth-card {
    padding: 24px 18px;
    border-radius: 24px;
  }
}
